Commit 7b3e5775 by 王昆

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

parents 397280f8 76d9741f
......@@ -78,6 +78,9 @@ class ActionAPI extends APIBase {
case "cancelItemInvoice":
opResult = await this.storderitemSve.cancelInvoice(action_body);
break;
case "invoiceTrade":
opResult = await this.storderitemSve.invoiceTrade(action_body);
break;
default:
......
......@@ -180,6 +180,13 @@ class StOrderItemDao extends Dao {
sql.push("AND saas_invoice_id = ''");
}
}
async invoiceTrade(id,order_type){
let sql = `select * from st_order_item where saas_invoice_id =:id and order_type =:order_type`;
return await this.customQuery(sql, {id:id,order_type:order_type});
}
}
module.exports = StOrderItemDao;
......@@ -9,7 +9,10 @@ class StOrderItemService extends ServiceBase {
}
async pageByCondition(params) {
let page = {count: 0, rows: []};
let page = {
count: 0,
rows: []
};
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
params.startRow = (params.currentPage - 1) * params.pageSize;
......@@ -36,7 +39,7 @@ class StOrderItemService extends ServiceBase {
}
let trade_time = params.trade_time;
if(!trade_time) {
if (!trade_time) {
return system.getResult(null, "请填写交易时间");
}
......@@ -44,27 +47,35 @@ class StOrderItemService extends ServiceBase {
if (order.check_status != "05") {
return system.getResult(null, "批次未审核");
}
if(order.trade_mode == "00") {
if (order.trade_mode == "00") {
return system.getResult(null, "批次未触发打款");
}
let itemParams = {ids: item_ids, trade_desc: params.trade_desc, trade_time: params.trade_time};
let countParams = {order_id: order.id, trade_status: "00"};
let orderParams = {id: order.id};
let itemParams = {
ids: item_ids,
trade_desc: params.trade_desc,
trade_time: params.trade_time
};
let countParams = {
order_id: order.id,
trade_status: "00"
};
let orderParams = {
id: order.id
};
let self = this;
await this.db.transaction(async t => {
await self.dao.updateTrade(itemParams, t);
let count = await self.dao.countItems(countParams, t);
if(count == order.item_count) {}
if (count == order.item_count) {}
orderParams.trade_status = count == order.item_count ? "00" : "03";
await self.storderDao.update(orderParams, t);
return order;
});
return system.getResultSuccess();
}
async tradeOnlineCB(params) {
}
async tradeOnlineCB(params) {}
async updateInvoice(params) {
let rs = await this.dao.updateInvoice(params);
return system.getResult(rs);
......@@ -83,12 +94,29 @@ class StOrderItemService extends ServiceBase {
let rs = await this.dao.bySaasInvoiceId(params);
return system.getResultSuccess(rs);
}
}
/**
* 根据 invoice_id 和 order_type 查询交易流水
* @param {*} params
*/
async invoiceTrade(params){
if(!params.id){
return system.getResult(null, `参数错误 ID不能为空`);
}
if(!params.order_type){
return system.getResult(null,`订单类型不能为空`);
}
try {
let res = await this.dao.invoiceTrade(this.trim(params.id),this.trim(params.order_type)) || [];
for(let item of res){
this.handleDate(item, ['updated_at', 'created_at'], 'YYYY-MM-DD HH:mm:ss');
}
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null,`系统错误`);
}
}
}
module.exports = StOrderItemService;
\ No newline at end of file
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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