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

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

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