Browse Source

直推收益

afa 10 months ago
parent
commit
72bdbf15c9

+ 4 - 1
application/admin/lang/zh-cn/general/config.php

@@ -87,5 +87,8 @@ return [
     'Direct income'                        => '直推收益',
     'Withdraw min amount'                  => '最小提现额',
     'Convert rate'                         => '折合Cny率',
-    'Giveaway'                             => '赠送手续费'
+    'Giveaway'                             => '赠送手续费',
+    'Giveaway txt'                         => '赠送描述',
+    'Pv rate'                              => '直推收益比例',
+    
 ];

+ 5 - 21
application/api/controller/Ledger.php

@@ -50,7 +50,7 @@ class Ledger extends Api
      * 资产变动明细
      * @return void
      */
-    public function coinList()
+    public function coinList( LedgerWalletModel $ledgerWalletModel)
     {
         $type_id  = $this->request->post('query.action'); // 账变类型
         $coin_type  = $this->request->post('query.coin_type'); // 資金类型
@@ -67,16 +67,13 @@ class Ledger extends Api
             case 'power':
                 $paginator = (new LedgerPowerChangeModel());
                 break;
-//            case 'server':
-//                $paginator = (new LedgerServersPowerChangeModel());
-//                break;
             case 'declaration':
                 $paginator = (new LedgerDeclarationChange());
                 break;
             case 'etc':
                 $paginator = (new LedgerTokenChangeModel());
                 break;
-            case 'aleo':
+            case 'token':
                 $paginator = (new LedgerTokenChangeModel());
                 break;
             case 'smh':
@@ -89,24 +86,11 @@ class Ledger extends Api
                 $this->error(__('Invalid parameters'));
                 break;
         }
-
-        $paginator = $paginator->where($where)->order('id DESC')->paginate($this->pageSize);
-        foreach ($paginator as $key => $item){
-            $paginator[$key]['change_amount'] = round($item['change_amount'], 4);
-            $paginator[$key]['present_amount'] = round($item['present_amount'], 4);
-            if($coin_type == 'smh'){
-                $paginator[$key]['action_name']   = (new LedgerSmhChangeModel())->pay_status[$item['action']];
-            }elseif($coin_type == 'qubic'){
-                $paginator[$key]['action_name']   = (new LedgerQubicChangeModel())->aciton_name[$item['action']];
-            }elseif($coin_type == 'aleo'){
-                $paginator[$key]['action_name']   = (new LedgerTokenChangeModel())->aciton_name[$item['action']];
-            }else{
-                $paginator[$key]['action_name']   = Action::getText($item['action']);
-            }
-        }
-        $res = $this->buildResp($paginator->total(), $paginator->currentPage(), $paginator->items());
+        $res['data'] = $paginator->where($where)->order('id DESC')->paginate($this->pageSize);
+        $res['statusList'] = LedgerWalletModel::getStatusList();
         $this->success('',$res);
     }
