Commit c0a41b2f by 王昆

gsb

parent f966fb03
...@@ -6,6 +6,15 @@ class OorderprocessDao extends Dao { ...@@ -6,6 +6,15 @@ class OorderprocessDao extends Dao {
super(Dao.getModelName(OorderprocessDao)); super(Dao.getModelName(OorderprocessDao));
} }
async delByOrderId(order_id) {
if (!order_id) {
return;
}
let sql = "DELETE FROM o_order_process WHERE order_id = :order_id";
await this.customUpdate(sql, {order_id: order_id});
}
async findByOrderIdAndStatus(orderId, status) { async findByOrderIdAndStatus(orderId, status) {
if (!orderId || !status) { if (!orderId || !status) {
return null; return null;
......
...@@ -8,6 +8,8 @@ class OorderstatusService extends ServiceBase { ...@@ -8,6 +8,8 @@ class OorderstatusService extends ServiceBase {
constructor() { constructor() {
super("order", ServiceBase.getDaoName(OorderstatusService)); super("order", ServiceBase.getDaoName(OorderstatusService));
this.oorderSve = system.getObject("service.order.oorderSve");
this.oorderinforegDao = system.getObject("db.order.oorderinforegDao"); this.oorderinforegDao = system.getObject("db.order.oorderinforegDao");
this.oorderdeliverDao = system.getObject("db.order.oorderdeliverDao"); this.oorderdeliverDao = system.getObject("db.order.oorderdeliverDao");
this.oorderprocessDao = system.getObject("db.order.oorderprocessDao"); this.oorderprocessDao = system.getObject("db.order.oorderprocessDao");
...@@ -40,6 +42,28 @@ class OorderstatusService extends ServiceBase { ...@@ -40,6 +42,28 @@ class OorderstatusService extends ServiceBase {
if (!_order) { if (!_order) {
return system.getResult(null, `订单不存在`); return system.getResult(null, `订单不存在`);
} }
// 完善订单特殊处理
if (_order.status == 1010) {
let chooseItems = [];
for (let citem of this.trim(params.service_items).split(",")) {
let productId = Number(this.trim(citem) || 0);
if (productId) {
chooseItems.push(productId);
}
}
let orderProcessList = await this.oorderSve.buildOrderProcess(_order.product_id, chooseItems);
if (!orderProcessList || orderProcessList.length == 0) {
return system.getResult(null, "产品流程未配置");
}
for (let process of orderProcessList) {
process.order_id = _order.id;
}
await this.oorderprocessDao.delByOrderId(_order.id);
await this.oorderprocessDao.bulkCreate(orderProcessList);
}
let _orderStatus = await this.getOrderProcessStatus(_order.id, _order.status); let _orderStatus = await this.getOrderProcessStatus(_order.id, _order.status);
let nextList = JSON.parse(_orderStatus.next_status); let nextList = JSON.parse(_orderStatus.next_status);
_orderStatus.next_status = nextList; _orderStatus.next_status = nextList;
...@@ -154,7 +178,6 @@ class OorderstatusService extends ServiceBase { ...@@ -154,7 +178,6 @@ class OorderstatusService extends ServiceBase {
params._order.service_items = this.trim(params.service_items); params._order.service_items = this.trim(params.service_items);
params._order.service_remark = this.trim(params.service_remark); params._order.service_remark = this.trim(params.service_remark);
params._order.status = this.trim(params.status); params._order.status = this.trim(params.status);
try { try {
//开启事务 //开启事务
await this.db.transaction(async t => { await this.db.transaction(async t => {
......
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