// +---------------------------------------------------------------------- declare (strict_types = 1); namespace app\api\model; use app\common\model\StaffMobile as StaffMobiles; use think\facade\Log; /** * 商家记录表模型 * Class Store * @package app\store\model */ class StaffMobile extends StaffMobiles { /** * 店长保存店员手机号 * @param $mobile * @param $shopId * @return bool * @throws \app\common\exception\BaseException * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function recordMobile($mobile,$shopId){ $userId = \app\api\service\User::getCurrentLoginUserId(); if (self::where(['user_id'=>$userId,'mobile'=>$mobile])->find()){ return true; } $staffUser = User::where('mobile',$mobile)->find(); if ($staffUser && $staffUser->role != User::NORMAL_USER){ return false; } //$manager = User::find($userId); try { $m = new self(); $m->user_id = $userId; $m->mobile = $mobile; $m->shop_id = $shopId; //$m->shop_id = $manager->shop_id??0; $m->save(); //self::insert(['user_id'=>$userId,'mobile'=>$mobile]); }catch (\Exception $e){ Log::error(__METHOD__.$e->getMessage()); return false; } return true; } }