Commit 08a5dfad by zhaoxiqing

Merge branch 'bpo-admin' of http://gitlab.gongsibao.com/jiangyong/zhichan into bpo-admin

parents 03f09f5f 1222ad3b
......@@ -160,6 +160,105 @@ class ChannelApi {
}
async orderInfo(queryobj, qobj, req) {
let param = system.decryption(queryobj.data);
// {"data_id":17,"channel_id":10002,"channel_merchant_id":"0","origin_merchant_id":"10048","pushplatform_channel_id":10000}
try {
param = JSON.parse(param);
} catch (error) {
console.log(error);
return system.getErrResult2("参数解析错误");
}
// 测试使用
// param.channel_merchant_id = 1;
// param.data_id = 511;
if (!param.channel_merchant_id) {
return system.getErrResult2("参数错误, 渠道商户不存在");
}
if (!param.data_id) {
return system.getErrResult2("参数错误, 订单不存在");
}
let merchant = await this.channelSve.merchantInfo({ id: param.channel_merchant_id }) || {};
merchant = merchant.data;
if (!merchant) {
return system.getErrResult2(`渠道商户${param.channel_merchant_id}不存在`);
}
let info = {
merchantName: merchant.merchant_name
};
if (merchant.origin_id == 10000) {
let order = await this.esettleSve.findTBLOrderById(param.data_id) || {};
info.createTime = moment(order.create_time).format('YYYY-MM-DD HH:mm:ss');
info.actualAmt = system.f2y(order.actual_amt);
info.incomeTax = system.f2y(order.income_tax);
info.serviceTax = system.f2y(order.service_tax);
info.deductAmt = system.f2y(order.deduct_amt);
} else {
let order = await this.esettleofflineSve.findById(param.data_id);
info.createTime = moment(order.created_at).format('YYYY-MM-DD HH:mm:ss');
info.actualAmt = system.f2y(order.actual_amt);
info.serviceTax = system.f2y(order.service_tax);
info.deductAmt = system.f2y(order.amt);
let incomeTax = await this.esettleofflineitemSve.sumIncome(order.id);
info.incomeTax = system.f2y(incomeTax);
}
return system.getResult2(info);
}
async itemPage(queryobj, qobj, req) {
let currentPage = Number(queryobj.currentPage || 1);
let pageSize = Number(queryobj.pageSize || 10);
let param = system.decryption(queryobj.data);
// {"data_id":17,"channel_id":10002,"channel_merchant_id":"0","origin_merchant_id":"10048","pushplatform_channel_id":10000}
try {
param = JSON.parse(param);
} catch (error) {
console.log(error);
return system.getErrResult2("参数解析错误");
}
// 测试使用
// param.channel_merchant_id = 9;
// param.data_id = "1209403539471060994";
if (!param.channel_merchant_id) {
return system.getErrResult2("参数错误, 渠道商户不存在");
}
if (!param.data_id) {
return system.getErrResult2("参数错误, 订单不存在");
}
let merchant = await this.channelSve.merchantInfo({ id: param.channel_merchant_id }) || {};
merchant = merchant.data;
if (!merchant) {
return system.getErrResult2(`渠道商户${param.channel_merchant_id}不存在`);
}
let page;
if (merchant.origin_id == 10000) {
page = await this.esettleSve.pageByOrderId(param.data_id, currentPage, pageSize);
} else {
page = await this.esettleofflineitemSve.pageByByOrderId(param.data_id, currentPage, pageSize);
if(page.rows) {
for(let row of page.rows) {
row.deduct_amt = row.amt;
row.trade_status = "02";
}
}
}
if(page && page.rows) {
for(let row of page.rows) {
row.actual_amt = system.f2y(row.actual_amt);
row.income_tax = system.f2y(row.income_tax);
row.service_tax = system.f2y(row.service_tax);
row.deduct_amt = system.f2y(row.deduct_amt);
}
}
return system.getResult2(page);
}
trim(o) {
if (!o) {
return "";
......
var system = require("../../system")
const md5 = require("MD5");
const logCtl = system.getObject("web.oplogCtl");
const moment = require("moment");
class ChannelApi2 {
constructor() {
this.channelSve = system.getObject("service.channelSve");
this.esettleSve = system.getObject("service.esettleSve");
this.restClient = system.getObject("util.restClient");
this.esettleofflineitemSve = system.getObject("service.esettleofflineitemSve");
this.FQURL = "http://yunfuapi-dev.gongsibao.com/crm/order/submit"
this.esettleofflineSve = system.getObject("service.esettleofflineSve");
}
//渠道绑定
async bindPlatform(queryobj, qobj, req) {
if (!this.trim(queryobj.platform_id)) {
return system.getErrResult2("platform_id不能为空")
}
if (!this.trim(queryobj.channel_id)) {
return system.getErrResult2("channel_id不能为空")
}
if (!this.trim(queryobj.platform_channel_id)) {
return system.getErrResult2("platform_channel_id不能为空")
}
var result = await this.channelSve.bindPlatform(queryobj);
return result;
}
//绑定渠道推送
async pushbindingchannel(queryobj, qobj, req) {
queryobj.begin = moment().subtract(1, 'days').format('YYYY-MM-DD 00:00:00'); /*前一天的时间*/
queryobj.end = moment().subtract(1, 'days').format('YYYY-MM-DD 23:59:59'); /*前一天的时间*/
var result = await this.channelSve.pushbindingchannel(queryobj);
var data = result.data;
if (data.length > 0) {
for (let i = 0; i < data.length; i++) {
if (data[i].channel_id == '10000' && data[i].origin_merchant_id != '') {
var busiData = await this.esettleSve.findBybusiId(data[i].origin_merchant_id);
if (busiData.length > 0) {
for (let j = 0; j < busiData.length; j++) {
var pushData = this.getBusiData(busiData[j], data[i]);
var rc = system.getObject("util.aliyunClient");
var rtn = null;
rtn = await rc.post(this.FQURL, pushData);
console.log(pushData)
console.log(rtn)
}
}
} else {
if (data[i].origin_merchant_id != '') {
var esettleoffline = await this.esettleofflineSve.findOne({ "ecompany_id": data[i].origin_merchant_id });
if (esettleoffline != null) {
var pushData = this.getBusiDatas(esettleoffline.dataValues, data[i]);
var rc = system.getObject("util.aliyunClient");
var rtn = null;
rtn = await rc.post(this.FQURL, pushData);
console.log(pushData)
console.log(rtn)
}
}
}
}
}
}
async paydayCount(queryobj, qobj, req) {
var data = await this.separateGet(queryobj);
console.log(data.dataValues)
}
async separateGet(queryobj) {
let encry = system.decryption(queryobj.param);
encry = JSON.parse(encry);
if (encry.channel_id == 10000) {
var busiData = await this.esettleSve.findByIdList(encry.data_id);
return busiData;
}
var esettleoffline = await this.esettleofflineitemSve.find({ "esettleoffline_id": encry.data_id });
return esettleoffline;
}
getBusiData(da, chnanel) {
var resultData = {
"idempotentId": da.out_trade_no,// 业务编号(订单id)
"idempotentSource": "bpo_xbg",// 来源编号,写死:bpo_xbg
"idempotentSourceName": "BPO",// 来源编号,写死:BPO薪必果
"thirdPartyChannelId": "10000",// 渠道id
"thirdPartyCustomerId": da.busi_id,// 第三方客户id
"productId": "5e6b02cc3290c3000a3a63dc",// 云服产品id (测试环境)
"allotRatio": "50",// 分润比例(百分比的数字部分(如:50代表50%))
"orderPrice": da.deduct_amt,// 订单金额
"productQuantity": "1",// 产品数量
"companyName": chnanel.merchant_name,// 公司名称
"phone": "13722223333"
};
var str = {
"data_id": da.id,// 发薪批次id tbl_order.id 或者 c_esettle_offline.id
"channel_id": chnanel.channel_id,//渠道id
"channel_merchant_id": da.busi_id,//渠道商户id
"origin_merchant_id": chnanel.origin_merchant_id,//来源商户id
"pushplatform_channel_id": chnanel.platform_id,//对方渠道id
};
let encry = System.encryption(JSON.stringify(str));
resultData.param = system.encryption(encry);
return resultData;
}
getBusiDatas(da, chnanel) {
var resultData = {
"idempotentId": da.id,// 业务编号(订单id)
"idempotentSource": "bpo_xbg",// 来源编号,写死:bpo_xbg
"idempotentSourceName": "BPO",// 来源编号,写死:BPO薪必果
"thirdPartyChannelId": "10000",// 渠道id
"thirdPartyCustomerId": da.busi_id,// 第三方客户id
"productId": "5e6b02cc3290c3000a3a63dc",// 云服产品id (测试环境)
"allotRatio": "50",// 分润比例(百分比的数字部分(如:50代表50%))
"orderPrice": da.amt,// 订单金额
"productQuantity": "1",// 产品数量
"companyName": da.ecompanyName,// 公司名称
"phone": "13722223333"
};
var str = {
"data_id": da.id,// 发薪批次id tbl_order.id 或者 c_esettle_offline.id
"channel_id": chnanel.channel_id,//渠道id
"channel_merchant_id": da.busi_id,//渠道商户id
"origin_merchant_id": chnanel.origin_merchant_id,//来源商户id
"pushplatform_channel_id": chnanel.platform_id,//对方渠道id
};
resultData.param = system.encryption(JSON.stringify(str));
return resultData;
}
trim(o) {
if (!o) {
return "";
}
return o.toString().trim();
}
}
module.exports = ChannelApi2;
......@@ -352,7 +352,7 @@ class EsettleService extends ServiceBase {
}
item.phone_no = item.mobile;
if(item.mobile && item.mobile.length > 4) {
if (item.mobile && item.mobile.length > 4) {
item.mobile = "*******" + item.mobile.substring(item.mobile.length - 4);
}
......@@ -569,7 +569,7 @@ class EsettleService extends ServiceBase {
var sql = [];
sql.push("SELECT ");
sql.push("t1.create_time, t1.pay_complete_time, t1.out_trade_no, t1.id, t1.busi_id,");
sql.push("t1.amt, t1.actual_amt, t1.deduct_amt, t1.service_tax, t1.added_value_tax,");
sql.push("t1.amt, t1.actual_amt, t1.deduct_amt, t1.service_tax, t1.added_value_tax, t1.income_tax,");
sql.push("t2.company_name,");
sql.push("t3.service_rate,");
sql.push("1")
......@@ -707,6 +707,7 @@ class EsettleService extends ServiceBase {
return stat;
}
async findIncomeTaxById(orderItemId) {
var getTax = {};
if (!orderItemId) {
......@@ -825,8 +826,8 @@ class EsettleService extends ServiceBase {
}
return list;
}
async findBybusiId(busiId){
if(!busiId){
async findBybusiId(busiId) {
if (!busiId) {
return [];
}
var sql = "SELECT * FROM `tbl_order` WHERE busi_id = :busiId";
......@@ -837,16 +838,69 @@ class EsettleService extends ServiceBase {
return list;
}
async findByIdList(tblOrderId){
if(!busiId){
return [];
}
var sql = "SELECT * FROM `tbl_order_item` WHERE order_id = :tblOrderId";
var list = await this.settledb.query(sql, { replacements: { tblOrderId:tblOrderId}});
if (list && list.length > 0) {
list = list[0, 0] || [];
}
return list;
async findByIdList(tblOrderId) {
if (!busiId) {
return [];
}
var sql = "SELECT * FROM `tbl_order_item` WHERE order_id = :tblOrderId";
var list = await this.settledb.query(sql, { replacements: { tblOrderId: tblOrderId } });
if (list && list.length > 0) {
list = list[0, 0] || [];
}
return list;
}
async countByOrderId(tblOrderId) {
if (!tblOrderId) {
return [];
}
var sql = "SELECT count(1) as num FROM `tbl_order_item` WHERE order_id = :tblOrderId";
var countrs = await this.settledb.query(sql, { replacements: { tblOrderId: tblOrderId } });
var total = 0;
if (countrs && countrs[0, 0] && countrs[0, 0].length > 0) {
return Number(countrs[0, 0][0].num || 0);
}
return 0;
}
async listByOrderId(tblOrderId, startRow, limit) {
if (!tblOrderId) {
return [];
}
let sql = [];
sql.push("SELECT");
// sql.push("id_no, id_name, mobile, out_trade_no, ");
sql.push("id_name, actual_amt, income_tax, service_tax, deduct_amt, ");
sql.push("trade_status");
sql.push("FROM `tbl_order_item` ");
sql.push("WHERE order_id = :tblOrderId");
sql.push("ORDER BY pay_complete_time DESC ");
sql.push("LIMIT :startRow, :limit")
var list = await this.settledb.query(sql.join(" "), { replacements: { tblOrderId: tblOrderId, startRow: startRow, limit: limit } });
if (list && list.length > 0) {
list = list[0, 0] || [];
}
return list;
}
async pageByOrderId(tblOrderId, currentPage, pageSize) {
currentPage = Number(currentPage || 1);
pageSize = Number(pageSize || 10);
let startRow = (currentPage - 1) * pageSize;
if (!tblOrderId) {
return { count: 0, rows: [] };
}
let total = await this.countByOrderId(tblOrderId);
if (total == 0) {
return { count: 0, rows: [] };
}
let list = await this.listByOrderId(tblOrderId, startRow, pageSize) || [];
return { count: total, rows: list };
}
}
module.exports = EsettleService;
......@@ -33,5 +33,42 @@ class EsettleofflineitemService extends ServiceBase {
}
return page;
}
async pageByByOrderId(esettleoffline_id, currentPage, pageSize) {
if (!esettleoffline_id) {
return {count:0, rows: []};
}
currentPage = Number(currentPage || 1);
pageSize = Number(pageSize || 10);
var where = {
esettleoffline_id: esettleoffline_id
};
var orderby = [
["id", 'desc']
];
var attributes = [
// "id_no", "id_name",
"id_name", "actual_amt", "income_tax", "service_tax", "amt"
];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
if (page && page.rows) {
for (var row of page.rows) {
}
}
return page;
}
async sumIncome(esettleoffline_id) {
let sql = "SELECT SUM(income_tax) AS incomeTax FROM `c_esettle_offline_item` WHERE esettleoffline_id = :esettleoffline_id";
var list = await this.dao.customQuery(sql, {esettleoffline_id: esettleoffline_id});
if(!list || list.length == 0) {
return 0;
}
return list[0].incomeTax || 0;
}
}
module.exports = EsettleofflineitemService;
\ No newline at end of file
......@@ -2,15 +2,31 @@ var app = new Vue({
el: "#app",
data: function () {
return {
a: 1000,
param: "",
currentPage: 1,
rows: ['0.00','0.00','0.00','0.00','0.00','2','0.00','0.00','0.00','0.00']
pageSize: 10,
rows: [],
info: {
createTime: "",
incomeTax: "",
deductAmt: "",
merchantName: "",
actualAmt: "",
itemCount: "",
serviceTax: "",
},
}
},
created: function () {
},
mounted: function () {
console.log(1111);
this.param = this.getUrlParams("data");
if(!this.param) {
this.$message.warning("请求参数错误");
return;
}
console.log(this.param, "--------------");
this.getInfo();
},
methods: {
postReq(path, data) {
......@@ -18,19 +34,65 @@ var app = new Vue({
return r.data ? r.data : null;
})
},
getSettleInfo() {
this.$root.postReq("赵庆提供接口地址", {
companyId: this.companyId
}).then(rd => {
console.log(rd);
// 打印返回结果
getUrlParams: function (name) {
return decodeURIComponent(
(new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null;
},
onColFormater(row, column, cellValue, index) {
if(column.property == 'trade_status') {
if(cellValue === '00') {
return "成功";
} else if(cellValue === "01") {
return "待处理";
} else if(cellValue === "02") {
return "失败";
} else if(cellValue === "03") {
return "成功";
} else {
return "";
}
}
return cellValue || "0";
},
getInfo() {
let self = this;
this.$root.postReq("/api/channelApi/orderInfo", {
data: self.param
}).then(d => {
if (d.status === 0) {
self.info = d.data || {};
self.getItemPage();
} else {
self.$message.warning(d.msg || "订单数据获取失败");
}
});
},
getItemPage() {
let self = this;
this.$root.postReq("/api/channelApi/itemPage", {
currentPage: self.currentPage,
pageSize: self.pageSize,
data: self.param
}).then(d => {
if (d.status === 0) {
let page = d.data || {};
console.log(page, '------------------------')
self.rows = page.rows || [];
self.info.itemCount = page.count || 0;
} else {
self.$message.warning(d.msg || "订单详情列表获取失败");
}
});
},
handleSizeChange(val) {
this.pageSize = val;
console.log(`每页 ${val} 条`);
this.getItemPage();
},
handleCurrentChange(val) {
this.currentPage = val;
console.log(`当前页: ${val}`);
this.getItemPage();
},
},
});
\ No newline at end of file
......@@ -46,46 +46,46 @@
12312321
<div style="display: flex; justify-content: space-between; font-size: 13px;">
<label >
<div style="padding: 5px 0px;">创建时间:2020-03-06 16:00:00</div>
<div style="padding: 5px 0px;">个税(元):0.00</div>
<div style="padding: 5px 0px;">总扣款金额(元):0.00</div>
<div style="padding: 5px 0px;">创建时间:{{info.createTime}}</div>
<div style="padding: 5px 0px;">个税(元):{{info.incomeTax}}</div>
<div style="padding: 5px 0px;">总扣款金额(元):{{info.deductAmt}}</div>
</label>
<label>
<div style="padding: 5px 0px;">商户名称:北京创知厚德有限公司</div>
<div style="padding: 5px 0px;">实发金额(元):0.00</div>
<div style="padding: 5px 0px;">商户名称:{{info.merchantName}}</div>
<div style="padding: 5px 0px;">实发金额(元):{{info.actualAmt}}</div>
</label>
<label>
<div style="padding: 5px 0px;">打款总笔数:800</div>
<div style="padding: 5px 0px;">服务费(元):0.00</div>
<div style="padding: 5px 0px;">打款总笔数:{{info.itemCount || 0}}</div>
<div style="padding: 5px 0px;">服务费(元):{{info.serviceTax}}</div>
</label>
</div>
<div style="height: 20px; background: darkgrey;color: white;font-size: 14px; padding: 2px 0px; margin-top: 30px; display: flex; justify-content: space-around;">
<label >实发金额(元)</label>
<label >个税(元)</label>
<label >服务费(元)</label>
<label >总扣款金额(元)</label>
<label >交易状态</label>
</div>
<div style="border: 1px solid darkgrey;display: flex; justify-content: space-around;height: 20px; line-height: 20px; font-size:13px;"
v-for="item in rows">
<label >0.00</label>
<label >0.00</label>
<label >0.00</label>
<label >0.00</label>
<label >成功</label>
</div>
<el-button type="primary" icon="el-icon-edit"></el-button>
<el-table
stripe
fix="true"
:data="rows"
style="width: 100%;margin-top: 23px;min-height: 500px;"
empty-text="无"
tooltip-effect="light"
header-cell-style="background-color: #F5F5F5;color: #2F2F2F;font-size: 14px;font-weight:400;"
row-style="height:50px;" >
<el-table-column prop="id_name" label="姓名" :formatter="onColFormater" align="center" ></el-table-column>
<el-table-column prop="actual_amt" label="实发总额(元)" :formatter="onColFormater" align="center" ></el-table-column>
<el-table-column prop="income_tax" label="个税(元)" :formatter="onColFormater" align="center" ></el-table-column>
<el-table-column prop="service_tax" label="服务费(元)" :formatter="onColFormater" align="center" ></el-table-column>
<el-table-column prop="deduct_amt" label="总扣款金额(元)" :formatter="onColFormater" align="center" ></el-table-column>
<el-table-column prop="trade_status" label="交易状态" :formatter="onColFormater" align="center" ></el-table-column>
</el-table>
<!-- 分页 -->
<div class="block" style="height: 20px;margin-top: 20px; background: cyan;">
<div class="block" style="height: 20px;margin-top: 20px; ">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10, 20, 30]"
:page-size="10"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="100">
:total="info.itemCount">
</el-pagination>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment