@@ -1129,13 +1109,13 @@ class OrderInfoService extends ServiceBase {
actionBody:
{
delivery_content:{},
order_info:{orderStatus:2},
order_info:{orderStatus:2},
product_info:{}
}
};
varsql="select * from c_order_delivery where sourceOrderNo=:sourceOrderNo";
varparamWhere={sourceOrderNo:actionBody.orderNo};
varparamWhere={sourceOrderNo:actionBody.orderNo};
varlist=awaitthis.customQuery(sql,paramWhere);
if(list&&list.length>0){
if(list[0].deliveryContent){
...
...
@@ -1242,85 +1222,84 @@ class OrderInfoService extends ServiceBase {
}
/**
* 需求统计(产品维度)
* 订单统计(产品维度)
* @param pobj
* @returns {Promise<void>}
*/
asyncgetOrdersStatisticsByUappId(pobj){
asyncgetOrdersStatisticsByUappId(pobj){
letac=pobj.actionBody;
letsql=`SELECT uapp_id,count(*) count,DATE_FORMAT(created_at,'%Y-%m-%d') time FROM c_order_info WHERE deleted_at is null `;
letwhereParam={};
if(ac.start&&ac.end){
if(ac.start&&ac.end){
sql+=` AND created_at >= :start AND created_at <= :end`;
whereParam.start=ac.start;
whereParam.end=ac.end;
}
if(ac.type_code){
if(ac.type_code){
sql+=` AND typeCode = :type_code`;
whereParam.type_code=ac.type_code;
}
if(ac.status){
sql+=` AND status = :status`;
if(ac.status){
sql+=` AND orderStatus = :status`;
whereParam.status=ac.status;
}
sql+=` GROUP BY uapp_id,DATE_FORMAT(created_at,'%Y-%m-%d') ORDER BY created_at ASC`
letresult=awaitthis.customQuery(sql,whereParam);
letresult=awaitthis.customQuery(sql,whereParam);
returnsystem.getResultSuccess(result);
}
/**
* 需求统计(产品维度)
* 订单统计(产品维度)
* @param pobj
* @returns {Promise<void>}
*/
asyncgetOrdersStatisticsByProduct(pobj){
asyncgetOrdersStatisticsByProduct(pobj){
letac=pobj.actionBody;
letsql=`SELECT b.itemCode typeCode,a.uapp_id,count( * ) count FROM c_order_info a left join c_order_product b on a.orderNo = b.sourceOrderNo WHERE b.itemCode is not null `;
letsql=`SELECT b.channelItemName typeCode,a.uapp_id,count( * ) count FROM c_order_info a left join c_order_product b on a.orderNo = b.sourceOrderNo WHERE b.itemCode is not null `;
letwhereParams={};
if(ac.start&&ac.end){
if(ac.start&&ac.end){
sql+=` and a.created_at >= :start and a.created_at <= :end `;
whereParams.start=ac.start;
whereParams.end=ac.end;
}
sql+=` GROUP BY b.itemCode,a.uapp_id`;
letresult=awaitthis.customQuery(sql,whereParams);
sql+=` GROUP BY b.channelItemName,a.uapp_id`;
letresult=awaitthis.customQuery(sql,whereParams);
returnsystem.getResultSuccess(result);
}
/**
* 订单对比
* @param pobj
* @returns {Promise<void>}
*/
asyncgetOrdersComparison(pobj){
letab=pobj.actionBody;
asyncgetOrdersComparison(pobj){
letab=pobj.actionBody;
letsql1=`select count(*) count from c_order_info a left join c_order_product b on a.orderNo = b.sourceOrderNo where a.deleted_at is null `;
letwhereParams={};
if(ab.startNow&&ab.endNow){
if(ab.startNow&&ab.endNow){
sql1+=` and a.created_at >= :start and a.created_at <= :end`;
@@ -1331,7 +1310,7 @@ class OrderInfoService extends ServiceBase {
* @param pobj
* @returns {Promise<void>}
*/
asyncgetOrdersComparisonList(pobj){
asyncgetOrdersComparisonList(pobj){
letab=pobj.actionBody;
letpageSize=Number(ab.pageSize||20);
letpageIndex=Number(ab.pageIndex||1);
...
...
@@ -1349,6 +1328,8 @@ class OrderInfoService extends ServiceBase {
a.orderStatusName,
c.contactName,
c.mobile,
a.isPushNum,
a.pushStatus,
a.created_at
FROM
center_order.c_order_info a
...
...
@@ -1358,46 +1339,51 @@ class OrderInfoService extends ServiceBase {
WHERE
a.deleted_at IS NULL`;
lettotalSql=`select count(DISTINCT(a.orderNo)) count from c_order_info a left join c_order_product b on a.orderNo = b.sourceOrderNo LEFT JOIN center_order.c_order_contacts c on a.orderNo = c.sourceOrderNo where a.deleted_at is null `
letwhereParams={};
if(ab.start&&ab.end){
letwhereParams={};
if(ab.start&&ab.end){
listSql+=` and a.created_at >= :start and a.created_at <= :end`;
totalSql+=` and a.created_at >= :start and a.created_at <= :end`;
whereParams.start=ab.start;
whereParams.end=ab.end;
}
if(ab.uapp_id){
if(ab.uapp_id){
listSql+=` and a.uapp_id = :uapp_id`;
totalSql+=` and a.uapp_id = :uapp_id`;
whereParams.uapp_id=ab.uapp_id;
}
if(ab.type_code){
if(ab.status){
listSql+=` and a.orderStatus = :status`;
totalSql+=` and a.orderStatus = :status`;
whereParams.status=ab.status;
}
if(ab.type_code){
listSql+=` and b.itemCode = :type_code`;
totalSql+=` and b.itemCode = :type_code`;
whereParams.type_code=ab.type_code;
}
if(ab.fuzzy_code){
if(ab.fuzzy_code){
listSql+=` and ( a.orderNo like :fuzzy_code or a.channelOrderNo like :fuzzy_code or c.mobile like :fuzzy_code)`;
totalSql+=` and ( a.orderNo like :fuzzy_code or a.channelOrderNo like :fuzzy_code or c.mobile like :fuzzy_code)`;
" `invoiceApplyStatus`,`opNotes`,`notes`,`channelItemCode`,`channelItemName`,`price`,priceDesc,priceTypeName,channelItemAppendName,`serviceItemCode`,`picUrl`,`serviceItemSnapshot`,`orderSnapshot`,created_at from "+
" v_order where uapp_id=:uapp_id and orderNo=:orderNo LIMIT 1";
sql="UPDATE `c_delivery_official_flow` SET officialFlow ='"+JSON.stringify(flowList)+"' where sourceOrderNo='"+actionBody.officialInfo.tmRegistNum+"'";
sql=sql.replace('\n','');
}
...
...
@@ -1763,7 +1749,7 @@ class OrderInfoService extends ServiceBase {
@@ -149,16 +149,16 @@ class NeedinfoService extends ServiceBase {
*/
asyncgetStatisticsByUappId(pobj){
letac=pobj.actionBody;
letsql=`SELECT uapp_id,count(*) count,DATE_FORMAT(created_at,'%Y-%m-%d') time FROM n_need_info WHERE deleted_at is null `;
letsql=`SELECT uapp_id,count(*) count,DATE_FORMAT(created_at,'%Y-%m-%d') time FROM n_need_info WHERE deleted_at is null AND (channelTypeName <> "商标交易" or channelTypeName is null)`;
letwhereParam={};
if(ac.start&&ac.end){
sql+=` AND created_at >= :start AND created_at <= :end`;
whereParam.start=ac.start;
whereParam.end=ac.end;
}
if(ac.type_code){
sql+=` AND typeCode = :type_code`;
whereParam.type_code=ac.type_code;
if(ac.type_name){
sql+=` AND typeName = :type_name`;
whereParam.type_name=ac.type_name;
}
if(ac.status){
sql+=` AND status = :status`;
...
...
@@ -176,28 +176,31 @@ class NeedinfoService extends ServiceBase {
*/
asyncgetNeedFunnelStatistics(pobj){
letac=pobj.actionBody;
letsql=`select count(*) count from n_need_info where deleted_at is null `;
letsql2=`select count(DISTINCT(a.needNo)) count from n_need_solution a left join n_need_info b on a.needNo = b.needNo where a.deleted_at is null`;
letsql=`select count(*) count from n_need_info where deleted_at is null AND (channelTypeName <> "商标交易" or channelTypeName is null) `;
letsql2=sql+` and status in('ygj','ygb','ycd')`;
letsql3=sql+` and status = 'ycd'`;
letwhereParams={};
if(ac.start&&ac.end){
sql+=` AND created_at >= :start and created_at <= :end`;
sql2+=` AND b.created_at >= :start and b.created_at <= :end`;
sql2+=` AND created_at >= :start and created_at <= :end`;
sql3+=` AND created_at >= :start and created_at <= :end`;
@@ -208,47 +211,61 @@ class NeedinfoService extends ServiceBase {
}
/**
* 需求统计(产品维度)
* 需求统计(产品类型)
* @param pobj
* @returns {Promise<void>}
*/
asyncgetStatisticsByProduct(pobj){
letac=pobj.actionBody;
letsql=`select typeCode,uapp_id,count(*) count from n_need_info where typeCode is not null `;
letsql=`select typeName typeCode,uapp_id,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName is null) `;
letwhereParams={};
if(ac.start&&ac.end){
sql+=` and created_at >= :start and created_at <= :end `;
whereParams.start=ac.start;
whereParams.end=ac.end;
}
sql+=` GROUP BY typeCode,uapp_id`;
sql+=` GROUP BY typeName,uapp_id`;
letresult=awaitthis.customQuery(sql,whereParams);
returnsystem.getResultSuccess(result);
}
/**
* 需求统计(获取产品类型)
* @param pobj
* @returns {Promise<void>}
*/
asyncgetNeedProductType(pobj){
letsql=`select typeName,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName is null) GROUP BY typeName`;
letresult=awaitthis.customQuery(sql);
lettypeNames=result.map(item=>{
returnitem.typeName;
})
returnsystem.getResultSuccess(typeNames);
}
/**
* 需求统计(区域维度)
* @param pobj
* @returns {Promise<void>}
*/
asyncgetStatisticsByCity(pobj){
letac=pobj.actionBody;
letsql=`select typeCode,province,count(*) count from n_need_info where province is not null and typeCode is not null `;
letsql=`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 null) `;
letwhereParams={};
if(ac.start&&ac.end){
sql+=` and created_at >= :start and created_at <= :end `;
whereParams.start=ac.start;
whereParams.end=ac.end;
}
if(ac.type_code){
sql+=` and typeCode = :typeCode`;
whereParams.typeCode=ac.type_code;
if(ac.type_name){
sql+=` and typeName = :typeName`;
whereParams.typeName=ac.type_name;
}
if(ac.uapp_id){
sql+=` and uapp_id = :uapp_id`;
whereParams.uapp_id=ac.uapp_id;
}
sql+=` GROUP BY province,typeCode`;
sql+=` GROUP BY province,typeName`;
letresult=awaitthis.customQuery(sql,whereParams);
returnsystem.getResultSuccess(result);
}
...
...
@@ -260,8 +277,8 @@ class NeedinfoService extends ServiceBase {
*/
asyncgetNeedComparison(pobj){
letab=pobj.actionBody;
letsql1=`select count(DISTINCT(needNo)) count from n_need_info where deleted_at is null `;
letsql2=`select count(DISTINCT(b.needNo)) count from n_need_solution a left join n_need_info b on a.needNo = b.needNo where a.deleted_at is null and b.status = 'ycd'`;
letsql1=`select count(DISTINCT(channelNeedNo)) count from n_need_info where deleted_at is null AND (channelTypeName <> "商标交易" or channelTypeName is null) `;
letsql2=`select count(DISTINCT(b.channelNeedNo)) count from n_need_solution a left join n_need_info b on a.needNo = b.needNo where a.deleted_at is null and b.status = 'ycd' AND (b.channelTypeName <> "商标交易" or b.channelTypeName is null)`;
letwhereParams={};
if(ab.startNow&&ab.endNow){
sql1+=` and created_at >= :start and created_at <= :end`;
...
...
@@ -274,10 +291,10 @@ class NeedinfoService extends ServiceBase {
@@ -315,13 +332,13 @@ class NeedinfoService extends ServiceBase {
}
lettag=actionBody.tag;
//需求列表
letneedSql=`select DISTINCT(a.channelNeedNo),b.app_name,a.needNo,a.typeName,a.province,a.city,a.publishContent,a.publishName,a.publishMobile,a.statusName,a.created_at from center_order.n_need_info a left join center_app.p_app b on a.uapp_id = b.uapp_id where a.deleted_at is null`;
letneedSql=`select DISTINCT(a.channelNeedNo),b.app_name,a.needNo,a.typeName,a.province,a.city,a.publishContent,a.publishName,a.publishMobile,a.statusName,a.created_at from center_order.n_need_info a left join center_app.p_app b on a.uapp_id = b.uapp_id where a.deleted_at is null AND (a.channelTypeName <> "商标交易" or a.channelTypeName is null) `;
//需求总数
letneedTotalSql=`select count(DISTINCT(a.channelNeedNo)) count from center_order.n_need_info a left join center_app.p_app b on a.uapp_id = b.uapp_id where a.deleted_at is null`;
letneedTotalSql=`select count(DISTINCT(a.channelNeedNo)) count from center_order.n_need_info a left join center_app.p_app b on a.uapp_id = b.uapp_id where a.deleted_at is null AND (a.channelTypeName <> "商标交易" or a.channelTypeName is null) `;
//需求成单
letneedToOrderSql=`select DISTINCT(b.channelNeedNo),c.app_name,b.channelNeedNo,b.province,b.city,b.typeName,b.publishContent,b.publishName,b.publishMobile,b.statusName,b.created_at from center_order.n_need_solution a left join center_order.n_need_info b on a.needNo = b.needNo left join center_app.p_app c on b.uapp_id = c.uapp_id where a.deleted_at is null and b.status = 'ycd'`;
letneedToOrderSql=`select DISTINCT(b.channelNeedNo),c.app_name,b.channelNeedNo,b.province,b.city,b.typeName,b.publishContent,b.publishName,b.publishMobile,b.statusName,b.created_at from center_order.n_need_solution a left join center_order.n_need_info b on a.needNo = b.needNo left join center_app.p_app c on b.uapp_id = c.uapp_id where a.deleted_at is null and b.status = 'ycd' AND (b.channelTypeName <> "商标交易" or b.channelTypeName is null) `;
//需求成单总数
letneedToOrderTotalSql=`select count(DISTINCT(a.channelNeedNo)) count from n_need_solution a left join n_need_info b on a.needNo = b.needNo where a.deleted_at is null and b.status = 'ycd'`;
letneedToOrderTotalSql=`select count(DISTINCT(a.channelNeedNo)) count from n_need_solution a left join n_need_info b on a.needNo = b.needNo where a.deleted_at is null and b.status = 'ycd' AND (b.channelTypeName <> "商标交易" or b.channelTypeName is null) `;
letwhereParams={};
if(actionBody.start&&actionBody.end){
needSql+=` and a.created_at >= :start and a.created_at <= :end`;
...
...
@@ -339,12 +356,19 @@ class NeedinfoService extends ServiceBase {
needToOrderTotalSql+=` and b.uapp_id = :uapp_id`;
whereParams.uapp_id=actionBody.uapp_id;
}
if(actionBody.type_code){
needSql+=` and a.typeCode = :type_code`;
needTotalSql+=` and a.typeCode = :type_code`;
needToOrderSql+=` and b.typeCode = :type_code`;
needToOrderTotalSql+=` and b.typeCode = :type_code`;
whereParams.type_code=actionBody.type_code;
if(actionBody.type_name){
needSql+=` and a.typeName = :type_name`;
needTotalSql+=` and a.typeName = :type_name`;
needToOrderSql+=` and b.typeName = :type_name`;
needToOrderTotalSql+=` and b.typeName = :type_name`;
whereParams.type_name=actionBody.type_name;
}
if(actionBody.status){
needSql+=` and a.status = :status`;
needTotalSql+=` and a.status = :status`;
needToOrderSql+=` and b.status = :status`;
needToOrderTotalSql+=` and b.status = :status`;
whereParams.status=actionBody.status;
}
if(actionBody.fuzzy_code){
needSql+=` and ( a.needNo like :fuzzy_code or a.channelNeedNo like :fuzzy_code or a.publishMobile like :fuzzy_code)`;
...
...
@@ -374,6 +398,7 @@ class NeedinfoService extends ServiceBase {
}
returnsystem.getResult(data);
}
/**
* 修改需求商机推送状态
* @param actionBody
...
...
@@ -451,10 +476,7 @@ class NeedinfoService extends ServiceBase {