Browse Source

支持广告渠道

joe 3 years ago
parent
commit
97a04b9df5

+ 4 - 0
CHANGELOG

@@ -2,3 +2,7 @@
 2022-02-14:
 ALTER TABLE twong.eb_dict_coin ADD mine_per_sec DECIMAL(8,8) DEFAULT 0.0 NOT NULL COMMENT '每秒可挖个数';
 ALTER TABLE twong.eb_dict_coin ADD status SMALLINT DEFAULT 0 NOT NULL COMMENT '0 上架但不可挖 -1 已下架 1 可挖';
+
+2022-02-16:
+ALTER TABLE twong.eb_user ADD channel INT(8) DEFAULT 0 NOT NULL COMMENT '渠道编号';
+CREATE INDEX eb_user_channel_IDX USING BTREE ON twong.eb_user (channel);

+ 5 - 0
README.md

@@ -121,3 +121,8 @@ php think workerman start admin
 ## 文档
 
 [TP6开发手册](https://www.kancloud.cn/manual/thinkphp6_0/content)
+
+## 1.4.0 更新
+1. 新增 user_coin 表字段
+2. 新增 dict_coin 表行
+3. 更新配置

+ 4 - 2
app/api/controller/wechat/AuthController.php

@@ -223,9 +223,10 @@ class AuthController
         }
 
         $data = UtilService::postMore([
-            ['spread_spid', 0],
-            ['spread_code', ''],
+            ['spread_spid', 0],     // 推广信息
+            ['spread_code', ''],    // 扫码信息
             ['iv', ''],
+            ['ch', 0],            // 渠道号
             ['encryptedData', ''],
         ]); //获取前台传的code
         try {
@@ -242,6 +243,7 @@ class AuthController
         $userInfo['openId'] = $userInfoWx['openid'];
         $userInfo['spid'] = $data['spread_spid'];
         $userInfo['code'] = $data['spread_code'];
+        $userInfo['channel'] = $data['ch'];
         $userInfo['session_key'] = $session_key;
         $userInfo['login_type'] = $login_type;
         $uid = WechatUser::routineOauth($userInfo);

+ 1 - 0
app/models/user/User.php

@@ -227,6 +227,7 @@ class User extends BaseModel
             'add_ip' => request()->ip(),
             'last_time' => time(),
             'last_ip' => request()->ip(),
+            'channel' => $routineUser['channel'],
             'user_type' => $routineUser['user_type']
         ]);
         $res = $res1 && $res2;

+ 8 - 5
app/models/user/WechatUser.php

@@ -91,13 +91,14 @@ class WechatUser extends BaseModel
         $routineInfo['session_key'] = $routine['session_key'];//会话密匙
         $routineInfo['unionid'] = $routine['unionId'];//用户在开放平台的唯一标识符
         $routineInfo['user_type'] = 'routine';//用户类型
+        $routineInfo['channel'] = $routine['channel'];
         $spid = 0;//绑定关系uid
-        $isCOde = false;
+        $isByQRScan = false;
         //获取是否有扫码进小程序
         if ($routine['code']) {
             if ($info = RoutineQrcode::getRoutineQrcodeFindType($routine['code'])) {
                 $spid = $info['third_id'];
-                $isCOde = true;
+                $isByQRScan = true;
             } else {
                 $spid = $routine['spid'];
             }
@@ -109,13 +110,15 @@ class WechatUser extends BaseModel
         if ($routineInfo['unionid'] != '' && ($uid = self::where(['unionid' => $routineInfo['unionid']])->where('user_type', '<>', 'h5')->value('uid'))) {
             self::edit($routineInfo, $uid, 'uid');
             $routineInfo['code'] = $spid;
-            $routineInfo['isPromoter'] = $isCOde;
-            if ($routine['login_type']) $routineInfo['login_type'] = $routine['login_type'];
+            $routineInfo['isPromoter'] = $isByQRScan;
+            if ($routine['login_type']) {
+                $routineInfo['login_type'] = $routine['login_type'];
+            }
             User::updateWechatUser($routineInfo, $uid);
         } else if ($uid = self::where(['routine_openid' => $routineInfo['routine_openid']])->where('user_type', '<>', 'h5')->value('uid')) { //根据小程序openid判断
             self::edit($routineInfo, $uid, 'uid');
             $routineInfo['code'] = $spid;
-            $routineInfo['isPromoter'] = $isCOde;
+            $routineInfo['isPromoter'] = $isByQRScan;
             if ($routine['login_type']) {
                 $routineInfo['login_type'] = $routine['login_type'];
             }