Commit b9624167 by 庄冰

baidutm

parent dc428cc6
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
/**
* 接收商标方案信息
*/
class OpNeedSolution extends APIBase {
//内部通知调用
constructor() {
super();
this.internalCallsNotifySve = system.getObject("service.dbcorder.internalCallsNotifySve");
}
//接收辅助、担保商标注册方案信息
async nbtzreceiveAssistTmData(pobj, qobj, req) {
return await this.internalCallsNotifySve.receiveAssistTmSolutionData(pobj);
}
//接收辅助、担保商标注册修改方案信息
async nbtzreceiveEditAssistTmData(pobj, qobj, req) {
return await this.internalCallsNotifySve.receiveEditAssistTmSolutionData(pobj);
}
}
module.exports = OpNeedSolution;
\ No newline at end of file
const system = require("../../../system"); const system = require("../../../system");
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
const moment = require('moment');
//内部通知调用 //内部通知调用
class InternalCallsNotifyService { class InternalCallsNotifyService {
constructor() { constructor() {
this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao"); this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.delivery_status = { this.delivery_status = {
"dqrfa": "待确认方案", "dqrfa": "待确认方案",
"fabtg": "方案不通过", "fabtg": "方案不通过",
...@@ -170,5 +173,118 @@ class InternalCallsNotifyService { ...@@ -170,5 +173,118 @@ class InternalCallsNotifyService {
return await this.orderinfoDao.customQuery(sql); return await this.orderinfoDao.customQuery(sql);
} }
//---------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------
async checkParams2(pobj) {//参数校验
if (!pobj.proxyCode) {
return system.getResult(null, "proxyCode不能为空");
}
if (!pobj.IntentionBizId) {
return system.getResult(null, "渠道需求号不能为空");
}
pobj.IntentionBizId ="20201217132620000001";
var needInfo = await this.needinfoDao.model.findOne({
attributes:["id","needNo","channelNeedNo","uapp_id"],
where:{channelNeedNo:pobj.IntentionBizId,channelTypeCode:2},
raw:true
});
if(!needInfo || !needInfo.needNo){
return system.getResult(null, "未知需求信息,10280");
}
pobj.needInfo = needInfo;
return system.getResultSuccess(pobj);
}
//接收辅助、担保商标注册信息
async receiveAssistTmSolutionData(pobj) {
var checkRes = await this.checkParams2(pobj);
if (checkRes.status == 0) {
var needInfo = pobj.needInfo;
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where:{needNo:needInfo.needNo,channelNeedNo:needInfo.channelNeedNo,solutionNo:pobj.proxyCode,isInvalid:0}
});
if (ns) {
return system.getResult(null, "保存商标方案信息失败,存在重复方案信息,不能重复提交,10300");
}
var nsObj = {
needNo:needInfo.needNo,channelNeedNo:needInfo.channelNeedNo,solutionNo:pobj.proxyCode,orderNo:pobj.serviceNo,
solutionContent:JSON.stringify(pobj)
}
var needSolution = await this.needsolutionDao.create(nsObj);
return system.getResultSuccess(needSolution);
} else {
return checkRes;
}
}
//接收辅助、担保商标注册修改信息
async receiveEditAssistTmSolutionData(pobj) {
if (!pobj.BizId) {
return system.getResult(null, "BizId不能为空");
}
var checkRes = await this.checkParams2(pobj);
if (checkRes.status == 0) {
var needInfo = pobj.needInfo;
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where:{channelNeedNo:needInfo.channelNeedNo,channelSolutionNo:pobj.BizId}
});
if (!ns) {
return system.getResult(null, "渠道方案号:"+pobj.BizId+"的方案不存在,10300");
}else{
var nsUpdateObj = {
id:ns.id,solutionNo:pobj.proxyCode,
solutionContent:JSON.stringify(pobj)
}
await this.needsolutionDao.update(nsUpdateObj);
var needSolution = await this.needsolutionDao.model.findOne({
where:{channelNeedNo:needInfo.channelNeedNo,channelSolutionNo:pobj.BizId}
});
return system.getResultSuccess(needSolution);
}
} else {
return checkRes;
}
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid(prefix) {
prefix = (prefix || "");
if (prefix) {
prefix = prefix.toUpperCase();
}
var prefixlength = prefix.length;
var subLen = 8 - prefixlength;
var uidStr = "";
if (subLen > 0) {
uidStr = await this.getUidInfo(subLen, 60);
}
var timStr = moment().format("YYYYMMDDHHmm");
return prefix + timStr + uidStr;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
} }
module.exports = InternalCallsNotifyService; module.exports = InternalCallsNotifyService;
\ 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