puzhibing
2023-06-30 f58cca364b731eac2d60a440ffaa804be3cd43fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/**
 * 管理初始化
 */
var TRevenue = {
    id: "TRevenueTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
/**
 * 初始化表格的列
 */
TRevenue.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '主键', field: 'id', visible: false, align: 'center', valign: 'middle'},
            {title: '收入类型(1=订单收入,2=分佣收入)', field: 'type', visible: false, align: 'center', valign: 'middle'},
            {title: '用户类型(1=用户,2=司机,3=代理商)', field: 'userType', visible: false, align: 'center', valign: 'middle'},
            {title: '用户id', field: 'userId', visible: false, align: 'center', valign: 'middle'},
            {title: '订单id', field: 'orderId', visible: false, align: 'center', valign: 'middle'},
            {title: '收入金额', field: 'amount', visible: false, align: 'center', valign: 'middle'},
            {title: '添加时间', field: 'createTime', visible: false, align: 'center', valign: 'middle'},
 
            {title: '订单号', field: 'code', visible: true, align: 'center', valign: 'middle'},
            {title: '交易时间', field: 'businessTime', visible: true, align: 'center', valign: 'middle'},
            {title: '交易类型', field: 'businessType', visible: true, align: 'center', valign: 'middle',
                formatter: function (value, row) {
                    if (row.businessType === 1){
                        return '<span>支付订单</span>'
                    }else if (row.businessType === 11){
                        return '<span>佣金提现</span>'
                    }else if (row.businessType === 12){
                        return '<span>余额提现</span>'
                    }
                }
            },
            {title: '司机姓名', field: 'driverName', visible: true, align: 'center', valign: 'middle'},
            {title: '司机电话', field: 'driverPhone', visible: true, align: 'center', valign: 'middle'},
            {title: '支付类型', field: 'payType', visible: true, align: 'center', valign: 'middle',
                formatter: function (value, row) {
                    if (row.payType === 1){
                        return '<span>微信支付</span>'
                    }else if (row.payType === 2){
                        return '<span>余额支付</span>'
                    }else if (row.payType === 3){
                        return '<span>线下收款</span>'
                    }else if (row.payType === 0){
                        return ''
                    }
                }
            },
            {title: '金额', field: 'amount', visible: true, align: 'center', valign: 'middle',
                formatter: function (value, row) {
                    if (row.businessType === 1){
                        return '+'+row.amount
                    }else{
                        return '-'+row.amount
                    }
                }
            },
            {title: '佣金抽成', field: 'commissionAmount', visible: true, align: 'center', valign: 'middle',
                formatter: function (value, row) {
                    if (row.businessType === 1){
                        if(row.commissionAmount !== 0){
                            return '-'+row.commissionAmount
                        }else {
                            return 0
                        }
                    }else {
                        return ''
                    }
                }
            },
            {title: '优惠券', field: 'discountedPrice', visible: true, align: 'center', valign: 'middle'},
            {title: '余额', field: 'accountBalance', visible: true, align: 'center', valign: 'middle'},
            {title: '状态', field: 'state', visible: true, align: 'center', valign: 'middle',
                formatter: function (value, row) {
                    if (row.state === 1){
                        return '<span>待审核</span>'
                    }else if (row.state === 2){
                        return '<span>完成</span>'
                    }else if (row.state === 108){
                        return '<span>完成</span>'
                    }else if (row.state === 109){
                        return '<span>完成</span>'
                    }
                }
            },
        {title: '操作', visible: true, align: 'center', valign: 'middle',width:150,
            formatter: function (value, row) {
                if (row.businessType === 1){
                    return `<a href="#" onclick="TRevenue.searchTRevenueOrderDetail('${row.code}')" style="color:blue">详情</a>`
                }else if (row.businessType === 11){
                    return `<a href="#" onclick="TRevenue.searchTRevenueCommissionDetail('${row.code}')" style="color:blue">详情</a>`
                }else if (row.businessType === 12){
                    return `<a href="#" onclick="TRevenue.searchTRevenueBalanceDetail('${row.code}')" style="color:blue">详情</a>`
                }
            }
        }
    ];
};
 
/**
 * 检查是否选中
 */
TRevenue.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TRevenue.seItem = selected[0];
        return true;
    }
};
 
/**
 * 点击添加
 */
TRevenue.openAddTRevenue = function () {
    var index = layer.open({
        type: 2,
        title: '添加',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tRevenue/tRevenue_add'
    });
    this.layerIndex = index;
};
 
/**
 * 打开查看详情
 */
TRevenue.openTRevenueDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tRevenue/tRevenue_update/' + TRevenue.seItem.id
        });
        this.layerIndex = index;
    }
};
 
/**
 * 打开查看佣金提现详情(使用中)
 */
TRevenue.searchTRevenueCommissionDetail = function (code) {
    var index = layer.open({
        type: 2,
        title: '佣金提现详情',
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tRevenue/commissionDetail?code=' + code
    });
    this.layerIndex = index;
};
 
/**
 * 打开查看余额提现详情(使用中)
 */
TRevenue.searchTRevenueBalanceDetail = function (code) {
    var index = layer.open({
        type: 2,
        title: '余额提现详情',
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tRevenue/balanceDetail?code=' + code
    });
    this.layerIndex = index;
};
 
/**
 * 打开查看支付订单详情(使用中)
 */
TRevenue.searchTRevenueOrderDetail = function (code) {
    console.log(code)
    var index = layer.open({
        type: 2,
        title: '支付订单详情',
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tRevenue/orderDetail?code=' + code
    });
    this.layerIndex = index;
};
 
/**
 * 删除
 */
TRevenue.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/tRevenue/delete", function (data) {
            Feng.success("删除成功!");
            TRevenue.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("tRevenueId",this.seItem.id);
        ajax.start();
    }
};
 
/**
 * 司机信息导出
 */
TRevenue.export=function(){
    var code=$("#code").val()
    var businessType=$("#businessType").val()
    var payType=$("#payType").val()
    var driverName=$("#driverName").val()
    var businessTime=$("#businessTime").val()
    window.location.href=Feng.ctxPath + "/tRevenue/export?code="+code
        +"&businessType="+businessType
        +"&payType="+payType
        +"&driverName="+driverName
        +"&businessTime="+businessTime
    ;
}
 
/**
 * 查询列表
 */
TRevenue.search = function () {
    var queryData = {};
    queryData['code'] = $("#code").val();
    queryData['businessType'] = $("#businessType").val();
    queryData['payType'] = $("#payType").val();
    queryData['driverName'] = $("#driverName").val();
    queryData['businessTime'] = $("#businessTime").val();
    TRevenue.table.refresh({query: queryData});
};
 
/**
 * 重置
 */
TRevenue.resetSearch = function (){
    $("#code").val('');
    $("#businessType").val('');
    $("#payType").val('');
    $("#driverName").val('');
    $("#businessTime").val('');
    TRevenue.search();
}
 
$(function () {
    var defaultColunms = TRevenue.initColumn();
    var table = new BSTable(TRevenue.id, "/tRevenue/list", defaultColunms);
    table.setPaginationType("client");
    TRevenue.table = table.init();
});