Commit 7eabebef authored by 秦海涛's avatar 秦海涛

update

parent 9ed34853
......@@ -57,32 +57,19 @@ const getActivityListByOpenId = async function (context) {
loginfo(context, "getActivityListByOpenId");
const { openId } = context;
let ActivityConfig = new ActivityConfigService(context);
let ActivityInstance = new ActivityInstanceService(context);
let ActivitySeller = new ActivitySellerService(context);
try {
let sellInfo = await ActivitySeller.findSellerInfo(openId);
console.log(sellInfo, "sellInfo");
if (sellInfo && sellInfo[0]) {
let result = await ActivityConfig.getActivityListByOpenId(
sellInfo && sellInfo[0].shopId,
context.data
);
let instanceInfo = await ActivityInstance.getMiniAppInstanceInfoByNick(
sellInfo[0].userNick
);
if (result) {
result.list.map((item) => {
item.activityId = item._id;
item.onlineUrl =
instanceInfo && instanceInfo[0] ? instanceInfo[0].online_url : "";
return item;
});
return resultsModel.success(result);
}
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "查询活动列表失败");
} else {
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "小程序未授权");
let result = await ActivityConfig.getActivityListByOpenId(
openId,
context.data
);
if (result) {
result.list.map((item) => {
item.activityId = item._id;
return item;
});
return resultsModel.success(result);
}
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "查询活动列表失败");
} catch (e) {
console.log("catch", "查询活动列表失败");
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "查询活动列表失败");
......@@ -98,17 +85,11 @@ const saveActivityInfoByHasId = async function (context) {
const { openId } = context;
let {
title = "",
subtitle = "",
activityId = "",
startTime,
endTime,
rule,
logoImg = "",
prizeInfoList = [],
taskList = [],
commandTitle,
beenInvitedText,
commandImg,
rule,
} = context.data;
let initialData;
if (activityId) {
......@@ -122,26 +103,6 @@ const saveActivityInfoByHasId = async function (context) {
"活动名称不可超过12个字"
);
}
if (!subtitle) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, "活动副标题为空");
} else if (subtitle.length > 16) {
return resultsModel.error(
CODE_TYPES.PARAMS_ERROR,
"活动副标题不可超过16个字"
);
}
if (!logoImg) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, "logo图片必须配置");
}
if (!commandTitle) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, "邀请者淘口令必须配置");
}
if (!beenInvitedText) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, "被邀请者文案必须配置");
}
if (!commandImg) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, "淘口令图片必须配置");
}
if (taskList.length === 0) {
return resultsModel.error(CODE_TYPES.PARAMS_ERROR, "任务配置必须配置一项");
} else {
......@@ -263,10 +224,6 @@ const saveActivityInfoByHasId = async function (context) {
);
}
}
let shopInfoResult = await ActivityTop.getShopId();
if (!shopInfoResult.success) {
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "获取淘宝店铺信息失败");
}
console.log(shopInfoResult, "shopInfo");
const baseData = {
title,
......@@ -274,12 +231,7 @@ const saveActivityInfoByHasId = async function (context) {
startTime,
endTime,
rule,
shopId: shopInfoResult.data.sid,
openId,
beenInvitedText,
commandTitle,
commandImg,
logoImg,
taskList,
};
prizeInfoList = prizeInfoList.map((v, i) => {
......
......@@ -188,11 +188,11 @@ module.exports = class ActivityConfigService {
}
//通过openId去获取当前商家活动列表
async getActivityListByOpenId(shopId, { pageSize = 10, pageNo = 1 }) {
async getActivityListByOpenId(openId, { pageSize = 10, pageNo = 1 }) {
return {
list: await this.activityconfigDao.find(
{
shopId,
openId,
deleteStatus: DELETE_STATUS.EXIST,
},
{
......@@ -209,7 +209,7 @@ module.exports = class ActivityConfigService {
}
),
total: await this.activityconfigDao.count({
shopId,
openId,
deleteStatus: DELETE_STATUS.EXIST,
}),
pageSize,
......@@ -217,6 +217,7 @@ module.exports = class ActivityConfigService {
};
}
//通过activityId去获取活动配置信息
async getActivityInfoByActivityId(activityId) {
return {
......
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