Browse Source

增加上级佣金发放、后台充值管理增加图片显示

Jason 1 year ago
parent
commit
3363e1967f
2 changed files with 24 additions and 19 deletions
  1. 23 1
      application/api/controller/Order.php
  2. 1 18
      public/assets/js/backend/trade/money_in.js

+ 23 - 1
application/api/controller/Order.php

@@ -8,6 +8,7 @@ use app\common\model\Goods;
 use app\common\model\MoneyLog;
 use app\common\model\Order AS OrderModel;
 use app\common\model\Users;
+use app\common\model\UsersPath;
 use think\Db;
 use think\Exception;
 
@@ -83,6 +84,11 @@ class Order extends Api
         if(!($user['balance'] > 0)){
             $this->error(__('余额不足'), '', 401);
         }
+        $balance_mini = (new Config())->getValue('balance_mini');//允许做单的最低余额
+        if($user['balance'] < $balance_mini){
+            $this->error(__('余额不足'), '', 401);
+        }
+
         $day_tasks_num  = (new Config())->getValue('day_tasks_num');//单日任务数
         $task_income    = (new Config())->getValue('task_income');//单次收益
         $amount_mini    = $user['balance'] * 0.4;
@@ -247,7 +253,23 @@ class Order extends Api
                     'task_last_time'=>  time()
                 ]);
             //向上级发放
-
+            $parent_ids = (new UsersPath())->where('user_id', $user['id'])->order('distance')->column('parent_id');
+            if(!empty($parent_ids)){
+                for($i = 1; $i <= 3; $i++){
+                    if(!isset($parent_ids[$i - 1])){
+                        //没设置就跳出
+                        break;
+                    }
+                    $radio = (new Config())->getValue('bonus_share_' . $i);
+                    if(!empty($radio) && $radio > 0 && $radio < 1){
+                        $bonus = $radio * $order_info['bonus'];
+                        if($bonus > 0.01){
+                            //上级佣金
+                            (new MoneyLog())->change($parent_ids[$i - 1], $bonus, MoneyLog::Commission, $user['id'], $i . '代会员奖励');
+                        }
+                    }
+                }
+            }
 
             // 提交事务
             Db::commit();

+ 1 - 18
public/assets/js/backend/trade/money_in.js

@@ -33,8 +33,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'bank_card', title: __('Bank_card'), operate: 'LIKE'},
                         {field: 'account_name', title: __('Account_name'), operate: false},
                         {field: 'amount', title: __('Amount'), operate: false},
-                        {field: 'img_url', title: __('充值截图'), formatter: Table.api.formatter.thumb, operate: false},
-                        {field: 'img_urls', title: __('Url'), formatter: Table.api.formatter.url, visible: false},
+                        {field: 'img_url', title: __('充值截图'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
                         {field: 'status', title: __("Status"),
                             searchList: {0:__('待支付'), 100:__('待处理'), 200:__('成功'), 400:__('失败'), 500:__('取消')},
                             formatter: Table.api.formatter.status
@@ -103,22 +102,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         api: {
             bindevent: function () {
                 Form.api.bindevent($("form[role=form]"));
-            },
-            formatter: {
-                thumb: function (value, row, index) {
-                    var html = '';
-                    html = '<a href="' + row.img_url + '" target="_blank"><img src="' + row.img_url + '" alt="" style="max-height:60px;max-width:120px"></a>';
-                    return '<div style="width:120px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + html + '</div>';
-                },
-                // url: function (value, row, index) {
-                //     return '<a href="' + row.img_url + '" target="_blank" class="label bg-green">' + row.url + '</a>';
-                // },
-                // filename: function (value, row, index) {
-                //     return '<div style="width:150px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + Table.api.formatter.search.call(this, value, row, index) + '</div>';
-                // },
-                // mimetype: function (value, row, index) {
-                //     return '<div style="width:80px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + Table.api.formatter.search.call(this, value, row, index) + '</div>';
-                // },
             }
         }
     };