Procházet zdrojové kódy

邀请页六个数据接口

lizhen_gitee před 1 rokem
rodič
revize
e4b8352702

+ 75 - 0
application/api/controller/Usercenter.php

@@ -21,6 +21,30 @@ class Usercenter extends Api
         $this->success(1,$list);
     }
 
+    //用户的业绩总额等
+    public function my_intro_data(){
+
+        //从lib/auth ->getUserinfo 拿过来
+        $userinfo['score'] = model('wallet')->getWallet($this->auth->id,'score');//积分
+        $userinfo['withdraw_score'] = Db::name('user_withdraw')->where('user_id',$this->auth->id)->where('status',1)->sum('score');//已兑换积分
+        $userinfo['share_score'] = Db::name('user_score_log')->where('user_id',$this->auth->id)->where('log_type','IN',[3,4])->sum('change_value');//分享奖励
+        $userinfo['intro_number'] = Db::name('user')->where('intro_uid',$this->auth->id)->count('id');//我的粉丝
+
+
+        //获取业绩
+        $yeji = $this->jiesuan_yeji($this->auth->id);
+        $userinfo['yeji'] = $yeji;
+
+        //代理规则
+        $rule = $this->jiesuan_daili_level($yeji);
+        $agent_score = bcdiv(bcmul($yeji,$rule['bili'],2),100,2);
+        $userinfo['agent_score'] = $agent_score;
+
+        $this->success(1,$userinfo);
+    }
+
+
+
     //生成我的视频海报
     //生成邀请码二维码图片
     public function inviteimage($introcode) {
@@ -100,4 +124,55 @@ class Usercenter extends Api
 
         $this->success('', $imgurl);
     }
+
+
+    /////////////////////////////
+    //获取业绩
+    private function jiesuan_yeji($user_id){
+        //找到所有下级
+        //$user_ids = Db::name('user')->where('find_in_set(:intro_ids,intro_ids)', ['intro_ids' => $user_id])->column('id');
+        $commonuser = new \app\common\model\User();
+        $user_ids = $commonuser->my_down_all($user_id,[$user_id]);
+//        dump($user_ids);
+
+        if(empty($user_ids)){
+            return 0;
+        }
+
+        $map = [
+            'status' => 1,
+            'have_paid' => ['gt',0],
+            'user_id' => ['IN',$user_ids],
+        ];
+        $yeji = Db::name('unishop_order')->where($map)->sum('order_price');
+
+        //减去提现的
+        $map = [
+            'status' => 1,
+            'user_id' => ['IN',$user_ids],
+        ];
+        $take_cash = Db::name('user_withdraw')->where($map)->sum('score');
+
+        $yeji = $yeji - $take_cash;
+
+        return $yeji;
+    }
+
+
+
+    //确认代理等级及规则
+    private function jiesuan_daili_level($yeji){
+
+        $data = Db::name('zongdai')->order('id asc')->select();
+//        dump($data);
+
+        $return = $data[0]; //默认第0个
+        foreach($data as $key => $rule){
+            if($yeji >= $rule['yeji']){
+                $return = $rule;
+            }
+        }
+
+        return $return;
+    }
 }

+ 2 - 2
application/extra/wallet.php

@@ -8,10 +8,10 @@ return [
         2  => '积分兑换', //score -
         21  => '积分兑换返回', //score +
         3  => '直推代理奖励', //支付后立刻获得 score +
-        4  => '间推代理奖励', //支付后立刻获得 score +
+        4  => '间推代理奖励', //支付后立刻获得 score +   废弃了
         5  => '下单收益',    //订单10日结算 score +
         6  => '总代奖励',    //订单10日结算 score +
-        7  => '总代奖励(间推)',//订单10日结算 score +
+        7  => '总代奖励(间推)',//订单10日结算 score +    废弃了
     ],
     'moneyname' => [
         'money'    => '佣金',

+ 1 - 1
public/assets/js/backend/unishop/product.js

@@ -635,7 +635,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload', 'vue'], fun
                         {field: 'look', title: __('Look')},
                         {field: 'sales', title: __('Sales')},
                         {field: 'real_sales', title: __('Real sales')},
-                        {field: 'no_buy_yet', title: __('No buy yet')},
+//                        {field: 'no_buy_yet', title: __('No buy yet')},
                         {field: 'real_look', title: __('Real look')},
                         {field: 'delivery_id', title: __('Delivery_id'), visible: false},
                         {field: 'delivery.name', title: __('Delivery_id'), visible: false},