Commit 18646194 by linboxuan

lin tj

parent 8bf4ecab
...@@ -4,14 +4,14 @@ const ServiceBase = require("../../sve.base"); ...@@ -4,14 +4,14 @@ const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
var moment = require('moment') var moment = require('moment')
class NeedinfoService extends ServiceBase { class NeedinfoService extends ServiceBase {
constructor () { constructor() {
super("dbneed", ServiceBase.getDaoName(NeedinfoService)); super("dbneed", ServiceBase.getDaoName(NeedinfoService));
this.execlient = system.getObject("util.execClient"); this.execlient = system.getObject("util.execClient");
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao"); this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao"); this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
this.needinfofqDao = system.getObject("db.dbneed.needinfofqDao"); this.needinfofqDao = system.getObject("db.dbneed.needinfofqDao");
} }
async getItemByNeedNo (pobj) { async getItemByNeedNo(pobj) {
var item = await this.dao.getItemByNeedNo(pobj.actionBody.needNo); var item = await this.dao.getItemByNeedNo(pobj.actionBody.needNo);
console.log(system.getResultSuccess(item)); console.log(system.getResultSuccess(item));
if (!item) { if (!item) {
...@@ -20,7 +20,7 @@ class NeedinfoService extends ServiceBase { ...@@ -20,7 +20,7 @@ class NeedinfoService extends ServiceBase {
return system.getResultSuccess(item); return system.getResultSuccess(item);
} }
async opSubmitNeed (pobj, actionBody, req) { async opSubmitNeed(pobj, actionBody, req) {
var needNo = await this.getBusUid("n"); var needNo = await this.getBusUid("n");
if (!actionBody.mobile) { if (!actionBody.mobile) {
return system.getResultFail(-5002, "mobile不能为空"); return system.getResultFail(-5002, "mobile不能为空");
...@@ -32,7 +32,7 @@ class NeedinfoService extends ServiceBase { ...@@ -32,7 +32,7 @@ class NeedinfoService extends ServiceBase {
uapp_id: pobj.appInfo.uapp_id, uapp_id: pobj.appInfo.uapp_id,
channelNeedNo: needNo, // 2020 0807 lin 修改内容 渠道需求号改为企服通需求号 不再单独获取新的uuid channelNeedNo: needNo, // 2020 0807 lin 修改内容 渠道需求号改为企服通需求号 不再单独获取新的uuid
needNo: needNo, needNo: needNo,
channelUserId: pobj.userInfo.channel_userid, channelUserId: pobj.userInfo ? pobj.userInfo.channel_userid : actionBody.mobile,
publishName: actionBody.userName, publishName: actionBody.userName,
publishContent: actionBody.description, publishContent: actionBody.description,
publishMobile: actionBody.mobile, publishMobile: actionBody.mobile,
...@@ -50,7 +50,7 @@ class NeedinfoService extends ServiceBase { ...@@ -50,7 +50,7 @@ class NeedinfoService extends ServiceBase {
return system.getResultSuccess(r); return system.getResultSuccess(r);
} }
async opNeedList (pobj, actionBody, req) { async opNeedList(pobj, actionBody, req) {
// 时间段,分页,排序,需求状态 条件展示未做 // 时间段,分页,排序,需求状态 条件展示未做
let statusDic = ['wts', 'yts', 'ygj', 'ygb', 'ycd'] let statusDic = ['wts', 'yts', 'ygj', 'ygb', 'ycd']
console.log(pobj); console.log(pobj);
...@@ -93,7 +93,7 @@ class NeedinfoService extends ServiceBase { ...@@ -93,7 +93,7 @@ class NeedinfoService extends ServiceBase {
return system.getResultSuccess(r); return system.getResultSuccess(r);
} }
async opNeedListBak (pobj, actionBody, req) { async opNeedListBak(pobj, actionBody, req) {
let statusDic = ['wts', 'yts', 'ygj', 'ygb', 'ycd'] let statusDic = ['wts', 'yts', 'ygj', 'ygb', 'ycd']
var sobj = { var sobj = {
search: { search: {
...@@ -128,7 +128,7 @@ class NeedinfoService extends ServiceBase { ...@@ -128,7 +128,7 @@ class NeedinfoService extends ServiceBase {
return system.getResultSuccess(r); return system.getResultSuccess(r);
} }
async opNeedClose (pobj, actionBody, req) { async opNeedClose(pobj, actionBody, req) {
var needinfo = await this.findOne({ channelNeedNo: actionBody.needNo }); var needinfo = await this.findOne({ channelNeedNo: actionBody.needNo });
if (!needinfo) { if (!needinfo) {
return system.getResultFail(-5004, "需求不存在"); return system.getResultFail(-5004, "需求不存在");
...@@ -148,25 +148,25 @@ class NeedinfoService extends ServiceBase { ...@@ -148,25 +148,25 @@ class NeedinfoService extends ServiceBase {
* @param pobj * @param pobj
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async getStatisticsByUappId(pobj){ async getStatisticsByUappId(pobj) {
let ac = pobj.actionBody; let ac = pobj.actionBody;
let sql = `SELECT uapp_id,count(*) count,DATE_FORMAT(DATE_ADD(created_at,INTERVAL 8 HOUR),'%Y-%m-%d') time FROM n_need_info WHERE deleted_at is null AND (channelTypeName <> "商标交易" or channelTypeName is not null)`; let sql = `SELECT uapp_id,count(*) count,DATE_FORMAT(DATE_ADD(created_at,INTERVAL 8 HOUR),'%Y-%m-%d') time FROM n_need_info WHERE deleted_at is null AND (channelTypeName <> "商标交易" or channelTypeName is not null)`;
let whereParam = {}; let whereParam = {};
if(ac.start&&ac.end){ if (ac.start && ac.end) {
sql += ` AND created_at >= :start AND created_at <= :end`; sql += ` AND created_at >= :start AND created_at <= :end`;
whereParam.start =await this.getTimeSubtraction(ac.start); whereParam.start = await this.getTimeSubtraction(ac.start);
whereParam.end =await this.getTimeSubtraction(ac.end); whereParam.end = await this.getTimeSubtraction(ac.end);
} }
if(ac.type_name){ if (ac.type_name) {
sql += ` AND typeName = :type_name`; sql += ` AND typeName = :type_name`;
whereParam.type_name = ac.type_name; whereParam.type_name = ac.type_name;
} }
if(ac.status){ if (ac.status) {
sql += ` AND status = :status`; sql += ` AND status = :status`;
whereParam.status = ac.status; whereParam.status = ac.status;
} }
sql += ` GROUP BY uapp_id,DATE_FORMAT(DATE_ADD(created_at,INTERVAL 8 HOUR),'%Y-%m-%d') ORDER BY created_at ASC` sql += ` GROUP BY uapp_id,DATE_FORMAT(DATE_ADD(created_at,INTERVAL 8 HOUR),'%Y-%m-%d') ORDER BY created_at ASC`
let result = await this.customQuery(sql,whereParam); let result = await this.customQuery(sql, whereParam);
return system.getResultSuccess(result); return system.getResultSuccess(result);
} }
...@@ -175,38 +175,38 @@ class NeedinfoService extends ServiceBase { ...@@ -175,38 +175,38 @@ class NeedinfoService extends ServiceBase {
* @param pobj * @param pobj
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async getNeedFunnelStatistics(pobj){ async getNeedFunnelStatistics(pobj) {
let ac = pobj.actionBody; let ac = pobj.actionBody;
let sql = `select count(*) count from n_need_info where deleted_at is null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `; let sql = `select count(*) count from n_need_info where deleted_at is null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `;
let sql2 = sql + ` and status in('ygj','ygb','ycd')`; let sql2 = sql + ` and status in('ygj','ygb','ycd')`;
let sql3 = sql + ` and status = 'ycd'`; let sql3 = sql + ` and status = 'ycd'`;
let whereParams = {}; let whereParams = {};
if (ac.start&&ac.end){ if (ac.start && ac.end) {
sql += ` AND created_at >= :start and created_at <= :end`; sql += ` AND created_at >= :start and created_at <= :end`;
sql2 += ` AND created_at >= :start and created_at <= :end`; sql2 += ` AND created_at >= :start and created_at <= :end`;
sql3 += ` AND created_at >= :start and created_at <= :end`; sql3 += ` AND created_at >= :start and created_at <= :end`;
whereParams.start =await this.getTimeSubtraction(ac.start); whereParams.start = await this.getTimeSubtraction(ac.start);
whereParams.end =await this.getTimeSubtraction(ac.end); whereParams.end = await this.getTimeSubtraction(ac.end);
} }
if(ac.uapp_id){ if (ac.uapp_id) {
sql += ` and uapp_id = :uapp_id`; sql += ` and uapp_id = :uapp_id`;
sql2 += ` and uapp_id = :uapp_id`; sql2 += ` and uapp_id = :uapp_id`;
sql3 += ` and uapp_id = :uapp_id`; sql3 += ` and uapp_id = :uapp_id`;
whereParams.uapp_id = ac.uapp_id; whereParams.uapp_id = ac.uapp_id;
} }
if(ac.type_name){ if (ac.type_name) {
sql += ` and typeName = :type_name`; sql += ` and typeName = :type_name`;
sql2 += ` and typeName = :type_name`; sql2 += ` and typeName = :type_name`;
sql3 += ` and typeName = :type_name`; sql3 += ` and typeName = :type_name`;
whereParams.type_name = ac.type_name; whereParams.type_name = ac.type_name;
} }
let total = await this.customQuery(sql,whereParams); let total = await this.customQuery(sql, whereParams);
let middle = await this.customQuery(sql2,whereParams); let middle = await this.customQuery(sql2, whereParams);
let finish = await this.customQuery(sql3,whereParams); let finish = await this.customQuery(sql3, whereParams);
let result = { let result = {
total:total[0].count, total: total[0].count,
middle:middle[0].count, middle: middle[0].count,
finish:finish[0].count finish: finish[0].count
} }
return system.getResult(result); return system.getResult(result);
} }
...@@ -216,17 +216,17 @@ class NeedinfoService extends ServiceBase { ...@@ -216,17 +216,17 @@ class NeedinfoService extends ServiceBase {
* @param pobj * @param pobj
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async getStatisticsByProduct(pobj){ async getStatisticsByProduct(pobj) {
let ac = pobj.actionBody; let ac = pobj.actionBody;
let sql = `select typeName typeCode,uapp_id,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `; let sql = `select typeName typeCode,uapp_id,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `;
let whereParams = {}; let whereParams = {};
if(ac.start&&ac.end){ if (ac.start && ac.end) {
sql += ` and created_at >= :start and created_at <= :end `; sql += ` and created_at >= :start and created_at <= :end `;
whereParams.start = await this.getTimeSubtraction(ac.start); whereParams.start = await this.getTimeSubtraction(ac.start);
whereParams.end = await this.getTimeSubtraction(ac.end); whereParams.end = await this.getTimeSubtraction(ac.end);
} }
sql += ` GROUP BY typeName,uapp_id`; sql += ` GROUP BY typeName,uapp_id`;
let result = await this.customQuery(sql,whereParams); let result = await this.customQuery(sql, whereParams);
return system.getResultSuccess(result); return system.getResultSuccess(result);
} }
...@@ -235,17 +235,17 @@ class NeedinfoService extends ServiceBase { ...@@ -235,17 +235,17 @@ class NeedinfoService extends ServiceBase {
* @param pobj * @param pobj
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async getStatisticsByChannel(pobj){ async getStatisticsByChannel(pobj) {
let ac = pobj.actionBody; let ac = pobj.actionBody;
let sql = `select typeName typeCode,uapp_id,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `; let sql = `select typeName typeCode,uapp_id,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `;
let whereParams = {}; let whereParams = {};
if(ac.start&&ac.end){ if (ac.start && ac.end) {
sql += ` and created_at >= :start and created_at <= :end `; sql += ` and created_at >= :start and created_at <= :end `;
whereParams.start = await this.getTimeSubtraction(ac.start); whereParams.start = await this.getTimeSubtraction(ac.start);
whereParams.end = await this.getTimeSubtraction(ac.end); whereParams.end = await this.getTimeSubtraction(ac.end);
} }
sql += ` GROUP BY uapp_id,typeName`; sql += ` GROUP BY uapp_id,typeName`;
let result = await this.customQuery(sql,whereParams); let result = await this.customQuery(sql, whereParams);
return system.getResultSuccess(result); return system.getResultSuccess(result);
} }
...@@ -254,10 +254,10 @@ class NeedinfoService extends ServiceBase { ...@@ -254,10 +254,10 @@ class NeedinfoService extends ServiceBase {
* @param pobj * @param pobj
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async getNeedProductType(pobj){ async getNeedProductType(pobj) {
let sql = `select typeName,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName is not null) GROUP BY typeName`; let sql = `select typeName,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName is not null) GROUP BY typeName`;
let result = await this.customQuery(sql); let result = await this.customQuery(sql);
let typeNames = result.map(item =>{ let typeNames = result.map(item => {
return item.typeName; return item.typeName;
}) })
return system.getResultSuccess(typeNames); return system.getResultSuccess(typeNames);
...@@ -268,25 +268,25 @@ class NeedinfoService extends ServiceBase { ...@@ -268,25 +268,25 @@ class NeedinfoService extends ServiceBase {
* @param pobj * @param pobj
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async getStatisticsByCity(pobj){ async getStatisticsByCity(pobj) {
let ac = pobj.actionBody; let ac = pobj.actionBody;
let sql = `select typeName typeCode,province,count(*) count from n_need_info where province is not null and typeCode is not null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `; let sql = `select typeName typeCode,province,count(*) count from n_need_info where province is not null and typeCode is not null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `;
let whereParams = {}; let whereParams = {};
if(ac.start&&ac.end){ if (ac.start && ac.end) {
sql += ` and created_at >= :start and created_at <= :end `; sql += ` and created_at >= :start and created_at <= :end `;
whereParams.start = await this.getTimeSubtraction(ac.start); whereParams.start = await this.getTimeSubtraction(ac.start);
whereParams.end = await this.getTimeSubtraction(ac.end); whereParams.end = await this.getTimeSubtraction(ac.end);
} }
if(ac.type_name){ if (ac.type_name) {
sql += ` and typeName = :typeName`; sql += ` and typeName = :typeName`;
whereParams.typeName = ac.type_name; whereParams.typeName = ac.type_name;
} }
if(ac.uapp_id){ if (ac.uapp_id) {
sql += ` and uapp_id = :uapp_id`; sql += ` and uapp_id = :uapp_id`;
whereParams.uapp_id = ac.uapp_id; whereParams.uapp_id = ac.uapp_id;
} }
sql += ` GROUP BY province,typeName`; sql += ` GROUP BY province,typeName`;
let result = await this.customQuery(sql,whereParams); let result = await this.customQuery(sql, whereParams);
return system.getResultSuccess(result); return system.getResultSuccess(result);
} }
...@@ -295,43 +295,43 @@ class NeedinfoService extends ServiceBase { ...@@ -295,43 +295,43 @@ class NeedinfoService extends ServiceBase {
* @param pobj * @param pobj
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async getNeedComparison(pobj){ async getNeedComparison(pobj) {
let ab =pobj.actionBody; let ab = pobj.actionBody;
let sql1 = `select count(DISTINCT(channelNeedNo)) count from n_need_info where deleted_at is null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `; let sql1 = `select count(DISTINCT(channelNeedNo)) count from n_need_info where deleted_at is null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `;
let sql2 = `select count(DISTINCT(b.channelNeedNo)) count from n_need_info b where b.deleted_at is null and b.status = 'ycd' AND (b.channelTypeName <> "商标交易" or b.channelTypeName is not null)`; let sql2 = `select count(DISTINCT(b.channelNeedNo)) count from n_need_info b where b.deleted_at is null and b.status = 'ycd' AND (b.channelTypeName <> "商标交易" or b.channelTypeName is not null)`;
let whereParams = {}; let whereParams = {};
if(ab.startNow&&ab.endNow){ if (ab.startNow && ab.endNow) {
sql1 += ` and created_at >= :start and created_at <= :end`; sql1 += ` and created_at >= :start and created_at <= :end`;
sql2 += ` and b.created_at >= :start and b.created_at <= :end`; sql2 += ` and b.created_at >= :start and b.created_at <= :end`;
whereParams.start = await this.getTimeSubtraction(ab.startNow); whereParams.start = await this.getTimeSubtraction(ab.startNow);
whereParams.end = await this.getTimeSubtraction(ab.endNow); whereParams.end = await this.getTimeSubtraction(ab.endNow);
} }
if(ab.uapp_id){ if (ab.uapp_id) {
sql1 += ` and uapp_id = :uapp_id`; sql1 += ` and uapp_id = :uapp_id`;
sql2 += ` and b.uapp_id = :uapp_id`; sql2 += ` and b.uapp_id = :uapp_id`;
whereParams.uapp_id = ab.uapp_id; whereParams.uapp_id = ab.uapp_id;
} }
if(ab.type_name){ if (ab.type_name) {
sql1 += ` and typeName = :type_name`; sql1 += ` and typeName = :type_name`;
sql2 += ` and b.typename = :type_name`; sql2 += ` and b.typename = :type_name`;
whereParams.type_name = ab.type_name; whereParams.type_name = ab.type_name;
} }
let totalRet1 = await this.customQuery(sql1,whereParams); let totalRet1 = await this.customQuery(sql1, whereParams);
let orderRet1 = await this.customQuery(sql2,whereParams); let orderRet1 = await this.customQuery(sql2, whereParams);
if(ab.startLast&&ab.endLast){ if (ab.startLast && ab.endLast) {
whereParams.start = await this.getTimeSubtraction(ab.startLast); whereParams.start = await this.getTimeSubtraction(ab.startLast);
whereParams.end = await this.getTimeSubtraction(ab.endLast); whereParams.end = await this.getTimeSubtraction(ab.endLast);
} }
let totalRet2 = await this.customQuery(sql1,whereParams); let totalRet2 = await this.customQuery(sql1, whereParams);
let orderRet2 = await this.customQuery(sql2,whereParams); let orderRet2 = await this.customQuery(sql2, whereParams);
let result ={ let result = {
now:{ now: {
total:totalRet1[0].count, total: totalRet1[0].count,
order:orderRet1[0].count order: orderRet1[0].count
}, },
last:{ last: {
total:totalRet2[0].count, total: totalRet2[0].count,
order:orderRet2[0].count order: orderRet2[0].count
} }
} }
return system.getResultSuccess(result); return system.getResultSuccess(result);
...@@ -343,7 +343,7 @@ class NeedinfoService extends ServiceBase { ...@@ -343,7 +343,7 @@ class NeedinfoService extends ServiceBase {
* @param actionBody * @param actionBody
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async getNeedComparisonList(pobj,actionBody){ async getNeedComparisonList(pobj, actionBody) {
let pageSize = Number(actionBody.pageSize || 20); let pageSize = Number(actionBody.pageSize || 20);
let pageIndex = Number(actionBody.pageIndex || 1); let pageIndex = Number(actionBody.pageIndex || 1);
let from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize); let from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize);
...@@ -360,7 +360,7 @@ class NeedinfoService extends ServiceBase { ...@@ -360,7 +360,7 @@ class NeedinfoService extends ServiceBase {
//需求成单总数 //需求成单总数
let needToOrderTotalSql = `select count(DISTINCT(b.channelNeedNo)) count from n_need_info b where b.deleted_at is null and b.status = 'ycd' AND (b.channelTypeName <> "商标交易" or b.channelTypeName is not null) `; let needToOrderTotalSql = `select count(DISTINCT(b.channelNeedNo)) count from n_need_info b where b.deleted_at is null and b.status = 'ycd' AND (b.channelTypeName <> "商标交易" or b.channelTypeName is not null) `;
let whereParams = {}; let whereParams = {};
if(actionBody.start&&actionBody.end){ if (actionBody.start && actionBody.end) {
needSql += ` and a.created_at >= :start and a.created_at <= :end`; needSql += ` and a.created_at >= :start and a.created_at <= :end`;
needTotalSql += ` and a.created_at >= :start and a.created_at <= :end`; needTotalSql += ` and a.created_at >= :start and a.created_at <= :end`;
needToOrderSql += ` and b.created_at >= :start and b.created_at <= :end`; needToOrderSql += ` and b.created_at >= :start and b.created_at <= :end`;
...@@ -369,52 +369,52 @@ class NeedinfoService extends ServiceBase { ...@@ -369,52 +369,52 @@ class NeedinfoService extends ServiceBase {
whereParams.end = await this.getTimeSubtraction(actionBody.end); whereParams.end = await this.getTimeSubtraction(actionBody.end);
} }
if(actionBody.uapp_id){ if (actionBody.uapp_id) {
needSql += ` and a.uapp_id = :uapp_id`; needSql += ` and a.uapp_id = :uapp_id`;
needTotalSql += ` and a.uapp_id = :uapp_id`; needTotalSql += ` and a.uapp_id = :uapp_id`;
needToOrderSql += ` and b.uapp_id = :uapp_id`; needToOrderSql += ` and b.uapp_id = :uapp_id`;
needToOrderTotalSql += ` and b.uapp_id = :uapp_id`; needToOrderTotalSql += ` and b.uapp_id = :uapp_id`;
whereParams.uapp_id = actionBody.uapp_id; whereParams.uapp_id = actionBody.uapp_id;
} }
if(actionBody.type_name){ if (actionBody.type_name) {
needSql += ` and a.typeName = :type_name`; needSql += ` and a.typeName = :type_name`;
needTotalSql += ` and a.typeName = :type_name`; needTotalSql += ` and a.typeName = :type_name`;
needToOrderSql += ` and b.typeName = :type_name`; needToOrderSql += ` and b.typeName = :type_name`;
needToOrderTotalSql += ` and b.typeName = :type_name`; needToOrderTotalSql += ` and b.typeName = :type_name`;
whereParams.type_name = actionBody.type_name; whereParams.type_name = actionBody.type_name;
} }
if(actionBody.status){ if (actionBody.status) {
needSql += ` and a.status = :status`; needSql += ` and a.status = :status`;
needTotalSql += ` and a.status = :status`; needTotalSql += ` and a.status = :status`;
needToOrderSql += ` and b.status = :status`; needToOrderSql += ` and b.status = :status`;
needToOrderTotalSql += ` and b.status = :status`; needToOrderTotalSql += ` and b.status = :status`;
whereParams.status = actionBody.status; whereParams.status = actionBody.status;
} }
if(actionBody.fuzzy_code){ if (actionBody.fuzzy_code) {
needSql += ` and ( a.needNo like :fuzzy_code or a.channelNeedNo like :fuzzy_code or a.publishMobile like :fuzzy_code)`; needSql += ` and ( a.needNo like :fuzzy_code or a.channelNeedNo like :fuzzy_code or a.publishMobile like :fuzzy_code)`;
needTotalSql += ` and ( a.needNo like :fuzzy_code or a.channelNeedNo like :fuzzy_code or a.publishMobile like :fuzzy_code)`; needTotalSql += ` and ( a.needNo like :fuzzy_code or a.channelNeedNo like :fuzzy_code or a.publishMobile like :fuzzy_code)`;
needToOrderSql += ` and ( b.needNo like :fuzzy_code or b.channelNeedNo like :fuzzy_code or b.publishMobile like :fuzzy_code)`; needToOrderSql += ` and ( b.needNo like :fuzzy_code or b.channelNeedNo like :fuzzy_code or b.publishMobile like :fuzzy_code)`;
needToOrderTotalSql += ` and ( b.needNo like :fuzzy_code or b.channelNeedNo like :fuzzy_code or b.publishMobile like :fuzzy_code)`; needToOrderTotalSql += ` and ( b.needNo like :fuzzy_code or b.channelNeedNo like :fuzzy_code or b.publishMobile like :fuzzy_code)`;
whereParams.fuzzy_code = "%"+actionBody.fuzzy_code+"%"; whereParams.fuzzy_code = "%" + actionBody.fuzzy_code + "%";
} }
needSql += ` order by a.created_at desc`; needSql += ` order by a.created_at desc`;
needToOrderSql += ` order by b.created_at desc`; needToOrderSql += ` order by b.created_at desc`;
if(pageSize != -1){ if (pageSize != -1) {
needSql += ` limit ${pageSize} offset ${from}`; needSql += ` limit ${pageSize} offset ${from}`;
needToOrderSql += ` limit ${pageSize} offset ${from}`; needToOrderSql += ` limit ${pageSize} offset ${from}`;
} }
let result,total; let result, total;
if(tag == 'need'){ if (tag == 'need') {
result = await this.customQuery(needSql,whereParams); result = await this.customQuery(needSql, whereParams);
total = await this.customQuery(needTotalSql,whereParams); total = await this.customQuery(needTotalSql, whereParams);
} }
if(tag == 'needToOrder'){ if (tag == 'needToOrder') {
result = await this.customQuery(needToOrderSql,whereParams); result = await this.customQuery(needToOrderSql, whereParams);
total = await this.customQuery(needToOrderTotalSql,whereParams); total = await this.customQuery(needToOrderTotalSql, whereParams);
} }
let data = { let data = {
total:total[0].count, total: total[0].count,
rows:result rows: result
} }
return system.getResult(data); return system.getResult(data);
} }
...@@ -462,22 +462,22 @@ class NeedinfoService extends ServiceBase { ...@@ -462,22 +462,22 @@ class NeedinfoService extends ServiceBase {
let ids2 = []; let ids2 = [];
let ids3 = []; let ids3 = [];
//已经存在的需求,更改状态 //已经存在的需求,更改状态
for(let i = 0;i < needs.length; i++){ for (let i = 0; i < needs.length; i++) {
let need = needs[i]; let need = needs[i];
let obj = { let obj = {
id:need.id, id: need.id,
} }
if(needDict[need.channelNeedNo] == 1){ if (needDict[need.channelNeedNo] == 1) {
obj.status = 'ygj'; obj.status = 'ygj';
obj.statusName = '已跟进'; obj.statusName = '已跟进';
ids1.push(need.channelNeedNo); ids1.push(need.channelNeedNo);
} }
if(needDict[need.channelNeedNo] == 2){ if (needDict[need.channelNeedNo] == 2) {
obj.status = 'ygb'; obj.status = 'ygb';
obj.statusName = '已关闭'; obj.statusName = '已关闭';
ids2.push(need.channelNeedNo); ids2.push(need.channelNeedNo);
} }
if(needDict[need.channelNeedNo] == 3){ if (needDict[need.channelNeedNo] == 3) {
obj.status = 'ycd'; obj.status = 'ycd';
obj.statusName = '已成单'; obj.statusName = '已成单';
ids3.push(need.channelNeedNo); ids3.push(need.channelNeedNo);
...@@ -489,85 +489,85 @@ class NeedinfoService extends ServiceBase { ...@@ -489,85 +489,85 @@ class NeedinfoService extends ServiceBase {
let createObj = []; let createObj = [];
let setFqObj1 = []; let setFqObj1 = [];
let setFqObj2 = []; let setFqObj2 = [];
for(let i =0;i<fqNeeds.length;i++){ for (let i = 0; i < fqNeeds.length; i++) {
let fqNeed = fqNeeds[i]; let fqNeed = fqNeeds[i];
if(!existIds.includes(fqNeed.channelNeedNo)){ if (!existIds.includes(fqNeed.channelNeedNo)) {
let obj = { let obj = {
channelNeedNo:fqNeed.channelNeedNo, channelNeedNo: fqNeed.channelNeedNo,
city:fqNeed.city || "", city: fqNeed.city || "",
province:fqNeed.province, province: fqNeed.province,
publishMobile:fqNeed.publishMobile, publishMobile: fqNeed.publishMobile,
disposeNotes:fqNeed.disposeNotes, disposeNotes: fqNeed.disposeNotes,
typeCode:fqNeed.typeCode, typeCode: fqNeed.typeCode,
created_at:fqNeed.created_at created_at: fqNeed.created_at
} }
if(fqNeed.status == 1){ if (fqNeed.status == 1) {
obj.status = 'ygj'; obj.status = 'ygj';
obj.statusName = '已跟进'; obj.statusName = '已跟进';
} }
if(fqNeed.status == 2){ if (fqNeed.status == 2) {
obj.status = 'ygb'; obj.status = 'ygb';
obj.statusName = '已关闭'; obj.statusName = '已关闭';
} }
if(fqNeed.status == 3){ if (fqNeed.status == 3) {
obj.status = 'ycd'; obj.status = 'ycd';
obj.statusName = '已成单'; obj.statusName = '已成单';
} }
if(fqNeed.status == 4 || fqNeed.status == 0){ if (fqNeed.status == 4 || fqNeed.status == 0) {
obj.status = 'yts'; obj.status = 'yts';
obj.statusName = '已推送'; obj.statusName = '已推送';
} }
if(['360_icp ','360_edi','360_sbzc'].includes(fqNeed.sourceCode)){ if (['360_icp ', '360_edi', '360_sbzc'].includes(fqNeed.sourceCode)) {
obj.uapp_id = 50; obj.uapp_id = 50;
} }
if(['baidu_edi','baidu_gsreg','baidu_icp','baidu_radiotv','baidu_wangwen'].includes(fqNeed.sourceCode)){ if (['baidu_edi', 'baidu_gsreg', 'baidu_icp', 'baidu_radiotv', 'baidu_wangwen'].includes(fqNeed.sourceCode)) {
obj.uapp_id = 44; obj.uapp_id = 44;
} }
if(['edi_ali','ic_ali','icp_ali','tm_ali','tmd_ali'].includes(fqNeed.sourceCode)){ if (['edi_ali', 'ic_ali', 'icp_ali', 'tm_ali', 'tmd_ali'].includes(fqNeed.sourceCode)) {
obj.uapp_id = 18; obj.uapp_id = 18;
} }
if(['youke'].includes(fqNeed.sourceCode)){ if (['youke'].includes(fqNeed.sourceCode)) {
obj.uapp_id = 40; obj.uapp_id = 40;
} }
if(['tm_jdyun'].includes(fqNeed.sourceCode)){ if (['tm_jdyun'].includes(fqNeed.sourceCode)) {
obj.uapp_id = 31; obj.uapp_id = 31;
} }
if(['tm_bw'].includes(fqNeed.sourceCode)){ if (['tm_bw'].includes(fqNeed.sourceCode)) {
obj.uapp_id = 35; obj.uapp_id = 35;
} }
if(['tm_1688'].includes(fqNeed.sourceCode)){ if (['tm_1688'].includes(fqNeed.sourceCode)) {
obj.uapp_id = 0; obj.uapp_id = 0;
} }
if(!setFqObj2.includes(fqNeed.channelNeedNo)){ if (!setFqObj2.includes(fqNeed.channelNeedNo)) {
createObj.push(obj); createObj.push(obj);
setFqObj2.push(fqNeed.channelNeedNo); setFqObj2.push(fqNeed.channelNeedNo);
} }
}else { } else {
setFqObj1.push(fqNeed.channelNeedNo); setFqObj1.push(fqNeed.channelNeedNo);
} }
} }
//企服通 批量更新状态 //企服通 批量更新状态
let updateRet =null; let updateRet = null;
if(setObj.length>0){ if (setObj.length > 0) {
// updateRet = await this.needinfoDao.bulkUpdate(setObj); // updateRet = await this.needinfoDao.bulkUpdate(setObj);
if(ids1.length>0){ if (ids1.length > 0) {
updateRet = await this.needinfoDao.bulkUpdateStatus('ygj','已跟进',ids1); updateRet = await this.needinfoDao.bulkUpdateStatus('ygj', '已跟进', ids1);
} }
if(ids2.length>0){ if (ids2.length > 0) {
updateRet = await this.needinfoDao.bulkUpdateStatus('ygb','已关闭',ids2); updateRet = await this.needinfoDao.bulkUpdateStatus('ygb', '已关闭', ids2);
} }
if(ids3.length>0){ if (ids3.length > 0) {
updateRet = await this.needinfoDao.bulkUpdateStatus('ycd','已成单',ids3); updateRet = await this.needinfoDao.bulkUpdateStatus('ycd', '已成单', ids3);
} }
if(updateRet.length > 0){ if (updateRet.length > 0) {
updateRet = await this.needinfofqDao.bulkUpdate(setFqObj1); updateRet = await this.needinfofqDao.bulkUpdate(setFqObj1);
} }
} }
//企服通 批量添加 //企服通 批量添加
if(createObj.length>0){ if (createObj.length > 0) {
updateRet = await this.needinfoDao.bulkCreate(createObj); updateRet = await this.needinfoDao.bulkCreate(createObj);
if(updateRet.length >0 ){ if (updateRet.length > 0) {
updateRet = await this.needinfofqDao.bulkUpdate(setFqObj2); updateRet = await this.needinfofqDao.bulkUpdate(setFqObj2);
} }
} }
......
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