where($where)->with(['app'])->find()) { return false; } if (empty($supplier['app'])) { $this->error = '登录失败, 未找到应用信息'; return false; } if ($supplier['app']['is_recycle']) { $this->error = '登录失败, 当前应用已删除'; return false; } // 保存登录状态 $this->loginState($supplier); return true; } /* * 修改密码 */ public function editPass($data, $user) { $user_info = User::detail($user['shop_user_id']); if ($data['password'] != $data['confirmPass']) { $this->error = '密码错误'; return false; } if ($user_info['password'] != salt_hash($data['oldpass'])) { $this->error = '两次密码不相同'; return false; } $date['password'] = salt_hash($data['password']); $user_info->save($date); return true; } /** * 保存登录状态 */ public function loginState($supplier) { $app = $supplier['app']; // 保存登录状态 $session = array( 'supplier' => [ 'shop_supplier_id' => $supplier['shop_supplier_id'], 'user_name' => $supplier['user_name'] ], 'app' => $app->toArray(), 'is_login' => true, ); session('jjjshop_supplier', $session); } /** * 修改 */ 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; } return $this->save([ 'link_name' => $data['link_name'], 'link_phone' => $data['link_phone'], 'address' => $data['address'], '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, 'notice' => $data['notice'] ]); } /** * 资金冻结 */ public function freezeMoney($money) { return $this->save([ 'money' => $this['money'] - $money, '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); } }