|
|
@ -7,7 +7,7 @@ class DingdanService extends Service { |
|
|
|
let { ctx } = this |
|
|
|
let modelLocal = ctx.model.Dingdan |
|
|
|
let chanpinModel = ctx.model.Chanpin |
|
|
|
let returnData = { hasError: false, msg: "数据错误", list: [] } |
|
|
|
let returnData = { hasError: false, msg: "数据错误", list: [], allxiaoshoujine: 0 } |
|
|
|
//新增
|
|
|
|
let subType = params.subType |
|
|
|
let returnComponent = params.returnData || [] |
|
|
@ -50,6 +50,23 @@ class DingdanService extends Service { |
|
|
|
let paramsLocalInfo = _.omit(paramsLocal, ["pageSize", "currentPage", "url"]) |
|
|
|
let paramsLocalInfoNotDel = { ...paramsLocalInfo, isExit: 1 } |
|
|
|
let res = await modelLocal.find(paramsLocalInfoNotDel).sort({ update_at: -1 }).skip((currentPage - 1) * pageSize).limit(pageSize) |
|
|
|
let whereOther = paramsLocalInfoNotDel["$where"] |
|
|
|
let paramsLocalInfoAgg = _.omit(paramsLocalInfoNotDel, ["$where"]) |
|
|
|
if (whereOther === "this.zuigaocaigoujia > this.xiaoshoujine") { |
|
|
|
paramsLocalInfoAgg["$expr"] = { |
|
|
|
"$gt": ["$zuigaocaigoujia", "$xiaoshoujine"] |
|
|
|
} |
|
|
|
} else if (whereOther === "this.pinmingxuanxiang.length>1") { |
|
|
|
paramsLocalInfoAgg["$expr"] = { |
|
|
|
"$gt": [{ "$size": "$pinmingxuanxiang" }, 1] |
|
|
|
} |
|
|
|
} |
|
|
|
let allxiaoshoujine = await modelLocal.aggregate([{ |
|
|
|
$match: paramsLocalInfoAgg, |
|
|
|
}, |
|
|
|
{ |
|
|
|
$group: { _id: null, totalSaleAmount: { $sum: '$xiaoshoujine' } } |
|
|
|
}]) |
|
|
|
let resData = []; |
|
|
|
for (let i = 0; i < res.length; i++) { |
|
|
|
let elei = res[i]; |
|
|
@ -66,6 +83,7 @@ class DingdanService extends Service { |
|
|
|
} |
|
|
|
returnData.hasError = false |
|
|
|
returnData.msg = "查询成功" |
|
|
|
returnData.allxiaoshoujine = Number(Number((_.get(allxiaoshoujine, [0, "totalSaleAmount"], 0)) || 0).toFixed(2)) |
|
|
|
returnData.list = resData |
|
|
|
} |
|
|
|
let allParamsLocalInfo = _.omit(paramsLocal, ["pageSize", "currentPage", "url"]) |
|
|
|