Commit d9d47b7f by 任晓松

update search params

parent f4a86237
...@@ -1298,12 +1298,12 @@ class OrderInfoService extends ServiceBase { ...@@ -1298,12 +1298,12 @@ class OrderInfoService extends ServiceBase {
*/ */
async getOrdersStatisticsByUappId(pobj) { async getOrdersStatisticsByUappId(pobj) {
let ac = pobj.actionBody; let ac = pobj.actionBody;
let sql = `SELECT a.uapp_id,count(*) count,DATE_FORMAT(a.created_at,'%Y-%m-%d') time FROM c_order_info a INNER JOIN c_order_product b ON a.orderNo = b.sourceOrderNo WHERE a.deleted_at is null `; let sql = `SELECT a.uapp_id,count(*) count,DATE_FORMAT(DATE_ADD(a.created_at,INTERVAL 8 HOUR),'%Y-%m-%d') time FROM c_order_info a INNER JOIN c_order_product b ON a.orderNo = b.sourceOrderNo WHERE a.deleted_at is null `;
let whereParam = {}; let whereParam = {};
if (ac.start && ac.end) { if (ac.start && ac.end) {
sql += ` AND a.created_at >= :start AND a.created_at <= :end`; sql += ` AND a.created_at >= :start AND a.created_at <= :end`;
whereParam.start = ac.start; whereParam.start = await this.getTimeSubtraction(ac.start);
whereParam.end = ac.end; whereParam.end = await this.getTimeSubtraction(ac.end);
} }
if(ac.pathName){ if(ac.pathName){
sql += ` AND b.pathName = :pathName`; sql += ` AND b.pathName = :pathName`;
...@@ -1313,7 +1313,7 @@ class OrderInfoService extends ServiceBase { ...@@ -1313,7 +1313,7 @@ class OrderInfoService extends ServiceBase {
sql += ` AND orderStatus = :status`; sql += ` AND orderStatus = :status`;
whereParam.status = ac.status; whereParam.status = ac.status;
} }
sql += ` GROUP BY a.uapp_id,DATE_FORMAT(a.created_at,'%Y-%m-%d') ORDER BY a.created_at ASC` sql += ` GROUP BY a.uapp_id,DATE_FORMAT(DATE_ADD(a.created_at,INTERVAL 8 HOUR),'%Y-%m-%d') ORDER BY a.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);
} }
...@@ -1329,8 +1329,8 @@ class OrderInfoService extends ServiceBase { ...@@ -1329,8 +1329,8 @@ class OrderInfoService extends ServiceBase {
let whereParams = {}; let whereParams = {};
if (ac.start && ac.end) { if (ac.start && ac.end) {
sql += ` and a.created_at >= :start and a.created_at <= :end `; sql += ` and a.created_at >= :start and a.created_at <= :end `;
whereParams.start = ac.start; whereParams.start = await this.getTimeSubtraction(ac.start);
whereParams.end = ac.end; whereParams.end = await this.getTimeSubtraction(ac.end);
} }
sql += ` GROUP BY b.pathName,a.uapp_id`; sql += ` GROUP BY b.pathName,a.uapp_id`;
let result = await this.customQuery(sql, whereParams); let result = await this.customQuery(sql, whereParams);
...@@ -1348,8 +1348,8 @@ class OrderInfoService extends ServiceBase { ...@@ -1348,8 +1348,8 @@ class OrderInfoService extends ServiceBase {
let whereParams = {}; let whereParams = {};
if (ac.start && ac.end) { if (ac.start && ac.end) {
sql += ` and a.created_at >= :start and a.created_at <= :end `; sql += ` and a.created_at >= :start and a.created_at <= :end `;
whereParams.start = ac.start; whereParams.start = await this.getTimeSubtraction(ac.start);
whereParams.end = ac.end; whereParams.end = await this.getTimeSubtraction(ac.end);
} }
sql += ` GROUP BY a.uapp_id,b.pathName`; sql += ` GROUP BY a.uapp_id,b.pathName`;
let result = await this.customQuery(sql, whereParams); let result = await this.customQuery(sql, whereParams);
...@@ -1367,8 +1367,8 @@ class OrderInfoService extends ServiceBase { ...@@ -1367,8 +1367,8 @@ class OrderInfoService extends ServiceBase {
let whereParams = {}; let whereParams = {};
if (ab.startNow && ab.endNow) { if (ab.startNow && ab.endNow) {
sql1 += ` and a.created_at >= :start and a.created_at <= :end`; sql1 += ` and a.created_at >= :start and a.created_at <= :end`;
whereParams.start = ab.startNow; whereParams.start = await this.getTimeSubtraction(ab.startNow);
whereParams.end = ab.endNow; whereParams.end = await this.getTimeSubtraction(ab.endNow);
} }
if (ab.uapp_id) { if (ab.uapp_id) {
sql1 += ` and a.uapp_id = :uapp_id`; sql1 += ` and a.uapp_id = :uapp_id`;
...@@ -1380,8 +1380,8 @@ class OrderInfoService extends ServiceBase { ...@@ -1380,8 +1380,8 @@ class OrderInfoService extends ServiceBase {
} }
let totalRet1 = await this.customQuery(sql1, whereParams); let totalRet1 = await this.customQuery(sql1, whereParams);
if (ab.startLast && ab.endLast) { if (ab.startLast && ab.endLast) {
whereParams.start = ab.startLast; whereParams.start = await this.getTimeSubtraction(ab.startLast);
whereParams.end = ab.endLast; whereParams.end = await this.getTimeSubtraction(ab.endLast);
} }
let totalRet2 = await this.customQuery(sql1, whereParams); let totalRet2 = await this.customQuery(sql1, whereParams);
let result = { let result = {
...@@ -1434,8 +1434,8 @@ class OrderInfoService extends ServiceBase { ...@@ -1434,8 +1434,8 @@ class OrderInfoService extends ServiceBase {
if (ab.start && ab.end) { if (ab.start && ab.end) {
listSql += ` and a.created_at >= :start and a.created_at <= :end`; listSql += ` and a.created_at >= :start and a.created_at <= :end`;
totalSql += ` 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.start = await this.getTimeSubtraction(ab.start);
whereParams.end = ab.end; whereParams.end = await this.getTimeSubtraction(ab.end);
} }
if (ab.uapp_id) { if (ab.uapp_id) {
listSql += ` and a.uapp_id = :uapp_id`; listSql += ` and a.uapp_id = :uapp_id`;
......
...@@ -151,12 +151,12 @@ class NeedinfoService extends ServiceBase { ...@@ -151,12 +151,12 @@ class NeedinfoService extends ServiceBase {
*/ */
async getStatisticsByUappId(pobj){ async getStatisticsByUappId(pobj){
let ac = pobj.actionBody; let ac = pobj.actionBody;
let sql = `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 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 = ac.start; whereParam.start =await this.getTimeSubtraction(ac.start);
whereParam.end = 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`;
...@@ -166,7 +166,7 @@ class NeedinfoService extends ServiceBase { ...@@ -166,7 +166,7 @@ class NeedinfoService extends ServiceBase {
sql += ` AND status = :status`; sql += ` AND status = :status`;
whereParam.status = ac.status; whereParam.status = ac.status;
} }
sql += ` GROUP BY uapp_id,DATE_FORMAT(created_at,'%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);
} }
...@@ -186,8 +186,8 @@ class NeedinfoService extends ServiceBase { ...@@ -186,8 +186,8 @@ class NeedinfoService extends ServiceBase {
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 = ac.start; whereParams.start =await this.getTimeSubtraction(ac.start);
whereParams.end = 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`;
...@@ -223,8 +223,8 @@ class NeedinfoService extends ServiceBase { ...@@ -223,8 +223,8 @@ class NeedinfoService extends ServiceBase {
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 = ac.start; whereParams.start = await this.getTimeSubtraction(ac.start);
whereParams.end = 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);
...@@ -242,8 +242,8 @@ class NeedinfoService extends ServiceBase { ...@@ -242,8 +242,8 @@ class NeedinfoService extends ServiceBase {
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 = ac.start; whereParams.start = await this.getTimeSubtraction(ac.start);
whereParams.end = ac.end; whereParams.end = await this.getTimeSubtraction(ac.start);
} }
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);
...@@ -275,8 +275,8 @@ class NeedinfoService extends ServiceBase { ...@@ -275,8 +275,8 @@ class NeedinfoService extends ServiceBase {
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 = ac.start; whereParams.start = await this.getTimeSubtraction(ac.start);
whereParams.end = 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`;
...@@ -304,8 +304,8 @@ class NeedinfoService extends ServiceBase { ...@@ -304,8 +304,8 @@ class NeedinfoService extends ServiceBase {
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 = ab.startNow; whereParams.start = await this.getTimeSubtraction(ab.startNow);
whereParams.end = 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`;
...@@ -320,8 +320,8 @@ class NeedinfoService extends ServiceBase { ...@@ -320,8 +320,8 @@ class NeedinfoService extends ServiceBase {
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 = ab.startLast; whereParams.start = await this.getTimeSubtraction(ab.startLast);
whereParams.end = 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);
...@@ -366,8 +366,8 @@ class NeedinfoService extends ServiceBase { ...@@ -366,8 +366,8 @@ class NeedinfoService extends ServiceBase {
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`;
needToOrderTotalSql += ` 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.start = await this.getTimeSubtraction(actionBody.start);
whereParams.end = actionBody.end; whereParams.end = await this.getTimeSubtraction(actionBody.end);
} }
if(actionBody.uapp_id){ if(actionBody.uapp_id){
......
...@@ -231,5 +231,10 @@ class ServiceBase { ...@@ -231,5 +231,10 @@ class ServiceBase {
} }
return uuid.join(''); return uuid.join('');
} }
async getTimeSubtraction(time){
let t = moment(time).subtract(8,'hours',).format();
return t;
}
} }
module.exports = ServiceBase; module.exports = ServiceBase;
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