Commit 9fef62dd authored by zhaofei's avatar zhaofei

s

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