Commit 3a5d9e7c by 王昆

Merge branch 'xggsve-trade' of gitlab.gongsibao.com:jiangyong/zhichan into xggsve-trade

parents 171b03be d60c2b2b
...@@ -91,6 +91,9 @@ class ActionAPI extends APIBase { ...@@ -91,6 +91,9 @@ class ActionAPI extends APIBase {
case "updateStatus": case "updateStatus":
opResult = await this.stpaySve.updateStatus(action_body); opResult = await this.stpaySve.updateStatus(action_body);
break; break;
case "tradeItemBycreditCode":
opResult = await this.storderitemSve.tradeItemBycreditCode(action_body);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
...@@ -168,6 +168,9 @@ class StOrderItemDao extends Dao { ...@@ -168,6 +168,9 @@ class StOrderItemDao extends Dao {
if (params.trade_status) { if (params.trade_status) {
sql.push("AND trade_status = :trade_status"); sql.push("AND trade_status = :trade_status");
} }
if (params.trade_status_array) {
sql.push("AND trade_status in (:trade_status_array)");
}
if (params.acc_name) { if (params.acc_name) {
params.acc_name_like = `%${params.acc_name}%`; params.acc_name_like = `%${params.acc_name}%`;
sql.push("AND acc_name LIKE :acc_name_like"); sql.push("AND acc_name LIKE :acc_name_like");
...@@ -178,6 +181,9 @@ class StOrderItemDao extends Dao { ...@@ -178,6 +181,9 @@ class StOrderItemDao extends Dao {
if (params.credit_code) { if (params.credit_code) {
sql.push("AND credit_code = :credit_code"); sql.push("AND credit_code = :credit_code");
} }
if(params.credit_code_array){
sql.push("AND credit_code in (:credit_code_array)");
}
if (params.createBegin) { if (params.createBegin) {
sql.push("AND created_at >= :createBegin"); sql.push("AND created_at >= :createBegin");
} }
...@@ -187,11 +193,22 @@ class StOrderItemDao extends Dao { ...@@ -187,11 +193,22 @@ class StOrderItemDao extends Dao {
if (params.unInvoice) { if (params.unInvoice) {
sql.push("AND saas_invoice_id = ''"); sql.push("AND saas_invoice_id = ''");
} }
if (params.saas_invoice_id) {
sql.push("AND saas_invoice_id = :saas_invoice_id");
}
if(params.data_ids && params.data_ids.length>0){
sql.push("AND id in (:data_ids)");
}
} }
async invoiceTrade(id,order_type){ async invoiceTrade(params){
let sql = `select * from st_order_item where saas_invoice_id =:id and order_type =:order_type`; let sql = [];
return await this.customQuery(sql, {id:id,order_type:order_type}); sql.push(`select * from st_order_item `);
sql.push("WHERE deleted_at IS NULL and 1=1 ");
this.setCondition(sql, params);
sql.push("ORDER BY created_at DESC");
sql.push("LIMIT :startRow, :pageSize");
return await this.customQuery(sql.join(" "), params);
} }
......
...@@ -31,6 +31,15 @@ class StOrderService extends ServiceBase { ...@@ -31,6 +31,15 @@ class StOrderService extends ServiceBase {
if (page.rows) { if (page.rows) {
for (var row of page.rows) { for (var row of page.rows) {
this.handleDate(row, ["created_at"], null); this.handleDate(row, ["created_at"], null);
if(row.acc_type == "00"){
row.acc_type_name = "银行";
}else if(row.acc_type == "01"){
row.acc_type_name = "支付宝";
}else if(row.acc_type ="02"){
row.acc_type_name ="微信"
}else{
row.acc_type_name = "其他";
}
} }
this.dictionary.setRowsName("ORDER", page.rows, ["order_type", "acc_type", "trade_mode", "trade_status", "check_status"]); this.dictionary.setRowsName("ORDER", page.rows, ["order_type", "acc_type", "trade_mode", "trade_status", "check_status"]);
} }
......
...@@ -109,7 +109,15 @@ class StOrderItemService extends ServiceBase { ...@@ -109,7 +109,15 @@ class StOrderItemService extends ServiceBase {
return system.getResult(null,`订单类型不能为空`); return system.getResult(null,`订单类型不能为空`);
} }
try { try {
let res = await this.dao.invoiceTrade(this.trim(params.id),this.trim(params.order_type)) || []; let tparam = {order_type:this.trim(params.order_type)};
if (params.data_ids && params.data_ids.length > 0) {
tparam.data_ids = params.data_ids;
} else if (params.id) {
tparam.saas_invoice_id = params.id;
} else {
return system.getResult([]);
}
let res = await this.dao.invoiceTrade(tparam) || [];
for(let item of res){ for(let item of res){
this.handleDate(item, ['updated_at', 'created_at'], 'YYYY-MM-DD HH:mm:ss'); this.handleDate(item, ['updated_at', 'created_at'], 'YYYY-MM-DD HH:mm:ss');
} }
...@@ -119,5 +127,63 @@ class StOrderItemService extends ServiceBase { ...@@ -119,5 +127,63 @@ class StOrderItemService extends ServiceBase {
return system.getResult(null,`系统错误`); return system.getResult(null,`系统错误`);
} }
} }
/**
* 根据统一社会信用代码获取所有的订单流水
* @param params
* @returns {Promise<void>}
*/
async tradeItemBycreditCode(params){
if(!(params.credit_code_array instanceof Array) && params.credit_code_array.length <0){
return system.getResult(null, `参数格式错误`);
}
try{
let page = {
count: 0,
rows: []
};
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
params.startRow = (params.currentPage - 1) * params.pageSize;
page.count = await this.dao.countByCondition(params);
if (page.count == 0) {
return system.getResultSuccess(page);
}
page.rows = await this.dao.invoiceTrade(params);
if(page.rows){
for (let item of page.rows) {
this.handleDate(item, ["created_at","trade_time"], null);
item.amt = system.f2y(item.amt);
item.actual_amt = system.f2y(item.actual_amt);
item.deduct_amt = system.f2y(item.deduct_amt);
item.service_tax = system.f2y(item.service_tax);
if(item.order_type == "10"){//00未设置 10平台交易 20商户交易
item.order_type_name = "平台交易";
}else if(item.order_type=="20"){
item.order_type_name = "商户交易";
}else{
item.order_type_name = "未设置";
}
if(item.trade_status=="00"){//交易状态 00 成功 01 待处理 02 失败
item.trade_status_name = "成功";
}else if(item.trade_status=="01"){
item.trade_status_name = "待处理";
}else if(item.trade_status=="02"){
item.trade_status_name = "失败";
}else{
item.trade_status_name = "";
}
}
}
return system.getResult(page);
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误`);
}
}
} }
module.exports = StOrderItemService; module.exports = StOrderItemService;
\ No newline at end of file
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