Просмотр исходного кода

Wesmiler OTC 提交更新 0729

APPLE 3 лет назад
Родитель
Сommit
2dccf5fd02

+ 150 - 0
application/admin/controller/store/TaxiUserWithdraw.php

@@ -0,0 +1,150 @@
+<?php
+
+
+namespace app\admin\controller\store;
+
+
+use app\common\controller\AdminController;
+use app\common\model\Users;
+use app\http\IResponse;
+use EasyWeChat\Factory;
+use GuzzleHttp\Exception\GuzzleException;
+use think\Db;
+
+class TaxiUserWithdraw extends AdminController
+{
+    /**
+     * 提现列表
+     *
+     * @return mixed
+     * @throws \think\exception\DbException
+     */
+    public function index()
+    {
+        $where = [];
+        //组合搜索
+        !empty(input('name')) && $where[]
+            = ['name', 'like', '%' . input('name') . '%'];
+        !empty(input('keyword')) && $where[]
+            = ['mobile', 'like', '%'.input('keyword').'%'];
+
+        $withdraw = model('common/TaxiUsersWithdraw');
+
+        return IResponse::paginate($withdraw->where($where)->order(['created_at'=>'desc'])->with(['user','taxiUser'])
+            ->paginate(input('limit'),false));
+    }
+
+    /**
+     * 更新数据
+     *
+     * @param $id
+     * @return \think\response\Json
+     */
+    public function update($id)
+    {
+        // 接收数据
+        $params = $this->request->param();
+        // 查询用户
+        $withdraw = model('common/TaxiUsersWithdraw')->findBy($id);
+        // 状态操作
+        $valid = $this->validate($params, [
+            'status|配置参数' => 'require|integer'
+        ]);
+        // 错误返回
+        (true !== $valid) && IResponse::failure($valid);
+        // 更新信息
+        $withdraw->updateBy($id, $params);
+        Db::startTrans();
+        try {
+            // 通过
+            $withdraw->status = $params['status'];
+            $withdraw->remittance_time = $params['status'] ==20? time() : 0;
+            $withdraw->	arrival_amount = $params['status'] ==20? $withdraw['amount'] : 0;
+            if(!$withdraw->save()){
+                Db::rollback();
+                IResponse::failure('提现审核失败');
+            }
+
+            // 拒绝退款
+            if($params['status'] == 30){
+                // 查用户
+                $user = model('common/Users')->getBy($withdraw['user_id']);
+                if(empty($user)){
+                    Db::rollback();
+                    IResponse::failure('司机账户错误,请联系管理员处理');
+                }
+
+
+                // 写入资金记录
+                $Users = new Users();
+                $Users->changePartnership($user['id'], $withdraw['amount'], '资产提现失败退还', 20,true);
+            }
+
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+            IResponse::failure('审核错误');
+        }
+
+        return IResponse::success('审核成功');
+    }
+
+    /**
+     * 删除
+     *
+     * @author 许祖兴 < zuxing.xu@lettered.cn>
+     * @date 2020/6/11 14:26
+     *
+     * @param $id
+     * @return \think\response\Json
+     */
+    public function delete($id)
+    {
+        model('common/UsersWithdraw')->deleteBy($id);
+        return IResponse::success([],'删除提现申请单成功');
+    }
+
+    /**
+     * 用户批量操作
+     *
+     * @author 许祖兴 < zuxing.xu@lettered.cn>
+     * @date 2020/6/11 14:34
+     *
+     * @return mixed
+     */
+    public function plectron(){
+        // 收参数
+        $params = $this->request->param();
+
+        foreach (str2arr($params['ids']) as $id){
+            $withdraw = model('common/UsersWithdraw')->getBy($id);
+            if ($this->request->isDelete()){
+                $withdraw->deleteBy($id);
+            }else
+                // 等待审核状态下才做更新
+                if ($withdraw['status'] == 1){
+                    $withdraw->allowField(true)->updateBy($id, $params);
+                    Db::startTrans();
+                    try {
+                        if ($params['status'] == 2){
+                            // 查用户
+                            $user = model('common/Users')->getBy($withdraw['user_id']);
+                            // 更新资金
+                            $user->where(['id' => $withdraw['user_id']])->setDec('balance', $withdraw['amount']);
+                            // 写入资金记录
+                            model('common/UsersBalanceRecord')::create([
+                                'user_id' => $withdraw['user_id'],
+                                'dec_amount' => $withdraw['amount'],
+                                'aft_amount' => round($user['balance'] - $withdraw['amount']),
+                                'remark' => '主动提现,¥' . $withdraw['amount'] . ',单号;' . $withdraw['draw_no']
+                            ], true);
+                        }
+                        Db::commit();
+                    }catch (\Exception $e){
+                        Db::rollback();
+                    }
+                }
+        }
+        return IResponse::success([],'操作成功');
+    }
+}

