Przeglądaj źródła

1. 优化提现控制器
2. 提现添加300、500 分页
3. 订单类型修改
4. scorelog,moneylog 修改类型

lyh 3 lat temu
rodzic
commit
87c839fd0e

+ 1 - 1
README.md

@@ -1,5 +1,5 @@
 ### 数据表修改记录
 
 ```mysql
-alter table db_money_log add withdraw_log_id int(11) null COMMENT 'type = 14 退回手续费记录ID' AFTER uid2;
+alter table db_money_log add withdraw_log_id int(11) null COMMENT 'type = 12 退回手续费记录ID' AFTER uid2;
 ```

+ 24 - 374
app/admin/controller/withdraw/Withdraw.php

@@ -7,6 +7,7 @@ namespace app\admin\controller\withdraw;
 
 use alipay\AopCertClient;
 use alipay\request\AlipayFundTransUniTransferRequest;
+use app\admin\logic\UserLogic;
 use app\admin\logic\WithdrawLogLogic;
 use app\admin\model\dao\WithdrawLog;
 use app\admin\traits\Curd;
@@ -17,9 +18,11 @@ use EasyAdmin\annotation\ControllerAnnotation;
 use EasyAdmin\annotation\NodeAnotation;
 use app\common\controller\AdminController;
 use app\common\model\WithDrawLogModel;
+use jianyan\excel\Excel;
 use think\App;
 use think\Exception;
 use think\exception\ValidateException;
+use think\facade\Cache;
 use think\facade\Db;
 
 /**
@@ -48,79 +51,10 @@ class Withdraw extends AdminController
             }
             list($page, $limit, $where) = $this->buildTableParames();
 
-            foreach ($where as $key => &$val) {
-                if ($val[0] == 'status') {
-                    $where[$key][0] = 'w.status';
-                }
+            Cache::set("WITHDRAW_EXPORT", ['page' => $page, 'limit' => $limit, 'where' => $where]);
 
+            list($count, $list) = WithdrawLogLogic::getList($page, $limit, $where, $this->user_map, $this->sort);
 
-            }
-
-            $count = $this->model
-//                ->withJoin('user', 'INNER')
-                ->where($this->user_map)
-                ->where($where)
-                ->count();
-            $list  = $this->model
-                ->alias('w')
-                ->leftJoin('user u', 'u.id = w.uid')
-//                ->withJoin('user', 'INNER')
-                ->where($this->user_map)
-                ->where($where)
-                ->field('w.*,u.path,u.user_type,u.luzi_money')
-                ->page($page, $limit)
-                ->order($this->sort)
-                ->select();
-
-            $withdrawLog = new WithdrawLogLogic();
-
-            foreach ($list as $key => &$val) {
-
-//                老刘下级  13824334135  uid    5344367
-//                郑跃兵   17888779318     uid 5344369,13866400965 uid 5344368
-//                大飞    19805553599 uid 5344633 ,18682271568    uid 5344640
-//
-//                if ($val['user_type'] == 10){
-//                    $val['tips_text'] = '潘总号';
-//                }else{
-//                    $val['tips_text'] = '其他线';
-//                }
-//                    $val['tips_text'] = '其他线';
-
-//
-//                if (strpos($val['path'], '5344367') !== false || $val['uid'] == 5344367){
-//                    $val['tips_text'] = '老刘下级';
-//                }
-
-
-//
-//                if ((strpos($val['path'], '5344633') !== false || $val['uid'] == 5344633) || (strpos($val['path'], '5344640') !== false || $val['uid'] == 5344640)){
-//                    $val['tips_text'] = '大飞下级';
-//                }elseif ((strpos($val['path'], '5344369') !== false || $val['uid'] == 5344369) || (strpos($val['path'], '5344368') !== false || $val['uid'] == 5344368)){
-//                    $val['tips_text'] = '郑跃兵下级';
-//                }
-
-
-//                if (strpos($val['path'], '7493433') !== false){
-//                    $val['tips_text'] = '心态下级';
-//                }
-//
-                if (strpos($val['path'], '7493466') !== false) {
-                    $val['tips_text'] = '郑下级';
-                }
-
-                if ($val['luzi_money'] > 0) {
-                    $val['tips_text'] = '撸子标记,不要提现';
-                } else {
-                    $val['tips_text'] = '';
-                }
-
-                $val['is_show'] = $withdrawLog->isShowReturnServiceMoney($val['id']);
-
-
-            }
-
-//            tips_text
             $data = [
                 'code'  => 0,
                 'msg'   => '',
@@ -129,27 +63,11 @@ class Withdraw extends AdminController
             ];
             return json($data);
         }
+
+        $this->assign('limits',[10, 15, 20, 25, 50, 100]);
         return $this->fetch();
     }
-    /**
-     * @NodeAnotation(title="取消提现")
-     */
-//    public function cancel ($id)
-//    {
-//        $row = $this->model->where('id', $id)->where('status', 'in', '0')->find();
-//        empty($row) && $this->error('取消失败');
-//        $row->status = 3;
-//        Db::startTrans();
-//        try {
-//            edit_user_money(9, $row['uid'], $row['apply_money']);
-//            $row->save();
-//            Db::commit();
-//        } catch (\Exception $e) {
-//            Db::rollback();
-//            $this->error('取消失败');
-//        }
-//        $this->success('取消成功');
-//    }
+
     /**
      * @NodeAnotation(title="提现失败")
      */
