123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- // +----------------------------------------------------------------------
- // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
- // +----------------------------------------------------------------------
- // | Author: 萤火科技 <admin@yiovo.com>
- // +----------------------------------------------------------------------
- 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;
- }
- }
|