Commit 62aff32d authored by 管新明's avatar 管新明

fix

parent 3c448328
/** @format */
import { CODE_TYPES, EIGHT_HOURS,PRIZE_TYPE,SHIP_STATUS } from './../constants' import { CODE_TYPES, EIGHT_HOURS,PRIZE_TYPE,SHIP_STATUS } from './../constants'
import { services, paramsCheck } from '../decorator' import { services, paramsCheck } from '../decorator'
...@@ -52,17 +50,17 @@ export default class BaseController { ...@@ -52,17 +50,17 @@ export default class BaseController {
async getAwardsList(context: Context, { session }, [awardsService]: [AwardsService]) { async getAwardsList(context: Context, { session }, [awardsService]: [AwardsService]) {
let { cloud } = context let { cloud } = context
let { let {
activityId = '', activityId,
title = '', title,
pageNo = 1, prizeId,
pageSize = 10, userNick,
prizeId = null, startTime,
userNick = '', endTime,
prizeType = null, shipStatus,
prizeDataType = null, prizeType,
shipStatus = null, prizeDataType,
startTime = null, pageNo,
endTime = null, pageSize
} = context.data } = context.data
// 获取活动中奖列表 // 获取活动中奖列表
let awardList = await awardsService.getAwardListByActivityId({ let awardList = await awardsService.getAwardListByActivityId({
...@@ -107,20 +105,30 @@ export default class BaseController { ...@@ -107,20 +105,30 @@ export default class BaseController {
} }
console.log(list, '导出报表') console.log(list, '导出报表')
let xlsxData = [ let xlsxData = [
// [ [
// <% for(var i = 0; i < winnersExportData.length; ++i) {%> '奖品编号',
// <%- `${winnersExportData[i]},` %> '用户id',
// <% } %> '中奖时间',
// ] '地址填写时间',
'奖品类型',
'发奖来源',
'奖品名称',
'收货人',
'联系方式',
'收货地址',
'发货状态',
'物流公司',
'物流单号'
]
] ]
res.forEach((v, index, arr) => { res.forEach((v, index, arr) => {
let prizeDataType = '/'; let prizeDataType = '/';
let prizeType = '/'; let prizeType = '/';
let shipTxt = '/'; let shipTxt = '/';
if (v) { if (v) {
// <% for(var i = 0; i < formatPrize.length; ++i) {%> <% for(var i = 0; i < formatPrize.length; ++i) {%>
// <%- `if (v.prizeDataType == ${formatPrize[i].prizeDataType}) prizeDataType = '${formatPrize[i].prizeSource}'` <%- `if (v.prizeDataType == ${formatPrize[i].prizeDataType}) prizeDataType = '${formatPrize[i].name}'`
// %><% } %> %><% } %>
// if (v.prizeDataType == 1) prizeDataType = '关卡获得' // if (v.prizeDataType == 1) prizeDataType = '关卡获得'
// if (v.prizeDataType == 2) prizeDataType = '排行榜' // if (v.prizeDataType == 2) prizeDataType = '排行榜'
// if (v.prizeDataType == 3) prizeDataType = '分享获得' // if (v.prizeDataType == 3) prizeDataType = '分享获得'
...@@ -136,19 +144,19 @@ export default class BaseController { ...@@ -136,19 +144,19 @@ export default class BaseController {
if (v.type == PRIZE_TYPE.THANK) prizeType = '谢谢参与' if (v.type == PRIZE_TYPE.THANK) prizeType = '谢谢参与'
} }
xlsxData.push([ xlsxData.push([
// <%- winnersExportData.includes('奖品编号') && `v._id,` %> v._id,
// <%- winnersExportData.includes('用户id') && `v.userNick,` %> v.userNick,
// <%- winnersExportData.includes('中奖时间') && `v.createTime ? formatTime(new Date(v.createTime + EIGHT_HOURS)) : '',` %> v.createTime ? formatTime(new Date(v.createTime + EIGHT_HOURS)) : '',
// <%- winnersExportData.includes('地址填写时间') && `v.type == 3 ? (v.receiveTime ? formatTime(new Date(v.receiveTime + EIGHT_HOURS)) : '暂未填写') : '/',` %> v.type == 3 ? (v.receiveTime ? formatTime(new Date(v.receiveTime + EIGHT_HOURS)) : '暂未填写') : '/',
// <%- winnersExportData.includes('奖品类型') && `prizeType` %> prizeType,
// <%- winnersExportData.includes('发奖来源') && `prizeDataType,` %> prizeDataType,
// <%- winnersExportData.includes('奖品名称') && `v.type == 2 ? `${v.credits || 0}积分` : v.name || '',` %> v.type == 2 ? `${v.credits || 0}积分` : v.name || '',
// <%- winnersExportData.includes('收货人') && `v.type == 3 ? v.receiveName || '' : '/',` %> v.type == 3 ? v.receiveName || '' : '/',
// <%- winnersExportData.includes('联系方式') && `v.type == 3 ? (v.phone ? v.phone + '' : '暂未填写') : '/',` %> v.type == 3 ? (v.phone ? v.phone + '' : '暂未填写') : '/',
// <%- winnersExportData.includes('收货地址') && `v.type == 3 ? v.province + v.city + v.area + v.streetName + v.addressDetail || '暂未填写' : '/',` %> v.type == 3 ? v.province + v.city + v.area + v.streetName + v.addressDetail || '暂未填写' : '/',
// <%- winnersExportData.includes('发货地址') && `shipTxt,` %> shipTxt,
// <%- winnersExportData.includes('物流公司') && `v.type == 3 ? v.shipCompany || '' : '/',` %> v.type == 3 ? v.shipCompany || '' : '/',
// <%- winnersExportData.includes('物流单号') && `v.type == 3 ? (v.shipNum ? v.shipNum + '' : '') : '/'` %> v.type == 3 ? (v.shipNum ? v.shipNum + '' : '') : '/'
]) ])
}) })
let buffer = xlsx.build([ let buffer = xlsx.build([
......
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