@@ -1205,7 +1206,7 @@ class OrderInfoService extends ServiceBase {
}
/**
* 需求统计(产品维度)
* 订单统计(产品维度)
* @param pobj
* @returns {Promise<void>}
*/
...
...
@@ -1223,7 +1224,7 @@ class OrderInfoService extends ServiceBase {
whereParam.type_code=ac.type_code;
}
if(ac.status){
sql+=` AND status = :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`
...
...
@@ -1232,20 +1233,20 @@ class OrderInfoService extends ServiceBase {
}
/**
* 需求统计(产品维度)
* 订单统计(产品维度)
* @param pobj
* @returns {Promise<void>}
*/
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){
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`;
sql+=` GROUP BY b.channelItemName,a.uapp_id`;
letresult=awaitthis.customQuery(sql,whereParams);
returnsystem.getResultSuccess(result);
}
...
...
@@ -1332,6 +1333,11 @@ class OrderInfoService extends ServiceBase {
totalSql+=` and a.uapp_id = :uapp_id`;
whereParams.uapp_id=ab.uapp_id;
}
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`;
...
...
@@ -2275,5 +2281,141 @@ class OrderInfoService extends ServiceBase {
@@ -207,41 +211,55 @@ 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!='商标交易'`;
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!='商标交易' 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 typeCode,province,count(*) count from n_need_info where province is not null and typeCode is not null AND channelTypeName!='商标交易' `;
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){
if(ac.type_name){
sql+=` and typeCode = :typeCode`;
whereParams.typeCode=ac.type_code;
whereParams.typeCode=ac.type_name;
}
if(ac.uapp_id){
sql+=` and uapp_id = :uapp_id`;
...
...
@@ -259,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(needNo)) count from n_need_info where deleted_at is null AND channelTypeName!='商标交易' `;
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' AND b.channelTypeName!='商标交易'`;
letwhereParams={};
if(ab.startNow&&ab.endNow){
sql1+=` and created_at >= :start and created_at <= :end`;
...
...
@@ -273,10 +291,10 @@ class NeedinfoService extends ServiceBase {
@@ -314,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!='商标交易' `;
//需求总数
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!='商标交易'`;
//需求成单
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!='商标交易'`;
//需求成单总数
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!='商标交易'`;
letwhereParams={};
if(actionBody.start&&actionBody.end){
needSql+=` and a.created_at >= :start and a.created_at <= :end`;
...
...
@@ -338,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)`;
...
...
@@ -373,6 +398,161 @@ class NeedinfoService extends ServiceBase {