| | |
| | | */ |
| | | class Supplier extends SupplierModel |
| | | { |
| | | |
| | | protected $append=['coordinate']; |
| | | public function getCoordinateAttr($v,$data) |
| | | { |
| | | return $data['latitude'].','.$data['longitude']; |
| | | } |
| | | /** |
| | | *检查登录 |
| | | */ |
| | |
| | | */ |
| | | public function edit($data){ |
| | | $isexist = $this->where('name','=',$data['name'])->where('shop_supplier_id','<>',$data['shop_supplier_id'])->find(); |
| | | $latitude=0; |
| | | $longitude=0; |
| | | if (!empty($data['coordinate'])){ |
| | | $coordinate=explode(',',$data['coordinate']); |
| | | $latitude=$coordinate[0]; |
| | | $longitude=$coordinate[1]; |
| | | } |
| | | if($isexist){ |
| | | $this->error = '店铺名称已存在'; |
| | | return false; |
| | |
| | | 'description' => $data['description'], |
| | | 'logo_id' => $data['logo_id'], |
| | | 'business_id' => $data['business_id'], |
| | | 'latitude' =>$latitude, |
| | | 'longitude' => $longitude, |
| | | 'app_id' => self::$app_id, |
| | | 'name' => $data['name'], |
| | | 'is_full' => 1, |
| | |
| | | 'freeze_money' => $this['freeze_money'] + $money, |
| | | ]); |
| | | } |
| | | |
| | | /** |
| | | * 获取列表数据 |
| | | */ |
| | | public function getList($params) |
| | | { |
| | | $model = $this; |
| | | if (isset($params['search']) && $params['search']) { |
| | | $model = $model->where('name', 'like', '%' . $params['search'] . '%'); |
| | | } |
| | | if(isset($params['shop_supplier_ids'])&&$params['shop_supplier_ids']){ |
| | | $model = $model->where('shop_supplier_id', 'in', $params['shop_supplier_ids']); |
| | | } |
| | | if(isset($params['is_takeout']) && $params['is_takeout'] > -1){ |
| | | $model = $model->where('is_takeout', '=', $params['is_takeout']); |
| | | } |
| | | // 查询列表数据 |
| | | return $model->with(['logo', 'superUser', 'business', 'qyQrcode']) |
| | | ->where('is_delete', '=', '0') |
| | | ->order(['create_time' => 'desc']) |
| | | ->paginate($params); |
| | | } |
| | | } |