belongsTo('app\common\model\store\User','store_user_id','store_user_id'); } /** * 店铺详情 * @param $where * @param array $with * @return static|null * @throws \think\exception\DbException */ public static function detail($where, $with = []) { !is_array($where) && $where = ['shop_id' => (int)$where]; return static::get(array_merge(['is_delete' => 0], $where), $with); } /** * 切换状态 * @param $status * @return false|int */ public function setStatus($status) { if($status == 1 && $this['stop_date'] == date("Y-m-d")){ return '当天已到达收款上限,停止接单'; } if($bool = $this->save(['status' => $status])){ $bool = true; } return $bool; } /** * 获取全部 * @param array $user * @return mixed */ public static function getAll($user = []) { $filter = []; if(isset($user['is_super']) && $user['is_super'] == 0) { $filter[] = ['store_user_id', 'in', User::getScope($user)]; } $model = new static; return $model->where('is_delete', '=', 0)->where($filter)->order(['shop_id' => 'asc'])->select(); } /** * 获取启用店铺 * @return mixed */ public static function getOnline() { $model = new static; //在线,并且当天未停止接单 $data = $model->where('status', '=', 1)->where('stop_date', '!=', date('Y-m-d'))->order(['shop_id' => 'asc'])->select()->toArray(); return array_column($data,'shop_id'); } /** * 切换状态 * @param $status * @return false|int */ public function changeStatus($status) { if($status == 1 && $this['stop_date'] == date("Y-m-d")){ return '当天已到达收款上限,停止接单'; } if($bool = $this->save(['status' => $status])){ $bool = true; } return $bool; } /** * 修改收款金额 * @param $data * @return bool */ public function updateMoney($data) { if ($data['max_money'] <= 0) { $this->error = '收款金额必须大于0'; return false; } return $this->save([ 'max_money' => $data['max_money'], ]) !== false; } }