Commit 54f9315e authored by 李硕's avatar 李硕

导出中奖名单的奖池类型字段prizeDataType修改和保存活动接口的防连点

parent e36dc314
...@@ -379,6 +379,14 @@ Component({ ...@@ -379,6 +379,14 @@ Component({
this.showItemTips('useUrlTips', 'success', ''); this.showItemTips('useUrlTips', 'success', '');
} }
} }
if (type == OBJECT_TYPE) {
if (!goodId) {
this.showItemTips('goodIdTips', 'error', '请选择商品链接');
}
else {
this.showItemTips('goodIdTips', 'success', '');
}
}
if (type == EQUITY_TYPE || type == OBJECT_TYPE) { if (type == EQUITY_TYPE || type == OBJECT_TYPE) {
if (!desc) { if (!desc) {
this.showItemTips('prizeDescTips', 'error', '请填写奖品描述'); this.showItemTips('prizeDescTips', 'error', '请填写奖品描述');
...@@ -458,7 +466,7 @@ Component({ ...@@ -458,7 +466,7 @@ Component({
return; return;
} }
} }
const { probabilityTips, prizeNumberTips, creditsValueTips, useUrlTips, prizeDescTips } = this.data; const { probabilityTips, prizeNumberTips, creditsValueTips, useUrlTips, prizeDescTips,goodIdTips } = this.data;
const isImagePass = image && imageTips.status !== "error"; const isImagePass = image && imageTips.status !== "error";
let stockPass = true; let stockPass = true;
...@@ -481,7 +489,7 @@ Component({ ...@@ -481,7 +489,7 @@ Component({
isImagePass && isImagePass &&
probabilityTips.status !== "error" && probabilityTips.status !== "error" &&
prizeNumberTips.status !== "error" && prizeNumberTips.status !== "error" &&
useUrlTips.status !== "error" && goodIdTips.status !== "error" &&
prizeDescTips.status !== "error"; prizeDescTips.status !== "error";
const isCreditsPass = const isCreditsPass =
type == CREDITS_TYPE && type == CREDITS_TYPE &&
......
...@@ -47,7 +47,7 @@ Component({ ...@@ -47,7 +47,7 @@ Component({
image: "", image: "",
credits: "", credits: "",
name: "", name: "",
switchStock:STOCK_NO_LIMIT, switchStock: STOCK_NO_LIMIT,
useStock: 0, useStock: 0,
rank: "2" rank: "2"
}, },
...@@ -68,7 +68,7 @@ Component({ ...@@ -68,7 +68,7 @@ Component({
commandImg: '', commandImg: '',
logoImg: '', logoImg: '',
beenInvitedText: '', beenInvitedText: '',
taskList:[ taskList: [
// { // {
// type: "beMembership",//会员 // type: "beMembership",//会员
// value: 20,//完成任务获得值 // value: 20,//完成任务获得值
...@@ -132,7 +132,7 @@ Component({ ...@@ -132,7 +132,7 @@ Component({
// value: '', // value: '',
// }, // },
beMembership: { beMembership: {
value:'', value: '',
checked: false checked: false
}, },
// sign: { // sign: {
...@@ -179,7 +179,8 @@ Component({ ...@@ -179,7 +179,8 @@ Component({
isStart: false, isStart: false,
originalStartTime: '', originalStartTime: '',
prizeDialogData: {}, prizeDialogData: {},
formState: formatValidator(descriptor) formState: formatValidator(descriptor),
isPostParams: true
}, },
props: {}, props: {},
didMount() { didMount() {
...@@ -229,12 +230,12 @@ Component({ ...@@ -229,12 +230,12 @@ Component({
}, },
setDataByKey(name, val) { setDataByKey(name, val) {
const keys = name.split('.'); const keys = name.split('.');
if(keys.length === 1) { if (keys.length === 1) {
this.setData({ this.setData({
[keys[0]]: val [keys[0]]: val
}) })
} }
if(keys.length === 2) { if (keys.length === 2) {
let targetKey = this.data[keys[0]]; let targetKey = this.data[keys[0]];
targetKey[keys[1]] = val; targetKey[keys[1]] = val;
let newVal = Object.assign({}, targetKey) let newVal = Object.assign({}, targetKey)
...@@ -242,7 +243,7 @@ Component({ ...@@ -242,7 +243,7 @@ Component({
[keys[0]]: newVal [keys[0]]: newVal
}) })
} }
if(keys.length === 3) { if (keys.length === 3) {
let targetKey = this.data[keys[0]]; let targetKey = this.data[keys[0]];
targetKey[keys[1]][keys[2]] = val; targetKey[keys[1]][keys[2]] = val;
let newVal = Object.assign({}, targetKey) let newVal = Object.assign({}, targetKey)
...@@ -302,7 +303,7 @@ Component({ ...@@ -302,7 +303,7 @@ Component({
console.log('fields', fields); console.log('fields', fields);
const { formState } = _this.data; const { formState } = _this.data;
_this.setFormTips(formState, errors, target) _this.setFormTips(formState, errors, target)
if(errors) { if (errors) {
resolve(false); resolve(false);
} else { } else {
resolve(true); resolve(true);
...@@ -317,10 +318,7 @@ Component({ ...@@ -317,10 +318,7 @@ Component({
let newValidator = {}; let newValidator = {};
Object.keys(formState).forEach(key => { Object.keys(formState).forEach(key => {
let error = errors.filter(v => target ? v.field === target && v.field === key : v.field === key).length && errors.filter(v => v.field === key)[0]; let error = errors.filter(v => target ? v.field === target && v.field === key : v.field === key).length && errors.filter(v => v.field === key)[0];
// 时间实时校验
if(key === 'timeRange' && formState[key].status === 'error') {
return
}
newValidator[key] = { newValidator[key] = {
status: error ? 'error' : 'success', status: error ? 'error' : 'success',
message: error ? error.message : '' message: error ? error.message : ''
...@@ -337,11 +335,11 @@ Component({ ...@@ -337,11 +335,11 @@ Component({
async onSubmit() { async onSubmit() {
const isValidForm = await this.validateForm(this.data); const isValidForm = await this.validateForm(this.data);
// console.log(this.formatActivityParams(this.data)) // console.log(this.formatActivityParams(this.data))
if(!isValidForm) return; if (!isValidForm) return;
console.log('成功') console.log('成功')
...@@ -349,17 +347,20 @@ Component({ ...@@ -349,17 +347,20 @@ Component({
console.log(params) console.log(params)
if (this.data.isPostParams) {
saveActivityInfo(params) this.setData({
.then(res => { isPostParams: false
if (res.success) {
this.backList()
} else {
this.showFailToast(res.message)
}
}).catch(err => {
console.log(err)
}) })
const { success, message } = await saveActivityInfo(params);
if (success) {
this.backList();
this.setData({
isPostParams: true
})
} else {
this.showFailToast(message);
}
}
}, },
showFailToast(text) { showFailToast(text) {
my.showToast({ my.showToast({
...@@ -386,7 +387,7 @@ Component({ ...@@ -386,7 +387,7 @@ Component({
beenInvitedText, beenInvitedText,
} = params; } = params;
return { return {
id, id,
activityId, activityId,
...@@ -407,7 +408,7 @@ Component({ ...@@ -407,7 +408,7 @@ Component({
formatTaskMapToList(taskMap) { formatTaskMapToList(taskMap) {
let list = []; let list = [];
Object.keys(taskMap).forEach(type => { Object.keys(taskMap).forEach(type => {
if(!taskMap[type].checked) return; if (!taskMap[type].checked) return;
let task = { let task = {
...taskMap[type], ...taskMap[type],
type type
...@@ -427,10 +428,10 @@ Component({ ...@@ -427,10 +428,10 @@ Component({
// 补足谢谢参与类型 // 补足谢谢参与类型
formatPobalityPrizeList(prizeInfoList = []) { formatPobalityPrizeList(prizeInfoList = []) {
let totalPercent = prizeInfoList.reduce((total, next) => { let totalPercent = prizeInfoList.reduce((total, next) => {
return total = addFloat(total, +next.probability) return total = addFloat(total, +next.probability)
}, 0) }, 0)
// 排名类型不含谢谢参与 // 排名类型不含谢谢参与
if(prizeInfoList[0].rank) return prizeInfoList; if (prizeInfoList[0].rank) return prizeInfoList;
let prizeInfoListCopy = prizeInfoList.concat().map((v, index) => ({ ...v, level: index })); let prizeInfoListCopy = prizeInfoList.concat().map((v, index) => ({ ...v, level: index }));
if (totalPercent < 100) { if (totalPercent < 100) {
......
...@@ -63,7 +63,7 @@ const findWinnerInfoList = async (context) => { ...@@ -63,7 +63,7 @@ const findWinnerInfoList = async (context) => {
let ad = item.province + item.city + item.area + item.addressdetail, type0 = item.type; let ad = item.province + item.city + item.area + item.addressdetail, type0 = item.type;
item.createTime = formatTime(new Date(item.createTime)) || ""; item.createTime = formatTime(new Date(item.createTime)) || "";
item.receiveTime = item.receiveTime ? formatTime(new Date(item.receiveTime)) : '未填'; item.receiveTime = item.receiveTime ? formatTime(new Date(item.receiveTime)) : '未填';
item.awardsType = prizePoolType[item.awardsType]; item.prizeDataType = prizePoolType[item.prizeDataType];
item.type = prizeKind[item.type]; item.type = prizeKind[item.type];
item.receiveName = type0 == 3 ? (item.receiveName || "未填") : '/'; item.receiveName = type0 == 3 ? (item.receiveName || "未填") : '/';
item.phone = type0 == 3 ? (item.phone || "未填") : '/'; item.phone = type0 == 3 ? (item.phone || "未填") : '/';
...@@ -127,9 +127,9 @@ const exportAwardsList = async (context) => { ...@@ -127,9 +127,9 @@ const exportAwardsList = async (context) => {
v.createTime ? formatTime(new Date(v.createTime + EIGHT_HOURS)) : "", v.createTime ? formatTime(new Date(v.createTime + EIGHT_HOURS)) : "",
v.type == 1 ? "/" : v.receiveTime ? formatTime(new Date(v.receiveTime + EIGHT_HOURS)) : "未填", v.type == 1 ? "/" : v.receiveTime ? formatTime(new Date(v.receiveTime + EIGHT_HOURS)) : "未填",
v.userNick || "/", v.userNick || "/",
prizePoolType[v.awardsType], prizePoolType[v.prizeDataType],
prizeKind[v.type], prizeKind[v.type],
v.name || "", v.prizeName || "",
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.city + v.area + v.addressdetail : "未填"), v.type == 1 ? "/" : (v.province ? v.province + v.city + v.area + v.addressdetail : "未填"),
...@@ -233,9 +233,9 @@ const exportAwardsInfoBySearch = async (context) => { ...@@ -233,9 +233,9 @@ const exportAwardsInfoBySearch = async (context) => {
v.createTime ? formatTime(new Date(v.createTime + EIGHT_HOURS)) : "", v.createTime ? formatTime(new Date(v.createTime + EIGHT_HOURS)) : "",
v.type == 1 ? "/" : v.receiveTime ? formatTime(new Date(v.receiveTime + EIGHT_HOURS)) : "未填", v.type == 1 ? "/" : v.receiveTime ? formatTime(new Date(v.receiveTime + EIGHT_HOURS)) : "未填",
v.userNick || "/", v.userNick || "/",
prizePoolType[v.awardsType], prizePoolType[v.prizeDataType],
prizeKind[v.type], prizeKind[v.type],
v.name || "", v.prizeName || "",
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.city + v.area + v.addressdetail : "未填"), v.type == 1 ? "/" : (v.province ? v.province + v.city + v.area + v.addressdetail : "未填"),
...@@ -325,7 +325,7 @@ const findWinnerInfoListBySearch = async (context) => { ...@@ -325,7 +325,7 @@ const findWinnerInfoListBySearch = async (context) => {
let ad = item.province + item.city + item.area + item.addressdetail, type0 = item.type; let ad = item.province + item.city + item.area + item.addressdetail, type0 = item.type;
item.createTime = formatTime(new Date(item.createTime)) || ""; item.createTime = formatTime(new Date(item.createTime)) || "";
item.receiveTime = item.receiveTime ? formatTime(new Date(item.receiveTime)) : '未填'; item.receiveTime = item.receiveTime ? formatTime(new Date(item.receiveTime)) : '未填';
item.awardsType = prizePoolType[item.awardsType]; item.prizeDataType = prizePoolType[item.prizeDataType];
item.type = prizeKind[item.type]; item.type = prizeKind[item.type];
item.receiveName = type0 == 3 ? (item.receiveName || "未填") : '/'; item.receiveName = type0 == 3 ? (item.receiveName || "未填") : '/';
item.phone = type0 == 3 ? (item.phone || "未填") : '/'; item.phone = type0 == 3 ? (item.phone || "未填") : '/';
......
...@@ -50,6 +50,7 @@ const getPrizeListAndAwards = async (activityId) => { ...@@ -50,6 +50,7 @@ const getPrizeListAndAwards = async (activityId) => {
}; };
}; };
// 获取待开奖列表 // 获取待开奖列表
const getWaitAwardsList = (prizeList, topscoreList, totalAwards, shopId) => { const getWaitAwardsList = (prizeList, topscoreList, totalAwards, shopId) => {
let waitAwardslist = []; let waitAwardslist = [];
...@@ -57,37 +58,40 @@ const getWaitAwardsList = (prizeList, topscoreList, totalAwards, shopId) => { ...@@ -57,37 +58,40 @@ const getWaitAwardsList = (prizeList, topscoreList, totalAwards, shopId) => {
if (!totalAwards || !topscoreList.length) { if (!totalAwards || !topscoreList.length) {
return waitAwardslist; return waitAwardslist;
} }
prizeList.forEach((v, index, arr) => { prizeList.forEach((prizeItem, index, arr) => {
if (!v.rank) { if (!prizeItem.rank) {
return; return;
} }
let rankPeriod = ~v.rank.indexOf("-") let rankPeriod = ~prizeItem.rank.indexOf("-")
? v.rank.split("-") ? prizeItem.rank.split("-")
: [v.rank, v.rank]; : [prizeItem.rank, prizeItem.rank];
// 截取排行区间的分数排行列表 // 截取排行区间的分数排行列表
let ranklist = topscoreList.slice( let ranklist = topscoreList.slice(
+rankPeriod[0] - 1, +rankPeriod[0] - 1,
Math.min(+rankPeriod[1], totalAwards) Math.min(+rankPeriod[1], totalAwards)
); );
// 整合开奖数据 // 整合开奖数据
ranklist.map((rank) => { ranklist.map((userItem) => {
waitAwardslist.push({ waitAwardslist.push({
activityId: v.activityId, activityId: prizeItem.activityId,
openId: rank.openId, rankRange: prizeItem.rank,
rankRange: v.rank, ename: prizeItem.ename,
rank: rank.rank, prizeDataType: prizeItem.prizeDataType,
ename: v.ename, startTime: prizeItem.startTime,
startTime: v.startTime, endTime: prizeItem.endTime,
endTime: v.endTime, prizeId: prizeItem._id,
prizeId: v._id, prizeName: prizeItem.name,
prizeName: v.name, image: prizeItem.image,
userNick: rank.userNick, type: prizeItem.type || "",
rankTime: rank.updateTime, amount: prizeItem.amount || "",
image: v.image, openId: userItem.openId,
maxScore: rank.maxScore, avatar: userItem.avatar,
shopId: shopId, rank: userItem.rank,
type: v.type || "", userNick: userItem.userNick,
amount: v.amount || "", rankTime: userItem.updateTime,
totalScore: userItem.totalScore,
drawStatus: DRAW_STATUS.WAITAWARD,
createTime: Date.now(),
createDay: Utils.default.dateFormatter( createDay: Utils.default.dateFormatter(
new Date(Date.now() + EIGHT_HOURS), new Date(Date.now() + EIGHT_HOURS),
"yyyy/MM/dd" "yyyy/MM/dd"
...@@ -98,6 +102,7 @@ const getWaitAwardsList = (prizeList, topscoreList, totalAwards, shopId) => { ...@@ -98,6 +102,7 @@ const getWaitAwardsList = (prizeList, topscoreList, totalAwards, shopId) => {
return waitAwardslist; return waitAwardslist;
}; };
// 设置活动开奖 // 设置活动开奖
const setActivity2openprize = async (waitAwardslist, _id) => { const setActivity2openprize = async (waitAwardslist, _id) => {
// 插入排行榜开奖记录表 rank_open_prize 若失败,则变更 // 插入排行榜开奖记录表 rank_open_prize 若失败,则变更
......
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