diff --git a/app/Admin/Common/QRCode.php b/app/Admin/Common/QRCode.php new file mode 100644 index 0000000..323c17d --- /dev/null +++ b/app/Admin/Common/QRCode.php @@ -0,0 +1,34 @@ +images = new Images(); + } + + /** + * 服务站专员评价小程序码 + */ + public function getServicePersonnel($id, $path) + { + $param = "page=details&id={$id}"; + $path = "zh_cjdianc/pages/Liar/loginindex"; + $codeStore = $this->images->createQrCode($param,$path); + $storeImgPath = 'QR_code/code_service_personnel_img/personnel_'.$id.'.jpg'; + $res = $this->images->uploadOss($codeStore,$storeImgPath); + if($res){ + return ['status' => true ,'path' => $storeImgPath]; + }else{ + return ['status' => false ,'path' => '']; + } + } + +} diff --git a/app/Admin/Controllers/v3/ServicePersonnelController.php b/app/Admin/Controllers/v3/ServicePersonnelController.php index 338feb1..43d77e0 100644 --- a/app/Admin/Controllers/v3/ServicePersonnelController.php +++ b/app/Admin/Controllers/v3/ServicePersonnelController.php @@ -7,6 +7,9 @@ use Dcat\Admin\Form; use Dcat\Admin\Grid; use Dcat\Admin\Show; use Dcat\Admin\Controllers\AdminController; +use App\Models\v3\ServicePersonnel as ServicePersonnelModel; +use App\Models\v3\Market as MarketModel; +use App\Models\v3\User as UserModel; class ServicePersonnelController extends AdminController { @@ -18,22 +21,31 @@ class ServicePersonnelController extends AdminController protected function grid() { return Grid::make(new ServicePersonnel(), function (Grid $grid) { + //市场 + $marketList = MarketModel::getMarketArray(); + $grid->column('id')->sortable(); - $grid->column('user_id'); + + $grid->column('head_url')->image('',50); $grid->column('name'); $grid->column('tel'); - $grid->column('market_id'); - $grid->column('type'); - $grid->column('status'); - $grid->column('qr_url'); - $grid->column('head_url'); - $grid->column('created_at'); - $grid->column('updated_at')->sortable(); - - $grid->filter(function (Grid\Filter $filter) { + $grid->column('market_id')->display(function($marketId) use ($marketList){ + return isset($marketList[$marketId]) ? $marketList[$marketId] : ''; + }); + $grid->column('type_text'); + $grid->column('qr_url')->image('',50); + $grid->column('status')->using(ServicePersonnelModel::$_STATUS)->label(config('label.status_label')); + + $grid->model()->orderby('id','desc'); + + $grid->filter(function (Grid\Filter $filter) use($marketList){ $filter->equal('id'); - + $filter->like('name'); + $filter->equal('type')->select(ServicePersonnelModel::$_TYPE); + $filter->equal('market_id')->select($marketList); }); + // 每页10条 + $grid->paginate(10); }); } @@ -69,18 +81,40 @@ class ServicePersonnelController extends AdminController protected function form() { return Form::make(new ServicePersonnel(), function (Form $form) { - $form->display('id'); - $form->text('user_id'); - $form->text('name'); - $form->text('tel'); - $form->text('market_id'); - $form->text('type'); - $form->text('status'); - $form->text('qr_url'); - $form->text('head_url'); - - $form->display('created_at'); - $form->display('updated_at'); + //市场 + $marketList = MarketModel::getMarketArray(); + // 用户 + $userList = UserModel::getUserArray(); + // 已绑定的用户 + $userHas = ServicePersonnelModel::pluck('user_id')->toArray(); + foreach($userList as $ku => $uv){ + if($ku != 0 && in_array($ku,$userHas)){ + unset($userList[$ku]); + } + } + + $form->column(6,function(Form $form){ + $form->hidden('id'); + $form->text('name')->required(); + $form->text('tel')->required(); + $form->image('head_url')->required(); + }); + $form->column(6,function(Form $form) use($marketList,$userList){ + $form->select('type')->options(ServicePersonnelModel::$_TYPE)->required(); + $form->select('market_id')->options($marketList)->required(); + $form->select('user_id')->options($userList)->required(); + }); + + $form->saved(function(Form $form){ + $id = $form->getKey(); + + // 生产专员二维码 + $qrCode = 0; + }); + $form->disableResetButton(); + $form->disableViewCheck(); + $form->disableEditingCheck(); + $form->disableCreatingCheck(); }); } } diff --git a/app/Admin/Controllers/v3/StoreController.php b/app/Admin/Controllers/v3/StoreController.php index 81b13fa..0e238ea 100644 --- a/app/Admin/Controllers/v3/StoreController.php +++ b/app/Admin/Controllers/v3/StoreController.php @@ -40,8 +40,24 @@ class StoreController extends AdminController $mmUser = MminfoModel::getMmInfo($mmUserId,'name'); return empty($mmUser) ? '' : $mmUser->name; }); - $grid->store_applet_img->image('',50); - $grid->cash_code_img->image('',50); + $grid->store_applet_img->display(function($appletImg){ + $id = $this->id; + $oldPath = 'https://img.lanzu.vip/addons/zh_cjdianc/data/code_store_img/wx_store_'.$id.'.jpg'; + $path = empty($appletImg) ? $oldPath : config('filesystems.disks.oss.img_host').'/'.$appletImg; + $img = ""; + + return $img; + }); + // ->image('',50); + $grid->cash_code_img->display(function($appletImg){ + $id = $this->id; + $oldPath = 'https://img.lanzu.vip/addons/zh_cjdianc/data/code_pay_img/wx_pay_'.$id.'.jpg'; + $path = empty($appletImg) ? $oldPath : config('filesystems.disks.oss.img_host').'/'.$appletImg; + $img = ""; + + return $img; + }); + // ->image('',50); $grid->sort->sortable(); $grid->is_rest->switch(); @@ -139,7 +155,7 @@ class StoreController extends AdminController $categoryList = CategoryModel::getArray([['parent_id','=',0]]); // 用户 $userList = UserModel::getUserArray(); - // 绑定了店铺的用户 + // 已绑定店铺的用户 $userHas = StoreModel::pluck('admin_id')->toArray(); foreach($userList as $ku => $uv){ @@ -173,7 +189,7 @@ class StoreController extends AdminController ->saving(function ($v) { return $v == 1 ? 1 : 0; }); - $form->text('address'); + $form->text('address')->required(); }); $form->column(6, function (Form $form) use($userList){ $form->image('business_license')->required()->uniqueName(); diff --git a/app/Models/v3/Banners.php b/app/Models/v3/Banners.php index 89524eb..bf2296d 100644 --- a/app/Models/v3/Banners.php +++ b/app/Models/v3/Banners.php @@ -64,7 +64,7 @@ class Banners extends Model public function imageUrl($value) { if(strripos($value,"http") === false){ - return env('OSS_IMG_HOST').'/'.$value; + return config('filesystems.disks.oss.img_host').'/'.$value; }else{ return $value; } diff --git a/app/Models/v3/Category.php b/app/Models/v3/Category.php index 7e4950b..2b3c595 100644 --- a/app/Models/v3/Category.php +++ b/app/Models/v3/Category.php @@ -73,7 +73,7 @@ class Category extends Model public function imageUrl($value) { if(strripos($value,"http") === false){ - return env('OSS_IMG_HOST').'/'.$value; + return config('filesystems.disks.oss.img_host').'/'.$value; }else{ return $value; } diff --git a/app/Models/v3/Goods.php b/app/Models/v3/Goods.php index 3fa366c..0105f41 100644 --- a/app/Models/v3/Goods.php +++ b/app/Models/v3/Goods.php @@ -62,7 +62,7 @@ class Goods extends Model public function imageUrl($value) { if(strripos($value,"http") === false){ - return env('OSS_IMG_HOST').'/'.$value; + return config('filesystems.disks.oss.img_host').'/'.$value; }else{ return $value; } diff --git a/app/Models/v3/GoodsActivity.php b/app/Models/v3/GoodsActivity.php index 2a2aa45..7cbdd9e 100644 --- a/app/Models/v3/GoodsActivity.php +++ b/app/Models/v3/GoodsActivity.php @@ -83,7 +83,7 @@ class GoodsActivity extends Model public function imageUrl($value) { if(strripos($value,"http") === false){ - return env('OSS_IMG_HOST').'/'.$value; + return config('filesystems.disks.oss.img_host').'/'.$value; }else{ return $value; } diff --git a/app/Models/v3/GoodsNew.php b/app/Models/v3/GoodsNew.php index c0b6dfe..69c921d 100644 --- a/app/Models/v3/GoodsNew.php +++ b/app/Models/v3/GoodsNew.php @@ -62,7 +62,7 @@ class GoodsNew extends Model public function imageUrl($value) { if(strripos($value,"http") === false){ - return env('OSS_IMG_HOST').'/'.$value; + return config('filesystems.disks.oss.img_host').'/'.$value; }else{ return $value; } diff --git a/app/Models/v3/ServicePersonnel.php b/app/Models/v3/ServicePersonnel.php index f68195b..eb25c81 100644 --- a/app/Models/v3/ServicePersonnel.php +++ b/app/Models/v3/ServicePersonnel.php @@ -12,5 +12,60 @@ class ServicePersonnel extends Model use SoftDeletes; protected $table = 'lanzu_service_personnel'; - + protected $dateFormat = 'U'; + + /* 查询记录数 limit */ + protected $perPage = 10; + + public static $_TYPE= [1=>'普通专员',2=>'市场经理']; + public static $_STATUS = [-1=>'禁用',0=>'禁用',1=>'启用',2=>'删除']; + + protected $appends = [ + 'type_text', + 'status_text' + ]; + + public function getTypeTextAttribute($value) + { + $value = $value ? $value : $this->type; + return isset(self::$_TYPE[$value]) ? self::$_TYPE[$value] : ''; + } + public function getStatusTextAttribute($value) + { + $value = $value ? $value : $this->status; + return isset(self::$_STATUS[$value]) ? self::$_STATUS[$value] : ''; + } + + /** + * 获取单条信息 + * @param int $id + * @param string $field + * @return string + */ + public static function getInfo($id,$field = '*') + { + return self::select($field)->find($id); + } + + /** + * 获取二级分类数组 + * id为键,title为值 + * @return array + */ + public static function getArray($where = [],$options = []) + { + $model = self::where('status',1) + ->whereNull('deleted_at'); + + if(count($where) > 0){ + $model->where($where); + } + $list = $model->pluck('id','name')->toArray(); + if(!empty($options)){ + $new = array_merge($options,$list); + return array_flip($new); + }else{ + return array_flip($list); + } + } } diff --git a/app/Models/v3/Store.php b/app/Models/v3/Store.php index c445f7b..0370a3b 100644 --- a/app/Models/v3/Store.php +++ b/app/Models/v3/Store.php @@ -11,7 +11,7 @@ class Store extends Model use HasDateTimeFormatter; use SoftDeletes; - protected $table = 'lanzu_store'; + protected $table = 'lanzu_store_new'; protected $dateFormat = 'U'; /* 查询记录数 limit */ @@ -107,7 +107,7 @@ class Store extends Model public function imageUrl($value) { if(strripos($value,"http") === false){ - return env('OSS_IMG_HOST').'/'.$value; + return config('filesystems.disks.oss.img_host').'/'.$value; }else{ return $value; } diff --git a/app/Models/v3/StoreNew.php b/app/Models/v3/StoreNew.php index 7db225f..62e9fc1 100644 --- a/app/Models/v3/StoreNew.php +++ b/app/Models/v3/StoreNew.php @@ -17,8 +17,8 @@ class StoreNew extends Model /* 查询记录数 limit */ protected $perPage = 10; - public static $_isRest= ['否','是']; - public static $_isOpen = ['关闭','开启']; + public static $_ISREST= ['否','是']; + public static $_ISOPEN = ['关闭','开启']; protected $appends = [ 'logo_url', @@ -35,12 +35,12 @@ class StoreNew extends Model public function getIsRestTextAttribute($value) { $value = $value ? $value : $this->is_rest; - return isset(self::$_onRest[$value]) ? self::$_onRest[$value] : ''; + return isset(self::$_ISREST[$value]) ? self::$_ISREST[$value] : ''; } public function getIsOpenTextAttribute($value) { $value = $value ? $value : $this->is_iopen; - return isset(self::$_isOpen[$value]) ? self::$_isOpen[$value] : ''; + return isset(self::$_ISOPEN[$value]) ? self::$_ISOPEN[$value] : ''; } /** @@ -107,7 +107,7 @@ class StoreNew extends Model public function imageUrl($value) { if(strripos($value,"http") === false){ - return env('OSS_IMG_HOST').'/'.$value; + return config('filesystems.disks.oss.img_host').'/'.$value; }else{ return $value; } diff --git a/config/filesystems.php b/config/filesystems.php index e8d5d51..1f00391 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -67,10 +67,12 @@ return [ 'secret_key' => env('OSS_ACCESS_SECRET'), 'endpoint' => env('OSS_ENDPOINT'), // 使用 ssl 这里设置如: https://oss-cn-beijing.aliyuncs.com 'bucket' => env('OSS_BUCKET'), - 'isCName' => env('OSS_IS_CNAME', false), // 如果 isCname 为 false,endpoint 应配置 oss 提供的域名如:`oss-cn-beijing.aliyuncs.com`,否则为自定义域名,,cname 或 cdn 请自行到阿里 oss 后台配置并绑定 bucket + 'isCName' => env('OSS_IS_CNAME', false), + // 如果 isCname 为 false,endpoint 应配置 oss 提供的域名如:`oss-cn-beijing.aliyuncs.com`,否则为自定义域名,,cname 或 cdn 请自行到阿里 oss 后台配置并绑定 bucket // 如果有更多的 bucket 需要切换,就添加所有bucket,默认的 bucket 填写到上面,不要加到 buckets 中 'buckets'=>[ ], + 'img_host' => env('OSS_IMG_HOST'), ], 's3' => [