| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace biz\saas\classes;
- use biz\admin\classes\ShopAdminClass;
- use biz\agent\classes\AgentAssetClass;
- use common\components\sms;
- use common\components\stringUtil;
- use common\components\util;
- use biz\base\classes\BaseClass;
- class ApplyClass extends BaseClass
- {
- public static $baseFile = '\biz\saas\models\Apply';
- //添加申请 shish 2020.2.10
- public static function addApply($data)
- {
- $mobile = isset($data['mobile']) ? $data['mobile'] : 0;
- if (stringUtil::isMobile($mobile) == false) {
- util::fail('请填写手机号');
- }
- $apply = self::getByCondition(['mobile' => $mobile]);
- if (!empty($apply)) {
- util::fail('手机号已被使用');
- }
- $apply = self::getByCondition(['adminId' => $data['adminId']]);
- if (!empty($apply)) {
- util::fail('您已申请过了');
- }
- $shopAdmin = ShopAdminClass::getByCondition(['adminId' => $data['adminId']]);
- if (!empty($shopAdmin)) {
- util::fail('您已经有门店了');
- }
- $prefix = $data['province'] == $data['city'] ? $data['province'] : $data['province'] . $data['city'];
- $dist = isset($data['dist']) ? $data['dist'] : '';
- $floor = isset($data['floor']) ? $data['floor'] : '';
- $data['fullAddress'] = $prefix . $dist . $data['address'] . $floor;
- $time = time();
- $data['addTime'] = $time;
- $mobile = $data['mobile'];
- sms::freeSend(15280215347, '客户 ' . $mobile . ' 已提交开店资料,请及时跟进');
- //邀请人数+1
- $introMerchantId = isset($data['introMerchantId']) ? $data['introMerchantId'] : '';
- if (!empty($introMerchantId)) {
- $agent = AgentAssetClass::getByCondition(['merchantId' => $introMerchantId], true);
- if (empty($agent)) {
- $time = time();
- $agent = AgentAssetClass::add(['merchantId' => $introMerchantId, 'addTime' => $time], true);
- }
- $agent->inviteNum += 1;
- $agent->save();
- }
- return self::add($data);
- }
- }
|