Commit e7eff166 by 兰国旗

Merge branch 'center-order' of gitlab.gongsibao.com:jiangyong/zhichan into center-order

parents c6caa2f4 d96f697b
......@@ -109,6 +109,12 @@ class OrderAPI extends APIBase {
case "bulkCreateOrders":
opResult = await this.orderinfoSve.bulkCreateOrders(pobj, req);
break;
case "receiveAliTmOrder"://接收阿里商标订单
opResult = await this.orderinfoSve.receiveAliTmOrder(pobj);
break;
case "receiveAliTmOrderRefund"://接收阿里商标订单退款信息
opResult = await this.orderinfoSve.receiveAliTmOrderRefund(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -7,6 +7,7 @@ module.exports = (db, DataTypes) => {
// solutionId :DataTypes.STRING(128),// 方案ID
orderNo :DataTypes.STRING(128),// 订单号
channelServiceNo :DataTypes.STRING(128),// 渠道服务单号
serviceOrderNo :DataTypes.STRING(128),// 服务单号
channelOrderNo :DataTypes.STRING(128),// 渠道订单号(页面中列表中显示该单号)
channelNeedNo :DataTypes.STRING(128), //渠道需求号(页面中列表中显示该需求号)
needNo :DataTypes.STRING(128), //需求号--用于服务商或需求表中创建订单
......
......@@ -323,27 +323,40 @@ class InternalCallsNotifyService {
date:new Date(),flowName:"提交确认注册⽅案,待用户确认"
};
await this.db.transaction(async function (t) {
for(var i=0;i<nsList.length;i++){
await this.updateSolution(nsList, flowObj,2, t);
})
return system.getResultSuccess();
}
}
async updateSolution(nsList, flowObj,needStatus, t) {
var intentionStatusList = ["未知", "⽅案待服务商确认", "⽅案待⽤户确认", "处理中", "已完成", "已关闭"];
for (var i = 0; i < nsList.length; i++) {
var ns = nsList[i];
if(ns && ns.id){
if(ns.solutionContent){
if(typeof ns.solutionContent === 'string'){
ns.solutionContent = JSON.parse(ns.solutionContent)
if (ns && ns.id) {
var updateObj = {
id: ns.id
};
var solutionContent = ns.solutionContent || {};
if (typeof ns.solutionContent === 'string') {
ns.solutionContent = JSON.parse(ns.solutionContent);
}
solutionContent.needStatus = needStatus;
solutionContent.needStatusName = intentionStatusList[needStatus];
if(needStatus==2){
// updateObj["status"] = "ybh";
}
if(needStatus==5){
updateObj["status"] = "yzf";
}
var flowList = ns.solutionContent.flowList || [];
flowList.push(flowObj);
ns.solutionContent.flowList = flowList;
}else{
ns.solutionContent={};
ns.solutionContent.flowList = [flowObj];
}
ns.solutionContent = JSON.stringify(ns.solutionContent);
await this.needsolutionDao.update(ns,t);
await this.needsolutionDao.update(ns, t);
}
}
})
return system.getResultSuccess();
}
}
/**
......@@ -367,16 +380,15 @@ class InternalCallsNotifyService {
var flowObj={
date:new Date(),flowName:"关闭方案"
};
if(ns.solutionContent){
ns.solutionContent = ns.solutionContent || {};
if(typeof ns.solutionContent === 'string'){
ns.solutionContent = JSON.parse(ns.solutionContent)
}
var flowList = ns.solutionContent.flowList || [];
flowList.push(flowObj);
ns.solutionContent.needStatus = 5;
ns.solutionContent.needStatusName = "已关闭";
ns.solutionContent.flowList = flowList;
}else{
ns.solutionContent.flowList = [flowObj];
}
ns.solutionContent = JSON.stringify(ns.solutionContent);
ns.status="yzf";
await this.needsolutionDao.update(ns);
......
......@@ -2444,5 +2444,100 @@ class OrderInfoService extends ServiceBase {
}
return system.getResult(updateRet)
}
/**
* 接收阿里云商标订单信息
* @param {*} pobj
*/
async receiveAliTmOrder(pobj){
var res = await this.checkAndPackageAliTmOrderParams(pobj);
if(!res || res.status!=0){
return res;
}
var orderNo = await this.getBusUid("tm" + pobj.appInfo.uapp_id);
var ab = pobj.actionBody;
ab.orderNo = orderNo;
var o = await this.dao.create(ab);
return system.getResultSuccess(o);
}
/**
* 检查封装阿里商标订单参数
* @param {*} pobj
*/
async checkAndPackageAliTmOrderParams(pobj){
if(!pobj || !pobj.actionBody){
return system.getResult(null, "订单参数不能为空,100100");
}
if(!pobj.appInfo){
return system.getResult(null, "未知用应信息,100200");
}
if(!pobj.userInfo){
return system.getResult(null, "未知用户信息,100300");
}
if(!pobj.actionBody.channelOrderNo){
return system.getResult(null, "阿里订单号不能为空,100110");
}
if(!pobj.actionBody.serviceOrderNo){
return system.getResult(null, "蜂擎订单号不能为空,100120");
}
if(!pobj.actionBody.serviceNo){
return system.getResult(null, "服务单号不能为空,100130");
}
if(!pobj.actionBody.needNo){
return system.getResult(null, "阿里需求号不能为空,100110");
}
var orderInfo = await this.dao.model.findOne({
where:{channelOrderNo:pobj.actionBody.channelOrderNo,uapp_id:pobj.appInfo.uapp_id},raw:true
});
if(orderInfo && orderInfo.id){
return system.getResult(null, "阿里订单号:"+pobj.actionBody.channelOrderNo+"的订单已存在,100140");
}
var ab = pobj.actionBody;
var appInfo = pobj.appInfo;
var userInfo = pobj.userInfo;
ab.uapp_id = appInfo.uapp_id;
ab.channelNeedNo = ab.needNo;
ab.channelUserId = userInfo.channel_userid;
ab.ownerUserId = userInfo.channel_userid;
ab.payTime = ab.payTime || new Date();
ab.orderStatus = 2;
ab.totalSum = ab.price;
ab.payTotalSum = ab.price;
return system.getResultSuccess();
}
/**
* 接收阿里商标订单退款信息
* @param {*} pobj
*/
async receiveAliTmOrderRefund(pobj){
if(!pobj || !pobj.actionBody){
return system.getResult(null, "订单参数不能为空,100100");
}
if(!pobj.appInfo){
return system.getResult(null, "未知用应信息,100200");
}
if(!pobj.userInfo){
return system.getResult(null, "未知用户信息,100300");
}
if(!pobj.actionBody.channelOrderNo){
return system.getResult(null, "阿里订单号不能为空,100110");
}
var orderInfo = await this.dao.model.findOne({
attributes:["id","channelOrderNo","payTotalSum"],
where:{channelOrderNo:pobj.actionBody.channelOrderNo,uapp_id:pobj.appInfo.uapp_id},raw:true
});
if(!orderInfo || !orderInfo.id){
return system.getResult(null, "阿里订单号:"+pobj.actionBody.channelOrderNo+"的订单不存在,100140");
}
orderInfo.refundSum = pobj.actionBody.refundSum || orderInfo.payTotalSum;
orderInfo.orderStatus = 16;
orderInfo.refundTime = pobj.actionBody.refundTime || new Date();
await this.dao.update(orderInfo);
return system.getResultSuccess();
}
}
module.exports = OrderInfoService;
......@@ -844,6 +844,7 @@ class AliyunQcService {
//接收tm用户方案反馈
async tmFeedbackSubmit(pobj) {
try {
var ab = pobj.actionBody;
if (!ab.intentionBizId) {
return system.getResultFail(-101, "渠道需求编号错误");
......@@ -862,25 +863,50 @@ class AliyunQcService {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
var nsList = await this.needsolutionDao.model.findAll({
where: { channelNeedNo: ab.intentionBizId, isInvalid: 0 }, raw: true
});
if (!ns) {
if (!nsList || nsList.length<1) {
return system.getResultSuccess();
}
await this.needsolutionDao.db.transaction(async function (t) {
var flowObj={
date:new Date(),flowName:"用户驳回方案,反馈信息"
};
await this.updateSolution(nsList, ab, flowObj,t);
})
return system.getResultSuccess(needinfo);
} catch (e) {
return system.getResultFail(-200,"error异常");
}
}
async updateSolution(nsList, ab, flowObj,t) {
var intentionStatusList = ["未知", "⽅案待服务商确认", "⽅案待⽤户确认", "处理中", "已完成", "已关闭"];
for (var i = 0; i < nsList.length; i++) {
var ns = nsList[i];
var updateObj = {
id: ns.id
};
var solutionContent = ns.solutionContent;
var solutionContent = ns.solutionContent || {};
if (typeof solutionContent === 'string') {
solutionContent = JSON.parse(solutionContent);
}
solutionContent.customerRemark = ab.description;
solutionContent.needStatus = 1;
updateObj["status"] = "ybh";
solutionContent.needStatusName = intentionStatusList[ab.intentionStatus];
solutionContent.needStatusName = intentionStatusList[1];
var flowList = solutionContent.flowList || [];
flowList.push(flowObj);
solutionContent.flowList = flowList;
solutionContent = JSON.stringify(solutionContent);
updateObj["solutionContent"] = solutionContent;
await this.needsolutionDao.update(updateObj);//方案状态修改
return system.getResultSuccess(needinfo);
await this.needsolutionDao.update(updateObj, 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