+    
     /**
      * 资产变动类型
      * @return void

+ 6 - 0
application/api/controller/Order.php

@@ -57,6 +57,12 @@ class Order extends Api
 
             //余额记录
             $ledgerWalletModel->changeWalletAccount($this->auth->id, Asset::TOKEN, -$order_info['price'], $ledgerWalletModel::Popular, $this->auth->id);
+
+            //直推收益: pv* ×10%
+            if($order_info['pv'] > 0 && $this->auth->parent_id > 0){
+                $pv = bcmul($order_info['pv'], getConfig('pv_rate'), 2);
+                $ledgerWalletModel->changeWalletAccount($this->auth->parent_id, Asset::TOKEN, $pv, $ledgerWalletModel::Direct, $this->auth->id);
+            }
             //扣除库存
             if($order_info->stock == 1 || time() >= $order_info->end_time) $order_info->status= $productPopular::STOP;
             $order_info->num  += 1;

+ 9 - 0
application/api/lang/en.php

@@ -10,4 +10,13 @@ return [
     'The withdrawal amount cannot be less than'                                  => 'The withdrawal amount cannot be less than',
     'Withdrawal failed, please contact customer service.'                        => 'Withdrawal failed, please contact customer service.',
     'Signature verification failed'                                              => 'ignature verification failed',
+    '热销支付'                               => 'Hot-selling payment',
+    '转让支付'                               => 'Transfer payment',
+    '转让收款'                               => 'Transfer receipt',
+    '充值'                                   => 'Recharge',
+    '提现'                                   => 'Withdraw',
+    '分享'                                   => 'Share',
+    '退回'                                   => 'Return',
+    '赠送'                                   => 'Gift fee',
+    '直推收益'                               => 'Direct income',
 ]; 

+ 1 - 0
application/api/lang/en/user.php

@@ -44,4 +44,5 @@ return [
     '分享'                                   => 'Share',
     '退回'                                   => 'Return',
     '赠送'                                   => 'Gift fee',
+    '直推收益'                               => 'Direct income',
 ];

+ 1 - 0
application/api/lang/zh-cn/user.php

@@ -44,4 +44,5 @@ return [
     '分享'                                  => '分享',
     '退回'                                  => '退回',
     '赠送'                                  => '赠送手续费',
+    '直推收益'                              => '直推收益',
 ];

+ 19 - 9
application/common/model/LedgerTokenChangeModel.php

@@ -8,22 +8,32 @@ class LedgerTokenChangeModel extends Model
 {
 
     protected $name = "ledger_token_change";
-    const Recharge          = 100;
-    const SysSend           = 105;
-    const Exchange          = 101;
-    const WithdrawCash      = 102;
-    const WithdrawReturn    = 103;
+    const Payment           = 0;
+    const Transfer          = 1;
+    const Receive           = 2;
+    const Recharge          = 3;
+    const Withdraw          = 4;
+    const Share             = 5;
+    const WithdrawReturn    = 6;
 
     /*
-     * 支付状态
+     * 支付状态 支付 1转让支付 2 转让收款 3充值 4提现 5分享 6提现退回
      */
     public $aciton_name = [
         '-1'                    => '全部',
+        self::Payment           => '支付',
+        self::Transfer          => '转让支付',
+        self::Receive           => '转让收款',
         self::Recharge          => '充值',
-        self::SysSend           => '今日产出',
-        self::Exchange          => '兑换',
-        self::WithdrawCash      => '提现',
+        self::Withdraw          => '提现',
+        self::Share             => '分享',
         self::WithdrawReturn    => '提现退回',
     ];
 
+
+    public static function getStatusList()
+    {
+        return [self::Payment => __('支付'), self::Transfer  => __('转让支付'), self::Receive => __('转让收款'), self::Recharge => __('充值'), self::Withdraw  => __('提现'), self::Share => __('分享'), self::WithdrawReturn => __('提现退回')];
+    }
+
 }

+ 4 - 3
application/common/model/LedgerWalletModel.php

@@ -33,6 +33,8 @@ class LedgerWalletModel extends Model
     const Share             = 5;
     const Return            = 6;
     const Giveaway          = 7;
+    const Direct            = 8;
+
     /*
      * 支付状态
      * 0未支付 100支付中 200支付成功 400支付失败
@@ -47,10 +49,9 @@ class LedgerWalletModel extends Model
         self::Share             => '分享',
         self::Return            => '退回',
         self::Giveaway          => '赠送手续费',
+        self::Direct            => '直推收益',
     ];
 
-
- 
     public static function getWalletChaBao($userID)
     {
         return self::where('user_id', $userID)->value('token');
@@ -76,7 +77,7 @@ class LedgerWalletModel extends Model
     public static function getStatusList()
     {
         return [self::Popular => __('热销支付'), self::Payment  => __('转让支付'), self::Receive => __('转让收款'), self::Recharge => __('充值'), 
-        self::Withdraw  => __('提现'), self::Share => __('分享'), self::Return => __('退回'), self::Giveaway => __('赠送')];
+        self::Withdraw  => __('提现'), self::Share => __('分享'), self::Return => __('退回'), self::Giveaway => __('赠送'), self::Direct => __('直推收益')];
     }
 
     /**