Commit 5c4e8847 by 宋毅

addOrderDelivery移到dao中进行调用

parent 814bc6da
......@@ -49,5 +49,10 @@ class OrderInfoDao extends Dao {
};
return await this.delete(sqlWhere);
}
async addOrderDelivery(data, orderNo, t) {//新增交付信息
const sql = "INSERT INTO `c_order_delivery` (`sourceOrderNo`,`deliveryContent`) VALUE('" +
orderNo + "','" + JSON.stringify(data) + "')";
await this.customInsert(sql, null, t);
}
}
module.exports = OrderInfoDao;
......@@ -4,67 +4,67 @@ const uuidv4 = require('uuid/v4');
class InternalCallsNotifyService {
constructor() {
this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao");
this.delivery_status={
"dqrfa": "待确认方案",
"fabtg": "方案不通过",
"dfwsfw": "待服务",
"dsccl": "待上传材料",
"dsh": "待审核",
"ddj": "待递交",
"ydj": "已递交",
"ywc": "已完成"
this.delivery_status = {
"dqrfa": "待确认方案",
"fabtg": "方案不通过",
"dfwsfw": "待服务",
"dsccl": "待上传材料",
"dsh": "待审核",
"ddj": "待递交",
"ydj": "已递交",
"ywc": "已完成"
};
this.statusContrast={
"WAITCONFIRM":{name:"待确认方案",value:"dqrfa"},
"CONFIRMFAIL":{name:"方案不通过",value:"fabtg"},
"READY":{name:"待上传材料",value:"dsccl"},
"WAITCOMMIT":{name:"待递交",value:"ddj"},
"WAITARTIFICIALEXAMINE":{name:"待审核",value:"dsh"},
"DOCFINISH": {name:"待审核",value:"dsh"},
"AWAITCHECK": {name:"待审核",value:"dsh"},
"COMMITED": {name:"已递交",value:"ydj"},
"ROBOT": {name:"已递交",value:"ydj"},
"ROBOTPAY": {name:"已递交",value:"ydj"},
"RECVCOMMIT": {name:"已递交",value:"ydj"},
this.statusContrast = {
"WAITCONFIRM": { name: "待确认方案", value: "dqrfa" },
"CONFIRMFAIL": { name: "方案不通过", value: "fabtg" },
"READY": { name: "待上传材料", value: "dsccl" },
"WAITCOMMIT": { name: "待递交", value: "ddj" },
"WAITARTIFICIALEXAMINE": { name: "待审核", value: "dsh" },
"DOCFINISH": { name: "待审核", value: "dsh" },
"AWAITCHECK": { name: "待审核", value: "dsh" },
"COMMITED": { name: "已递交", value: "ydj" },
"ROBOT": { name: "已递交", value: "ydj" },
"ROBOTPAY": { name: "已递交", value: "ydj" },
"RECVCOMMIT": { name: "已递交", value: "ydj" },
};
}
//接收辅助、担保商标注册信息
async receiveAssistTmData(pobj){
async receiveAssistTmData(pobj) {
var checkRes = await this.checkParams(pobj);
if(checkRes.status==0){
var deliveryData = await this.packagingTmDeliveryData(pobj,null);
if (checkRes.status == 0) {
var deliveryData = await this.packagingTmDeliveryData(pobj, null);
//获取交付信息
var orderdeliveryRes = await this.getOrderDelivery(pobj.sourceOrderNo,pobj.serviceNo);
if(orderdeliveryRes && orderdeliveryRes.length>0){
return system.getResult(null,"保存商标订单交付信息失败,存在重复交付信息,不能重复提交,10300");
var orderdeliveryRes = await this.getOrderDelivery(pobj.sourceOrderNo, pobj.serviceNo);
if (orderdeliveryRes && orderdeliveryRes.length > 0) {
return system.getResult(null, "保存商标订单交付信息失败,存在重复交付信息,不能重复提交,10300");
}
this.addOrderDelivery(deliveryData,deliveryData.sourceOrderNo);
await this.orderinfoDao.model.update({isSolution:1}, { where: { orderNo: pobj.sourceOrderNo }});
await this.orderinfoDao.addOrderDelivery(deliveryData, deliveryData.sourceOrderNo);
await this.orderinfoDao.model.update({ isSolution: 1 }, { where: { orderNo: pobj.sourceOrderNo } });
return system.getResultSuccess();
}else{
} else {
return checkRes;
}
}
//接收辅助、担保商标注册修改信息
async receiveEditAssistTmData(pobj){
async receiveEditAssistTmData(pobj) {
var checkRes = await this.checkParams(pobj);
if(checkRes.status==0){
if (checkRes.status == 0) {
//获取交付信息
var orderdeliveryRes = await this.getOrderDelivery(pobj.sourceOrderNo,pobj.serviceNo);
if(!orderdeliveryRes || orderdeliveryRes.length<1){
return system.getResult(null,"未知交付信息,10150");
var orderdeliveryRes = await this.getOrderDelivery(pobj.sourceOrderNo, pobj.serviceNo);
if (!orderdeliveryRes || orderdeliveryRes.length < 1) {
return system.getResult(null, "未知交付信息,10150");
}
var orderdelivery = orderdeliveryRes[0];
var deliveryData = await this.packagingTmDeliveryData(pobj,orderdelivery.deliveryContent);
this.putOrderDelivery(deliveryData,deliveryData.sourceOrderNo,deliveryData.serviceNo);
await this.orderinfoDao.model.update({isSolution:1}, { where: { orderNo: pobj.sourceOrderNo }});
var deliveryData = await this.packagingTmDeliveryData(pobj, orderdelivery.deliveryContent);
this.putOrderDelivery(deliveryData, deliveryData.sourceOrderNo, deliveryData.serviceNo);
await this.orderinfoDao.model.update({ isSolution: 1 }, { where: { orderNo: pobj.sourceOrderNo } });
return system.getResultSuccess();
}else{
} else {
return checkRes;
}
}
//-----------------------------------------------------------------------------------------------------
async checkParams(pobj){//参数校验
//-----------------------------------------------------------------------------------------------------
async checkParams(pobj) {//参数校验
if (!pobj.serviceNo) {
return system.getResult(null, "业务单号不能为空不能为空,10100");
}
......@@ -72,9 +72,9 @@ class InternalCallsNotifyService {
return system.getResult(null, "来源单号不能为空,10110");
}
var orderinfo = await this.orderinfoDao.model.findOne({
where:{orderNo:pobj.sourceOrderNo},raw:true
where: { orderNo: pobj.sourceOrderNo }, raw: true
});
if(!orderinfo || !orderinfo.id){
if (!orderinfo || !orderinfo.id) {
return system.getResult(null, "未知订单,10120");
}
if (!pobj.tm) {
......@@ -124,15 +124,15 @@ class InternalCallsNotifyService {
}
return system.getResultSuccess(pobj);
}
async packagingTmDeliveryData(pobj,deliveryData) {//重新组装商标交付信息
async packagingTmDeliveryData(pobj, deliveryData) {//重新组装商标交付信息
var deliveryStatusList = [];
if(deliveryData && deliveryData.deliveryStatusList){
if (deliveryData && deliveryData.deliveryStatusList) {
deliveryStatusList = deliveryData.deliveryStatusList;
}
var nclOne = pobj.nclones[0];
if(nclOne.tmStatus){
if (nclOne.tmStatus) {
var deliveryStatusObj = this.statusContrast[nclOne.tmStatus];
if(deliveryStatusObj && deliveryStatusObj.value){
if (deliveryStatusObj && deliveryStatusObj.value) {
var deliveryStatus = deliveryStatusObj.value;
var deliveryStatusName = deliveryStatusObj.name;
deliveryStatusList.push({
......@@ -142,7 +142,7 @@ class InternalCallsNotifyService {
});
pobj.deliveryStatus = deliveryStatus;
pobj.deliveryStatusName = deliveryStatusName;
}else{
} else {
deliveryStatusList.push({
deliveryStatus: nclOne.tmStatus,
deliveryStatusName: nclOne.tmStatus,
......@@ -150,23 +150,23 @@ class InternalCallsNotifyService {
});
}
}
pobj.deliveryStatusList = deliveryStatusList;
pobj.deliveryStatusList = deliveryStatusList;
pobj.opNotes = ""; //操作备注
return pobj;
}
putOrderDelivery(data, orderNo, channelOrderNo) {//修改交付信息
var sql = "UPDATE `c_order_delivery` SET deliveryContent ='" + JSON.stringify(data) + "' where sourceOrderNo='" + orderNo + "'";
sql = sql + " and deliveryContent->'$.serviceNo' = '"+channelOrderNo+"'";
sql = sql + " and deliveryContent->'$.serviceNo' = '" + channelOrderNo + "'";
this.orderinfoDao.customUpdate(sql);
}
addOrderDelivery(data, orderNo) {//新增交付信息
addOrderDelivery(data, orderNo) {//新增交付信息--废弃,调用dao中的,20201102-sy
var sql = "INSERT INTO `c_order_delivery` (`sourceOrderNo`,`deliveryContent`) VALUE('" +
orderNo + "','" + JSON.stringify(data) + "')";
this.orderinfoDao.customQuery(sql);
}
async getOrderDelivery(orderNo,channelOrderNo) {//查询交付信息
async getOrderDelivery(orderNo, channelOrderNo) {//查询交付信息
var sql = "select * from `c_order_delivery` where sourceOrderNo='" + orderNo + "'";
sql = sql + " and deliveryContent->'$.serviceNo' = '"+channelOrderNo+"'";
sql = sql + " and deliveryContent->'$.serviceNo' = '" + channelOrderNo + "'";
return await this.orderinfoDao.customQuery(sql);
}
//----------------------------------------------------------------------------------------------------------
......
......@@ -6,6 +6,7 @@ class OrderInfoService extends ServiceBase {
constructor() {
super("dbcorder", ServiceBase.getDaoName(OrderInfoService));
this.flowlogDao = system.getObject("db.dbcorder.flowlogDao");
this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao");
this.orderproductDao = system.getObject("db.dbcorder.orderproductDao");
this.ordercontactsDao = system.getObject("db.dbcorder.ordercontactsDao");
this.orderReceiptVoucherDao = system.getObject("db.dbcpay.orderreceiptvoucherDao");
......@@ -82,7 +83,7 @@ class OrderInfoService extends ServiceBase {
quantity: actionBody.quantity,// 订单数量(即产品的倍数,默认值为1)
opPayType: "00",// 操作付款类型:00: 创建订单, 10: 补单
serviceItemSnapshot: JSON.stringify(actionBody.product_info), //产品快照
orderSnapshot:JSON.stringify(actionBody.deliveryData.apply)
orderSnapshot: JSON.stringify(actionBody.deliveryData.apply)
};
var orderProduct = await this.orderproductDao.create(orderProductObj, t);//订单产品
var orderReceiptVoucherObj = {
......@@ -118,7 +119,7 @@ class OrderInfoService extends ServiceBase {
return await self.db.transaction(async function (t) {
var orderNo = await self.getBusUid("ot" + pobj.appInfo.uapp_id);
if (pobj.actionBody.channelOrder && pobj.actionBody.channelOrder.channelOrderNo) {
var count = await self.dao.findCount({where: {channelOrderNo: pobj.actionBody.channelOrder.channelOrderNo}});
var count = await self.dao.findCount({ where: { channelOrderNo: pobj.actionBody.channelOrder.channelOrderNo } });
if (count > 0) {
return system.getResultFail(-1, "订单不能重复创建s");
}
......@@ -149,7 +150,7 @@ class OrderInfoService extends ServiceBase {
return await self.db.transaction(async function (t) {
var orderNo = await self.getBusUid("re" + pobj.appInfo.uapp_id);
var item = await self.createOrder(pobj, orderNo, t);
self.addOrderDelivery(pobj.actionBody.deliveryData, orderNo);
await self.orderinfoDao.addOrderDelivery(pobj.actionBody.deliveryData, orderNo, t);
return system.getResultSuccess({
orderNo: orderNo,
channelServiceNo: pobj.actionBody.channelOrder.channelServiceNo || orderNo,
......@@ -202,17 +203,17 @@ class OrderInfoService extends ServiceBase {
}
/**
* 新增交付信息
* 新增交付信息--废弃,从dao中调用,20201102-sy
* @param data
* @param orderNo
*/
addOrderDelivery(data, orderNo) {
try{
addOrderDelivery(data, orderNo, t) {
try {
var sql = "INSERT INTO `c_order_delivery` (`sourceOrderNo`,`deliveryContent`) VALUE('" +
orderNo + "','" + JSON.stringify(data) + "')";
this.customQuery(sql);
await this.customInsert(sql);
return system.getResultSuccess();
}catch (e) {
} catch (e) {
return system.getResultFail();
}
......@@ -225,7 +226,7 @@ class OrderInfoService extends ServiceBase {
* @returns {Promise<{msg: *, data: (*|null), status: number}>}
*/
async submitReview(pobj, actionBody) {
try{
try {
var packagingTmResult = await this.packagingTmReDeliveryData(pobj, pobj.actionBody);
if (packagingTmResult.status != 0) {
return packagingTmResult;
......@@ -236,7 +237,7 @@ class OrderInfoService extends ServiceBase {
sql = sql.replace('\n', '');
const result = await this.customUpdate(sql);
return system.getResultSuccess();
}catch (e) {
} catch (e) {
return system.getResultFail();
}
}
......@@ -296,11 +297,11 @@ class OrderInfoService extends ServiceBase {
sql += ` and json_extract(deliveryContent,'$.apply.askforId')='${actionBody.askforId}'`;
sqlCount += ` and json_extract(deliveryContent,'$.apply.askforId')='${actionBody.askforId}'`;
}
if(actionBody.applicantName){
if (actionBody.applicantName) {
sql += ` and json_extract(deliveryContent,'$.applyUser.applicantName') like '%${actionBody.applicantName}%'`;
sqlCount += ` and json_extract(deliveryContent,'$.applyUser.applicantName') like '%${actionBody.applicantName}%'`;
}
if(actionBody.status){
if (actionBody.status) {
sql += ` and json_extract(deliveryContent,'$.deliveryStatusName')='${actionBody.status}'`;
sqlCount += ` and json_extract(deliveryContent,'$.deliveryStatusName')='${actionBody.status}'`;
}
......@@ -332,7 +333,7 @@ class OrderInfoService extends ServiceBase {
* @param actionBody
* @returns {Promise<void>}
*/
async getOfficialList(pobj,actionBody){
async getOfficialList(pobj, actionBody) {
let pageSize = Number(actionBody.pageSize || 20);
if (pageSize > 50) {
pageSize = 50;
......@@ -355,11 +356,11 @@ class OrderInfoService extends ServiceBase {
sql += ` and json_extract(officialInfo,'$.askforId')='${actionBody.askforId}'`;
sqlCount += ` and json_extract(officialInfo,'$.askforId')='${actionBody.askforId}'`;
}
if (actionBody.applicantName){
if (actionBody.applicantName) {
sql += ` and json_extract(officialInfo,'$.applicantName') like '%${actionBody.applicantName}%'`;
sqlCount += ` and json_extract(officialInfo,'$.applicantName') like'%${actionBody.applicantName}%'`;
}
if(actionBody.fileType){
if (actionBody.fileType) {
sql += ` and json_extract(officialInfo,'$.fileType')='${actionBody.fileType}'`;
sqlCount += ` and json_extract(officialInfo,'$.fileType')='${actionBody.fileType}'`;
}
......@@ -390,11 +391,11 @@ class OrderInfoService extends ServiceBase {
* @param actionBody
* @returns {Promise<void>}
*/
async addOfficial(pobj,actionBody){
if(!actionBody.orderNo){
return system.getResult(null,'orderNo can not be empty');
async addOfficial(pobj, actionBody) {
if (!actionBody.orderNo) {
return system.getResult(null, 'orderNo can not be empty');
}
try{
try {
let orderSql = `select channelUserId from c_order_info where orderNo = '${actionBody.orderNo}'`;
let list = await this.customQuery(orderSql);
if (!list || list.length == 0) {
......@@ -403,14 +404,14 @@ class OrderInfoService extends ServiceBase {
let orderItem = list[0];
let data = {
serviceNo: actionBody.orderNo,
channelUserId:orderItem.channelUserId,
channelUserId: orderItem.channelUserId,
officialInfo: actionBody.officialData,
created_at: new Date(),
updated_at: new Date()
}
await this.officialDao.create(data);
return system.getResultSuccess();
}catch (e) {
} catch (e) {
return system.getResultFail();
}
......
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