Commit 0b9c9acc by 宋毅

tj

parent 7a24dcb1
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class OrderAPI extends APIBase {
constructor() {
super();
this.orderinfoSve = system.getObject("service.dbcorder.orderinfoSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "icOrderStatusNotify"://操作工商流程通知信息
opResult = await this.orderinfoSve.icOrderStatusNotify(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = OrderAPI;
\ No newline at end of file
......@@ -5,11 +5,12 @@ class OrderInfoDao extends Dao {
super(Dao.getModelName(OrderInfoDao));
}
async getItemStatusByOrderNo(orderNo, uapp_id) {
return await this.model.findOne({
var sqlWhere = {
where: {
orderNo: orderNo, uapp_id: uapp_id
orderNo: orderNo
},
attributes: [
"id",
"orderNo",
"channelServiceNo",
"channelOrderNo",
......@@ -23,9 +24,14 @@ class OrderInfoDao extends Dao {
"totalSum",
"payTotalSum",
"refundSum",
"invoiceApplyStatus"],
"invoiceApplyStatus",
"created_at"],
raw: true
});
};
if (uapp_id) {
sqlWhere.where.uapp_id = uapp_id;
}
return await this.model.findOne(sqlWhere);
}
}
module.exports = OrderInfoDao;
......@@ -238,6 +238,51 @@ class OrderInfoService extends ServiceBase {
}
return system.getResultSuccess();
}
//-------------------------------服务商通知订单流程-------------start----------------
async icOrderStatusNotify(pobj, actionBody) {//获取订单交付信息
var item = await this.dao.getItemStatusByOrderNo(actionBody.orderNo);
if (!item) {
return system.getResult(null, "order data is empty!");
}
var updateDeliveryInfo = [];
var deliveryInfo = await this.getOrderDeliveryInfo(pobj);
var addi = 0;
if (deliveryInfo.status == 0 && deliveryInfo.data && deliveryInfo.data.length > 0) {
updateDeliveryInfo = deliveryInfo.data;
} else {
updateDeliveryInfo.push({
orderDeliveryStatus: "已下单",
orderDeliveryStatusName: "已下单",
updated: item.created_at
});
addi = 1;
}
var dataIndex = updateDeliveryInfo.findIndex(f => f.orderDeliveryStatus == actionBody.orderDeliveryStatus);
if (dataIndex > -1) {
updateDeliveryInfo[dataIndex].orderDeliveryStatusName = actionBody.orderDeliveryStatusName;
updateDeliveryInfo[dataIndex].updated = actionBody.updated;
} else {
updateDeliveryInfo.push({
orderDeliveryStatus: actionBody.orderDeliveryStatus,
orderDeliveryStatusName: actionBody.orderDeliveryStatusName,
updated: actionBody.updated
});
}
var sql = null;
if (addi > 0) {
sql = "INSERT INTO `c_order_delivery` (`sourceOrderNo`,`deliveryContent`) VALUE('" +
actionBody.orderNo + "','" + JSON.stringify(updateDeliveryInfo) + "')";
}
else {
sql = "UPDATE `c_order_delivery` SET deliveryContent ='" + JSON.stringify(updateDeliveryInfo) + "' where sourceOrderNo='" + actionBody.orderNo + "'";
}
this.customQuery(sql);
return system.getResultSuccess();
}
//-------------------------------服务商通知订单流程-------------end----------------
}
module.exports = OrderInfoService;
\ 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