Explorar el Código

邀请人数+1

shish hace 6 años
padre
commit
a613ec7297
Se han modificado 1 ficheros con 47 adiciones y 33 borrados
  1. 47 33
      biz/saas/classes/ApplyClass.php

+ 47 - 33
biz/saas/classes/ApplyClass.php

@@ -3,6 +3,7 @@
 namespace biz\saas\classes;
 
 use biz\admin\classes\AdminShopClass;
+use biz\agent\classes\AgentAssetClass;
 use common\components\sms;
 use common\components\stringUtil;
 use common\components\util;
@@ -10,37 +11,50 @@ 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('您已申请过了');
-		}
-		$adminShop = AdminShopClass::getByCondition(['adminId' => $data['adminId']]);
-		if (!empty($adminShop)) {
-			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 . ' 已提交开店资料,请及时跟进');
-		return self::add($data);
-	}
-	
+
+    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('您已申请过了');
+        }
+        $adminShop = AdminShopClass::getByCondition(['adminId' => $data['adminId']]);
+        if (!empty($adminShop)) {
+            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);
+    }
+
 }