Commit 75dd282d by 兰国旗

laolan

parent 0f4e118b
const system = require("../../../system");
const Dao = require("../../dao.base");
class RegCenterorderDao extends Dao {
constructor() {
super(Dao.getModelName(RegCenterorderDao));
}
async getItemByNeedNo(needNo) {
return await this.model.findOne({
where: {
needNo: needNo
},
attributes: [
"id",
"uapp_id",
"needNo",
"channelNeedNo",
"channelUserId",
"followManUserId",
"followManMobile",
"city",
"province",
"publishContent",
"publishName",
"publishMobile",
"notes",
"followContent",
"disposeNotes",
"status",
"statusName",
"typeCode",
"typeName",
"channelTypeCode",
"channelTypeName",
"publisherOnlyCode",
"followManName",
"followManOnlyCode",
"created_at"],
raw: true
});
}
async getItemByChannelNeedNo(channelNeedNo) {
return await this.model.findOne({
where: {
channelNeedNo: channelNeedNo
},
attributes: [
"id",
"uapp_id",
"needNo",
"channelNeedNo",
"channelUserId",
"followManUserId",
"followManMobile",
"city",
"province",
"publishContent",
"publishName",
"publishMobile",
"notes",
"followContent",
"disposeNotes",
"status",
"typeCode",
"typeName",
"channelTypeCode",
"channelTypeName",
"publisherOnlyCode",
"followManName",
"followManOnlyCode",
"created_at"
],
raw: true
});
}
}
module.exports = RegCenterorderDao;
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("regcenterorder", {
uapp_id: DataTypes.INTEGER,
channelNeedNo: DataTypes.STRING(128), //渠道需求号(页面中列表中显示该需求号)
needNo: DataTypes.STRING(128), //需求号--用于服务商或需求表中创建订单
channelUserId: DataTypes.INTEGER,//发布者id
publishName: DataTypes.STRING,//发布者姓名
publisherOnlyCode: DataTypes.STRING(50),//发布者唯一码
publishContent: DataTypes.STRING,//发布内容
publishMobile: DataTypes.STRING,//发布者手机号
followManUserId: DataTypes.INTEGER,//跟进人id
followManName: DataTypes.STRING,//跟进人姓名
followManMobile: DataTypes.STRING,//跟进人手机号(合伙人)
followManOnlyCode: DataTypes.STRING(50),//跟进者唯一码
followContent: DataTypes.JSON,//跟进内容
productOneType_id: DataTypes.STRING,//产品大类Id
productType_id: DataTypes.STRING,//产品类型Id
notes: DataTypes.STRING,//备注
disposeNotes: DataTypes.STRING,//处理的备注
statusName: DataTypes.STRING,
status: {
//wts未推送,yts已推送,ygj已跟进,ycd已成单
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.push_chance_type),
set: function (val) {
this.setDataValue("status", val);
this.setDataValue("statusName", uiconfig.config.pdict.push_chance_type[val]);
}
},
city: DataTypes.STRING(50), // 城市
province: DataTypes.STRING(50), // 省份
typeCode: DataTypes.STRING(50), //产品类型编码',
typeName: DataTypes.STRING(50), //类型产品名称',
channelTypeCode: DataTypes.STRING(50), //渠道产品类型编码',
channelTypeName: DataTypes.STRING(255), //渠道产品类型名称',
level: DataTypes.STRING(20), //商机等级
probability: DataTypes.STRING(20), //商机概率
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'n_need_info',
validate: {
},
indexes: [
]
});
}
//工商注册
const system = require("../../../system");
const moment = require('moment');
const ServiceBase = require("../../sve.base");
class RegCenterOrderService extends ServiceBase {
class RegCenterOrderService{
constructor() {
super("reg", ServiceBase.getDaoName(RegCenterOrderService));
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao");
......@@ -43,9 +41,10 @@ class RegCenterOrderService extends ServiceBase {
if (!actionBody.type) {
return system.getResultFail(-5003, "type不能为空");
}
var ninfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (ninfo) {
return system.getResultSuccess(ninfo);
var needInfo = await this.needinfoDao.findOne({ channelNeedNo: actionBody.intentionBizId });
console.log('needInfo---',needInfo)
if (needInfo) {
return system.getResultSuccess(needInfo);
}
var nobj = {
uapp_id: pobj.appInfo.uapp_id,
......@@ -69,7 +68,7 @@ class RegCenterOrderService extends ServiceBase {
// if (nobj.channelTypeCode == 7 || nobj.channelTypeCode == 5) {
// nobj.province = nobj.city, nobj.city = "";
// }
var needInfo = await this.dao.create(nobj);
var needInfo = await this.needinfoDao.create(nobj);
return system.getResultSuccess(needInfo);
}
......@@ -185,27 +184,28 @@ class RegCenterOrderService extends ServiceBase {
//渠道方案号获取需求详情
async getItemByChannelSolutionNo(pobj) {
var i = 0;
var bizIdLength = pobj.actionBody.length;
var bizIdList = [];
for (i = 0; i <= bizIdLength; i++) {
bizIdList.push(pobj.actionBody[i].bizId)
}
bizIdListStr = bizIdList.join(",");
// var solutionitem = await this.needsolutionDao.findOne({ channelSolutionNo: pobj.actionBody.bizId });
var sql = "select * from n_need_solution where channelSolutionNo in (" + bizIdListStr + ")";
var solutionitem = await this.customQuery(sql);
if (solutionitem.length < 1) {
console.log('getItemByChannelSolutionNo---',pobj)
// var i = 0;
// var bizIdLength = pobj.actionBody.length;
// var bizIdList = [];
// for (i = 0; i <= bizIdLength; i++) {
// bizIdList.push(pobj.actionBody[i].bizId)
// }
// bizIdListStr = bizIdList.join(",");
var solutionitem = await this.needsolutionDao.findOne({ channelSolutionNo: pobj.actionBody.bizId });
// var sql = "select * from n_need_solution where channelSolutionNo in (" + bizIdListStr + ")";
// var solutionitem = await this.customQuery(sql);
if (!solutionitem) {
return system.getResult(null, "方案数据为空,30210");
}
var item = await this.dao.getItemByNeedNo(solutionitem[0].needNo);
var item = await this.needinfoDao.getItemByNeedNo(solutionitem.needNo);
if (!item) {
return system.getResult(null, "需求数据为空,30210");
}
item.solutionProvince = solutionitem[0].solutionContent.solution.Area || solutionitem[0].solutionContent.solution.area;
item.solutionContent = solutionitem[0].solutionContent
item.channelSolutionNo = solutionitem[0].channelSolutionNo
item.solutionProvince = solutionitem.solutionContent.solution.Area || solutionitem.solutionContent.solution.area;
item.solutionContent = solutionitem.solutionContent
item.channelSolutionNo = solutionitem.channelSolutionNo
return system.getResultSuccess(item);
}
......@@ -347,7 +347,7 @@ class RegCenterOrderService extends ServiceBase {
return system.getResultFail(-101, "渠道方案编号不能为空");
}
if(ab.isDirectBuy && ab.isDirectBuy==1){//直接下单
var oldNs = await this.dao.model.findOne({
var oldNs = await this.orderinfoDao.model.findOne({
where: { orderNo: ab.orderNo }, raw: true
});
var newNsObj={
......@@ -388,14 +388,14 @@ class RegCenterOrderService extends ServiceBase {
if(oldNs && oldNs.id){
ns = oldNs;
}else{
ns = await this.dao.create(newNsObj);
ns = await this.needsolutionDao.create(newNsObj);
}
var ns2 = await this.dao.model.findOne({
var ns2 = await this.needsolutionDao.model.findOne({
where: { id: ns.id }, raw: true
});
return system.getResultSuccess(ns2);
}else{
var needsolutioninfo = await this.dao.model.findOne({
var needsolutioninfo = await this.needsolutionDao.model.findOne({
attributes:["id","solutionContent","status","orderNo"],
where: { channelSolutionNo: ab.channelSolutionNo,isInvalid:0 }, raw: true
});
......@@ -416,8 +416,8 @@ class RegCenterOrderService extends ServiceBase {
needsolutioninfo.status = "ywc";
}
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
await this.dao.update(needsolutioninfo);
var ns = await this.dao.model.findOne({
await this.needsolutionDao.update(needsolutioninfo);
var ns = await this.needsolutionDao.model.findOne({
where: { id: needsolutioninfo.id }, raw: true
});
return system.getResultSuccess(ns);
......
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