wesmiler преди 3 години
родител
ревизия
035561edab

+ 57 - 0
source/application/api/controller/user/dealer/Capital.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace app\api\controller\user\dealer;
+
+use app\api\controller\Controller;
+use app\api\model\dealer\Setting;
+use app\api\model\dealer\User as DealerUserModel;
+use app\api\model\dealer\Withdraw as WithdrawModel;
+
+/**
+ * 佣金明细
+ * Class Capital
+ * @package app\api\controller\user\dealer
+ */
+class Capital extends Controller
+{
+    /* @var \app\api\model\User $user */
+    private $user;
+
+    private $dealer;
+    private $setting;
+
+    /**
+     * 构造方法
+     * @throws \app\common\exception\BaseException
+     * @throws \think\exception\DbException
+     */
+    public function _initialize()
+    {
+        parent::_initialize();
+        // 用户信息
+        $this->user = $this->getUser();
+        // 分销商用户信息
+        $this->dealer = DealerUserModel::detail($this->user['user_id']);
+        // 分销商设置
+        $this->setting = Setting::getAll();
+    }
+
+
+    /**
+     * 分销商提现明细
+     * @param int $status
+     * @return array
+     * @throws \think\exception\DbException
+     */
+    public function lists($status = -1)
+    {
+        $model = new \app\api\model\dealer\Capital();
+        return $this->renderSuccess([
+            // 提现明细列表
+            'list' => $model->getList($this->user['user_id'], (int)$status),
+            // 页面文字
+            'words' => $this->setting['words']['values'],
+        ]);
+    }
+
+}

+ 29 - 0
source/application/api/model/dealer/Capital.php

@@ -20,4 +20,33 @@ class Capital extends CapitalModel
         'update_time',
     ];
 
+    protected $types = [
+        1=>'佣金结算',
+        2=>'平级佣金',
+        3=>'推荐佣金',
+        4=>'直推订单佣金',
+        5=>'间推订单佣金',
+        99=>'其他',
+    ];
+
+    /**
+     * 获取分销商提现明细
+     * @param $user_id
+     * @param int $apply_status
+     * @return \think\Paginator
+     * @throws \think\exception\DbException
+     */
+    public function getList($user_id, $apply_status = -1)
+    {
+        $types = $this->types;
+        $this->where('user_id', '=', $user_id);
+        $apply_status > -1 && $this->where('status', '=', $apply_status);
+        return $this->order(['create_time' => 'desc'])
+            ->paginate(15, false, [
+                'query' => \request()->request()
+            ])->each(function($item, $k) use($types){
+
+                $item['type_name'] = isset($types[$item['type']])? $types[$item['type']] : '未知';
+            });
+    }
 }

+ 1 - 1
source/application/api/service/User.php

@@ -233,7 +233,7 @@ class User
         $reverseScore = isset($config['reverse_score_'.$firstLevel])? floatval($config['reverse_score_'.$firstLevel]) : 0;
         //var_dump($equalScore1.'+++'.$equalScore2.'++'.$reverseScore);
         if($firstLevel>$userLevel && $reverseScore>0){
-            $model->grantMoney($firstId, $reverseScore, 2, "来自用户[{$userId}]反推[{$firstLevelName}]奖");
+            $model->grantMoney($firstId, $reverseScore, 3, "来自用户[{$userId}]反推[{$firstLevelName}]奖");
         }
 
         return true;

+ 2 - 2
source/application/common/model/dealer/Order.php

@@ -182,7 +182,7 @@ class Order extends BaseModel
             $awardScore1 = floatval($payMoney * $awardScoreRate1/100);
             $awardScore2 = floatval($payMoney * $awardScoreRate2/100);
             if($firstId && $firstInfo && $awardScore1>0){
-                User::grantMoney($firstId, $awardScore1);
+                User::grantMoney($firstId, $awardScore1,4,'直推订单佣金');
             }
 
             //二级佣金
@@ -190,7 +190,7 @@ class Order extends BaseModel
                 ->field('user_id,referee_id')
                 ->find();
             if($secondId && $secondInfo && $awardScore2>0){
-                User::grantMoney($secondInfo, $awardScore2);
+                User::grantMoney($secondInfo, $awardScore2,5,'间推订单佣金');
             }
         }