letneedSql=`select b.app_name,a.needNo,a.channelNeedNo,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`;
//需求总数
letneedTotalSql=`select count(*) 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`;
//需求成单
letneedToOrderSql=`select DISTINCT(b.needNo),c.app_name,b.channelNeedNo,b.province,b.city,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'`;
//需求成单总数
letneedToOrderTotalSql=`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 and b.status = 'ycd'`;
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`;
whereParams.start=actionBody.start;
whereParams.end=actionBody.end;
}
if(actionBody.uapp_id){
needSql+=` and a.uapp_id = :uapp_id`;
needTotalSql+=` and a.uapp_id = :uapp_id`;
needToOrderSql+=` and b.uapp_id = :uapp_id`;
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(pageSize!=-1){
needSql+=` order by a.id desc limit ${pageSize} offset ${from}`;
needToOrderSql+=` order by b.id desc limit ${pageSize} offset ${from}`;