ApplyClass.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace biz\saas\classes;
  3. use biz\admin\classes\ShopAdminClass;
  4. use biz\agent\classes\AgentAssetClass;
  5. use common\components\sms;
  6. use common\components\stringUtil;
  7. use common\components\util;
  8. use biz\base\classes\BaseClass;
  9. class ApplyClass extends BaseClass
  10. {
  11. public static $baseFile = '\biz\saas\models\Apply';
  12. //添加申请 shish 2020.2.10
  13. public static function addApply($data)
  14. {
  15. $mobile = isset($data['mobile']) ? $data['mobile'] : 0;
  16. if (stringUtil::isMobile($mobile) == false) {
  17. util::fail('请填写手机号');
  18. }
  19. $apply = self::getByCondition(['mobile' => $mobile]);
  20. if (!empty($apply)) {
  21. util::fail('手机号已被使用');
  22. }
  23. $apply = self::getByCondition(['adminId' => $data['adminId']]);
  24. if (!empty($apply)) {
  25. util::fail('您已申请过了');
  26. }
  27. $shopAdmin = ShopAdminClass::getByCondition(['adminId' => $data['adminId']]);
  28. if (!empty($shopAdmin)) {
  29. util::fail('您已经有门店了');
  30. }
  31. $prefix = $data['province'] == $data['city'] ? $data['province'] : $data['province'] . $data['city'];
  32. $dist = isset($data['dist']) ? $data['dist'] : '';
  33. $floor = isset($data['floor']) ? $data['floor'] : '';
  34. $data['fullAddress'] = $prefix . $dist . $data['address'] . $floor;
  35. $time = time();
  36. $data['addTime'] = $time;
  37. $mobile = $data['mobile'];
  38. sms::freeSend(15280215347, '客户 ' . $mobile . ' 已提交开店资料,请及时跟进');
  39. //邀请人数+1
  40. $introMerchantId = isset($data['introMerchantId']) ? $data['introMerchantId'] : '';
  41. if (!empty($introMerchantId)) {
  42. $agent = AgentAssetClass::getByCondition(['merchantId' => $introMerchantId], true);
  43. if (empty($agent)) {
  44. $time = time();
  45. $agent = AgentAssetClass::add(['merchantId' => $introMerchantId, 'addTime' => $time], true);
  46. }
  47. $agent->inviteNum += 1;
  48. $agent->save();
  49. }
  50. return self::add($data);
  51. }
  52. }