|
|
@ -7,15 +7,26 @@ class ExportDataService extends Service { |
|
|
|
let { ctx } = this |
|
|
|
let modelLocal = ctx.model[params.model] |
|
|
|
let subType = params.subType |
|
|
|
let paramsLocal = _.omit(params, ["subType", "url", "model"]) |
|
|
|
let whereOther = params["$where"] |
|
|
|
let paramsLocal = _.omit(params, ["subType", "url", "model", "$where"]) |
|
|
|
let paramsLocalInfoAgg = { ...paramsLocal, isExit: 1 } |
|
|
|
let msgObj = { |
|
|
|
exportS6: "成功导出S6订单", |
|
|
|
exportxiaoshou: "成功导出销售订单", |
|
|
|
} |
|
|
|
let ParamsLocalNotDel = { ...paramsLocal, isExit: 1 } |
|
|
|
let res = await modelLocal.find(ParamsLocalNotDel).sort({ update_at: -1 }) |
|
|
|
let count = await modelLocal.find(ParamsLocalNotDel).count() |
|
|
|
let returnData = { hasError: false, msg: msgObj[subType], subType, list: res, count } |
|
|
|
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 res = await modelLocal.aggregate([{ |
|
|
|
$match: paramsLocalInfoAgg, |
|
|
|
}, { $sort: { update_at: -1 } }]).exec() |
|
|
|
let returnData = { hasError: false, msg: msgObj[subType], subType, list: res } |
|
|
|
return returnData |
|
|
|
} |
|
|
|
} |
|
|
|