|
|
|
@ -19,6 +19,7 @@ use Dcat\Admin\Grid; |
|
|
|
use Dcat\Admin\Show; |
|
|
|
use Dcat\Admin\Controllers\AdminController; |
|
|
|
use \App\Models\LanzuCsInfo as modelCsInfo; |
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
use function foo\func; |
|
|
|
|
|
|
|
class LanzuCsInfoController extends AdminController |
|
|
|
@ -31,6 +32,8 @@ class LanzuCsInfoController extends AdminController |
|
|
|
protected function grid() |
|
|
|
{ |
|
|
|
return Grid::make(new LanzuCsInfo('userBalance'), function (Grid $grid) { |
|
|
|
$grid->model()->orderBy('created_at','desc'); |
|
|
|
$grid->paginate(10); |
|
|
|
$user = Admin::user(); |
|
|
|
if ($user->isRole('lanzu_cs')) {//如何是社区站点角色登陆,则只能看到自己的信息
|
|
|
|
$grid->model()->where('admin_user_id', $user->id); |
|
|
|
@ -114,28 +117,31 @@ class LanzuCsInfoController extends AdminController |
|
|
|
$form->saved(function (Form $form, $cid) { |
|
|
|
$model = new modelCsInfo(); |
|
|
|
if ($form->isCreating()) { |
|
|
|
//>>1.添加登录帐号
|
|
|
|
$res = Auth::addAdminUser($form, $model, $cid, 'lanzu_cs',3); |
|
|
|
if ($res == -1) { |
|
|
|
return $form->error('该手机号作为登陆帐号已存在!'); |
|
|
|
} elseif ($res == -2) { |
|
|
|
return $form->error('添加失败!'); |
|
|
|
} |
|
|
|
DB::transaction(function () use ($form, $model, $cid){ |
|
|
|
//>>1.添加登录帐号
|
|
|
|
$res = Auth::addAdminUser($form, $model, $cid, 'lanzu_cs'); |
|
|
|
if ($res == -1) { |
|
|
|
return $form->error('该手机号作为登陆帐号已存在!'); |
|
|
|
} elseif ($res == -2) { |
|
|
|
return $form->error('添加失败!'); |
|
|
|
} |
|
|
|
|
|
|
|
//>>2.生成小程序二维码
|
|
|
|
$cs = $model->find($cid); |
|
|
|
$aid = $cs->admin_user_id; |
|
|
|
$images = new Images(); |
|
|
|
$param = "p=index&sid={$aid}"; |
|
|
|
$path = 'zh_cjdianc/pages/Liar/loginindex'; |
|
|
|
$qrcode = $images->createQrCode($param, $path); |
|
|
|
$fileName = 'public/upload/' . 'qrcode' . '/' . date('Y') . '/' . date('m-d') . '/' . rand(100000000000000, 999999999999999) . '.png'; |
|
|
|
$result = $images->uploadOss($qrcode, $fileName); |
|
|
|
if ($result == true) { |
|
|
|
//>>3.保存二维码路径
|
|
|
|
$cs->qrcode_path = $fileName; |
|
|
|
$cs->save(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//>>2.生成小程序二维码
|
|
|
|
$cs = $model->find($cid); |
|
|
|
$aid = $cs->admin_user_id; |
|
|
|
$images = new Images(); |
|
|
|
$param = "p=index&sid={$aid}"; |
|
|
|
$path = 'zh_cjdianc/pages/Liar/loginindex'; |
|
|
|
$qrcode = $images->createQrCode($param, $path); |
|
|
|
$fileName = 'public/upload/' . 'qrcode' . '/' . date('Y') . '/' . date('m-d') . '/' . rand(100000000000000, 999999999999999) . '.png'; |
|
|
|
$result = $images->uploadOss($qrcode, $fileName); |
|
|
|
if ($result == true) { |
|
|
|
//>>3.保存二维码路径
|
|
|
|
$cs->qrcode_path = $fileName; |
|
|
|
$cs->save(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
//>>4.编辑时同步登陆帐号状态
|
|
|
|
$adu = new AdminUsers(); |
|
|
|
|