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

update

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