letsql=`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)`;
letsql=`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)`;
letwhereParam={};
letwhereParam={};
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`;
letsql=`select typeName typeCode,uapp_id,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `;
letsql=`select count(*) count from n_need_info where deleted_at is null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `;
letwhereParams={};
letsql2=sql+` and status in('ygj','ygb','ycd')`;
if(ac.start&&ac.end){
letsql3=sql+` and status = 'ycd'`;
sql+=` and created_at >= :start and created_at <= :end `;
letsql=`select typeName typeCode,uapp_id,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName 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 not null) `;
letwhereParams={};
letwhereParams={};
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 `;
letsql=`select typeName,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName is not null) GROUP BY typeName`;
letresult=awaitthis.customQuery(sql);
lettypeNames=result.map(item=>{
returnitem.typeName;
})
returnsystem.getResultSuccess(typeNames);
}
/**
/**
* 需求统计(区域维度)
* 需求统计(产品类型) 总数
* @param pobj
* @param pobj
* @returns {Promise<void>}
* @returns {Promise<void>}
*/
*/
asyncgetStatisticsByCity(pobj){
asyncgetStatisticsByChannel(pobj){
letac=pobj.actionBody;
letac=pobj.actionBody;
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 not null) `;
letsql=`select typeName typeCode,uapp_id,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `;
letwhereParams={};
letwhereParams={};
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 `;
letsql=`select typeName,count(*) count from n_need_info where typeName is not null AND (channelTypeName <> "商标交易" or channelTypeName is not null) GROUP BY typeName`;
letsql1=`select count(DISTINCT(channelNeedNo)) count from n_need_info where deleted_at is null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `;
letresult=awaitthis.customQuery(sql);
letsql2=`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)`;
lettypeNames=result.map(item=>{
letwhereParams={};
returnitem.typeName;
if(ab.startNow&&ab.endNow){
})
sql1+=` and created_at >= :start and created_at <= :end`;
returnsystem.getResultSuccess(typeNames);
sql2+=` and b.created_at >= :start and b.created_at <= :end`;
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 not 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 not null) `;
sql+=` and typeName = :typeName`;
//需求总数
whereParams.typeName=ac.type_name;
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 not null) `;
}
//需求成单
if(ac.uapp_id){
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_info b inner join center_app.p_app c on b.uapp_id = c.uapp_id where b.deleted_at is null and b.status = 'ycd' AND (b.channelTypeName <> "商标交易" or b.channelTypeName is not null) `;
sql+=` and uapp_id = :uapp_id`;
//需求成单总数
whereParams.uapp_id=ac.uapp_id;
letneedToOrderTotalSql=`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) `;
}
letwhereParams={};
sql+=` GROUP BY province,typeName`;
if(actionBody.start&&actionBody.end){
letresult=awaitthis.customQuery(sql,whereParams);
needSql+=` and a.created_at >= :start and a.created_at <= :end`;
returnsystem.getResultSuccess(result);
needTotalSql+=` and a.created_at >= :start and a.created_at <= :end`;
needToOrderSql+=` and b.created_at >= :start and b.created_at <= :end`;
needToOrderTotalSql+=` and b.created_at >= :start and b.created_at <= :end`;
letsql1=`select count(DISTINCT(channelNeedNo)) count from n_need_info where deleted_at is null AND (channelTypeName <> "商标交易" or channelTypeName is not null) `;
needSql+=` and a.typeName = :type_name`;
letsql2=`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)`;
needTotalSql+=` and a.typeName = :type_name`;
letwhereParams={};
needToOrderSql+=` and b.typeName = :type_name`;
if(ab.startNow&&ab.endNow){
needToOrderTotalSql+=` and b.typeName = :type_name`;
sql1+=` and created_at >= :start and created_at <= :end`;
whereParams.type_name=actionBody.type_name;
sql2+=` and b.created_at >= :start and b.created_at <= :end`;
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 not 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 not 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_info b inner join center_app.p_app c on b.uapp_id = c.uapp_id where b.deleted_at is null and b.status = 'ycd' AND (b.channelTypeName <> "商标交易" or b.channelTypeName is not null) `;
//需求成单总数
letneedToOrderTotalSql=`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) `;
letwhereParams={};
if(actionBody.start&&actionBody.end){
needSql+=` 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`;
needToOrderTotalSql+=` and b.created_at >= :start and b.created_at <= :end`;