Parcourir la source

Wesmiler 2021-0115第4期分销功能新增

wesmiler il y a 5 ans
Parent
commit
e3aad4aeb7

+ 1 - 1
app/api/controller/MemberController.php

@@ -269,7 +269,7 @@ class MemberController extends BaseController
             if ($avatar) {
                 $memberData['avatar'] = $avatar;
             }
-            PRedis::set('members:reg:info:' . $this->userId, $memberData, 3600);
+            //PRedis::set('members:reg:info:' . $this->userId, $memberData, 3600);
             if (!Member::saveData(['id' => $this->userId], $memberData)) {
                 Db::rollback();
                 showJson(1004, 2104);

+ 1 - 1
app/api/controller/TestController.php

@@ -54,7 +54,7 @@ class TestController extends HomeBaseController
             ->find();
         $order = $order? $order->toArray() : [];
         $order['check_name'] = 'FORCE_CHECK';
-        $order['real_name'] = '张三';
+        $order['real_name'] = '陈永平';
         var_dump($order);
         $result = Wechat::transferOrder($order);
 

+ 20 - 0
app/weixin/model/Member.php

@@ -371,6 +371,26 @@ class Member extends Model
     }
 
     /**
+     * 获取邀请的分销用户信息
+     * @param $userId 当前用户ID
+     * @param string $field 返回字段,连表u-当前用户,uu连表用户
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public static function getInviteInfo($userId, $field=''){
+        $field = $field? $field : 'u.id,uu.id as invite_id,uu.openid,uu.parent_id';
+        $info = Member::alias('u')
+            ->leftJoin('user uu','uu.id=u.parent_id')
+            ->where(['u.id'=> $userId,'uu.user_type'=> 2,'uu.agent_type'=> 1,'uu.agent_status'=> 1])
+            ->field($field)
+            ->find();
+
+        return $info? $info->toArray() : [];
+    }
+
+    /**
      * 充值记录
      * @param $params
      * @param int $pageSize

+ 11 - 0
app/weixin/model/UserBalanceLog.php

@@ -7,4 +7,15 @@ use think\Model;
 class UserBalanceLog extends Model
 {
     protected $table = 'sg_user_balance_log';
+
+    /**
+     * 验证用户是否已经结算过对应类型收益
+     * @param $userid 结算用户ID
+     * @param $sourceUid 来源用户ID
+     * @param $type 收益类型
+     * @return mixed
+     */
+    public static function checkHasMarket($userid, $sourceUid, $type){
+        return UserBalanceLog::where(['user_id'=> $userid, 'source_uid'=> $sourceUid,'type'=> $type, 'status'=> 1])->value('id');
+    }
 }

+ 10 - 0
app/weixin/model/UserProfile.php

@@ -2,6 +2,7 @@
 
 namespace app\weixin\model;
 
+use app\weixin\service\Award;
 use app\weixin\service\PRedis;
 use think\Db;
 use think\Model;
@@ -49,6 +50,15 @@ class UserProfile extends Model
         // 加入怦然心动,关闭隐身
         Member::saveData(['id'=> $userId], ['is_heart'=> 1]);
 
+        // 完善资料分销奖励
+        $inviteInfo = Member::getInviteInfo($userId);
+        $inviteId = isset($inviteInfo['invite_id'])? $inviteInfo['invite_id'] : 0;
+        if($inviteInfo && $inviteId>0){
+            if(!UserBalanceLog::checkHasMarket($inviteId, $userId, 4)){
+                Award::marketAward($inviteId, $userId, 4);
+            }
+        }
+
         // 不在送爱心
         return false;
 

+ 2 - 1
app/weixin/model/Wechat.php

@@ -672,12 +672,13 @@ class Wechat
         // 测试支付金额
         $payDebug = config('weixin.payDebug');
         if ($payDebug) {
-            $totalFee = 0.01;
+            $totalFee = 0.3;
         }
         if (empty($openid) || empty($orderNo) || empty($totalFee)) {
             return ['code' => 'error', 'message' => '参数错误'];
         }
         $unified = array(
+//            'mch_appid' => 'ww80960cfd3748a47f',
             'mch_appid' => $appId,
             'mchid' => trim($mchId),
             'nonce_str' => Wechat::createNonceStr(),

+ 12 - 0
app/weixin/service/Member.php

@@ -6,6 +6,7 @@
 namespace app\weixin\service;
 
 use app\weixin\model\AccountLog;
+use app\weixin\model\UserBalanceLog;
 use app\weixin\model\UserProfile;
 use app\weixin\model\Member as MemberModel;
 use app\weixin\model\Wechat;
@@ -163,6 +164,17 @@ class Member
                 Wechat::sendTplMsg($openid, $params);
             }
 
+            // 认证分销收益结算
+            $inviteInfo = MemberModel::getInviteInfo($userId);
+            $inviteId = isset($inviteInfo['invite_id'])? $inviteInfo['invite_id'] : 0;
+            if($inviteInfo && $inviteId>0){
+                $types = ['idcard'=> 5, 'education'=> 6, 'position'=> 7];
+                $type = isset($types[$scene])? $types[$scene] : 0;
+                if($type && !UserBalanceLog::checkHasMarket($inviteId, $userId, $type)){
+                    Award::marketAward($inviteId, $userId, $type);
+                }
+            }
+
             return ['id'=> $userId];
         } catch (\Exception $exception){
             // var_dump($exception);

+ 6 - 1
develop_v4.md

@@ -25,9 +25,14 @@
 1. user表
 1)agent_type  新增分销用户标识字段
 2)agent_status 分销审核字段
+2)agent_create_time 分销用户注册时间
 
 2. user_balance_log表
 调整字段作为账户余额变动记录表
 
 3. market表
-新增分销参数配置表
+新增分销参数配置表
+
+4. book 表 
+增加  is_market 是否结算收益
+

+ 4 - 1
task.md

@@ -11,4 +11,7 @@ http://wx.nnsg520.com/api/task/catchMakeHearts?key=Baiybe6db4H2xKL65C1bNb83a07WT
 
 
 拾光申请微信未审核自动取消任务    每3小时, 第0分钟 执行	
-http://wx.nnsg520.com/api/task/cancelContact?key=Baiybe6db4H2xKL65C1bNb83a07HSTsk
+http://wx.nnsg520.com/api/task/cancelContact?key=Baiybe6db4H2xKL65C1bNb83a07HSTsk
+
+报名活动结束自动结算分销收益    每20分钟执行1次
+http://wx.nnsg520.com/api/task/catchBookMarket?key=Baiybe6db4H2xKL65MAbNb83a07PPTsc