Commit 81edbdbc by 王昆

gsb

parent f5e9178b
......@@ -13,6 +13,7 @@ class OrderCtl extends CtlBase {
this.productSve = system.getObject("service.product.productSve");
this.ordersignlogSve = system.getObject("service.order.ordersignlogSve");
this.orderauthlogSve = system.getObject("service.order.orderauthlogSve");
this.feeSve = system.getObject("service.order.feeSve");
}
/**
......@@ -55,7 +56,7 @@ class OrderCtl extends CtlBase {
if(pobj.product_type=='1'){ //如果是单个产品 需要转化单价
pobj.product_unit_price = system.y2f(pobj.product_unit_price);
}
// TODO:需要去调用商户钱包 扣钱
// 需要去调用商户钱包 扣钱
if(pobj.id){
let reduceAccountBalanceRes = await this.merchantaccountSve.addordelavailable({merchant_id: this.trim(pobj.merchant_id),amount:pobj.price*(-1)});
if(reduceAccountBalanceRes.status!=0){
......@@ -95,7 +96,7 @@ class OrderCtl extends CtlBase {
}
pobj.audit_user_id=req.loginUser.id; //获取审核人
let res = await this.orderSve.auditEorder(pobj);
//TODO:审核订单成功之后
// 审核订单成功之后
if(res.status==0){
this.pushMerchantTrade(pobj);
}
......@@ -130,7 +131,7 @@ class OrderCtl extends CtlBase {
}
}
if(params.audit_status=='30'){ //订单审核失败
//TODO:推送给赵大哥
// 推送给赵大哥
let reduceAccountBalanceRes = await this.merchantaccountSve.addordelavailable({merchant_id: this.trim(orderBean.merchant_id),amount:orderBean.price});
console.log("订单审核失败 余额退回 "+JSON.stringify(reduceAccountBalanceRes));
}
......@@ -151,6 +152,8 @@ class OrderCtl extends CtlBase {
return system.getResult(null, `订单【${pobj.id}】不存在`);
}
let res = await this.orderSve.getEorderById(pobj);
// 计费
await this.feeSve.setRowsFee([res.data], "engine_account_id");
return res;
}catch (e) {
console.log(e);
......@@ -195,6 +198,8 @@ class OrderCtl extends CtlBase {
for (let item of res.data.rows) {
item.product_info = productMap[item.product_id];
}
// 设置计费内容
await this.feeSve.setRowsFee(res.data.rows, "engine_account_id");
return res;
}catch (e) {
console.log(e);
......
......@@ -111,6 +111,24 @@ class FeeService extends ServiceBase {
}
}
async setRowsFee(rows, field) {
if (!rows || rows.length == 0 || !field) {
return;
}
let ids = [];
for (let item of rows) {
let id = Number(item[field] || 0);
if (!id) {
continue;
}
ids.push(id);
}
let map = await this.accountBulk({ids: ids}).data || {};
for (let item of rows) {
item.fee = map[Number(item[field] || 0)] || {};
}
}
}
module.exports = FeeService;
\ 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