Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (req , res , next)=>{
let query = req.query;
let ep = new eventproxy();
req.models.ads2_new_rebate_order_shop_info.find({
date : orm.between(query.startTime , query.endTime),
day_type : query.day_type,
rebate_type : orm.not_in(["ALL"]),
plan_id : orm.not_in(["ALL"]),
unique_plan_id_num : orm.gt(0)
} , {
limit : query.limit / 1 || 20,
offset : query.limit * (query.page - 1) / 1 || 0,
order : ["-unique_is_rebate_order_num"]
} , (err , data) => {
ep.emit("one" , data);
});
req.models.ads2_new_rebate_order_shop_info.find({
date : orm.between(query.startTime , query.endTime),
day_type : query.day_type,
}).count((err , data) => {
const now = new Date();
const year = moment(now).format("YYYY");
const month = moment(now).format("MM");
let start;
let end;
if(+month >= 3) {
start = moment(new Date(new Date(year, month - 2, 1) - 24 * 60 * 60 * 1000)).format("YYYY-MM-DD");
end = moment(new Date(new Date(year, month - 1, 1) - 24 * 60 * 60 * 1000)).format("YYYY-MM-DD");
} else if(+month === 2) {
start = moment(new Date(new Date(year - 1, 12, 1) - 24 * 60 * 60 * 1000)).format("YYYY-MM-DD");
end = moment(new Date(new Date(year, 1, 1) - 24 * 60 * 60 * 1000)).format("YYYY-MM-DD");
} else {
start = moment(new Date(new Date(year - 1, 11, 1) - 24 * 60 * 60 * 1000)).format("YYYY-MM-DD");
end = moment(new Date(new Date(year - 1, 12, 1) - 24 * 60 * 60 * 1000)).format("YYYY-MM-DD");
}
params.date = orm.between(start, end);
delete params.day_type;
return params;
},
secondParams(query, params) {
secondParams(query, params, data) {
var now = new Date().getTime(),
date = util.getDate(new Date(now - 24 * 60 * 60 * 1000)),
topic_ids = _.uniq(_.pluck(data, "topic_id"));
return {
topic_id : topic_ids,
date : orm.between(date + " 00:00:00", date + " 23:59:59"),
key : ["topic_reply_num", "topic_praise_num", "topic_subreply_user_num",
"topic_reply_user_num", "topic_subreply_num", "topic_collect_num"]
};
},
thirdParams(query, params, data) {
params() {
var now = new Date(),
ydate = util.getDate(new Date(now.getTime() - 24 * 60 * 60 * 1000));
return {
date : orm.between(new Date(ydate + " 00:00:00"), new Date(ydate + " 23:59:59")),
type : "H5",
region : orm.not_in(["ALL"]),
day_type : 1
}
},
flexible_btn: [{
return (req , res , next) => {
let query = req.query;
if(!query.startTime){
res.json({
code: 200,
components: Component,
modelData: [],
});
return;
}
let dates = util.times(query.startTime, query.endTime, "1");
req.models.ImDetail.find({
date : orm.between(query.startTime , query.endTime),
day_type: query.day_type
} , (err , data) => {
let map;
if(query.message_type == "number"){
map = {
"single_mess_pv" : "单聊",
"group_mess_pv" : "群聊"
}
}else{
map = {
"single_mess_uv" : "单聊",
"group_mess_uv" : "群聊"
}
}
let Result = util.ChartData(dates , Object.keys(map));
//加载数据
fixedParams(query, filter_key, req, cb) {
query.type = "2";
if(!query.coupon_id) {
query.created_at =
orm.between(
new Date(query.startTime + " 00:00:00").getTime()/1000,
new Date(query.endTime + " 23:59:59").getTime()/1000
);
}
query.date = orm.between(
new Date(util.getDate(new Date(new Date() - 24 * 60 * 60 * 1000)) + " 00:00:00"),
new Date(util.getDate(new Date(new Date() - 24 * 60 * 60 * 1000)) + " 23:59:59")
);
cb(null, query);
},
params(query, filter_key) {
fixedParams(query, filter_key, req, cb) {
var endTime = new Date(query.startTime + " 23:59:59"),
startTime = util.date(query.startTime, query.day_type);
query.date = orm.between(startTime, endTime);
query.type = "1";
cb(null, query);
},
filter(data, filter_key, dates, filter_key2, page, params) {
_sendData(type, req, res, next) {
var query = req.query,
params = {},
dates = [];
if(!query.startTime && !query.endTime) {
params = this.default;
} else {
if((this._checkDate(query.startTime, "startTime参数出错", next)
&& this._checkDate(query.endTime, "endTime参数出错", next))) {
params.date = orm.between(new Date(query.startTime + " 00:00:00"), new Date(query.endTime + " 23:59:59"));
Object.keys(this.default).forEach((key) => {
if(key !== "date" && !query[key]) {
params[key] = this.default[key];
}
});
dates = utils.times(query.startTime, query.endTime, query.day_type);
}
}
Object.keys(query).forEach((key) => {
if(key.indexOf("filter") > -1) {
this[key] = query[key];
delete query[key];
}
if(key === "key_type") {
this[key] = query[key];
}
params(query) {
var now = new Date(),
ydate = util.getDate(new Date(now.getTime() - 24 * 60 * 60 * 1000)),
qdate = util.getDate(new Date(now.getTime() - 2 * 24 * 60 * 60 * 1000)),
params = {
date : orm.between(new Date(qdate + " 00:00:00"), new Date(ydate + " 23:59:59")),
region : "ALL",
day_type : 1,
type : query.type || "ios"
};
return params;
},
secondParams(query, params) {
params(query, params) {
params.date = orm.between(
moment(new Date(query.startTime)).format("YYYY-MM-DD"),
moment(new Date(query.endTime)).format("YYYY-MM-DD")
);
params.ver = "all";
return params;
},
filter(data, query) {