Commit 3dfa5a54 by 宋毅

tj

parent 3256c44f
...@@ -41,6 +41,7 @@ class Need extends APIBase { ...@@ -41,6 +41,7 @@ class Need extends APIBase {
opResult = system.getResult(null, "验证码错误"); opResult = system.getResult(null, "验证码错误");
return opResult; return opResult;
} }
await self.utilsMsgSendSve.removeVerificationCode(pobj.actionBody.Info[0].formInfo.contactsPhone);
} }
switch (action_type) { switch (action_type) {
case "test"://测试 case "test"://测试
......
...@@ -47,6 +47,7 @@ class Order extends APIBase { ...@@ -47,6 +47,7 @@ class Order extends APIBase {
opResult = system.getResult(null, "验证码错误"); opResult = system.getResult(null, "验证码错误");
return opResult; return opResult;
} }
await self.utilsMsgSendSve.removeVerificationCode(pobj.actionBody.Info[0].formInfo.contactsPhone);
} }
} }
switch (action_type) { switch (action_type) {
...@@ -91,6 +92,9 @@ class Order extends APIBase { ...@@ -91,6 +92,9 @@ class Order extends APIBase {
break; break;
case "refundOrder"://退款接口 case "refundOrder"://退款接口
opResult = await this.orderinfoSve.refundOrder(pobj.actionBody, req); opResult = await this.orderinfoSve.refundOrder(pobj.actionBody, req);
if(opResult.status>0){
await self.orderDeliverySve.sendNotification(pobj.actionBody.orderNum,320);
}
break; break;
case "jftime"://计费时间修改 case "jftime"://计费时间修改
opResult = await this.orderinfoSve.jftime(pobj.actionBody, req); opResult = await this.orderinfoSve.jftime(pobj.actionBody, req);
......
...@@ -93,6 +93,18 @@ class OrderDeliveryDao extends Dao{ ...@@ -93,6 +93,18 @@ class OrderDeliveryDao extends Dao{
var list = await this.customQuery(sql, params); var list = await this.customQuery(sql, params);
return list; return list;
} }
/**
* 通过订单号获取资质证照信息
*/
async getQcInfoByMainOrderNum(mainOrderNum){
var params = {
mainOrderNum: mainOrderNum
};
var sql = "select deliver_content from v_order_oproduct_odelivery where tx_orders_num = :mainOrderNum "+
"and deliver_content is not null and (product_type='/qcfw/icp/' or product_type='/qcfw/edi/' ) order by updated_at desc limit 1";
var list = await this.customQuery(sql, params);
return list;
}
/** /**
* 获取订单交付信息 * 获取订单交付信息
*/ */
......
...@@ -8,50 +8,126 @@ class NeedSolutionService extends ServiceBase { ...@@ -8,50 +8,126 @@ class NeedSolutionService extends ServiceBase {
this.needInfoDao = system.getObject("db.need.needInfoDao"); this.needInfoDao = system.getObject("db.need.needInfoDao");
this.utilsMsgSendSve = system.getObject("service.utilsSve.utilsMsgSendSve"); this.utilsMsgSendSve = system.getObject("service.utilsSve.utilsMsgSendSve");
} }
/** /**
* 发送短信通知 * 发送消息通知
* @param {*} mobile 接收人手机号 * @param {*} needInfo 需求信息
* @param {*} userId 用户id
* @param {*} consultType 产品类型
* @param {*} consultName 产品类型名称
* @param {*} status 状态 * @param {*} status 状态
*/ */
async sendSmsNotification(mobile, userId, consultType, consultName, status) { async sendNotification(needInfo, status) {
try { try {
var nameArr = consultName ? consultName.split("/") : []; if(!needInfo || !status || !needInfo.consult_type){
return system.getResultFail();
}
var nameArr = needInfo && needInfo.consult_type_name ? needInfo.consult_type_name.split("/") : [];
var productName = null; var productName = null;
if (nameArr && nameArr.length == 4) { if (nameArr && nameArr.length == 4) {
productName = nameArr[2]; productName = nameArr[2];
} }
var params = { phoneNumber: mobile, messageBody: null }; var typeOne =null;
var webinfoParams = { "title": null, "subAccount": userId, "messageBody": null };//站内信通知参数 if (needInfo.consult_type.indexOf("/ic/") >= 0) {//工商产品
var messageBody = null; typeOne = "ic";
var webinfoMessageBody = null;
if (consultType.indexOf("/ic/") >= 0) {//工商产品
messageBody = MsgTemplate.ic.need[status] && MsgTemplate.ic.need[status].sms ? MsgTemplate.ic.need[status].sms : "";
messageBody = messageBody.replace(/{productName}/g, productName);
webinfoMessageBody = MsgTemplate.ic.need[status] && MsgTemplate.ic.need[status].webinfo ? MsgTemplate.ic.need[status].webinfo : "";
webinfoMessageBody = webinfoMessageBody.replace(/{productName}/g, productName);
webinfoParams.title = MsgTemplate.ic.need[status] && MsgTemplate.ic.need[status].webinfotitle ? MsgTemplate.ic.need[status].webinfotitle : "";
} }
if (consultType.indexOf("/qcfw/") >= 0) {//资质证照产品 if (needInfo.consult_type.indexOf("/qcfw/") >= 0) {//资质证照产品
typeOne="qcfw";
}
if(!typeOne || !productName){
return system.getResultFail();
}
var params = {};
if(needInfo.contacts_mobile){//短信
var sms = MsgTemplate[typeOne].need[status] && MsgTemplate[typeOne].need[status].sms ? MsgTemplate[typeOne].need[status].sms : "";
if(sms){
if(productName){
sms = sms.replace(/{productName}/g, productName);
}
if(needInfo.region_name){
sms = sms.replace(/{area}/g, needInfo.region_name);
}
if(needInfo.user_id){
sms = sms.replace(/{userId}/g, needInfo.user_id);
}
if(needInfo.user_name){
sms = sms.replace(/{userName}/g, needInfo.user_name);
}
if (sms.indexOf("{")<0 && sms.indexOf("}")<0) {
params["phoneList"] = [{phoneNumber:needInfo.contacts_mobile,messageBody:sms}];
}
}
}
if(needInfo.user_id){//站内信
var webinfo = MsgTemplate[typeOne].need[status] && MsgTemplate[typeOne].need[status].webinfo ? MsgTemplate[typeOne].need[status].webinfo : "";
var webinfotitle = MsgTemplate[typeOne].need[status] && MsgTemplate[typeOne].need[status].webinfotitle ? MsgTemplate[typeOne].need[status].webinfotitle : "";
if(webinfo && webinfotitle){
if(productName){
webinfo = webinfo.replace(/{productName}/g, productName);
}
if(needInfo.region_name){
webinfo = webinfo.replace(/{area}/g, needInfo.region_name);
}
if(needInfo.user_id){
webinfo = webinfo.replace(/{userId}/g, needInfo.user_id);
}
if(needInfo.user_name){
webinfo = webinfo.replace(/{userName}/g, needInfo.user_name);
}
if (webinfo.indexOf("{")<0 && webinfo.indexOf("}")<0) {
params["subAccountList"] = [{title:webinfotitle,subAccount:needInfo.user_id,messageBody:webinfo}];
}
}
}
if(needInfo.wechat_no){//微信
var wechatMsg = MsgTemplate[typeOne].need[status] && MsgTemplate[typeOne].need[status].wx ? MsgTemplate[typeOne].need[status].wx : "";
var wechattitle = MsgTemplate[typeOne].need[status] && MsgTemplate[typeOne].need[status].webinfotitle ? MsgTemplate[typeOne].need[status].webinfotitle : "";
if(wechatMsg && wechattitle){
if(productName){
wechatMsg = wechatMsg.replace(/{productName}/g, productName);
}
if(needInfo.region_name){
wechatMsg = wechatMsg.replace(/{area}/g, needInfo.region_name);
}
if(needInfo.solutionNum){
wechatMsg = wechatMsg.replace(/{solutionNum}/g, needInfo.solutionNum);
}
if(needInfo.user_id){
wechatMsg = wechatMsg.replace(/{userId}/g, needInfo.user_id);
}
if(needInfo.user_name){
wechatMsg = wechatMsg.replace(/{userName}/g, needInfo.user_name);
}
if (wechatMsg.indexOf("{")<0 && wechatMsg.indexOf("}")<0) {
params["wechatList"] = [{title:wechattitle,wechatNumber:needInfo.wechat_no,messageBody:wechatMsg}];
}
}
} }
// console.log(messageBody,"ddddddddd"); if(needInfo.email){//邮箱
if (userId && webinfoParams.title && messageBody && messageBody.indexOf("{") < 0 && messageBody.indexOf("}") < 0 && webinfoMessageBody && webinfoMessageBody.indexOf("{") < 0 && webinfoMessageBody.indexOf("}") < 0) { var emailMsg = MsgTemplate[typeOne].need[status] && MsgTemplate[typeOne].need[status].email ? MsgTemplate[typeOne].need[status].email : "";
params.messageBody = messageBody; if(emailMsg){
webinfoParams.messageBody = webinfoMessageBody; if(productName){
// await this.utilsMsgSendSve.sendMessageByPhone(params);//发送短信 emailMsg = emailMsg.replace(/{productName}/g, productName);
await this.utilsMsgSendSve.sendMessageVerify({ phoneList: [params], subAccountList: [webinfoParams] }); }
if(needInfo.region_name){
emailMsg = emailMsg.replace(/{area}/g, needInfo.region_name);
}
if(needInfo.user_id){
emailMsg = emailMsg.replace(/{userId}/g, needInfo.user_id);
}
if(needInfo.user_name){
emailMsg = emailMsg.replace(/{userName}/g, needInfo.user_name);
}
if (emailMsg.indexOf("{")<0 && emailMsg.indexOf("}")<0) {
params["emailList"] = [{email:needInfo.email,messageBody:emailMsg}];
}
}
} }
return; await this.utilsMsgSendSve.sendMessageVerify(params);
return system.getResultSuccess();
} catch (e) { } catch (e) {
this.execClient.execLogs("needSolutionSve.js/sendSmsNotification(发送短信通知)方法出现异常", { mobile: mobile, consultType: consultType, consultName: consultName, status: status }, "needSolutionSve_sendSmsNotification_error", null, e.stack); this.execClient.execLogs("needSolutionSve.js/sendNotification(发送短信通知)方法出现异常", { needInfo:needInfo, status: status }, "needSolutionSve_sendNotification_error", null, e.stack);
return; return system.getResultFail();
} }
} }
//服务商提交/修改方案 //服务商提交/修改方案
async submitSolution(pobj) { async submitSolution(pobj) {
...@@ -101,7 +177,8 @@ class NeedSolutionService extends ServiceBase { ...@@ -101,7 +177,8 @@ class NeedSolutionService extends ServiceBase {
await self.dao.update(updateObj, t); await self.dao.update(updateObj, t);
await self.needInfoDao.update({ id: needinfo.id, status: "3" }, t); await self.needInfoDao.update({ id: needinfo.id, status: "3" }, t);
//发送短信通知 //发送短信通知
self.sendSmsNotification(needinfo.contacts_mobile, needinfo.user_id, needinfo.consult_type, needinfo.consult_type_name, 3); needinfo.solutionNum = ab.solutionNum;
self.sendNotification(needinfo, 3);
return system.getResultSuccess(); return system.getResultSuccess();
}); });
...@@ -125,9 +202,9 @@ class NeedSolutionService extends ServiceBase { ...@@ -125,9 +202,9 @@ class NeedSolutionService extends ServiceBase {
return await self.db.transaction(async function (t) { return await self.db.transaction(async function (t) {
await self.needInfoDao.update({ id: needinfo.id, status: "3" }, t); await self.needInfoDao.update({ id: needinfo.id, status: "3" }, t);
await self.dao.create(createObj, t); await self.dao.create(createObj, t);
//发送短信通知 //发送消息通知
// self.sendSmsNotification(needinfo.contacts_mobile,needinfo.consult_type,needinfo.consult_type_name,3); needinfo.solutionNum = solution_num;
self.sendSmsNotification(needinfo.contacts_mobile, needinfo.user_id, needinfo.consult_type, needinfo.consult_type_name, 3); self.sendNotification(needinfo, 3);
return system.getResultSuccess(solution_num); return system.getResultSuccess(solution_num);
}); });
...@@ -185,8 +262,4 @@ class NeedSolutionService extends ServiceBase { ...@@ -185,8 +262,4 @@ class NeedSolutionService extends ServiceBase {
}) })
} }
} }
module.exports = NeedSolutionService; module.exports = NeedSolutionService;
// var task = new NeedSolutionService(); \ No newline at end of file
// task.sendSmsNotification("15675201933","/ic/cpreg/","/工商服务/云上园区注册/",3).then(d=>{
// console.log("eeeeeeeeeeeeee"+d);
// })
\ No newline at end of file
...@@ -238,8 +238,8 @@ class OrderInfoService extends ServiceBase { ...@@ -238,8 +238,8 @@ class OrderInfoService extends ServiceBase {
user_id: pobj.actionBody.interface.para.uin, user_id: pobj.actionBody.interface.para.uin,
delivery_status: 1, delivery_status: 1,
user_name: txorderdetail.goodsDetail.formInfo.userName, user_name: txorderdetail.goodsDetail.formInfo.userName,
email: txorderdetail.goodsDetail.formInfo.email || "", email: txorderdetail.goodsDetail.formInfo.Email || "",
wechat_no: txorderdetail.goodsDetail.formInfo.wechatNo || "" wechat_no: txorderdetail.goodsDetail.formInfo.WechatNo || ""
} }
var orderDeliveryinfo = await self.orderDeliveryDao.create(orderDeliveryobj, t); var orderDeliveryinfo = await self.orderDeliveryDao.create(orderDeliveryobj, t);
var orderPayobj = { var orderPayobj = {
...@@ -267,6 +267,9 @@ class OrderInfoService extends ServiceBase { ...@@ -267,6 +267,9 @@ class OrderInfoService extends ServiceBase {
if (!ispush) { if (!ispush) {
return system.getResultSuccess(); return system.getResultSuccess();
} }
txorderdetail.goodsDetail.formInfo.buyTime=new Date(txorderdetail.payEndTime);
txorderdetail.goodsDetail.formInfo.timeSpan=1;
txorderdetail.goodsDetail.formInfo.timeUnit="y";
//生产者------订单推送 //生产者------订单推送
var pushobj = { var pushobj = {
"actionType": "produceData",// Y 功能名称 "actionType": "produceData",// Y 功能名称
......
...@@ -46,6 +46,20 @@ class UtilsMsgSendService extends AppServiceBase { ...@@ -46,6 +46,20 @@ class UtilsMsgSendService extends AppServiceBase {
return await this.redisClient.getCache(key); return await this.redisClient.getCache(key);
} }
/** /**
* 删除验证码
* @param {*} phoneNumber 手机号
*/
async removeVerificationCode(phoneNumber) {
if (!phoneNumber) {
return system.getResult(null, "手机号不能为空");
}
if (!(/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(phoneNumber))) {
return system.getResult(null, "手机号有误,请输入正确手机号");
}
var key = this.prefix + phoneNumber;
return await this.redisClient.delete(key);
}
/**
* 发送信息 * 发送信息
* @param {*} params 格式: * @param {*} params 格式:
{ {
...@@ -154,6 +168,29 @@ class UtilsMsgSendService extends AppServiceBase { ...@@ -154,6 +168,29 @@ class UtilsMsgSendService extends AppServiceBase {
} }
} }
} }
if (verifyResult) {
return verifyResult;
}
if (params.emailList && params.emailList.length > 0) {
for (let index = 0; index < params.emailList.length; index++) {
var element = params.emailList[index];
if (element) {
if (!element.email) {
verifyResult = system.getResult(null, "邮箱不能为空");
break;
}
if (!element.messageBody) {
verifyResult = system.getResult(null, "微信消息主体不能为空");
break;
}
reqParam.emailTpl.push(element.messageBody);
reqParam.emailList.push(element.email);
}
}
}
if (verifyResult) {
return verifyResult;
}
var sendResult = await this.sendMessage(reqParam); var sendResult = await this.sendMessage(reqParam);
if (sendResult.status == 1) { if (sendResult.status == 1) {
this.redisClient.setWithEx(shaStr, 1, setCacheEx); this.redisClient.setWithEx(shaStr, 1, setCacheEx);
......
...@@ -60,10 +60,10 @@ identifyCode参数约定命名方式:文件名_方法名_日志类型 ...@@ -60,10 +60,10 @@ identifyCode参数约定命名方式:文件名_方法名_日志类型
| 业务标识 | 业务描述 | | 业务标识 | 业务描述 |
| ---- | ---- | | ---- | ---- |
| orderDeliverySve_sendSmsNotification_error | 发送短信通知异常(订单) | | orderDeliverySve_sendNotification_error | 发送短信通知异常(订单) |
| orderDeliverySve_createQualificationCertificateInfo_error | 创建资质信息异常 | | orderDeliverySve_createQualificationCertificateInfo_error | 创建资质信息异常 |
| orderDeliverySve_createApplyInfo_error | 创建申请实体异常 | | orderDeliverySve_createApplyInfo_error | 创建申请实体异常 |
| needSolutionSve_sendSmsNotification_error | 发送短信通知异常(需求方案) | | needSolutionSve_sendNotification_error | 发送短信通知异常(需求方案) |
## **<a name="getProductUsageInfo"> 控制台总览-产品使用信息</a>** ## **<a name="getProductUsageInfo"> 控制台总览-产品使用信息</a>**
......
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