@@ -157,61 +75,12 @@ class Withdraw extends AdminController
     {
         if ($this->request->isPost()) {
             $post = $this->request->post();
-            $row  = $this->model->where('id', $id)->where('status', 'in', '0')->find();
-            empty($row) && $this->error('取消失败');
-
-            $row->status    = 3;
-            $row->fail_log  = $post['error_text'];
-            $is_backsx      = $post['is_backsx'];
-            $row->is_backsx = $is_backsx;
 
-            Db::startTrans();
-            try {
-                if ($is_backsx == 1) {
-                    edit_user_money(10, $row['uid'], $row['apply_money']);
-                } else {
-                    edit_user_money(10, $row['uid'], $row['practical_money']);
-                }
+            list($return, $msg) = WithdrawLogLogic::withdrawError($id, $post);
 
-                Db::name('user')->where('id', $row['uid'])->dec('total_withdraw', $row['apply_money'])->update();
-//                Db::name('user')->whereIn('id', $row['path'])->dec('total_team_withdraw', $row['apply_money'])->update();
-//                Db::name('user')->whereIn('id', $row['uid'])->dec('total_team_withdraw', $row['apply_money'])->update();
-                $row->save();
-                Db::commit();
-            } catch (\Exception $e) {
-                Db::rollback();
-                $this->error('取消失败' . $e->getMessage());
-            }
-            $this->success('取消成功');
+            $return === true ? $this->success($msg) : $this->error($msg);
         }
 
-//
-//        if ($this->request->isPost()) {
-//            $row = $this->model->where('id', $id)->where('status', 'in', '0')->find();
-//            empty($row) && $this->error('取消失败');
-//            if ($row['status'] != 1){
-//                $this->error('状态错误,请刷新数据');
-//            }
-//
-//            $this->model->startTrans();
-//            try {
-//                $this->model->where('id', $post['id'])->save(['status'=>3,'error_text'=>$error_text, 'is_backsx'=>$is_backsx]);
-//                if ($is_backsx == 1){
-//                    edit_user_xz(15, $order_info['uid'], $order_info['xz_num']+$order_info['shouxu'], $order_info['hf_ordersn'], $order_info['shouxu']);
-//                    edit_user_couponnum(5, $order_info['uid'], $order_info['price']/10);
-//                }else{
-//                    edit_user_xz(15, $order_info['uid'], $order_info['xz_num'], $order_info['hf_ordersn'], 0);
-//                    edit_user_couponnum(5, $order_info['uid'], $order_info['price']/10);
-//                }
-//
-//                $this->model->commit();
-//            } catch (\Exception $e) {
-//                $this->model->rollback();
-//                $this->error('失败'.$e->getMessage());
-//            }
-//            $this->success('成功');
-//        }
-
         return $this->fetch();
     }
 