+ 2 - 2
application/api/controller/v1/taxiUser/Order.php

@@ -90,8 +90,8 @@ class Order extends ApiController
 
         $order = isset($lists[0])? $lists[0] : [];
         $lastOrderTime = isset($order['created_at'])? $order['created_at']['val'] : time();
-        $hasNewOrder = $lastOrderTime != $taxiUser->last_order_time? true : false;
-        $taxiUser->last_order_time = $lastOrderTime;
+        $hasNewOrder = $order && $lastOrderTime != $taxiUser->last_order_time? true : false;
+        $taxiUser->last_order_time = $hasNewOrder? $lastOrderTime : $taxiUser->last_order_time;
         $taxiUser->save();
 
         $count = $lists->count();

+ 18 - 0
application/common/model/TaxiUsersWithdraw.php

@@ -45,6 +45,24 @@ class TaxiUsersWithdraw extends BaseModel
      * @param $value
      * @return false|string
      */
+    public function getWechatQrcodeAttr($value)
+    {
+        return ['val'=>$value,'url'=> get_annex_url($value)];
+    }
+
+    /**
+     * @param $value
+     * @return false|string
+     */
+    public function getAlipayQrcodeAttr($value)
+    {
+        return ['val'=>$value,'url'=> get_annex_url($value)];
+    }
+
+    /**
+     * @param $value
+     * @return false|string
+     */
     public function getCreatedAtAttr($value)
     {
         return ['val'=>$value,'text'=>date('m.d H:i', $value)];

+ 2 - 2
public/manage/assets/module/setter.js

@@ -5,8 +5,8 @@ layui.define(function (exports) {
         // baseServer: 'http://manage.gxrrj.cn/api/',
         // baseServer: 'http://renrenjie.com/manage/',
         // baseServer: 'https://rrj.gxnwsoft.com/manage/',
-        // baseServer: 'http://127.0.3.10/manage/',
-        baseServer: 'https://rrc.mp.dongerkj.com/manage/',
+        baseServer: 'http://127.0.3.10/manage/',
+        // baseServer: 'https://rrc.mp.dongerkj.com/manage/',
         // baseServer: 'http://rrjie.gxnwsoft.com/manage/',
         mapKey: 'X5IBZ-XFY36-UGFSZ-MP2XB-VCS35-ZNBKZ',
         pageTabs: false,

+ 201 - 0
public/manage/pages/store/taxi-user-withdraw.html

@@ -0,0 +1,201 @@
+<style type="text/css">
+    .xm-label-block {
+        background-color: #287bd2
+    }
+</style>
+
+<!-- 正文开始 -->
+<div class="layui-fluid">
+    <div class="layui-card">
+        <div class="layui-card-body">
+            <div class="layui-form toolbar" id="tbToolBar">
+                <div class="layui-form-item">
+                    <div class="layui-inline">
+                        <label class="layui-form-label w-auto">手机号:</label>
+                        <div class="layui-input-inline mr0">
+                            <input name="keyword" class="layui-input" type="text" placeholder="司机手机号"/>
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">状  态:</label>
+                        <div class="layui-input-inline mr0">
+                            <select name="status">
+                                <option value="">所有</option>
+                                <option value="10">待审</option>
+                                <option value="20">审核</option>
+                                <option value="30">驳回</option>
+                            </select>
+                        </div>
+                    </div>
+                    <div class="layui-inline" style="padding-right: 110px;">
+                        <button class="layui-btn icon-btn" lay-filter="formSubSearchWithdraw" lay-submit>
+                            <i class="layui-icon">&#xe615;</i>查询
+                        </button>
+                    </div>
+                </div>
+            </div>
+
+            <div class="layui-tab layui-tab-brief">
+
+                <table id="dataTable" lay-filter="dataTable"></table>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script type="text/html" id="toolBarTpl">
+    <div class="layui-btn-group fl">
+        <a table-data="{'url':'store/taxiuserwithdraw/plectron','action':'put',param:{'status': 20}}" class="layui-btn layui-btn-sm layui-icon layui-icon-play table-toolbar-btn">&nbsp;审核</a >
+        <a table-data="{'url':'store/taxiuserwithdraw/plectron','action':'put',param:{'status': 30}}" confirm class="layui-btn layui-btn-sm layui-icon layui-icon-pause table-toolbar-btn">&nbsp;驳回</a>
+        <a table-data="{'url':'store/taxiuserwithdraw/plectron','action':'delete'}" confirm class="layui-btn layui-btn-sm layui-icon layui-icon-close table-toolbar-btn">&nbsp;删除</a>
+    </div>
+</script>
+
+<!-- 表格操作列 -->
+<script type="text/html" id="tableBarWithdraw">
+    {{# if(d.status == 20){ }}
+    <a class="layui-btn layui-btn-disabled layui-btn-warm layui-btn-xs" lay-tips="禁止操作">审核</a>
+    <a class="layui-btn layui-btn-disabled layui-btn-xs" lay-tips="禁止操作">驳回</a>
+    <a class="layui-btn layui-btn-disabled layui-btn-xs" lay-tips="禁止操作">删除</a>
+    {{# }else if(d.status == 10){ }}
+    <a class="layui-btn layui-btn-xs" perm-show="put:/store/taxiuserwithdraw/<id>" lay-event="confirm">审核</a>
+    <a class="layui-btn layui-btn-warm layui-btn-xs" perm-show="put:/store/taxiuserwithdraw/<id>" lay-event="refuse">驳回</a>
+    <a class="layui-btn layui-btn-danger layui-btn-xs" perm-show="delete:/store/taxiuserwithdraw/<id>" lay-event="del">删除</a>
+    {{# }else{ }}
+    <a class="layui-btn layui-btn-disabled layui-btn-warm layui-btn-xs" lay-tips="禁止操作">审核</a>
+    <a class="layui-btn layui-btn-disabled layui-btn-xs" lay-tips="禁止操作">驳回</a>
+    <a class="layui-btn layui-btn-danger layui-btn-xs" perm-show="delete:/store/taxiuserwithdraw/<id>" lay-event="del">删除</a>
+    {{# } }}
+</script>
+<!-- 表格状态列 -->
+<script type="text/html" id="tableStateWithdraw">
+    {{# if(d.status == 10){ }}
+    <span class="layui-badge layui-badge-yellow">待审核</span>
+    {{# }else if(d.status == 20){ }}
+    <span class="layui-badge layui-badge-green">已审核</span>
+    {{# }else{ }}
+    <span class="layui-badge layui-badge-gray">驳回</span>
+    {{# } }}
+</script>
+
+<!-- js部分 -->
+<script>
+    layui.use(['layer', 'form', 'table', 'util', 'notice','md5', 'admin', 'setter', 'xmSelect'], function () {
+        var $ = layui.jquery;
+        var layer = layui.layer;
+        var form = layui.form;
+        var table = layui.table;
+        var util = layui.util;
+        var admin = layui.admin;
+        var notice = layui.notice;
+        var setter = layui.setter;
+        var md5 = layui.md5;
+        var xmSelect = layui.xmSelect;
+
+        form.render('select');
+        // 渲染表格
+        var insTb = table.render({
+            elem: '#dataTable',
+            url: setter.baseServer + 'store/taxiuserwithdraw',
+            page: true,
+            // toolbar: true,
+            toolbar: '#toolBarTpl',
+            cellMinWidth: 100,
+            cols: [[
+                {type: 'checkbox'},
+                {field: 'order_no', title: '单号'},
+                {field: 'user', title: '用户',templet: function (d) {
+                        return '<a href="javascript:;" class="taxi-user-view" style="color: #35cc98;border-bottom: 1px solid;"> '
+                        + ( d.user ?  d.user.nickname + '(' + d.taxi_user.mobile + ')' : '用户不存在') + ' </a>';
+                    }, width: 200
+                },
+                {field: 'type', title: '收款方式',templet: function (d) {
+                    var type = ['未知','银行卡','微信','支付宝'];
+                    return type[d.pay_type];
+                    }, width: 120},
+                {field: 'account', title: '收款账号', templet: function (d) {
+                        if(d.pay_type == 1){
+                            return '收款人:'+d.real_name+';'+'银行卡号:'+d.bank_card_no+';开户行:'+(d.desposit_bank||'')+' '+d.sub_branch+';';
+                        }else if(d.pay_type == 2){
+                            return '收款人:'+d.real_name+';微信号:'+d.wechat+'; 收款码:<a href="'+d.wechat_qrcode.url+'"><img width="80px" height="80px" src="'+d.wechat_qrcode.url+'"></a>';
+                        }else if(d.pay_type == 3){
+                            return '收款人:'+d.real_name+';支付宝:'+d.alipay+'; 收款码:<a href="'+d.alipay_qrcode.url+'"><img width="80px" height="80px" src="'+d.alipay_qrcode.url+'"></a>';
+                        }
+                    }, width: 200},
+                {field: 'amount', title: '提现金额',width: 120},
+                {
+                    field: 'created_at', sort: true, templet: function (d) {
+                        return util.toDateString(d.created_at * 1e3);
+                    }, title: '创建时间', width: 180
+                },
+                {field: 'status', templet: '#tableStateWithdraw', title: '状态', width: 120},
+                {fixed:'right', align: 'center', toolbar: '#tableBarWithdraw', title: '操作', minWidth: 200}
+            ]],
+            done:function () {
+                admin.renderPerm()
+            }
+        });
+        // 搜索
+        form.on('submit(formSubSearchWithdraw)', function (data) {
+            insTb.reload({where: data.field}, 'data');
+        });
+
+        // 工具条点击事件
+        table.on('tool(dataTable)', function (obj) {
+            var data = obj.data;
+            var layEvent = obj.event;
+            if (layEvent === 'confirm') { // 审核
+                layer.confirm('确定要审核“' + data.order_no + '”的提现申请吗?', {
+                    skin: 'layui-layer-admin',
+                    shade: .1
+                }, function (i) {
+                    layer.close(i);
+                    layer.load(2);
+                    admin.req('store/taxiuserwithdraw/' + data.id, {status: 20}, function (r) {
+                        layer.closeAll('loading');
+                        if (r.code === 10000) {
+                            notice.msg(r.message, {icon: 1});
+                            insTb.reload({}, 'data');
+                        } else {
+                            notice.msg(r.message, {icon: 2});
+                        }
+                    }, 'PUT');
+                });
+            } else if (layEvent === 'refuse') { // 驳回
+                layer.confirm('确定要驳回“' + data.order_no + '”的提现申请吗?', {
+                    skin: 'layui-layer-admin',
+                    shade: .1
+                }, function (i) {
+                    layer.close(i);
+                    layer.load(2);
+                    admin.req('store/taxiuserwithdraw/' + data.id, {status: 30}, function (r) {
+                        layer.closeAll('loading');
+                        if (r.code === 10000) {
+                            notice.msg(r.message, {icon: 1});
+                            insTb.reload({}, 'data');
+                        } else {
+                            notice.msg(r.message, {icon: 2});
+                        }
+                    }, 'PUT');
+                });
+            } else if (layEvent === 'del') { // 删除
+                layer.confirm('确定要删除“' + data.order_no + '”的提现申请吗?', {
+                    skin: 'layui-layer-admin',
+                    shade: .1
+                }, function (i) {
+                    layer.close(i);
+                    layer.load(2);
+                    admin.req('store/taxiuserwithdraw/' + data.id, function (r) {
+                        layer.closeAll('loading');
+                        if (r.code === 10000) {
+                            notice.msg(r.message, {icon: 1});
+                            insTb.reload({}, 'data');
+                        } else {
+                            notice.msg(r.message, {icon: 2});
+                        }
+                    }, 'DELETE');
+                });
+            }
+        });
+    });
+</script>

+ 9 - 0
route/route.php

@@ -695,6 +695,15 @@ Route::group('manage',function (){
             // 提现管理资源路由
             Route::resource('withdraw','admin/store.Withdraw');
 
+            // 司机提现
+            Route::group('taxiuserwithdraw',function (){
+                // 批量操作
+                Route::rule('/plectron','admin/store.TaxiUserWithdraw/plectron');
+            });
+            // 司机提现管理资源路由
+            Route::resource('taxiuserwithdraw','admin/store.TaxiUserWithdraw');
+
+
             // 文章
             Route::group('article',function (){
                 // 分类