StaffMobile.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\api\model;
  13. use app\common\model\StaffMobile as StaffMobiles;
  14. use think\facade\Log;
  15. /**
  16. * 商家记录表模型
  17. * Class Store
  18. * @package app\store\model
  19. */
  20. class StaffMobile extends StaffMobiles
  21. {
  22. /**
  23. * 店长保存店员手机号
  24. * @param $mobile
  25. * @param $shopId
  26. * @return bool
  27. * @throws \app\common\exception\BaseException
  28. * @throws \think\db\exception\DataNotFoundException
  29. * @throws \think\db\exception\DbException
  30. * @throws \think\db\exception\ModelNotFoundException
  31. */
  32. public static function recordMobile($mobile,$shopId){
  33. $userId = \app\api\service\User::getCurrentLoginUserId();
  34. if (self::where(['user_id'=>$userId,'mobile'=>$mobile])->find()){
  35. return true;
  36. }
  37. $staffUser = User::where('mobile',$mobile)->find();
  38. if ($staffUser && $staffUser->role != User::NORMAL_USER){
  39. return false;
  40. }
  41. //$manager = User::find($userId);
  42. try {
  43. $m = new self();
  44. $m->user_id = $userId;
  45. $m->mobile = $mobile;
  46. $m->shop_id = $shopId;
  47. //$m->shop_id = $manager->shop_id??0;
  48. $m->save();
  49. //self::insert(['user_id'=>$userId,'mobile'=>$mobile]);
  50. }catch (\Exception $e){
  51. Log::error(__METHOD__.$e->getMessage());
  52. return false;
  53. }
  54. return true;
  55. }
  56. }