@@ -221,218 +90,8 @@ class Withdraw extends AdminController
      */
     public function tx($id)
     {
-
-
-//        if (in_array(env('APP.CUR_SYS_PARAMS'), [1, 2])){
-//            $this->error('错误');
-//        }
-        $info = $this->model->where('id', $id)->where('status', 0)->find();
-        if (empty($info))
-            $this->error('提现记录不存在');
-        $user = Db::name('user')->findOrEmpty(['id' => $info['uid']]);
-        if (empty($user) || $user['status'] != 1)
-            $this->error('用户不存在或已被禁用');
-
-        if ($user['luzi_money'] > 0) {
-            $this->error('撸子账号 联系技术处理');
-        }
-
-//        $this->error('通道错误,失败');
-//        if ($user['is_auth'] != 1)
-//            $this->error('该用户还未实名认证');
-
-
-        Db::name('user')->whereIn('id', $user['path'])->inc('total_team_withdraw', $info['apply_money'])->update();
-        Db::name('user')->whereIn('id', $user['id'])->inc('total_team_withdraw', $info['apply_money'])->update();
-
-        // 支付宝提现
-        if ($info['channel'] == 1) {
-
-            // 电科支付宝提现代付
-            if (false) {
-                Db::startTrans();
-                try {
-
-                    $interface_url = 'http://1.14.197.47/proxy/pay/fetch'; //正式
-                    $out_trade_no  = createdOrderWithdrawSn($info['uid']);
-                    $params        = [
-                        'appId'          => 'diankef',
-                        'version'        => '1.0',
-                        'nonceStr'       => nonce_str(15),
-                        'amount'         => intval($info['practical_money'] * 100),
-                        'orderId'        => $out_trade_no,
-                        'accountName'    => $info['zfb_name'],
-                        'accountNo'      => $info['zfb_number'],
-                        'bankName'       => '网商银行',
-                        'asyncNotifyUrl' => env('PAYSQZ.PAYBACK_DAIFU_ZFB_NEWURL'),
-                        'quick'          => 1,
-                        'subject'        => '余额提现'
-                    ];
-
-                    ksort($params);
-                    $services       = new ThirdPayServices();
-                    $params['sign'] = $services->diankesigndf($params);
-
-
-                    //        提交确定支付
-                    sr_log('确认提交提现' . json_encode($params));
-                    $result = curlPost($interface_url, $params);
-                    sr_log('result:' . $result);
-
-                    $res = json_decode($result);
-                    if (isset($res->status) && $res->status == 9) {
-                        Db::name('withdraw_log')->where('id', $id)->update(['status' => 4, 'out_biz_no' => $out_trade_no, 'update_at' => date('Y-m-d H:i:s', time()), 'final_transfer_type' => 1]);
-
-                    } else {
-                        sr_throw('支付错误,请联系客服');
-                    }
-
-                    Db::commit();
-                } catch (\Exception $e) {
-                    Db::rollback();
-
-                    $this->error($e->getMessage());
-                }
-            }
-
-
-            Db::name('withdraw_log')->where('id', $id)->update(['status' => 1, 'out_biz_no' => '1111', 'update_at' => date('Y-m-d H:i:s', time()), 'final_transfer_type' => 1]);
-            $this->success('提现成功');
-
-
-//            try {
-////
-//                /** 初始化 **/
-//                $aop = new AopCertClient();
-//                $pay_info = Db::name('pay_config')->where('channel', 1)->where('status', 1)->find();
-//                /** 支付宝网关 **/
-//                $aop -> gatewayUrl = "https://openapi.alipay.com/gateway.do";
-//
-//                /** 应用id,如何获取请参考:https://opensupport.alipay.com/support/helpcenter/190/201602493024 **/
-//                $aop -> appId = $pay_info['app_id'];
-//
-//                /** 密钥格式为pkcs1,如何获取私钥请参考:https://opensupport.alipay.com/support/helpcenter/207/201602471154?ant_source=antsupport **/
-//                $aop -> rsaPrivateKey = $pay_info['private_key'];
-//
-//                /** 应用公钥证书路径,下载后保存位置的绝对路径  **/
-//                $appCertPath = $pay_info['app_cert_path'];
-//
-//                /** 支付宝公钥证书路径,下载后保存位置的绝对路径 **/
-//                $alipayCertPath = $pay_info['pay_cert_path'];
-//
-//                /** 支付宝根证书路径,下载后保存位置的绝对路径 **/
-//                $rootCertPath = $pay_info['pay_root_cert'];
-//
-//                /** 设置签名类型 **/
-//                $aop -> signType= "RSA2";
-//
-//                /** 设置请求格式,固定值json **/
-//                $aop -> format = "json";
-//
-//                /** 设置编码格式 **/
-//                $aop -> charset= "utf-8";
-//
-//                /** 调用getPublicKey从支付宝公钥证书中提取公钥 **/
-//                $aop -> alipayrsaPublicKey = $aop -> getPublicKey($alipayCertPath);
-//
-//                /** 是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内 **/
-//                $aop -> isCheckAlipayPublicCert = true;
-//
-//                /** 调用getCertSN获取证书序列号 **/
-//                $aop -> appCertSN = $aop -> getCertSN($appCertPath);
-//
-//                /** 调用getRootCertSN获取支付宝根证书序列号 **/
-//                $aop -> alipayRootCertSN = $aop -> getRootCertSN($rootCertPath);
-//
-//                /** 实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.fund.trans.uni.transfer(单笔转账接口) **/
-//                $request = new AlipayFundTransUniTransferRequest();
-//                $out_biz_no = time() . rand(10000, 99999) . $info['uid'];
-//                /** 设置业务参数,具体接口参数传值以文档说明为准:https://opendocs.alipay.com/apis/api_28/alipay.fund.trans.uni.transfer/ **/
-//                $request -> setBizContent("{".
-//
-//                    /** 商户端的唯一订单号,对于同一笔转账请求,商户需保证该订单号唯一 **/
-//                    "\"out_biz_no\":\"".$out_biz_no."\",".
-//
-//                    /** 转账金额,TRANS_ACCOUNT_NO_PWD产品取值最低0.1  **/
-//                    "\"trans_amount\":\"".$info['practical_money']."\",".
-//
-//                    /** 产品码,单笔无密转账到支付宝账户固定为:TRANS_ACCOUNT_NO_PWD **/
-//                    "\"product_code\":\"TRANS_ACCOUNT_NO_PWD\",".
-//
-//                    /** 场景码,单笔无密转账到支付宝账户固定为:DIRECT_TRANSFER  **/
-//                    "\"biz_scene\":\"DIRECT_TRANSFER\",".
-//
-//                    /** 转账业务的标题,用于在支付宝用户的账单里显示 **/
-//                    "\"order_title\":\"提现\",".
-//
-//                    /** 收款方信息 **/
-//                    "\"payee_info\":{".
-//
-//                    /** 参与方的唯一标识,收款支付宝账号或者支付宝吧账号唯一会员ID **/
-//                    "\"identity\":\"".$info['zfb_number']."\",".
-//
-//                    /** 参与方的标识类型:ALIPAY_USER_ID 支付宝的会员ID  **/
-//                    "\"identity_type\":\"ALIPAY_LOGON_ID\",".
-//
-//                    /** 参与方真实姓名,如果非空,将校验收款支付宝账号姓名一致性。当identity_type=ALIPAY_LOGON_ID时,本字段必填 **/
-//                    "\"name\":\"".$info['zfb_name']."\"".
-//                    "},".
-//
-//                    /** 业务备注  **/
-//                    "\"remark\":\"单笔转账\"".
-//
-//                    "}");
-//
-//                $result = $aop -> execute($request);
-//
-////                sr_log('支付宝体现返回'.json_encode($result));
-//
-//
-//                /** 获取接口调用结果,如果调用失败,可根据返回错误信息到该文档寻找排查方案:https://opensupport.alipay.com/support/helpcenter/114 **/
-////                $res = json_encode($result, JSON_UNESCAPED_UNICODE);
-////                $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
-////                $resultCode = $result->{$responseNode}->code;
-//
-//                if (isset($result->alipay_fund_trans_uni_transfer_response->code) && $result->alipay_fund_trans_uni_transfer_response->code == 10000) {
-
-//                } else {
-//                    Db::name('withdraw_log')->where('id', $id)->update(['fail_log' => $result->alipay_fund_trans_uni_transfer_response->sub_msg, 'status' => 3]);
-//                    edit_user_money(9, $info['uid'], $info['apply_money']);
-//                    $this->success('提现失败');
-//                }
-////                sr_log(json_encode($res));
-////                $rpm = $this->apiRequest('adminWithdrawal', compact('id'));
-////                if ($rpm['code'] != 200)
-////                    $this->error($rpm['msg']);
-//            } catch (Exception $e) {
-//                sr_log($e->getMessage());
-//                $this->error('提现失败');
-//            }
-        } else {
-            $info->status              = 1;
-            $info->update_at           = date('Y-m-d H:i:s', time());
-            $info->final_transfer_type = 3;
-
-            $info->save();
-
-
-        }
-//        $transferstatus = get_config(2, 'TRANSFERSTATUS'); // 获取支付设置
-//        if ($transferstatus == 1 || $transferstatus == 2) { // 自动转账
-//            try {
-//                $rpm = $this->apiRequest('adminWithdrawal', compact('id'));
-//                if ($rpm['code'] != 200)
-//                    $this->error($rpm['msg']);
-//            } catch (\Exception $e) {
-//                $this->error('提现失败');
-//            }
-//        } else { // 手动执行
-//            $info->status = 1;
-//            $info->update_at = date('Y-m-d H:i:s', time());
-//            $info->final_transfer_type = 3;
-//            $info->save();
-//        }
-        $this->success('提现成功');
+        list($return, $msg) = WithdrawLogLogic::tx($id);
+        $return === true ? $this->success($msg) : $this->error($msg);
     }
 
     /**
@@ -441,25 +100,17 @@ class Withdraw extends AdminController
     public function export()
     {
         list($page, $limit, $where) = $this->buildTableParames();
-        $tableName = $this->model->getName();
-        $tableName = CommonTool::humpToLine(lcfirst($tableName));
-        $prefix    = config('database.connections.mysql.prefix');
-        $dbList    = Db::query("show full columns from {$prefix}{$tableName}");
-        $header    = [];
-        foreach ($dbList as $vo) {
-            $comment = !empty($vo['Comment']) ? $vo['Comment'] : $vo['Field'];
-            if (!in_array($vo['Field'], $this->noExportFields)) {
-                $header[] = [$comment, $vo['Field']];
-            }
+
+        if (empty($where)) {
+            $search = Cache::get("WITHDRAW_EXPORT");
+            $page   = $search['page'];
+            $limit  = $search['limit'];
+            $where  = $search['where'];
         }
-        $list     = $this->model
-            ->where($where)
-            ->withJoin('user', 'INNER')
-            ->where($where)
-            ->limit(100000)
-            ->order('id', 'desc')
-            ->select()
-            ->toArray();
+
+        $header = getExportHeader($this->model->getName(), $this->noExportFields);
+
+        $list     = WithdrawLogLogic::getExportList($where, $page, $limit);
         $fileName = time();
         return Excel::exportData($list, $header, $fileName, 'xlsx');
     }
@@ -469,11 +120,10 @@ class Withdraw extends AdminController
      */
     public function withdrawdata()
     {
-
-        $tx_success = Db::name('withdraw_log')->where('status', 1)->sum('practical_money');
+        $tx_success = WithdrawLog::SumPracticalMoneyByStatus(1);
         $this->assign('tx_success', $tx_success);
 
-        $tx = Db::name('withdraw_log')->where('status', 0)->sum('practical_money');
+        $tx = WithdrawLog::SumPracticalMoneyByStatus(0);
         $this->assign('tx', $tx);
 
         return $this->fetch();

+ 16 - 10
app/admin/logic/MoneyLogLogic.php

@@ -15,20 +15,26 @@ use think\facade\Db;
 class MoneyLogLogic
 {
 
-    // 1.积分兑换  2.提现  3.购买商品  4.积分兑换  5.广告任务包分红,6-团队收益,8-利润结算兑换,10-提现失败退还,12-平台充补,13-平台扣除 14-提现失败退还手续费',
+    // 1.预约福袋  2.回收商品 3.预约福袋空盒退回  4.奖金流失  5.直推收益到奖金  6-奖金领取  7-团队收益到奖金  8-利润结算兑换  9-余额提现  10-提现失败退还  11-提现多次返回  12-提现手续费退回,13-提现失败退回 14-奖金领取退回  15-系统退回  16-平台充值  17-平台扣除
     private static $typeMap = [
         ['id' => 0, 'name' => '其他'],
-        ['id' => 1, 'name' => '积分兑换'],
-        ['id' => 2, 'name' => '提现'],
-        ['id' => 3, 'name' => '购买商品'],
-        ['id' => 4, 'name' => '积分兑换'],
-        ['id' => 5, 'name' => '广告任务包分红'],
-        ['id' => 6, 'name' => '团队收益'],
+        ['id' => 1, 'name' => '预约福袋'],
+        ['id' => 2, 'name' => '回收商品'],
+        ['id' => 3, 'name' => '预约福袋空盒退回'],
+        ['id' => 4, 'name' => '奖金流失'],
+        ['id' => 5, 'name' => '直推收益到奖金'],
+        ['id' => 6, 'name' => '奖金领取'],
+        ['id' => 7, 'name' => '团队收益到奖金'],
         ['id' => 8, 'name' => '利润结算兑换'],
+        ['id' => 9, 'name' => '余额提现'],
         ['id' => 10, 'name' => '提现失败退还'],
-        ['id' => 12, 'name' => '平台充补'],
-        ['id' => 13, 'name' => '平台扣除'],
-        ['id' => 14, 'name' => '提现失败退还手续费'],
+        ['id' => 11, 'name' => '提现多次返回'],
+        ['id' => 12, 'name' => '提现手续费退回'],
+        ['id' => 13, 'name' => '提现失败退回'],
+        ['id' => 14, 'name' => '奖金领取退回'],
+        ['id' => 15, 'name' => '系统退回'],
+        ['id' => 16, 'name' => '平台充值'],
+        ['id' => 17, 'name' => '平台扣除'],
     ];
 
     private static $stateMap = [

+ 6 - 7
app/admin/logic/ScoreLogLogic.php

@@ -15,17 +15,16 @@ use think\facade\Db;
 class ScoreLogLogic
 {
 
-    // 1. 报名消费抢购扣除 2.消费券任务发放 3.爆仓 补足前面两个的百分之七十 4.爆仓那个全部返回 5 商城购买商品返积分 6兑换商品,12-平台充补,13-平台扣除
+    // 预约福袋  2.预约福袋空盒退回  3.买商品送积分   4.提现多次返回  6.兑换商品,  12-平台充补,13-平台扣除
     private static $typeMap = [
         ['id' => 0, 'name' => '其他'],
-        ['id' => 1, 'name' => '报名消费抢购扣除'],
-        ['id' => 2, 'name' => '消费券任务发放'],
-        ['id' => 3, 'name' => '爆仓 补足前面两个的百分之七十'],
-        ['id' => 4, 'name' => '爆仓那个全部返回'],
-        ['id' => 5, 'name' => '商城购买商品返积分'],
+        ['id' => 1, 'name' => '预约福袋'],
+        ['id' => 2, 'name' => '预约福袋空盒退回'],
+        ['id' => 3, 'name' => '买商品送积分'],
+        ['id' => 4, 'name' => '提现多次返回'],
         ['id' => 6, 'name' => '兑换商品'],
         ['id' => 12, 'name' => '平台充补'],
-        ['id' => 13, 'name' => '平台扣除'],
+        ['id' => 13, 'name' => '平台扣除']
     ];
 
     private static $stateMap = [

+ 152 - 2
app/admin/logic/WithdrawLogLogic.php

@@ -9,12 +9,162 @@ use app\admin\model\dao\ScoreLog;
 use app\admin\model\dao\ShopOrder;
 use app\admin\model\dao\User;
 use app\admin\model\dao\WithdrawLog;
+use app\common\model\WithDrawLogModel;
 use think\facade\Cache;
 use think\facade\Db;
 
 class WithdrawLogLogic
 {
 
+    public static function getList($page, $limit, $where, $userMap, $sort)
+    {
+        foreach ($where as $key => &$val) {
+            if ($val[0] == 'status') {
+                $where[$key][0] = 'w.status';
+            }
+        }
+        $model = new WithDrawLogModel();
+
+        $count = $model
+//                ->withJoin('user', 'INNER')
+            ->where($userMap)
+            ->where($where)
+            ->count();
+        $list  = $model
+            ->alias('w')
+            ->leftJoin('user u', 'u.id = w.uid')
+//                ->withJoin('user', 'INNER')
+            ->where($userMap)
+            ->where($where)
+            ->field('w.*,u.path,u.user_type,u.luzi_money')
+            ->page($page, $limit)
+            ->order($sort)
+            ->select();
+
+        $withdrawLog = new WithdrawLogLogic();
+
+        foreach ($list as $key => &$val) {
+
+//                老刘下级  13824334135  uid    5344367
+//                郑跃兵   17888779318     uid 5344369,13866400965 uid 5344368
+//                大飞    19805553599 uid 5344633 ,18682271568    uid 5344640
+//
+//                if ($val['user_type'] == 10){
+//                    $val['tips_text'] = '潘总号';
+//                }else{
+//                    $val['tips_text'] = '其他线';
+//                }
+//                    $val['tips_text'] = '其他线';
+
+//
+//                if (strpos($val['path'], '5344367') !== false || $val['uid'] == 5344367){
+//                    $val['tips_text'] = '老刘下级';
+//                }
+
+
+//
+//                if ((strpos($val['path'], '5344633') !== false || $val['uid'] == 5344633) || (strpos($val['path'], '5344640') !== false || $val['uid'] == 5344640)){
+//                    $val['tips_text'] = '大飞下级';
+//                }elseif ((strpos($val['path'], '5344369') !== false || $val['uid'] == 5344369) || (strpos($val['path'], '5344368') !== false || $val['uid'] == 5344368)){
+//                    $val['tips_text'] = '郑跃兵下级';
+//                }
+
+
+//                if (strpos($val['path'], '7493433') !== false){
+//                    $val['tips_text'] = '心态下级';
+//                }
+//
+            if (strpos($val['path'], '7493466') !== false) {
+                $val['tips_text'] = '郑下级';
+            }
+
+            if ($val['luzi_money'] > 0) {
+                $val['tips_text'] = '撸子标记,不要提现';
+            } else {
+                $val['tips_text'] = '';
+            }
+
+            $val['is_show'] = $withdrawLog->isShowReturnServiceMoney($val['id']);
+
+
+        }
+
+        return [$count, $list];
+    }
+
+    public static function withdrawError($id, $post)
+    {
+        $model = new WithDrawLogModel();
+        $row   = $model->where('id', $id)->where('status', 'in', '0')->find();
+        if (empty($row)) return [false, '取消失败'];
+
+        $row->status    = 3;
+        $row->fail_log  = $post['error_text'];
+        $is_backsx      = $post['is_backsx'];
+        $row->is_backsx = $is_backsx;
+
+        Db::startTrans();
+        try {
+            if ($is_backsx == 1) {
+                edit_user_money(10, $row['uid'], $row['apply_money']);
+            } else {
+                edit_user_money(10, $row['uid'], $row['practical_money']);
+            }
+
+            Db::name('user')->where('id', $row['uid'])->dec('total_withdraw', $row['apply_money'])->update();
+            $row->save();
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+            return [false, '取消失败' . $e->getMessage()];
+        }
+
+        return [true, '取消成功'];
+    }
+
+    public static function tx($id)
+    {
+        $model = new WithDrawLogModel();
+        $info  = $model->where('id', $id)->where('status', 0)->find();
+        if (empty($info)) return [false, '提现记录不存在'];
+
+        $user = User::getUserOrEmptyById($info['uid']);
+        if (empty($user) || $user['status'] != 1) return [false, '用户不存在或已被禁用'];
+
+        if ($user['luzi_money'] > 0) return [false, '撸子账号 联系技术处理'];
+
+        User::updateTotalTeamWithdraw($user['path'], $info['apply_money']);
+        User::updateTotalTeamWithdraw($user['id'], $info['apply_money']);
+
+        // 支付宝提现
+        if ($info['channel'] == 1) {
+            $updateData = ['status' => 1, 'out_biz_no' => '1111', 'final_transfer_type' => 1];
+            WithdrawLog::update($id, $updateData);
+
+            return [true, '提现成功'];
+        } else {
+
+            $info->status              = 1;
+            $info->update_at           = date('Y-m-d H:i:s', time());
+            $info->final_transfer_type = 3;
+
+            $info->save();
+        }
+        return [true, '提现成功'];
+    }
+
+    public static function getExportList($where, $page, $limit)
+    {
+        return (new WithDrawLogModel())
+            ->where($where)
+            ->withJoin('user', 'INNER')
+            ->where($where)
+            ->page($page, $limit)
+            ->order('id', 'desc')
+            ->select()
+            ->toArray();
+    }
+
     public function returnServiceMoney($post)
     {
         $withdrawLog = WithdrawLog::getWithdrawLogById($post['id']);
@@ -40,7 +190,7 @@ class WithdrawLogLogic
             $afterMoney   = $withdrawLog['service_money'] + $post['service_money'];
             $moneyLog     = [
                 'uid'             => $withdrawLog['uid'],
-                'type'            => 14,
+                'type'            => 12,
                 'money'           => $post['service_money'],
                 'create_at'       => date('Y-m-d H:i:s'),
                 'state'           => 1,
@@ -73,7 +223,7 @@ class WithdrawLogLogic
         return $withdrawLog;
     }
 
-    public function isShowReturnServiceMoney($id)
+    private function isShowReturnServiceMoney($id)
     {
         $key = 'WITHDRAWLOGRETURNSERVICEMONEY_' . $id;
         if (Cache::has($key) && 1 == 2) {

+ 5 - 0
app/admin/model/dao/User.php

@@ -113,6 +113,11 @@ class User extends BaseDao
             ->update($userData);
     }
 
+    public static function updateTotalTeamWithdraw($path, $apply_money)
+    {
+        Db::name('user')->whereIn('id', $path)->inc('total_team_withdraw', $apply_money)->update();
+    }
+
     public function getUserDetail($id)
     {
         return $this->model

+ 12 - 1
app/admin/model/dao/WithdrawLog.php

@@ -30,8 +30,19 @@ class WithdrawLog extends BaseDao
         return Db::table(self::$table)->where(['id' => $id])
             ->update([
                 'service_money' => $serviceMoney,
-                'update_at'   => date('Y-m-d H:i:s')
+                'update_at'     => date('Y-m-d H:i:s')
             ]);
     }
 
+    public static function update($id, $updateData)
+    {
+        $updateData['update_at'] = sr_getcurtime(time());
+        Db::name('withdraw_log')->where('id', $id)->update($updateData);
+    }
+
+    public static function SumPracticalMoneyByStatus($int)
+    {
+        return Db::name('withdraw_log')->where('status', $int)->sum('practical_money');
+    }
+
 }

+ 1 - 1
public/static/admin/js/mall/goods_order.js

@@ -54,7 +54,7 @@ define(["jquery", "easy-admin"], function ($, ea) {
                         field: 'order_type',
                         title: '订单类型',
                         width: 120,
-                        selectList: {1: '商城类型', 2: '积分兑换', 3: '任务包兑换券', 4: '提货券', 5:'星钻兑换'}
+                        selectList: {1: '商城订单', 2: '积分订单', 3: '兑换券', 4: '锁定积分兑换', 5:'福袋发货订单'}
                     },
                     {
                         field: 'status', minWidth: 120, title: '订单状态', search: 'select', templet: function (d) {

+ 1 - 1
public/static/admin/js/mall/shop_order.js

@@ -54,7 +54,7 @@ define(["jquery", "easy-admin"], function ($, ea) {
                         field: 'order_type',
                         title: '订单类型',
                         width: 120,
-                        selectList: {1: '商城类型', 2: '积分兑换', 3: '任务包兑换券', 4: '提货券', 5:'星钻兑换'}
+                        selectList: {1: '商城订单', 2: '积分订单', 3: '兑换券', 4: '锁定积分兑换', 5:'福袋发货订单'}
                     },
                     {
                         field: 'status', minWidth: 120, title: '订单状态', search: 'select', templet: function (d) {

+ 23 - 19
public/static/admin/js/user/user.js

@@ -22,22 +22,22 @@ define(["jquery", "easy-admin"], function ($, ea) {
                 init: init,
                 toolbar: ['refresh',
                     [
-                    //     {
-                    //     text: '添加',
-                    //     url: init.add_url,
-                    //     method: 'open',
-                    //     auth: 'add',
-                    //     class: 'layui-btn layui-btn-normal layui-btn-sm',
-                    //     icon: 'fa fa-plus ',
-                    // }
-                    // , {
-                    //     text: '邀请',
-                    //     url: 'user.user/invite',
-                    //     method: 'open',
-                    //     auth: 'invite',
-                    //     class: 'layui-btn layui-btn-success layui-btn-sm',
-                    //     icon: 'fa fa-plus ',
-                    // }
+                        //     {
+                        //     text: '添加',
+                        //     url: init.add_url,
+                        //     method: 'open',
+                        //     auth: 'add',
+                        //     class: 'layui-btn layui-btn-normal layui-btn-sm',
+                        //     icon: 'fa fa-plus ',
+                        // }
+                        // , {
+                        //     text: '邀请',
+                        //     url: 'user.user/invite',
+                        //     method: 'open',
+                        //     auth: 'invite',
+                        //     class: 'layui-btn layui-btn-success layui-btn-sm',
+                        //     icon: 'fa fa-plus ',
+                        // }
                     ], 'export'],
                 cols: [[
                     {type: "checkbox"},
@@ -53,7 +53,13 @@ define(["jquery", "easy-admin"], function ($, ea) {
                     {field: 'nickname', width: 120, title: '昵称'},
                     {field: 'mobile', minWidth: 120, title: '手机号'},
                     {field: 'pass_enable', minWidth: 120, title: '密码'},
-                    {field: 'user_type', width: 100, title: '账户类型', search: 'select', selectList: {1: '正常注册', 9: '扶持号', 10:'潘总'}},
+                    {
+                        field: 'user_type',
+                        width: 100,
+                        title: '账户类型',
+                        search: 'select',
+                        selectList: {1: '正常注册', 9: '扶持号', 10: '潘总'}
+                    },
 
                     // {
                     //     field: 'level',
@@ -184,7 +190,6 @@ define(["jquery", "easy-admin"], function ($, ea) {
         // },
 
 
-
         details: function () {
             ea.listen();
         },
@@ -332,7 +337,6 @@ define(["jquery", "easy-admin"], function ($, ea) {
                     {field: 'order_id', minWidth: 220, title: '订单id'},
 
 
-
                 ]],
             });
             ea.listen();

+ 1 - 0
public/static/admin/js/withdraw/withdraw.js

@@ -13,6 +13,7 @@ define(["jquery", "easy-admin"], function ($, ea) {
             ea.table.render({
                 init: init,
                 toolbar: ['refresh', 'export'],
+                limits: [10, 15, 20, 25, 50, 100, 300, 500],
                 cols: [[
                     {type: "checkbox"},
                     {field: 'id', width: 100, title: 'ID', search: false},