| | |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.ks.daylucky.pojo.DO.ActivityExtraInfo; |
| | | import com.ks.daylucky.pojo.DO.ActivityTag; |
| | | import com.ks.daylucky.pojo.VO.admin.ActivityAdminVo; |
| | | import com.ks.daylucky.service.ActivityExtraInfoService; |
| | | import com.ks.daylucky.service.ActivityTagService; |
| | | import com.ks.daylucky.util.factory.vo.ActivityAdminVoFactory; |
| | | import com.ks.daylucky.util.factory.vo.LuckyActivityFactory; |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.ks.lucky.exception.*; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | | @RequestMapping("/admin/activity") |
| | |
| | | @Resource |
| | | private ActivityExtraInfoService activityExtraInfoService; |
| | | |
| | | @Resource |
| | | private ActivityTagService activityTagService; |
| | | |
| | | /** |
| | | * 添加活动 |
| | |
| | | ActivityExtraInfo extraInfo = LuckyActivityFactory.getActivityExtra(vo.getOpenInfo()); |
| | | extraInfo.setActivityId(activityId); |
| | | activityExtraInfoService.add(extraInfo); |
| | | //提取Tags |
| | | if (vo.getActivity().getTags() != null && vo.getActivity().getTags().size() > 0) { |
| | | activityTagService.setTags(activityId, (vo.getActivity().getTags())); |
| | | } |
| | | |
| | | switch (type) { |
| | | //保存 |
| | |
| | | return JsonUtil.loadFalseResult("添加出错"); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getActivityDetail") |
| | | public String getActivityDetail(HttpServletRequest request, Long id) { |
| | | LuckyActivity activity = luckyActivityService.getActivityDetail(id); |
| | | List<ActivityTag> tagList = activityTagService.getTagList(id); |
| | | ActivityExtraInfo info = activityExtraInfoService.getDetail(activity.getId()); |
| | | ActivityAdminVo bean = ActivityAdminVoFactory.create(activity, tagList, info.getValidDay()); |
| | | return JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(bean)); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | UserInfo user = userInfoMap.get(Long.parseLong(info.getUid())); |
| | | |
| | | if (user != null) { |
| | | if (user.getId().longValue() == acceptData.getUid()) { |
| | | continue; |
| | | } |
| | | // if (user.getId().longValue() == acceptData.getUid()) { |
| | | // continue; |
| | | // } |
| | | voList.add(new ActivityJoinerRankInfoVO(new SimpleUser(user.getId(), user.getNickName(), user.getPortrait()), info.getRank(), info.getWeight())); |
| | | } |
| | | } |
| | |
| | | private String tagBgColor; |
| | | |
| | | @NotEmpty(message = "标签前景色不能为空") |
| | | private String tagFontColr; |
| | | private String tagFontColor; |
| | | |
| | | private Date createTime; |
| | | |
| | | private Date updateTime; |
| | | |
| | | private Integer weight; |
| | | |
| | | public String getTagFontColor() { |
| | | return tagFontColor; |
| | | } |
| | | |
| | | public void setTagFontColor(String tagFontColor) { |
| | | this.tagFontColor = tagFontColor; |
| | | } |
| | | |
| | | public Long getId() { |
| | | return id; |
| | |
| | | |
| | | public void setTagBgColor(String tagBgColor) { |
| | | this.tagBgColor = tagBgColor == null ? null : tagBgColor.trim(); |
| | | } |
| | | |
| | | public String getTagFontColr() { |
| | | return tagFontColr; |
| | | } |
| | | |
| | | public void setTagFontColr(String tagFontColr) { |
| | | this.tagFontColr = tagFontColr == null ? null : tagFontColr.trim(); |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | |
| | | package com.ks.daylucky.pojo.VO.admin; |
| | | |
| | | import com.ks.daylucky.pojo.DO.ActivityTag; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | |
| | | /** |
| | | * poster : https://daylucky-1255749512.cos.ap-nanjing.myqcloud.com/image/activity/poster/4dad5e05-9fa8-4f47-8b40-f5b5255ee4fc.png |
| | | */ |
| | | |
| | | private Long id; |
| | | private String poster; |
| | | private List<BannerBean> bannerList; |
| | | private List<ActivityTag> tags; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public List<BannerBean> getBannerList() { |
| | | return bannerList; |
| | |
| | | this.poster = poster; |
| | | } |
| | | |
| | | public List<ActivityTag> getTags() { |
| | | return tags; |
| | | } |
| | | |
| | | public void setTags(List<ActivityTag> tags) { |
| | | this.tags = tags; |
| | | } |
| | | |
| | | public static class BannerBean { |
| | | private String id; |
| | |
| | | * desc : 参与条件说明 |
| | | */ |
| | | |
| | | private Long id; |
| | | private AdInfoBean adInfo; |
| | | private Integer must; |
| | | private String desc; |
| | |
| | | |
| | | public void setMust(Integer must) { |
| | | this.must = must; |
| | | } |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getDesc() { |
| | |
| | | * minPersonCount : 1000 |
| | | * day : 2 |
| | | */ |
| | | |
| | | private Long id; |
| | | private Integer minPersonCount; |
| | | private Integer maxPersonCount; |
| | | private Integer day; |
| | | private String desc; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public Integer getMaxPersonCount() { |
| | | return maxPersonCount; |
| | | } |
| | | |
| | | public void setMaxPersonCount(Integer maxPersonCount) { |
| | | this.maxPersonCount = maxPersonCount; |
| | | } |
| | | |
| | | public String getDesc() { |
| | | return desc; |
| | |
| | | * data : {"total":"100","count":"1000","type":2} |
| | | * selected : true |
| | | */ |
| | | |
| | | private Long id; |
| | | private String title; |
| | | private DataBeanX data; |
| | | private String type; |
| | | private boolean selected; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getType() { |
| | | return type; |
| | |
| | | |
| | | |
| | | /** |
| | | * 设置TAG |
| | | * |
| | | * @param activityId |
| | | * @param tags |
| | | */ |
| | | public void setTags(Long activityId, List<ActivityTag> tags); |
| | | |
| | | |
| | | /** |
| | | * 获取标签列表 |
| | | * |
| | | * @param activityId |
| | |
| | | package com.ks.daylucky.service; |
| | | |
| | | import com.ks.daylucky.pojo.DO.ActivityExtraInfo; |
| | | import com.ks.daylucky.pojo.DO.UserActivityExtraInfo; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | |
| | |
| | | import com.ks.daylucky.pojo.DO.ActivityTag; |
| | | import com.ks.daylucky.service.ActivityTagService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | @Service |
| | | public class ActivityTagServiceImpl implements ActivityTagService { |
| | |
| | | activityTagMapper.insertSelective(tag); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void setTags(Long activityId, List<ActivityTag> tags) { |
| | | if (tags == null) { |
| | | return; |
| | | } |
| | | |
| | | List<ActivityTag> oList = getTagList(activityId); |
| | | |
| | | //删除TAG |
| | | if (tags.size() == 0) { |
| | | for (ActivityTag tag : oList) { |
| | | activityTagMapper.deleteByPrimaryKey(tag.getId()); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | //获取老ID |
| | | Set<Long> ids = new HashSet<>(); |
| | | for (ActivityTag tag : oList) { |
| | | ids.add(tag.getId()); |
| | | } |
| | | |
| | | for (int i = 0; i < tags.size(); i++) { |
| | | ActivityTag tag = tags.get(i); |
| | | tag.setWeight(tags.size() - i); |
| | | if (tag.getId() == null) { |
| | | //新增 |
| | | tag.setCreateTime(new Date()); |
| | | tag.setActivityId(activityId); |
| | | addActivityTag(tag); |
| | | } else { |
| | | ids.remove(tag.getId()); |
| | | //更新权重 |
| | | ActivityTag update = new ActivityTag(); |
| | | update.setId(tag.getId()); |
| | | update.setWeight(tag.getWeight()); |
| | | update(update); |
| | | } |
| | | } |
| | | |
| | | //删除需要删除的标签 |
| | | for (Long id : ids) { |
| | | delete(id); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<ActivityTag> getTagList(Long activityId) { |
| | | return activityTagMapper.listByActivityId(activityId); |
New file |
| | |
| | | package com.ks.daylucky.util.factory.vo; |
| | | |
| | | import com.ks.daylucky.pojo.DO.ActivityTag; |
| | | import com.ks.daylucky.pojo.VO.admin.ActivityAdminVo; |
| | | import com.ks.lucky.pojo.DO.*; |
| | | import com.ks.lucky.pojo.DTO.ActivityAwardParams; |
| | | import com.ks.lucky.pojo.DTO.sponsorad.AlipayLifeAdInfo; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class ActivityAdminVoFactory { |
| | | |
| | | |
| | | public static ActivityAdminVo create(LuckyActivity activity, List<ActivityTag> tagList,int validDay) { |
| | | ActivityAdminVo vo = new ActivityAdminVo(); |
| | | vo.setActivity(createActivityBean(activity, tagList)); |
| | | vo.setAwardInfo(createAwardList(activity)); |
| | | vo.setJoinInfo(createJoinInfo(activity)); |
| | | vo.setOpenInfo(createOpenInfo(activity)); |
| | | vo.getOpenInfo().setDay(validDay); |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * createActivityBean |
| | | * |
| | | * @param activity |
| | | * @param tagList |
| | | * @return |
| | | */ |
| | | public static ActivityAdminVo.ActivityBean createActivityBean(LuckyActivity activity, List<ActivityTag> tagList) { |
| | | ActivityAdminVo.ActivityBean bean = new ActivityAdminVo.ActivityBean(); |
| | | bean.setId(activity.getId()); |
| | | bean.setBannerList(createBannerList(activity.getBannerList())); |
| | | bean.setPoster(activity.getMaterialPoster()); |
| | | bean.setTags(tagList); |
| | | return bean; |
| | | } |
| | | |
| | | private static List<ActivityAdminVo.ActivityBean.BannerBean> createBannerList(List<LuckyActivityImage> imageList) { |
| | | List<ActivityAdminVo.ActivityBean.BannerBean> beanList = new ArrayList<>(); |
| | | for (LuckyActivityImage image : imageList) { |
| | | ActivityAdminVo.ActivityBean.BannerBean bean = new ActivityAdminVo.ActivityBean.BannerBean(); |
| | | bean.setId(image.getId()); |
| | | bean.setUrl(image.getUrl()); |
| | | beanList.add(bean); |
| | | } |
| | | return beanList; |
| | | } |
| | | |
| | | /** |
| | | * createAwardList |
| | | * |
| | | * @param activity |
| | | * @return |
| | | */ |
| | | private static List<ActivityAdminVo.AwardInfoBean> createAwardList(LuckyActivity activity) { |
| | | List<ActivityAdminVo.AwardInfoBean> list = new ArrayList<>(); |
| | | for (LuckyActivityAwards awards : activity.getAwardsList()) { |
| | | ActivityAdminVo.AwardInfoBean bean = new ActivityAdminVo.AwardInfoBean(); |
| | | bean.setId(awards.getId()); |
| | | bean.setTitle(""); |
| | | if (awards.getActivityAwardParams() != null) { |
| | | if (awards.getActivityAwardParams().getType() == ActivityAwardParams.ActivityAwardTypeEnum.alipayRedPackage) { |
| | | bean.setType(LuckyActivityAwardMaterial.ActivityAwardMaterialType.alipayRedPackage.name()); |
| | | ActivityAdminVo.AwardInfoBean.DataBeanX dataBeanX = new ActivityAdminVo.AwardInfoBean.DataBeanX(); |
| | | dataBeanX.setCount(awards.getCount()); |
| | | dataBeanX.setTotal(awards.getActivityAwardParams().getRedPackage()); |
| | | dataBeanX.setType(awards.getAwardWay()); |
| | | bean.setData(dataBeanX); |
| | | } |
| | | } |
| | | list.add(bean); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private static ActivityAdminVo.JoinInfoBean createJoinInfo(LuckyActivity activity) { |
| | | ActivityAdminVo.JoinInfoBean bean = new ActivityAdminVo.JoinInfoBean(); |
| | | bean.setId(activity.getSponsorInfo().getId()); |
| | | bean.setDesc(activity.getSponsorInfo().getAd().getDesc()); |
| | | if (activity.getSponsorInfo().getAd().getAdType() == LuckySponsorAd.SponsorAdType.alipayLife) { |
| | | bean.setMust(activity.getSponsorInfo().getAd().getAlipayLifeAdInfo().getMustAttention() ? 1 : 0); |
| | | ActivityAdminVo.JoinInfoBean.AdInfoBean adInfoBean = new ActivityAdminVo.JoinInfoBean.AdInfoBean(); |
| | | adInfoBean.setType(activity.getSponsorInfo().getAd().getAdType().name()); |
| | | ActivityAdminVo.JoinInfoBean.AdInfoBean.DataBean dataBean = new ActivityAdminVo.JoinInfoBean.AdInfoBean.DataBean(); |
| | | AlipayLifeAdInfo alipayLife = activity.getSponsorInfo().getAd().getAlipayLifeAdInfo(); |
| | | dataBean.setDesc(alipayLife.getDesc()); |
| | | dataBean.setIcon(alipayLife.getIcon()); |
| | | dataBean.setName(alipayLife.getName()); |
| | | dataBean.setSceneId(alipayLife.getSceneId()); |
| | | adInfoBean.setData(dataBean); |
| | | bean.setAdInfo(adInfoBean); |
| | | } |
| | | return bean; |
| | | } |
| | | |
| | | |
| | | private static ActivityAdminVo.OpenInfoBean createOpenInfo(LuckyActivity activity) { |
| | | ActivityAdminVo.OpenInfoBean bean = new ActivityAdminVo.OpenInfoBean(); |
| | | bean.setId(activity.getOpenInfo().getId()); |
| | | bean.setMinPersonCount(activity.getOpenInfo().getMinPersonCount()); |
| | | bean.setMaxPersonCount(activity.getMaxPersonCount()); |
| | | bean.setDesc(activity.getOpenInfo().getRemarks()); |
| | | return bean; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | public static LabelVO create(ActivityTag tag) { |
| | | LabelVO vo = new LabelVO(tag.getTagName(), tag.getTagBgColor(), tag.getTagFontColr()); |
| | | LabelVO vo = new LabelVO(tag.getTagName(), tag.getTagBgColor(), tag.getTagFontColor()); |
| | | return vo; |
| | | } |
| | | |
| | |
| | | */ |
| | | private static LuckyActivity createActivity(Long sponsorId, ActivityAdminVo.ActivityBean bean) { |
| | | LuckyActivity activity = new LuckyActivity(); |
| | | activity.setId(bean.getId()); |
| | | activity.setSponsorId(sponsorId); |
| | | activity.setMaterialPoster(bean.getPoster()); |
| | | activity.setMaxPersonCount(100000); |
| | |
| | | int level = 0; |
| | | for (ActivityAdminVo.AwardInfoBean bean : awardInfo) { |
| | | LuckyActivityAwards awards = new LuckyActivityAwards(); |
| | | awards.setId(bean.getId()); |
| | | awards.setMaterial(createAwardMaterial(bean)); |
| | | awards.setLevel(level++); |
| | | awards.setCount(bean.getData().getCount()); |
| | |
| | | */ |
| | | private static LuckyActivitySponsorInfo createSponsorInfo(Long sponsorId, ActivityAdminVo.JoinInfoBean bean) { |
| | | LuckyActivitySponsorInfo sponsorInfo = new LuckyActivitySponsorInfo(); |
| | | sponsorInfo.setId(bean.getId()); |
| | | sponsorInfo.setSponsorId(sponsorId); |
| | | sponsorInfo.setAd(createSponsorAd(sponsorId, bean)); |
| | | sponsorInfo.setSponsors(new LuckySponsors(sponsorId)); |
| | |
| | | */ |
| | | private static LuckyActivityOpenInfo createOpenInfo(ActivityAdminVo.OpenInfoBean bean) { |
| | | LuckyActivityOpenInfo openInfo = new LuckyActivityOpenInfo(); |
| | | openInfo.setId(bean.getId()); |
| | | openInfo.setOpenType(LuckyActivityOpenInfo.OPEN_TYPE_PERSON_AND_TIME); |
| | | openInfo.setMinPersonCount(bean.getMinPersonCount()); |
| | | openInfo.setRemarks(bean.getDesc()); |
| | |
| | | spring: |
| | | profiles: |
| | | active: dev |
| | | active: pro |
| | |
| | | <result column="activity_id" property="activityId" jdbcType="BIGINT"/> |
| | | <result column="tag_name" property="tagName" jdbcType="VARCHAR"/> |
| | | <result column="tag_bg_color" property="tagBgColor" jdbcType="VARCHAR"/> |
| | | <result column="tag_font_colr" property="tagFontColr" jdbcType="VARCHAR"/> |
| | | <result column="tag_font_color" property="tagFontColor" jdbcType="VARCHAR"/> |
| | | <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | <result column="weight" property="weight" jdbcType="INTEGER"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | id, activity_id, tag_name, tag_bg_color, tag_font_colr, create_time, update_time, |
| | | id, activity_id, tag_name, tag_bg_color, tag_font_color, create_time, update_time, |
| | | weight |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long"> |
| | |
| | | </delete> |
| | | <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.ks.daylucky.pojo.DO.ActivityTag"> |
| | | insert into activity_tag (id, activity_id, tag_name, |
| | | tag_bg_color, tag_font_colr, create_time, |
| | | tag_bg_color, tag_font_color, create_time, |
| | | update_time, weight) |
| | | values (#{id,jdbcType=BIGINT}, #{activityId,jdbcType=BIGINT}, #{tagName,jdbcType=VARCHAR}, |
| | | #{tagBgColor,jdbcType=VARCHAR}, #{tagFontColr,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, |
| | | #{tagBgColor,jdbcType=VARCHAR}, #{tagFontColor,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, |
| | | #{updateTime,jdbcType=TIMESTAMP}, #{weight,jdbcType=INTEGER}) |
| | | </insert> |
| | | <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" |
| | |
| | | <if test="tagBgColor != null"> |
| | | tag_bg_color, |
| | | </if> |
| | | <if test="tagFontColr != null"> |
| | | tag_font_colr, |
| | | <if test="tagFontColor != null"> |
| | | tag_font_color, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | create_time, |
| | |
| | | <if test="tagBgColor != null"> |
| | | #{tagBgColor,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="tagFontColr != null"> |
| | | #{tagFontColr,jdbcType=VARCHAR}, |
| | | <if test="tagFontColor != null"> |
| | | #{tagFontColor,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | #{createTime,jdbcType=TIMESTAMP}, |
| | |
| | | <if test="tagBgColor != null"> |
| | | tag_bg_color = #{tagBgColor,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="tagFontColr != null"> |
| | | tag_font_colr = #{tagFontColr,jdbcType=VARCHAR}, |
| | | <if test="tagFontColor != null"> |
| | | tag_font_color = #{tagFontColor,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | |
| | | set activity_id = #{activityId,jdbcType=BIGINT}, |
| | | tag_name = #{tagName,jdbcType=VARCHAR}, |
| | | tag_bg_color = #{tagBgColor,jdbcType=VARCHAR}, |
| | | tag_font_colr = #{tagFontColr,jdbcType=VARCHAR}, |
| | | tag_font_color = #{tagFontColor,jdbcType=VARCHAR}, |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | | update_time = #{updateTime,jdbcType=TIMESTAMP}, |
| | | weight = #{weight,jdbcType=INTEGER} |
| | |
| | | |
| | | } |
| | | |
| | | .tag-contaner { |
| | | display: flex; |
| | | word-break: break-word; |
| | | } |
| | | |
| | | .tag-contaner .tag { |
| | | padding: 3px 5px; |
| | | border-radius: 5px; |
| | | font-size: 14px; |
| | | margin-right: 10px; |
| | | position: relative; |
| | | } |
| | | |
| | | .tag-contaner .tag .del { |
| | | position: absolute; |
| | | top: -8px; |
| | | right: -8px; |
| | | width: 16px; |
| | | height: 16px; |
| | | |
| | | } |
| | | |
| | | |
| | | </style> |
| | | </head> |
| | |
| | | <img class="layui-upload-img poster" id="poster"> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | |
| | | </div> |
| | | </div> |
| | | <button class="layui-btn layui-btn-radius layui-btn-normal hidden" |
| | | |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appName" class="layui-form-label"> |
| | | 活动标签</label> |
| | | <div class="layui-input-inline"> |
| | | <div class="tag-contaner" id="tags"> |
| | | |
| | | <div v-for="(item,index) in activity.tags" class="tag" |
| | | v-bind:style="{'color':item.tagFontColor,'background':item.tagBgColor}"> |
| | | {{item.tagName}} |
| | | <img class="del" src="img/ic_close_img.png" v-on:click="delTag(index)"> |
| | | |
| | | </div> |
| | | |
| | | <div class="layui-btn layui-btn-xs" v-on:click="addTag">添加标签</div> |
| | | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <button class="layui-btn layui-btn-radius layui-btn-normal" |
| | | id="saveActivityInfo" lay-submit="">保存 |
| | | </button> |
| | | |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <button class="layui-btn layui-btn-radius layui-btn-normal hidden" id="saveAwardInfo" lay-submit="">保存 |
| | | <button class="layui-btn layui-btn-radius layui-btn-normal hidden" id="saveAwardInfo" lay-submit=""> |
| | | 保存 |
| | | </button> |
| | | |
| | | |
| | |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label"> |
| | | <span class="x-red">*</span>最大参与人数</label> |
| | | <div class="layui-input-inline"> |
| | | <label class="desc">最少1000人,最多100000人,默认5000人</label> |
| | | <div class="flex-row flex-center"> |
| | | <input type="text" name="maxPersonCount" required="" lay-verify="integer" |
| | | autocomplete="off" class="layui-input input-small" placeholder="正整数"> 人 |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label"> |
| | | <span class="x-red">*</span>开奖时间/活动有效期</label> |
| | | <div class="layui-input-inline"> |
| | | <label class="desc">至少1天,最多7天,默认3天(活动发布时起)</label> |
| | |
| | | </div> |
| | | </div> |
| | | |
| | | <button class="layui-btn layui-btn-radius layui-btn-normal hidden" id="saveOpenInfo" lay-submit="">保存 |
| | | <button class="layui-btn layui-btn-radius layui-btn-normal hidden" id="saveOpenInfo" lay-submit=""> |
| | | 保存 |
| | | </button> |
| | | </form> |
| | | </div> |
| | |
| | | console.log(field); |
| | | |
| | | if (!parseInt(field.minPersonCount)) { |
| | | common.notify.error("请填写正确的参与人数"); |
| | | common.notify.error("请填写正确的最小参与人数"); |
| | | return false; |
| | | } |
| | | |
| | | if (!parseInt(field.maxPersonCount)) { |
| | | common.notify.error("请填写正确的最大参与人数"); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | if (!parseInt(field.day)) { |
| | | common.notify.error("请填写正确的天数"); |
| | |
| | | common.notify.error("至少参与人数的范围为:1000-100000"); |
| | | return false; |
| | | } |
| | | |
| | | if (parseInt(field.maxPersonCount) < 1000 || parseInt(field.maxPersonCount) > 100000) { |
| | | common.notify.error("至多参与人数的范围为:1000-100000"); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | if (parseInt(field.day) < 1 || parseInt(field.day) > 7) { |
| | | common.notify.error("活动有效期的范围为:1-7"); |
| | |
| | | var posterFileList; |
| | | var bannerFileList; |
| | | common.initLayui(function () { |
| | | |
| | | |
| | | |
| | | |
| | | //layui相关初始化成功 |
| | | app.initData(); |
| | | |
| | |
| | | var app = new Vue({ |
| | | el: '#main', |
| | | data: { |
| | | activity: {}, |
| | | tempAwardsList: [], |
| | | openInfo: { |
| | | activity: { |
| | | tags: [] |
| | | }, |
| | | tempAwardsList: [], |
| | | openInfo: {}, |
| | | joinInfo: { |
| | | adInfo: {}}, |
| | | adInfo: {} |
| | | }, |
| | | temp: {//临时数据,用于提交到服务端 |
| | | |
| | | }, |
| | |
| | | watch: { |
| | | tempAwardsList: function () { |
| | | setTimeout(function () { |
| | | // layui.use(['form'], function () { |
| | | // form = layui.form; |
| | | // form.render(); |
| | | // }) |
| | | if (common.layuiForm) |
| | | common.layuiForm.render(); |
| | | }); |
| | | }, |
| | | activity: function () { |
| | | setTimeout(function () { |
| | | common.layuiForm.render(); |
| | | }); |
| | | } |
| | |
| | | this.openInfo = _.cloneDeep(temp.openInfo); |
| | | this.joinInfo = _.cloneDeep(temp.joinInfo); |
| | | }, |
| | | addTag: function () { |
| | | $this = this; |
| | | layer.open({ |
| | | type: 1 //Page层类型 |
| | | , |
| | | btn: ["确定", "取消"] |
| | | , |
| | | title: '添加标签' |
| | | , |
| | | skin: 'layui-layer-prompt' |
| | | , |
| | | content: "<div><input id='transfer-msg' type='text' class='layui-layer-input' value='' placeholder='标签内容'><input style='margin-top:10px;' type='text' class='layui-layer-input' value='' placeholder='标签背景颜色,如#FF0000'><input style='margin-top:10px;' type='text' class='layui-layer-input' value='' placeholder='标签字体颜色,如#FF0000'></div>" |
| | | , |
| | | yes: function (index, layero) { |
| | | //按钮【按钮一】的回调 |
| | | const tagName = $(layero).find("input").eq(0).val(); |
| | | const tagBgColor = $(layero).find("input").eq(1).val(); |
| | | const tagFontColor = $(layero).find("input").eq(2).val(); |
| | | if (tagName && tagBgColor && tagFontColor) { |
| | | if ($this.activity.tags == null) { |
| | | $this.activity.tags = []; |
| | | } |
| | | |
| | | for (var i = 0; i < $this.activity.tags.length; i++) { |
| | | |
| | | if ($this.activity.tags[i].tagName == tagName) { |
| | | common.notify.error("请不要添加相同的标签"); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | |
| | | $this.activity.tags.push({ |
| | | tagName: tagName, |
| | | tagBgColor: tagBgColor, |
| | | tagFontColor: tagFontColor, |
| | | }); |
| | | |
| | | layer.close(index) |
| | | } else { |
| | | common.notify.error("请将数据补充完整"); |
| | | |
| | | } |
| | | |
| | | } |
| | | }); |
| | | |
| | | |
| | | }, |
| | | delTag: function (index) { |
| | | this.activity.tags.splice(index, 1); |
| | | }, |
| | | //初始化数据 |
| | | initData() { |
| | | $this = this; |
| | | //获取是否有缓存 |
| | | var tempActivity = common.getTempData("activity"); |
| | | if (tempActivity) { |
| | | $this.setTempData(JSON.parse(tempActivity)); |
| | | } |
| | | |
| | | /**************初始化抽奖信息************/ |
| | | |
| | | //删除所有选择的文件 |
| | |
| | | common.layuiForm.on('submit(form-activity-info)', |
| | | function (data) { |
| | | field = common.layuiForm.val('form-activity-info'); |
| | | console.log(field) |
| | | if (!validManager.verifyActivityInfo()) { |
| | | app.finishSubmit(); |
| | | return false; |
| | |
| | | }, |
| | | |
| | | //添加 |
| | | requestAdd: function (data,type) { |
| | | requestAdd: function (data, type) { |
| | | var params = { |
| | | data: data, |
| | | type:type |
| | | type: type |
| | | } |
| | | |
| | | //发异步,把数据提交给php |
| | |
| | | icon: 6 |
| | | }, |
| | | function () { |
| | | layer.close(this); |
| | | layer.close(this); |
| | | }); |
| | | } else { |
| | | layer.msg(res.msg); |
| | |
| | | layer.close(app.submitLoading) |
| | | } |
| | | //所有数据已经取完 |
| | | var temp = JSON.stringify(this.temp); |
| | | if (finish) { |
| | | console.log("获取到的结果"); |
| | | console.log(this.temp); |
| | | // app.setTempData(this.temp); |
| | | // app.initData(); |
| | | this.requestAdd(JSON.stringify(this.temp),'publish'); |
| | | // this.requestAdd(JSON.stringify(this.temp), 'publish'); |
| | | //保存内容 |
| | | common.saveTempData("activity", temp); |
| | | window.location.href = "activity-preview.html" |
| | | } |
| | | }, |
| | | |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html class="x-admin-sm" xmlns:v-bind="http://www.w3.org/1999/xhtml"> |
| | | |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <title>欢迎页面-X-admin2.2</title> |
| | | <meta name="renderer" content="webkit"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" |
| | | content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
| | | <link rel="stylesheet" href="./css/font.css"> |
| | | <link rel="stylesheet" href="./css/xadmin.css"> |
| | | <link rel="stylesheet" href="./css/common.css"> |
| | | <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="./js/xadmin.js"></script> |
| | | <script type="text/javascript" src="./js/vue.min.js"></script> |
| | | <script src="js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> |
| | | <!-- 让IE8/9支持媒体查询,从而兼容栅格 --> |
| | | <!--[if lt IE 9]> |
| | | <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script> |
| | | <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> |
| | | <script src="js/http.js"></script> |
| | | |
| | | <![endif]--> |
| | | |
| | | <style> |
| | | body { |
| | | background: white; |
| | | } |
| | | |
| | | #main { |
| | | max-width: 700px; |
| | | padding: 20px; |
| | | } |
| | | |
| | | .item .title { |
| | | background: #EEEEEE; |
| | | color: black; |
| | | font-weight: bold; |
| | | padding: 2px 10px; |
| | | font-size: 16px; |
| | | } |
| | | |
| | | .item .content { |
| | | padding: 10px 10px; |
| | | font-size: 14px; |
| | | color: grey; |
| | | } |
| | | |
| | | p { |
| | | line-height: 20px; |
| | | } |
| | | |
| | | div { |
| | | line-height: 20px; |
| | | } |
| | | |
| | | .item .content .banner { |
| | | max-width: 150px; |
| | | max-height: 150px; |
| | | margin-right: 15px; |
| | | } |
| | | |
| | | .item .content .icon { |
| | | width: 60px; |
| | | height: 60px; |
| | | } |
| | | |
| | | </style> |
| | | </head> |
| | | <body> |
| | | <div id="main"> |
| | | |
| | | <div class="body"> |
| | | |
| | | |
| | | <div class="item"> |
| | | |
| | | <div class="title"> |
| | | 抽奖活动封面: |
| | | </div> |
| | | <div class="content"> |
| | | <img class="banner" v-bind:src="activity.poster"/> |
| | | </div> |
| | | |
| | | |
| | | </div> |
| | | |
| | | <div class="item"> |
| | | |
| | | <div class="title"> |
| | | 抽奖活动横幅: |
| | | </div> |
| | | <div class="content" style="display: flex;flex-wrap: wrap;"> |
| | | <img class="banner" v-bind:src="banner.url" v-for="banner in activity.bannerList"/> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | <div class="item"> |
| | | |
| | | <div class="title"> |
| | | 奖品信息共{{awardInfo.length}}项: |
| | | </div> |
| | | <div class="content"> |
| | | |
| | | <div class="award" v-for="(item,index) in awardInfo" style="display: flex;"> |
| | | 奖品信息{{index+1}}:[{{item.type}}]{{item.name}} 预估奖金成本:{{item.data.total}}元 |
| | | </div> |
| | | |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | <div class="item"> |
| | | |
| | | <div class="title"> |
| | | 参与条件: |
| | | </div> |
| | | <div class="content"> |
| | | |
| | | <div>{{joinInfo.must?'必要参与条件:':'非必要参与条件:'}}</div> |
| | | <div> |
| | | <p>sceneId:{{joinInfo.adInfo.data.sceneId}}</p> |
| | | <p>生活号名称:{{joinInfo.adInfo.data.name}}</p> |
| | | <p>生活号头像:</p> |
| | | <p><img class="icon" v-bind:src="joinInfo.adInfo.data.icon"></p> |
| | | |
| | | <p>参与条件说明:<br><span v-html="joinInfo.desc?joinInfo.desc.replace(/\n/g,'<br>') :'未设置'"> {{joinInfo.desc?joinInfo.desc :'未设置'}}</span> |
| | | </p> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | <div class="item"> |
| | | |
| | | <div class="title"> |
| | | 开奖条件: |
| | | </div> |
| | | <div class="content"> |
| | | <div>至少参与人数:{{openInfo.minPersonCount}}人</div> |
| | | <div>至多参与人数:{{openInfo.maxPersonCount}}人</div> |
| | | <div>有效期:{{openInfo.day}}天</div> |
| | | <div>开奖条件说明:</div> |
| | | <span v-html="openInfo.desc?openInfo.desc.replace(/\n/g,'<br>'):'无/未设置'"></span> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | <div class="item"> |
| | | 本次活动需要预付金额:<span style="color: red;font-size: 20px;">{{money}}元</span> |
| | | |
| | | |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <hr class="layui-bg-gray"> |
| | | |
| | | |
| | | <div class="bottom"> |
| | | <div class="layui-col-md4"> |
| | | <button class="layui-btn layui-btn-primary" v-on:click="back">返回修改</button> |
| | | </div> |
| | | |
| | | <div class="layui-col-md8" style="text-align: right;"> |
| | | <button class="layui-btn layui-btn-normal" style="width: 150px" v-on:click="saveActivity">仅保存</button> |
| | | |
| | | <button class="layui-btn" style="width: 150px" v-on:click="publishActivity">发布活动</button> |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <script src="js/lodash.js"></script> |
| | | <script src="js/common.js"></script> |
| | | |
| | | <script> |
| | | common.initLayui(function () { |
| | | //layui相关初始化成功 |
| | | app.initData(); |
| | | }); |
| | | |
| | | var data; |
| | | |
| | | var app = new Vue({ |
| | | el: '#main', |
| | | data: { |
| | | activity: {}, |
| | | awardInfo: [], |
| | | openInfo: {}, |
| | | joinInfo: { |
| | | adInfo: {} |
| | | }, |
| | | money: 0.00 |
| | | }, |
| | | created: function () { |
| | | |
| | | }, |
| | | methods: { |
| | | //初始化数据 |
| | | initData() { |
| | | data = common.getTempData("activity"); |
| | | if (!data) { |
| | | common.notify.error("活动数据为空") |
| | | return; |
| | | } |
| | | // var data = "{\"activity\":{\"id\":10048,\"poster\":\"https://daylucky-1255749512.cos.ap-nanjing.myqcloud.com/image/activity/poster/71b27cc5-d3cb-4bfc-b602-0326a44b7fb8.jpeg\",\"bannerList\":[],\"tags\":[]},\"joinInfo\":{\"id\":50,\"adInfo\":{\"data\":{\"icon\":\"https://daylucky-1255749512.cos.ap-nanjing.myqcloud.com/image/activity/sponsorad/ecd50bfd-6ae9-4246-9cca-45b95498dcdb.png\",\"name\":\"天天快省\",\"sceneId\":\"48a5df949dd5406193dcdba81f0bb9fd\",\"desc\":\"每天为广大用户提供日常生活热门资讯,推荐吃喝玩乐等优惠和内容服务\"},\"type\":\"alipayLife\"},\"must\":0,\"desc\":\"注:无需关注生活号,生活号仅作呈现\\n参与说明:\\n1. 本次抽奖活动是由生活号[天天快省]赞助所有奖品;\\n2. 本抽奖活动绝对真实有效、公平公正;\\n3. 感恩每个参与抽奖活动的用户;\"},\"openInfo\":{\"id\":50,\"minPersonCount\":40000,\"maxPersonCount\":50000,\"day\":3,\"desc\":\"1. 若累计参与抽奖人数不足40000人,本活动将不会开奖;\\n2. 在开奖时间提前达到30000人需等待至开奖时间达到后开奖;\\n3. 为了保障本抽奖活动公平性,抽奖人数达50000人后将会提前开奖;\\n4. 开奖后五分钟内中奖者即可收到中奖提醒消息。\"},\"awardInfo\":[{\"id\":92,\"title\":\"\",\"data\":{\"total\":2000,\"count\":1,\"type\":1},\"type\":\"alipayRedPackage\",\"selected\":false},{\"id\":93,\"title\":\"\",\"data\":{\"total\":5000,\"count\":500,\"type\":1},\"type\":\"alipayRedPackage\",\"selected\":false},{\"id\":94,\"title\":\"\",\"data\":{\"total\":10000,\"count\":5000,\"type\":2},\"type\":\"alipayRedPackage\",\"selected\":false}]}"; |
| | | var temp = JSON.parse(data); |
| | | for (key in temp) { |
| | | this[key] = temp[key]; |
| | | } |
| | | var money = 0; |
| | | for (var i = 0; i < this.awardInfo.length; i++) { |
| | | var award = this.awardInfo[i]; |
| | | var type = award.data.type; |
| | | switch (type) { |
| | | //平分 |
| | | case 1: |
| | | var percent = award.data.total / award.data.count; |
| | | award.type = '分' |
| | | award.name = "固定金额红包" + percent + "元×" + award.data.count + "份" |
| | | break; |
| | | //随机 |
| | | case 2: |
| | | award.type = '随' |
| | | award.name = this.awardInfo[i].name = "随机金额红包共" + award.data.total + "元," + award.data.count + "份" |
| | | break; |
| | | |
| | | } |
| | | money += parseFloat(this.awardInfo[i].data.total) |
| | | } |
| | | this.money = money; |
| | | }, |
| | | back: function () { |
| | | window.history.go(-1); |
| | | }, |
| | | //添加 |
| | | requestAdd: function (data, type) { |
| | | var params = { |
| | | data: data, |
| | | type: type |
| | | } |
| | | |
| | | common.show |
| | | |
| | | //发异步,把数据提交给php |
| | | ksapp.post('/admin/activity/addActivity', params, function (res) { |
| | | if (res.code == 0) { |
| | | var index = layer.alert("增加成功", { |
| | | icon: 6 |
| | | }, |
| | | function () { |
| | | layer.close(index); |
| | | }); |
| | | common.removeTempData("activity"); |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | |
| | | }, function (res) { |
| | | }); |
| | | }, |
| | | |
| | | saveActivity: function () { |
| | | this.requestAdd(data, 'save'); |
| | | }, |
| | | publishActivity: function () { |
| | | this.requestAdd(data, 'publish'); |
| | | }, |
| | | } |
| | | }); |
| | | </script> |
| | | </body> |
| | | |
| | | </html> |
| | |
| | | , common.layuiElement = layui.element |
| | | , common.layuiLayer = layui.layer |
| | | , common.layuiForm = layui.form; |
| | | ; |
| | | common.layuiForm.verify({ |
| | | decimal: [/^(?:[1-9][0-9]*\.[0-9]+|0\.(?!0+$)[0-9]+|0)$/, '请输入数字'], |
| | | integer: [/^\+?[1-9][0-9]*$/, '请输入正整数'], |
| | |
| | | error(msg) { |
| | | layer.msg(msg, {icon: 5, anim: 6}); |
| | | } |
| | | |
| | | |
| | | }, |
| | | saveTempData: function (key, value) { |
| | | layui.data('temp', { |
| | | key: key |
| | | , value: value |
| | | }); |
| | | }, |
| | | getTempData: function (key) { |
| | | var local = layui.data('temp'); |
| | | if (local) { |
| | | return local[key]; |
| | | } |
| | | return null; |
| | | }, |
| | | removeTempData: function (key) { |
| | | layui.data('temp', { |
| | | key: key |
| | | ,remove: true |
| | | }); |
| | | } |
| | | |
| | | } |
| | | ; |
| | |
| | | package com.ks.daylucky; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.ks.daylucky.pojo.DO.ActivityExtraInfo; |
| | | import com.ks.daylucky.pojo.DO.ActivityTag; |
| | | import com.ks.daylucky.pojo.VO.admin.ActivityAdminVo; |
| | | import com.ks.daylucky.service.ActivityExtraInfoService; |
| | | import com.ks.daylucky.service.ActivityService; |
| | | import com.ks.daylucky.service.ActivityTagService; |
| | | import com.ks.daylucky.util.factory.vo.ActivityAdminVoFactory; |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.ks.lucky.exception.LuckyActivityException; |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import com.ks.lucky.remote.service.LuckyActivityService; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | @SpringBootTest |
| | | public class ActivityTest { |
| | | Logger logger= LoggerFactory.getLogger(ActivityTest.class); |
| | | |
| | | @Resource |
| | | private ActivityService activityService; |
| | | |
| | | @Reference(version = "1.0.0",check = false) |
| | | @Resource |
| | | private ActivityTagService activityTagService; |
| | | |
| | | @Resource |
| | | private ActivityExtraInfoService activityExtraInfoService; |
| | | |
| | | @Reference(version = "1.0.0", check = false) |
| | | private LuckyActivityService luckyActivityService; |
| | | |
| | | |
| | | @Test |
| | | public void add(){ |
| | | LuckyActivity luckyActivity=new LuckyActivity(); |
| | | public void add() { |
| | | LuckyActivity luckyActivity = new LuckyActivity(); |
| | | luckyActivity.setState(LuckyActivity.STATE_NOT_PUBLISH); |
| | | // luckyActivity.set |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void getAdminVO() { |
| | | LuckyActivity activity = luckyActivityService.getActivityDetail(10048L); |
| | | List<ActivityTag> tagList = activityTagService.getTagList(activity.getId()); |
| | | ActivityExtraInfo info = activityExtraInfoService.getDetail(activity.getId()); |
| | | ActivityAdminVo adminVo = ActivityAdminVoFactory.create(activity, tagList, info.getValidDay()); |
| | | logger.info(new Gson().toJson(adminVo)); |
| | | while(true); |
| | | } |
| | | |
| | | |
| | | } |