Commit 9fef62dd authored by zhaofei's avatar zhaofei

s

parent 5041c6ee
......@@ -110,7 +110,7 @@ export default class BaseController {
async exportAwardsInfoBySearch(context: Context, { session }, [awardsService]: [AwardsService]) {
/******VV */
let { cloud } = context
let { activityId, title, prizeId, userId: userNick, timeStart, timeEnd, shipStatus, prizeDataType } = context.data
let { activityId, title, prizeId, userId: userNick, timeStart, timeEnd, shipStatus, prizeType: type, prizeDataType } = context.data
if (!activityId) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, `缺少activityId`)
}
......@@ -118,7 +118,7 @@ export default class BaseController {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, `缺少title`)
}
console.log('prizeId=====', prizeId)
if (!prizeId && !userNick && !timeStart && !timeEnd && !shipStatus && !prizeDataType) {
if (!prizeId && !userNick && !timeStart && !timeEnd && !shipStatus && !prizeDataType && !type) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, `未填写筛选信息`)
}
console.log(
......@@ -142,42 +142,42 @@ export default class BaseController {
timeStart,
timeEnd,
shipStatus,
type,
prizeDataType
)
let awardslist = []
//导出中奖名单的pagesize和pageNo
let pageSize0 = 500
let pageNo = 1
if (total > pageSize0) {
let totalPage = Math.ceil(total / pageSize0)
for (let i = 1; i <= totalPage; i++) {
pageNo = i
let awardMore = await awardsService.getUserPrizeByActivityId(
activityId,
pageNo,
pageSize0,
prizeId,
userNick,
timeStart,
timeEnd,
shipStatus,
prizeDataType
)
awardslist = awardslist.concat(awardMore)
}
} else {
awardslist = await awardsService.getUserPrizeByActivityId(
let pageSize0 = 500;
let pageNo = 1;
let totalPage = Math.ceil(total / pageSize0);
let result = []
for (let i = 1; i <= totalPage; i++) {
pageNo = i
result.push(awardsService.getUserPrizeByActivityId(
activityId,
pageNo,
total,
pageSize0,
prizeId,
userNick,
timeStart,
timeEnd,
shipStatus,
prizeDataType
)
))
}
const res = await Promise.all(result);
for (let i = 1; i <= totalPage; i++) {
awardslist.push(res[i])
}
// await Promise.all(result).then(res=>{
// for (let i = 1; i <= totalPage; i++) {
// awardslist.push(res[i])
// }
// })
console.log(`awardslist:》》》 ${JSON.stringify(awardslist)}《《《`)
if (awardslist.length > 0) {
let xlsxData = [
......@@ -214,7 +214,7 @@ export default class BaseController {
v.name || '',
v.type == 1 ? '/' : v.receiveName || '',
v.type == 1 ? '/' : v.phone || '未填',
v.type == 1 ? '/' : v.province ? v.province: '未填',
v.type == 1 ? '/' : v.province ? v.province : '未填',
v.type == 1 ? '/' : v.city ? v.city : '未填',
v.type == 1 ? '/' : v.area ? v.area : '未填',
v.type == 1 ? '/' : v.addressDetail ? v.addressDetail : '未填',
......@@ -263,6 +263,7 @@ export default class BaseController {
timeStart,
timeEnd,
shipStatus,
prizeType: type,
prizeDataType
} = context.data
console.log('data>>>>>', context.data)
......@@ -273,7 +274,7 @@ export default class BaseController {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, `缺少title`)
}
console.log('prizeId=====', prizeId)
if (!prizeId && !userNick && !timeStart && !timeEnd && !shipStatus && !prizeDataType) {
if (!prizeId && !userNick && !timeStart && !timeEnd && !shipStatus && !prizeDataType && !type) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, `未填写筛选信息`)
}
console.log(
......@@ -297,6 +298,7 @@ export default class BaseController {
timeStart,
timeEnd,
shipStatus,
type,
prizeDataType
)
console.log('totle=========', total)
......
......@@ -106,9 +106,11 @@ export default class AwardsService {
timeStart: number,
timeEnd: number,
shipStatus: number,
type: number
type: number,
prizeDataType: number
) {
let p = prizeId ? { _id: prizeId } : ''
let pt = prizeDataType ? { prizeDataType: prizeDataType } : ''
let u = userNick ? { userNick: { $regex: '.*' + userNick + '.*' } } : ''
let c = timeStart > 0 && timeEnd > 0 ? { createTime: { $gt: timeStart, $lt: timeEnd } } : ''
let s = shipStatus
......@@ -119,7 +121,7 @@ export default class AwardsService {
: { shipStatus: SHIP_STATUS.HAS_SHIP }
: ''
let t = type ? { type: +type } : ''
let arr = [p, u, c, s, t]
let arr = [p, u, c, s, t, pt]
arr = arr.filter(i => {
return i
})
......@@ -160,4 +162,4 @@ export default class AwardsService {
return 0
}
}
}
}
\ No newline at end of file
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