Browse Source

注册&实名赠送积分

xialei 1 year ago
parent
commit
ea5049cfa7
2 changed files with 94 additions and 0 deletions
  1. 44 0
      app/common/repositories/user/UserRepository.php
  2. 50 0
      app/controller/api/user/User.php

+ 44 - 0
app/common/repositories/user/UserRepository.php

@@ -933,6 +933,47 @@ class UserRepository extends BaseRepository
933
         return $user;
933
         return $user;
934
     }
934
     }
935
 
935
 
936
+        /**
937
+     * @param int $uid 用户ID
938
+     * @param string $score 积分
939
+     * @param int $status 积分状态
940
+     * @param string $mark 备注
941
+     * @param string $has_qian 连续签到天数
942
+     * @param string $today_signintime 签到时间
943
+     * @param int $order_id 订单ID
944
+     * @param int $pm 1-收入。2-支出
945
+     * @param string $order_type
946
+     * @throws DbException
947
+     */
948
+    public function sign_add($uid, $score, $status, $mark, $has_qian = '', $today_signintime = '', $order_id = 0, $pm = 1, $order_type = '',$type='',$settlement_time = '')
949
+    {
950
+        if(!in_array($type,[1,2])){
951
+            // 其他情况都直接返回,因为目前只有365专区购买才可以获得
952
+            return false;
953
+        }
954
+
955
+        $ins_data['uid'] = $uid;
956
+        $ins_data['continuity_day'] = $has_qian;
957
+        $ins_data['reward_socre'] = $score;
958
+        $ins_data['signin_time'] = $today_signintime;
959
+        $ins_data['addtime'] = time();
960
+        $ins_data['status'] = $status;
961
+        $ins_data['mark'] = $mark;
962
+        $ins_data['type'] = $type;
963
+        $ins_data['settlement_time'] = $settlement_time;// 结算时间 真正到了结算时间会结算
964
+        $ins_data['order_id'] = $order_id;
965
+        $ins_data['pm'] = $pm;
966
+        $ins_data['order_type'] = $order_type;
967
+        Db::name('user_sign_score')->insertGetId($ins_data);
968
+
969
+        if($pm == 1 && $status == 1){
970
+            Db::name('user')->where('uid',$uid)->inc('score', $score)->update();
971
+        }
972
+        if($pm == 2){
973
+            Db::name('user')->where('uid', $uid)->dec('score', $score)->update();
974
+        }
975
+    }
976
+
936
     /**
977
     /**
937
      * @param string $type
978
      * @param string $type
938
      * @param array $userInfo
979
      * @param array $userInfo
@@ -962,6 +1003,9 @@ class UserRepository extends BaseRepository
962
 //
1003
 //
963
 //            Queue::push(SendNewPeopleCouponJob::class, $user->uid);
1004
 //            Queue::push(SendNewPeopleCouponJob::class, $user->uid);
964
 
1005
 
1006
+            //赠送积分 注册送10积分
1007
+            $this->sign_add($user['uid'], 10,1,'注册送10积分','','');
1008
+
965
             Db::commit();
1009
             Db::commit();
966
             return $user;
1010
             return $user;
967
         } catch (\Exception $e) {
1011
         } catch (\Exception $e) {

+ 50 - 0
app/controller/api/user/User.php

@@ -720,6 +720,14 @@ class User extends BaseController
720
             $params['status'] = 1;
720
             $params['status'] = 1;
721
             $res = $this->repository->add_cer($params, $member_id);
721
             $res = $this->repository->add_cer($params, $member_id);
722
             if ($res) {
722
             if ($res) {
723
+                //赠送积分 完善实名送20个积分,同时送邀请人20个积
724
+                $this->sign_add($member_id, 20,1,'完善实名系统赠送20个积分','','');
725
+                $member_info = Db::name('user')->where( array('uid' => $member_id) )->find(); 
726
+                if($member_info['spread_uid']){
727
+                     //首次邀请好友奖励积分
728
+                    $spreadUid = $member_info['spread_uid'];
729
+                    $this->sign_add($spreadUid, 20,1,'好友完善实名系统赠送20个积分','','');
730
+                }
723
                 return app('json')->success($res);
731
                 return app('json')->success($res);
724
             } else {
732
             } else {
725
                 return app('json')->fail('认证失败');
733
                 return app('json')->fail('认证失败');
@@ -730,6 +738,48 @@ class User extends BaseController
730
 
738
 
731
     }
739
     }
732
 
740
 
741
+
742
+        /**
743
+     * @param int $uid 用户ID
744
+     * @param string $score 积分
745
+     * @param int $status 积分状态
746
+     * @param string $mark 备注
747
+     * @param string $has_qian 连续签到天数
748
+     * @param string $today_signintime 签到时间
749
+     * @param int $order_id 订单ID
750
+     * @param int $pm 1-收入。2-支出
751
+     * @param string $order_type
752
+     * @throws DbException
753
+     */
754
+    public function sign_add($uid, $score, $status, $mark, $has_qian = '', $today_signintime = '', $order_id = 0, $pm = 1, $order_type = '',$type='',$settlement_time = '')
755
+    {
756
+        if(!in_array($type,[1,2])){
757
+            // 其他情况都直接返回,因为目前只有365专区购买才可以获得
758
+            return false;
759
+        }
760
+
761
+        $ins_data['uid'] = $uid;
762
+        $ins_data['continuity_day'] = $has_qian;
763
+        $ins_data['reward_socre'] = $score;
764
+        $ins_data['signin_time'] = $today_signintime;
765
+        $ins_data['addtime'] = time();
766
+        $ins_data['status'] = $status;
767
+        $ins_data['mark'] = $mark;
768
+        $ins_data['type'] = $type;
769
+        $ins_data['settlement_time'] = $settlement_time;// 结算时间 真正到了结算时间会结算
770
+        $ins_data['order_id'] = $order_id;
771
+        $ins_data['pm'] = $pm;
772
+        $ins_data['order_type'] = $order_type;
773
+        Db::name('user_sign_score')->insertGetId($ins_data);
774
+
775
+        if($pm == 1 && $status == 1){
776
+            Db::name('user')->where('uid',$uid)->inc('score', $score)->update();
777
+        }
778
+        if($pm == 2){
779
+            Db::name('user')->where('uid', $uid)->dec('score', $score)->update();
780
+        }
781
+    }
782
+
733
     /**
783
     /**
734
      * 申请代理
784
      * 申请代理
735
      * name:公司名称
785
      * name:公司名称