3个文件已删除
2 文件已重命名
37个文件已修改
34个文件已添加
| | |
| | | package com.ks.lucky.pojo.DO; |
| | | |
| | | import org.springframework.data.annotation.Transient; |
| | | import org.yeshi.utils.mybatis.Column; |
| | | import org.yeshi.utils.mybatis.Table; |
| | | import org.yeshi.utils.generater.mybatis.Column; |
| | | import org.yeshi.utils.generater.mybatis.Table; |
| | | |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotEmpty; |
| | |
| | | //已开奖,已经显示 |
| | | public final static int STATE_OPENED = 41; |
| | | |
| | | //开奖失败 |
| | | public final static int STATE_OPEN_FAIL = 42; |
| | | |
| | | @Column(name="id") |
| | | |
| | | @Column(name = "id") |
| | | private Long id; |
| | | |
| | | @Column(name="app_id") |
| | | @Column(name = "app_id") |
| | | @NotNull(message = "应用ID不能为空") |
| | | private Long appId; |
| | | |
| | | @Column(name="sponsor_id") |
| | | @Column(name = "sponsor_id") |
| | | @NotNull(message = "赞助商不能为空") |
| | | private Long sponsorId; |
| | | |
| | | @Column(name="`name`") |
| | | @Column(name = "`name`") |
| | | @NotEmpty(message = "活动名称不能为空") |
| | | private String name; |
| | | |
| | | @Column(name="material_poster") |
| | | @Column(name = "material_poster") |
| | | @NotEmpty(message = "活动海报不能为空") |
| | | private String materialPoster; |
| | | |
| | | @Column(name="material_tag_image") |
| | | @Column(name = "material_tag_image") |
| | | private String materialTagImage; |
| | | |
| | | @Column(name="material_") |
| | | @Column(name = "material_") |
| | | private String material; |
| | | |
| | | @Column(name="`desc`") |
| | | @Column(name = "`desc`") |
| | | private String desc; |
| | | /** |
| | | * 最大人数 |
| | | */ |
| | | @Column(name="max_person_count") |
| | | @Column(name = "max_person_count") |
| | | private Integer maxPersonCount; |
| | | |
| | | /** |
| | | * 现有人数 |
| | | */ |
| | | @Column(name="current_person_count") |
| | | @Column(name = "current_person_count") |
| | | private Integer currentPersonCount; |
| | | |
| | | @Column(name="`state`") |
| | | @Column(name = "`state`") |
| | | private Integer state; |
| | | |
| | | @Column(name="state_remarks") |
| | | @Column(name = "state_remarks") |
| | | private String stateRemarks; |
| | | |
| | | @Column(name="pre_start_time") |
| | | @Column(name = "pre_start_time") |
| | | @NotNull(message = "开始时间不能为空") |
| | | private Date preStartTime; |
| | | |
| | | @Column(name="actual_start_time") |
| | | @Column(name = "actual_start_time") |
| | | private Date actualStartTime; |
| | | |
| | | @Column(name="pre_finish_time") |
| | | @Column(name = "pre_finish_time") |
| | | private Date preFinishTime; |
| | | |
| | | @Column(name="actual_finish_time") |
| | | @Column(name = "actual_finish_time") |
| | | private Date actualFinishTime; |
| | | |
| | | @Column(name="pre_open_time") |
| | | @Column(name = "pre_open_time") |
| | | private Date preOpenTime; |
| | | |
| | | @Column(name="actual_open_time") |
| | | @Column(name = "actual_open_time") |
| | | private Date actualOpenTime; |
| | | |
| | | @Column(name="create_time") |
| | | @Column(name = "create_time") |
| | | private Date createTime; |
| | | |
| | | @Column(name="update_time") |
| | | @Column(name = "update_time") |
| | | private Date updateTime; |
| | | |
| | | @Transient |
| | |
| | | package com.ks.lucky.pojo.DO; |
| | | |
| | | import org.yeshi.utils.mybatis.Column; |
| | | import org.yeshi.utils.mybatis.Table; |
| | | import org.yeshi.utils.generater.mybatis.Column; |
| | | import org.yeshi.utils.generater.mybatis.Table; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | @Table("lucky_activity_join_record") |
New file |
| | |
| | | package com.ks.lucky.pojo.DTO.mq; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 活动助力 |
| | | */ |
| | | public class ActivityAssistMsgDTO implements Serializable { |
| | | //活动ID |
| | | private Long activityId; |
| | | //应用ID |
| | | private Long appId; |
| | | //用户ID |
| | | private String uid; |
| | | //目标用户ID |
| | | private String targetUid; |
| | | //是否助力成功 |
| | | private Boolean success; |
| | | //发生时间 |
| | | private Date dateTime; |
| | | |
| | | |
| | | public ActivityAssistMsgDTO(Long activityId, Long appId, String uid, String targetUid, Boolean success, Date dateTime) { |
| | | this.activityId = activityId; |
| | | this.appId = appId; |
| | | this.uid = uid; |
| | | this.targetUid = targetUid; |
| | | this.success = success; |
| | | this.dateTime = dateTime; |
| | | } |
| | | |
| | | public Boolean getSuccess() { |
| | | return success; |
| | | } |
| | | |
| | | public void setSuccess(Boolean success) { |
| | | this.success = success; |
| | | } |
| | | |
| | | public Long getActivityId() { |
| | | return activityId; |
| | | } |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public Long getAppId() { |
| | | return appId; |
| | | } |
| | | |
| | | public void setAppId(Long appId) { |
| | | this.appId = appId; |
| | | } |
| | | |
| | | public String getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(String uid) { |
| | | this.uid = uid; |
| | | } |
| | | |
| | | public String getTargetUid() { |
| | | return targetUid; |
| | | } |
| | | |
| | | public void setTargetUid(String targetUid) { |
| | | this.targetUid = targetUid; |
| | | } |
| | | |
| | | public Date getDateTime() { |
| | | return dateTime; |
| | | } |
| | | |
| | | public void setDateTime(Date dateTime) { |
| | | this.dateTime = dateTime; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lucky.pojo.DTO.mq; |
| | | |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardResult; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 中奖消息 |
| | | */ |
| | | public class ActivityDrawnMsgDTO implements Serializable { |
| | | //用户信息 |
| | | private String uid; |
| | | private Long appId; |
| | | |
| | | //活动ID |
| | | private Long activityId; |
| | | //中奖ID |
| | | private Long awardResultId; |
| | | //状态 |
| | | private Integer awardResultState; |
| | | //状态说明 |
| | | private String awardResultStateDesc; |
| | | //触发日期 |
| | | private Date dateTime; |
| | | |
| | | |
| | | public static ActivityDrawnMsgDTO create(LuckyActivityAwardResult result) { |
| | | ActivityDrawnMsgDTO dto = new ActivityDrawnMsgDTO(); |
| | | dto.setActivityId(result.getActivityId()); |
| | | dto.setAppId(result.getAppId()); |
| | | dto.setAwardResultId(result.getId()); |
| | | dto.setAwardResultState(result.getState()); |
| | | dto.setAwardResultStateDesc(result.getStateDesc()); |
| | | dto.setDateTime(new Date()); |
| | | dto.setUid(result.getUid()); |
| | | return dto; |
| | | } |
| | | |
| | | |
| | | public String getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(String uid) { |
| | | this.uid = uid; |
| | | } |
| | | |
| | | public Long getAppId() { |
| | | return appId; |
| | | } |
| | | |
| | | public void setAppId(Long appId) { |
| | | this.appId = appId; |
| | | } |
| | | |
| | | public Long getActivityId() { |
| | | return activityId; |
| | | } |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public Long getAwardResultId() { |
| | | return awardResultId; |
| | | } |
| | | |
| | | public void setAwardResultId(Long awardResultId) { |
| | | this.awardResultId = awardResultId; |
| | | } |
| | | |
| | | public Integer getAwardResultState() { |
| | | return awardResultState; |
| | | } |
| | | |
| | | public void setAwardResultState(Integer awardResultState) { |
| | | this.awardResultState = awardResultState; |
| | | } |
| | | |
| | | public String getAwardResultStateDesc() { |
| | | return awardResultStateDesc; |
| | | } |
| | | |
| | | public void setAwardResultStateDesc(String awardResultStateDesc) { |
| | | this.awardResultStateDesc = awardResultStateDesc; |
| | | } |
| | | |
| | | public Date getDateTime() { |
| | | return dateTime; |
| | | } |
| | | |
| | | public void setDateTime(Date dateTime) { |
| | | this.dateTime = dateTime; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lucky.pojo.DTO.mq; |
| | | |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinRecord; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 中奖消息 |
| | | */ |
| | | public class ActivityJoinMsgDTO implements Serializable { |
| | | //用户信息 |
| | | private Long joinId; |
| | | //用户ID |
| | | private String uid; |
| | | //应用ID |
| | | private Long appId; |
| | | //活动ID |
| | | private Long activityId; |
| | | //触发日期 |
| | | private Date dateTime; |
| | | |
| | | |
| | | public static ActivityJoinMsgDTO create(LuckyActivityJoinRecord record) { |
| | | ActivityJoinMsgDTO dto = new ActivityJoinMsgDTO(); |
| | | dto.setActivityId(record.getActivityId()); |
| | | dto.setAppId(record.getAppId()); |
| | | dto.setUid(record.getUid()); |
| | | dto.setJoinId(record.getId()); |
| | | dto.setDateTime(new Date()); |
| | | return dto; |
| | | } |
| | | |
| | | public Long getJoinId() { |
| | | return joinId; |
| | | } |
| | | |
| | | public void setJoinId(Long joinId) { |
| | | this.joinId = joinId; |
| | | } |
| | | |
| | | public String getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(String uid) { |
| | | this.uid = uid; |
| | | } |
| | | |
| | | public Long getAppId() { |
| | | return appId; |
| | | } |
| | | |
| | | public void setAppId(Long appId) { |
| | | this.appId = appId; |
| | | } |
| | | |
| | | public Long getActivityId() { |
| | | return activityId; |
| | | } |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public Date getDateTime() { |
| | | return dateTime; |
| | | } |
| | | |
| | | public void setDateTime(Date dateTime) { |
| | | this.dateTime = dateTime; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lucky.pojo.DTO.mq; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 获取状态改变消息 |
| | | */ |
| | | public class ActivityStateChangeMsgDTO implements Serializable { |
| | | //活动ID |
| | | private Long activityId; |
| | | //状态 |
| | | private Integer state; |
| | | //状态简介 |
| | | private String stateDesc; |
| | | //触发时间 |
| | | private Date dateTime; |
| | | |
| | | public ActivityStateChangeMsgDTO(Long activityId, Integer state, String stateDesc, Date dateTime) { |
| | | this.activityId = activityId; |
| | | this.state = state; |
| | | this.stateDesc = stateDesc; |
| | | this.dateTime = dateTime; |
| | | } |
| | | |
| | | public Long getActivityId() { |
| | | return activityId; |
| | | } |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public Integer getState() { |
| | | return state; |
| | | } |
| | | |
| | | public void setState(Integer state) { |
| | | this.state = state; |
| | | } |
| | | |
| | | public String getStateDesc() { |
| | | return stateDesc; |
| | | } |
| | | |
| | | public void setStateDesc(String stateDesc) { |
| | | this.stateDesc = stateDesc; |
| | | } |
| | | |
| | | public Date getDateTime() { |
| | | return dateTime; |
| | | } |
| | | |
| | | public void setDateTime(Date dateTime) { |
| | | this.dateTime = dateTime; |
| | | } |
| | | } |
| | |
| | | */ |
| | | public List<LuckyActivityAwardResult> getUnRecievedAward(Long appId, String uid, int page, int pageSize); |
| | | |
| | | |
| | | /** |
| | | * 获取用户未领取的奖项 |
| | | * @param appId |
| | | * @param uid |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | public LuckyActivityAwardResult getUnRecievedAward(Long appId, String uid, Long activityId); |
| | | |
| | | public long countUnRecievedAward(Long appId, String uid); |
| | | |
| | | |
| | | /** |
| | | * 获取详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public LuckyActivityAwardResult getDetail(Long id); |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * 获取助力记录 |
| | | * |
| | | * @param joinId |
| | | * @param appId |
| | | * @param uid |
| | | * @param eventKey |
| | | * @return |
| | | */ |
| | | public LuckyActivityJoinAssist getRecord(@NotNull Long joinId, @NotEmpty Long appId, @NotEmpty String uid, @NotNull ActivityJoinAssistEvent eventKey); |
| | | |
| | | |
| | | /** |
| | | * 获取助力列表 |
| | | * |
| | | * @param activityId |
| | |
| | | * @param count |
| | | * @return |
| | | */ |
| | | public List<ActivitySimpleUser> getJoinerList(Long activityId, int page, int count); |
| | | public List<ActivitySimpleUser> getJoinerList(Long activityId,Integer userType, int page, int count); |
| | | |
| | | |
| | | /** |
| | | * 获取参与者的数量 |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | public long countJoiner(Long activityId,Integer userType); |
| | | |
| | | /** |
| | | * 活动参与者统计信息 |
New file |
| | |
| | | package com.ks.lucky.utils; |
| | | |
| | | public class LuckyCMQConstant { |
| | | /** |
| | | * 活动状态改变主题 |
| | | */ |
| | | public final static String TOPIC_ACTIVITY_STATE_CHANGE = "topic-lucky-activity-state-change"; |
| | | |
| | | /** |
| | | * 助力主题 |
| | | */ |
| | | public final static String TOPIC_ASSIST = "topic-lucky-assist"; |
| | | |
| | | /** |
| | | * 活动中奖 |
| | | */ |
| | | public final static String TOPIC_ACTIVITY_DRAWN = "topic-lucky-activity-drawn"; |
| | | |
| | | /** |
| | | * 活动参与 |
| | | */ |
| | | public final static String TOPIC_ACTIVITY_JOIN= "topic-lucky-activity-join"; |
| | | |
| | | |
| | | public final static String TAG_ACTIVITY_STATE_CHANGE = "activityState"; |
| | | |
| | | public final static String TAG_ASSIST = "assist"; |
| | | |
| | | public final static String TAG_ACTIVITY_DRAWN = "activityDrawn"; |
| | | |
| | | public final static String TAG_ACTIVITY_JOIN= "activityJoin"; |
| | | } |
File was renamed from service-lucky/src/main/java/com/ks/lucky/util/mq/CMQConsumeRunner.java |
| | |
| | | package com.ks.lucky.util.mq; |
| | | package com.ks.lucky.utils.mq; |
| | | |
| | | public interface CMQConsumeRunner { |
| | | public void start(); |
| | |
| | | package com.ks.daylucky.config; |
| | | |
| | | import com.ks.daylucky.util.mq.consumer.MsgConsumer; |
| | | import com.ks.lucky.utils.mq.CMQConsumeRunner; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | |
| | | |
| | | Logger log = LoggerFactory.getLogger(CMQConsumeConfig.class); |
| | | |
| | | //订阅主题 |
| | | // public CMQConsumeConfig(){ |
| | | // CMQManager.getInstance(); |
| | | // |
| | | // } |
| | | |
| | | |
| | | @Bean(initMethod = "start", destroyMethod = "destroy") |
| | | public CMQConsumeRunner msgConsumer() { |
| | | //订阅活动状态改变主题与助力主题 |
| | | CMQConsumeRunner runner = new MsgConsumer(); |
| | | return runner; |
| | | } |
| | | } |
| | |
| | | private String region; |
| | | |
| | | |
| | | @Value("${cos.accessHost}") |
| | | private String accessHost; |
| | | |
| | | |
| | | @Bean |
| | | public COSInitParams cosInitParams() { |
| | | log.info(">>>>>>>>>>> cos config init."); |
| | |
| | | params.setRegion(region); |
| | | params.setSecretId(secretId); |
| | | params.setSecretKey(secretKey); |
| | | params.setAccessHost(accessHost); |
| | | |
| | | COSManager.getInstance().init(params); |
| | | return params; |
| | |
| | | package com.ks.daylucky.controller.api.client; |
| | | |
| | | import com.ks.daylucky.pojo.DO.ActivityDrawnRecieveNotifyInfo; |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.pojo.VO.ActivityAwardVO; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.pojo.VO.UserActivityUnRecievedAwardVO; |
| | | import com.ks.daylucky.pojo.VO.*; |
| | | import com.ks.daylucky.service.ActivityDrawnRecieveNotifyInfoService; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.daylucky.util.UserInfoUtil; |
| | | import com.ks.daylucky.util.factory.vo.ActivityDetailVOFactory; |
| | | import com.ks.daylucky.util.factory.vo.ActivityListItemInfoVOFactory; |
| | | import com.ks.lucky.exception.LuckyActivityAwardException; |
| | | import com.ks.lucky.exception.LuckyActivityAwardResultException; |
| | |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private ActivityDrawnRecieveNotifyInfoService activityDrawnRecieveNotifyInfoService; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取未领奖的奖励信息 |
| | | * 获取领奖通知弹框 |
| | | * |
| | | * @param acceptData |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("getUnRecieveAward") |
| | | public String getUnRecieveAward(AcceptData acceptData) { |
| | | List<LuckyActivityAwardResult> resultList = luckyActivityAwardResultService.getUnRecievedAward(acceptData.getApp().getId(), acceptData.getUid() + "", 1, 1); |
| | | if (resultList != null && resultList.size() > 0) { |
| | | LuckyActivityAwardResult result = resultList.get(0); |
| | | @RequestMapping("getRecieveAwardNotify") |
| | | public String getRecieveAwardNotify(AcceptData acceptData, Long activityId) { |
| | | ActivityDrawnRecieveNotifyInfo info = activityDrawnRecieveNotifyInfoService.getShowNotifyInfo(acceptData.getApp().getId(), acceptData.getUid(), activityId); |
| | | if (info != null) { |
| | | UserActivityUnRecievedAwardVO vo = new UserActivityUnRecievedAwardVO(); |
| | | LuckyActivityAwards award = luckyActivityAwardService.getAwardDetail(result.getAwardId()); |
| | | vo.setAwardName(award.getAwardName()); |
| | | vo.setAwardId(award.getId()); |
| | | vo.setPicture(award.getAwardPoster()); |
| | | LuckyActivityAwards award = info.getAwards(); |
| | | |
| | | vo.setTitle("活动期号:NO." + award.getActivityId()); |
| | | vo.setActivityId(activityId); |
| | | vo.setType(info.getType()); |
| | | vo.setId(info.getId()); |
| | | |
| | | switch (info.getType()) { |
| | | case ActivityDrawnRecieveNotifyInfo.TYPE_UNRECIEVE: |
| | | vo.setDesc("未领取,可在\"我的-全部抽奖\"中查看"); |
| | | vo.setAward(ActivityListItemInfoVOFactory.create(award, null)); |
| | | break; |
| | | case ActivityDrawnRecieveNotifyInfo.TYPE_OUTDATE: |
| | | vo.setDesc("注:中奖日起7天内未领取奖品,将会把对应奖品原路退回赞助商,切记中奖后按时领取奖品。"); |
| | | vo.setAward(ActivityListItemInfoVOFactory.create(award, award.getLevel())); |
| | | break; |
| | | } |
| | | return JsonUtil.loadTrueResult(vo); |
| | | } |
| | | return JsonUtil.loadFalseResult(""); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置中奖通知弹框已读 |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("setDrawnNotifyRead") |
| | | public String setDrawnNotifyRead(AcceptData acceptData, String id) { |
| | | |
| | | ActivityDrawnRecieveNotifyInfo info = activityDrawnRecieveNotifyInfoService.selectByPrimaryKey(id); |
| | | |
| | | String uid = null; |
| | | Long appId = null; |
| | | |
| | | if (info.getAwardResult() != null) { |
| | | uid = info.getAwardResult().getUid(); |
| | | appId = info.getAwardResult().getAppId(); |
| | | } |
| | | |
| | | if (uid == null || appId == null) { |
| | | return JsonUtil.loadFalseResult("信息获取出错"); |
| | | } |
| | | |
| | | if (acceptData.getUid().longValue() != Long.parseLong(uid) || acceptData.getApp().getId().longValue() != appId) { |
| | | return JsonUtil.loadFalseResult("不是自己的中奖"); |
| | | } |
| | | activityDrawnRecieveNotifyInfoService.setNotifyShown(info.getId()); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 领取奖品 |
| | | * |
| | |
| | | |
| | | import com.ks.daylucky.pojo.DO.ActivityScanRecord; |
| | | import com.ks.daylucky.pojo.DO.AppConfig; |
| | | import com.ks.daylucky.pojo.VO.ActivityShareInfoVO; |
| | | import com.ks.daylucky.pojo.DTO.AssistJoinInfoDTO; |
| | | import com.ks.daylucky.pojo.VO.AlipayXCXShareInfoVO; |
| | | import com.ks.daylucky.pojo.DTO.ConfigKeyEnum; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.pojo.DTO.ActivityDetailInfoDTO; |
| | | import com.ks.daylucky.pojo.VO.ActivityDetailVO; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.service.*; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.daylucky.util.RSAUtil; |
| | | import com.ks.daylucky.util.activity.ActivityUtil; |
| | | import com.ks.daylucky.util.factory.vo.ActivityDetailVOFactory; |
| | | import com.ks.daylucky.util.factory.vo.ActivityListItemInfoVOFactory; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.encrypt.AESUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.security.AccessControlContext; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private AppConfigService appConfigService; |
| | | |
| | | @Resource |
| | | private ActivityExtraInfoService activityExtraInfoService; |
| | | |
| | | @Resource |
| | | private UserActivityExtraInfoService userActivityExtraInfoService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | //分享信息 |
| | | |
| | | ActivityShareInfoVO shareInfoDTO = new ActivityShareInfoVO(); |
| | | String activityShareImage = null; |
| | | try { |
| | | activityShareImage = activityExtraInfoService.getShareImageLink(activityId, vo.getActivity().getAwardList(), acceptData.getApp().getId()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | AlipayXCXShareInfoVO shareInfoDTO = new AlipayXCXShareInfoVO(); |
| | | shareInfoDTO.setPath(String.format("/pages/activity-detail/activity-detail?id=%s&joinInfo=%s", activityId, ActivityUtil.getShareJoinInfo(acceptData.getUid(), activityId))); |
| | | shareInfoDTO.setTitle("测试标题"); |
| | | shareInfoDTO.setDesc("测试简介"); |
| | | // shareInfoDTO.setBgImgUrl(); |
| | | shareInfoDTO.setBgImgUrl(activityShareImage); |
| | | vo.setShareInfo(shareInfoDTO); |
| | | |
| | | //已经加入活动就需要返回助力分享图 |
| | | if (vo.isJoined()) { |
| | | |
| | | SimpleUser user = userInfoService.getSimpleUser(acceptData.getUid()); |
| | | if (user != null) { |
| | | String assistShareImage = null; |
| | | try { |
| | | assistShareImage = userActivityExtraInfoService.getShareImageLink(activityId, user, acceptData.getApp().getId()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | shareInfoDTO = new AlipayXCXShareInfoVO(); |
| | | shareInfoDTO.setPath(String.format("/pages/activity-detail/activity-detail?id=%s&joinInfo=%s", activityId, ActivityUtil.getShareJoinInfo(acceptData.getUid(), activityId))); |
| | | shareInfoDTO.setTitle("测试标题"); |
| | | shareInfoDTO.setDesc("测试简介"); |
| | | shareInfoDTO.setBgImgUrl(assistShareImage); |
| | | vo.setAssistShareInfo(shareInfoDTO); |
| | | } |
| | | } |
| | | |
| | | |
| | | //加入浏览记录 |
| | | ActivityScanRecord record = new ActivityScanRecord(); |
| | |
| | | public String getJoinerList(AcceptData acceptData, Long activityId, int page) { |
| | | List<SimpleUser> voList = new ArrayList<>(); |
| | | |
| | | List<ActivitySimpleUser> list = luckyActivityJoinService.getJoinerList(activityId, page, Constant.PAGE_SIZE); |
| | | List<ActivitySimpleUser> list = luckyActivityJoinService.getJoinerList(activityId,null, page, Constant.PAGE_SIZE); |
| | | if (list != null && list.size() > 0) { |
| | | Map<Long, UserInfo> userInfoMap = userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(list)); |
| | | for (ActivitySimpleUser info : list) { |
| | |
| | | import com.ks.daylucky.pojo.DO.SponsorSignUpRecord; |
| | | import com.ks.daylucky.pojo.DTO.ConfigKeyEnum; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.pojo.VO.AlipayXCXShareInfoVO; |
| | | import com.ks.daylucky.service.AdviceService; |
| | | import com.ks.daylucky.service.AppConfigService; |
| | | import com.ks.daylucky.service.SponsorSignUpService; |
| | | import com.ks.daylucky.util.activity.ActivityUtil; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | AppConfig config = appConfigService.getConfigCache(acceptData.getApp().getId(), key, acceptData.getVersion()); |
| | | data.put(key.name(), config.getValue()); |
| | | } |
| | | |
| | | //获取应用分享图 |
| | | AppConfig config = appConfigService.getConfigCache(acceptData.getApp().getId(), ConfigKeyEnum.shareImageLink, acceptData.getVersion()); |
| | | if (config != null) { |
| | | AlipayXCXShareInfoVO shareInfoDTO = new AlipayXCXShareInfoVO(); |
| | | shareInfoDTO.setPath("/pages/rewards/rewards"); |
| | | shareInfoDTO.setTitle("测试标题"); |
| | | shareInfoDTO.setDesc("测试简介"); |
| | | shareInfoDTO.setBgImgUrl(config.getValue()); |
| | | data.put("shareInfo", shareInfoDTO); |
| | | } |
| | | |
| | | |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | |
| | | import com.ks.daylucky.pojo.DTO.UserMsgSettings; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.pojo.VO.UserConfigVO; |
| | | import com.ks.daylucky.pojo.VO.UserMsgVO; |
| | | import com.ks.daylucky.service.UserInfoExtraService; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.daylucky.service.UserMsgService; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.daylucky.util.RSAUtil; |
| | | import com.ks.daylucky.util.UserInfoUtil; |
| | | import com.ks.daylucky.util.factory.vo.UserMsgVOFactory; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | |
| | | @RequestMapping("getUserMsgList") |
| | | public String getUserMsgList(AcceptData acceptData, int page) { |
| | | List<UserMsg> msgList = userMsgService.getUserMsgList(acceptData.getUid(), page, Constant.PAGE_SIZE); |
| | | List<UserMsgVO> voList = new ArrayList<>(); |
| | | if (msgList != null) { |
| | | for (UserMsg userMsg : msgList) { |
| | | voList.add(UserMsgVOFactory.create(userMsg)); |
| | | } |
| | | } |
| | | |
| | | |
| | | long count = userMsgService.countUserMsg(acceptData.getUid()); |
| | | Gson gson = JsonUtil.getConvertDateToShortNameBuilder(new GsonBuilder().excludeFieldsWithoutExposeAnnotation()).create(); |
| | | Gson gson = JsonUtil.getConvertDateToShortNameBuilder(new GsonBuilder()).create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", gson.toJson(msgList)); |
| | | data.put("data", gson.toJson(voList)); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getUserConfig") |
| | | public String getUserConfig(AcceptData acceptData){ |
| | | public String getUserConfig(AcceptData acceptData) { |
| | | //消息未读数 |
| | | UserInfoExtra extra= userInfoExtraService.getUserInfoExtra(acceptData.getUid()); |
| | | if(extra==null){ |
| | | UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(acceptData.getUid()); |
| | | if (extra == null) { |
| | | return JsonUtil.loadFalseResult("用户不存在"); |
| | | } |
| | | UserConfigVO vo=new UserConfigVO(); |
| | | UserConfigVO vo = new UserConfigVO(); |
| | | vo.setMsgCount(extra.getMsgUnreadCount()); |
| | | return JsonUtil.loadTrueResult(vo); |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.dao; |
| | | |
| | | import com.ks.daylucky.pojo.DO.ActivityDrawnRecieveNotifyInfo; |
| | | import com.ks.lib.common.dao.MongodbBaseDao; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Repository |
| | | public class ActivityDrawnRecieveNotifyInfoDao extends MongodbBaseDao<ActivityDrawnRecieveNotifyInfo> { |
| | | |
| | | public void updateSelective(ActivityDrawnRecieveNotifyInfo bean) { |
| | | Query query = new Query(); |
| | | Update update = new Update(); |
| | | query.addCriteria(Criteria.where("id").is(bean.getId())); |
| | | if (bean.getAwardResult() != null) { |
| | | update.set("awardResult", bean.getAwardResult()); |
| | | } |
| | | if (bean.getAwards() != null) { |
| | | update.set("awards", bean.getAwards()); |
| | | } |
| | | if (bean.getShown() != null) { |
| | | update.set("shown", bean.getShown()); |
| | | } |
| | | if (bean.getShowTime() != null) { |
| | | update.set("showTime", bean.getShowTime()); |
| | | } |
| | | if (bean.getCreateTime() != null) { |
| | | update.set("createTime", bean.getCreateTime()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | |
| | | /** |
| | | * 获取需要显示的通知 |
| | | * @param appId |
| | | * @param uid |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | public ActivityDrawnRecieveNotifyInfo getShowNotifyInfo(Long appId, Long uid, Long activityId) { |
| | | Query query = new Query(); |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | andList.add(Criteria.where("awardResult.uid").is(uid+"")); |
| | | andList.add(Criteria.where("awardResult.appId").is(appId)); |
| | | andList.add(Criteria.where("shown").is(false)); |
| | | if (activityId != null) { |
| | | andList.add(Criteria.where("awardResult.activityId").is(activityId)); |
| | | } |
| | | |
| | | Criteria ands[] = new Criteria[andList.size()]; |
| | | andList.toArray(ands); |
| | | query.addCriteria(new Criteria().andOperator(ands)); |
| | | return findOne(query); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.dao; |
| | | |
| | | import com.ks.daylucky.pojo.DO.ActivityExtraInfo; |
| | | import com.ks.lib.common.dao.MongodbBaseDao; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Repository |
| | | public class ActivityExtraInfoDao extends MongodbBaseDao<ActivityExtraInfo> { |
| | | |
| | | |
| | | /** |
| | | * 选择性修改 |
| | | * |
| | | * @param info |
| | | */ |
| | | public void updateSelective(ActivityExtraInfo info) { |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("activityId").is(info.getActivityId())); |
| | | |
| | | Update update = new Update(); |
| | | if (info.getShareImageLink() != null) { |
| | | update.set("shareImageLink", info.getShareImageLink()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.dao; |
| | | |
| | | import com.ks.daylucky.pojo.DO.UserActivityExtraInfo; |
| | | import com.ks.lib.common.dao.MongodbBaseDao; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Repository |
| | | public class UserActivityExtraInfoDao extends MongodbBaseDao<UserActivityExtraInfo> { |
| | | |
| | | /** |
| | | * 选择性修改 |
| | | * |
| | | * @param info |
| | | */ |
| | | public void updateSelective(UserActivityExtraInfo info) { |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("id").is(info.getId())); |
| | | |
| | | Update update = new Update(); |
| | | if (info.getShareImageLink() != null) { |
| | | update.set("shareImageLink", info.getShareImageLink()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.dao; |
| | | |
| | | import com.ks.daylucky.pojo.DO.UserMsg; |
| | | import com.ks.daylucky.query.UserMsgQuery; |
| | | import com.ks.lib.common.dao.MongodbBaseDao; |
| | | import com.ks.lib.common.util.MongoDBQueryUtil; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Repository |
| | | public class UserMsgDao extends MongodbBaseDao<UserMsg> { |
| | | |
| | | |
| | | public List<UserMsg> list(UserMsgQuery queryCondition) { |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | if (queryCondition.msgType != null) { |
| | | andList.add(Criteria.where("msgType").is(queryCondition.msgType)); |
| | | } |
| | | |
| | | if (queryCondition.uid != null) { |
| | | andList.add(Criteria.where("uid").is(queryCondition.uid)); |
| | | } |
| | | |
| | | Criteria[] ands = new Criteria[andList.size()]; |
| | | andList.toArray(ands); |
| | | Query query = new Query(); |
| | | query.skip(queryCondition.start); |
| | | query.limit(queryCondition.count); |
| | | query.addCriteria(new Criteria().andOperator(ands)); |
| | | if (queryCondition.sortList != null && queryCondition.sortList.size() > 0) { |
| | | query.with(Sort.by(MongoDBQueryUtil.convertSQLSort(queryCondition.sortList))); |
| | | } |
| | | return findList(query); |
| | | |
| | | } |
| | | |
| | | public long count(UserMsgQuery queryCondition) { |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | if (queryCondition.msgType != null) { |
| | | andList.add(Criteria.where("msgType").is(queryCondition.msgType)); |
| | | } |
| | | |
| | | if (queryCondition.uid != null) { |
| | | andList.add(Criteria.where("uid").is(queryCondition.uid)); |
| | | } |
| | | |
| | | Criteria[] ands = new Criteria[andList.size()]; |
| | | andList.toArray(ands); |
| | | Query query = new Query(); |
| | | query.addCriteria(new Criteria().andOperator(ands)); |
| | | return count(query); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.exception; |
| | | |
| | | import com.ks.lib.common.exception.BaseException; |
| | | |
| | | public class ActivityDrawnRecieveNotifyInfoException extends BaseException{ |
| | | |
| | | |
| | | public ActivityDrawnRecieveNotifyInfoException(int code, String msg) { |
| | | super(code, msg); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.DO; |
| | | |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardResult; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwards; |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.mongodb.core.index.Indexed; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 活动中奖领取通知 |
| | | */ |
| | | @Document(collection = "activityDrawnRecieveNotifyInfo") |
| | | public class ActivityDrawnRecieveNotifyInfo { |
| | | |
| | | public final static int TYPE_UNRECIEVE = 1; |
| | | public final static int TYPE_OUTDATE = 2; |
| | | |
| | | |
| | | @Id |
| | | private String id; |
| | | |
| | | @NotNull(message = "中奖结果不能为空") |
| | | private LuckyActivityAwardResult awardResult; |
| | | @NotNull(message = "奖项不能为空") |
| | | private LuckyActivityAwards awards; |
| | | |
| | | @Indexed |
| | | private Boolean shown; |
| | | |
| | | private Date showTime; |
| | | @NotNull(message = "通知类型不能为空") |
| | | private Integer type; |
| | | |
| | | private Date createTime; |
| | | |
| | | private Date updateTime; |
| | | |
| | | public static ActivityDrawnRecieveNotifyInfo create(LuckyActivityAwards awards, LuckyActivityAwardResult awardResult, int type) { |
| | | ActivityDrawnRecieveNotifyInfo info = new ActivityDrawnRecieveNotifyInfo(); |
| | | info.setShown(false); |
| | | info.setAwardResult(awardResult); |
| | | info.setAwards(awards); |
| | | info.setType(type); |
| | | return info; |
| | | } |
| | | |
| | | |
| | | public Integer getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(Integer type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public static String createId(Long resultId, int type) { |
| | | return resultId + "-" + type; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public LuckyActivityAwardResult getAwardResult() { |
| | | return awardResult; |
| | | } |
| | | |
| | | public void setAwardResult(LuckyActivityAwardResult awardResult) { |
| | | this.awardResult = awardResult; |
| | | } |
| | | |
| | | public LuckyActivityAwards getAwards() { |
| | | return awards; |
| | | } |
| | | |
| | | public void setAwards(LuckyActivityAwards awards) { |
| | | this.awards = awards; |
| | | } |
| | | |
| | | public Boolean getShown() { |
| | | return shown; |
| | | } |
| | | |
| | | public void setShown(Boolean shown) { |
| | | this.shown = shown; |
| | | } |
| | | |
| | | public Date getShowTime() { |
| | | return showTime; |
| | | } |
| | | |
| | | public void setShowTime(Date showTime) { |
| | | this.showTime = showTime; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.DO; |
| | | |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Document(collection = "activityExtraInfo") |
| | | public class ActivityExtraInfo { |
| | | @Id |
| | | private Long activityId; |
| | | //活动分享图 |
| | | private String shareImageLink; |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | public Long getActivityId() { |
| | | return activityId; |
| | | } |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public String getShareImageLink() { |
| | | return shareImageLink; |
| | | } |
| | | |
| | | public void setShareImageLink(String shareImageLink) { |
| | | this.shareImageLink = shareImageLink; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.DO; |
| | | |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 用户与活动相关的附加信息 |
| | | */ |
| | | @Document(collection = "userActivityExtraInfo") |
| | | public class UserActivityExtraInfo { |
| | | @Id |
| | | private String id; |
| | | private Long activityId; |
| | | private Long uid; |
| | | //分享图链接 |
| | | private String shareImageLink; |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public Long getActivityId() { |
| | | return activityId; |
| | | } |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public Long getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(Long uid) { |
| | | this.uid = uid; |
| | | } |
| | | |
| | | public String getShareImageLink() { |
| | | return shareImageLink; |
| | | } |
| | | |
| | | public void setShareImageLink(String shareImageLink) { |
| | | this.shareImageLink = shareImageLink; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public static String createId(Long activityId, Long uid) { |
| | | return activityId + "-" + uid; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.ks.daylucky.pojo.DO; |
| | | |
| | | import com.ks.daylucky.pojo.DTO.msg.LuckyMsgContent; |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | import java.util.UUID; |
| | | |
| | | @Document(collection = "userMsg") |
| | | public class UserMsg { |
| | | |
| | | public enum UserMsgType { |
| | | lucky("抽奖消息", ""); |
| | | |
| | | private UserMsgType(String name, String icon) { |
| | | private String name; |
| | | |
| | | private UserMsgType(String name, String icon) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | } |
| | | |
| | | public static String createId(Long uid) { |
| | | |
| | | return uid + "#" + UUID.randomUUID(); |
| | | } |
| | | |
| | | |
| | | private Long id; |
| | | @Id |
| | | private String id; |
| | | |
| | | @NotNull(message = "用户ID不能为空") |
| | | private Long uid; |
| | | @NotNull(message = "消息类型不能为空") |
| | | private UserMsgType msgType; |
| | | |
| | | @NotNull(message = "消息内容不能为空") |
| | | private String msgContent; |
| | | private LuckyMsgContent luckyMsgContent; |
| | | |
| | | private Date createTime; |
| | | |
| | | private Date updateTime; |
| | | |
| | | public Long getId() { |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | |
| | | this.msgType = msgType; |
| | | } |
| | | |
| | | public String getMsgContent() { |
| | | return msgContent; |
| | | } |
| | | |
| | | public void setMsgContent(String msgContent) { |
| | | this.msgContent = msgContent == null ? null : msgContent.trim(); |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | |
| | | public LuckyMsgContent getLuckyMsgContent() { |
| | | return luckyMsgContent; |
| | | } |
| | | |
| | | public void setLuckyMsgContent(LuckyMsgContent luckyMsgContent) { |
| | | this.luckyMsgContent = luckyMsgContent; |
| | | } |
| | | } |
| | |
| | | newerCourse("newer_course_url", "新手教程"), |
| | | commonQuestion("common_question_url", "常见问题"), |
| | | activityDetailHelp("activity_detail_help_link", "活动详情帮助链接"), |
| | | disclaimers("disclaimers", "免责声明"); |
| | | disclaimers("disclaimers", "免责声明"), |
| | | shareImageLink("share_image_link", "应用分享图"), |
| | | activityShareImageBg("activity_share_image_bg", "活动分享底图"), |
| | | assistShareImageBg("assist_share_image_bg", "助力分享底图"); |
| | | |
| | | private String key; |
| | | |
| | |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | |
| | | public class LuckyMsgContent { |
| | | private SimpleUser user; |
| | | // private |
| | | |
| | | public enum LuckyMsgType { |
| | | joinSuccess("参与成功"), |
| | | notDrawn("未中奖"), |
| | | drawn("中奖了"), |
| | | openFail("开奖失败"), |
| | | assist("助力"), |
| | | assistAndJoin("助力且参与"), |
| | | receiveOutDate("过期未领取"); |
| | | |
| | | private LuckyMsgType(String name) { |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 活动ID |
| | | */ |
| | | private Long activityId; |
| | | /** |
| | | * 活动期号 |
| | | */ |
| | | private String dateNumber; |
| | | /** |
| | | * 开奖状态 |
| | | */ |
| | | private String openState; |
| | | /** |
| | | * 中奖状态 |
| | | */ |
| | | private String drawnState; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remarks; |
| | | /** |
| | | * |
| | | */ |
| | | private Integer weight; |
| | | /** |
| | | * 领取状态 |
| | | */ |
| | | private String receiveState; |
| | | /** |
| | | * 奖品权益 |
| | | */ |
| | | private String outDateAwardState; |
| | | |
| | | /** |
| | | * 奖品名称 |
| | | */ |
| | | private String awardName; |
| | | |
| | | public String getAwardName() { |
| | | return awardName; |
| | | } |
| | | |
| | | public void setAwardName(String awardName) { |
| | | this.awardName = awardName; |
| | | } |
| | | |
| | | //助力用户 |
| | | private SimpleUser assistUser; |
| | | //活动消息类型 |
| | | private LuckyMsgType luckyMsgType; |
| | | |
| | | public Long getActivityId() { |
| | | return activityId; |
| | | } |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public String getDateNumber() { |
| | | return dateNumber; |
| | | } |
| | | |
| | | public void setDateNumber(String dateNumber) { |
| | | this.dateNumber = dateNumber; |
| | | } |
| | | |
| | | public String getOpenState() { |
| | | return openState; |
| | | } |
| | | |
| | | public void setOpenState(String openState) { |
| | | this.openState = openState; |
| | | } |
| | | |
| | | public String getDrawnState() { |
| | | return drawnState; |
| | | } |
| | | |
| | | public void setDrawnState(String drawnState) { |
| | | this.drawnState = drawnState; |
| | | } |
| | | |
| | | public String getRemarks() { |
| | | return remarks; |
| | | } |
| | | |
| | | public void setRemarks(String remarks) { |
| | | this.remarks = remarks; |
| | | } |
| | | |
| | | public Integer getWeight() { |
| | | return weight; |
| | | } |
| | | |
| | | public void setWeight(Integer weight) { |
| | | this.weight = weight; |
| | | } |
| | | |
| | | public String getReceiveState() { |
| | | return receiveState; |
| | | } |
| | | |
| | | public void setReceiveState(String receiveState) { |
| | | this.receiveState = receiveState; |
| | | } |
| | | |
| | | public String getOutDateAwardState() { |
| | | return outDateAwardState; |
| | | } |
| | | |
| | | public void setOutDateAwardState(String outDateAwardState) { |
| | | this.outDateAwardState = outDateAwardState; |
| | | } |
| | | |
| | | public SimpleUser getAssistUser() { |
| | | return assistUser; |
| | | } |
| | | |
| | | public void setAssistUser(SimpleUser assistUser) { |
| | | this.assistUser = assistUser; |
| | | } |
| | | |
| | | public LuckyMsgType getLuckyMsgType() { |
| | | return luckyMsgType; |
| | | } |
| | | |
| | | public void setLuckyMsgType(LuckyMsgType luckyMsgType) { |
| | | this.luckyMsgType = luckyMsgType; |
| | | } |
| | | } |
| | |
| | | //赞助商的其他活动 |
| | | private Integer sponsorActivityCount; |
| | | |
| | | //分享信息 |
| | | private ActivityShareInfoVO shareInfo; |
| | | //活动分享信息 |
| | | private AlipayXCXShareInfoVO shareInfo; |
| | | |
| | | //助力分享信息 |
| | | private AlipayXCXShareInfoVO assistShareInfo; |
| | | |
| | | //免责申明 |
| | | private String disclaimers; |
| | | |
| | | |
| | | public AlipayXCXShareInfoVO getAssistShareInfo() { |
| | | return assistShareInfo; |
| | | } |
| | | |
| | | public void setAssistShareInfo(AlipayXCXShareInfoVO assistShareInfo) { |
| | | this.assistShareInfo = assistShareInfo; |
| | | } |
| | | |
| | | public String getDisclaimers() { |
| | | return disclaimers; |
| | |
| | | this.disclaimers = disclaimers; |
| | | } |
| | | |
| | | public ActivityShareInfoVO getShareInfo() { |
| | | public AlipayXCXShareInfoVO getShareInfo() { |
| | | return shareInfo; |
| | | } |
| | | |
| | | public void setShareInfo(ActivityShareInfoVO shareInfo) { |
| | | public void setShareInfo(AlipayXCXShareInfoVO shareInfo) { |
| | | this.shareInfo = shareInfo; |
| | | } |
| | | |
File was renamed from service-daylucky/src/main/java/com/ks/daylucky/pojo/VO/ActivityShareInfoVO.java |
| | |
| | | package com.ks.daylucky.pojo.VO; |
| | | |
| | | public class ActivityShareInfoVO { |
| | | public class AlipayXCXShareInfoVO { |
| | | private String path; |
| | | private String title; |
| | | private String desc; |
| | |
| | | * 活动详情 |
| | | */ |
| | | public class UserActivityUnRecievedAwardVO { |
| | | |
| | | @Expose |
| | | private String id; |
| | | @Expose |
| | | private String title; |
| | | @Expose |
| | | private Long awardId; |
| | | @Expose |
| | | private String picture; |
| | | @Expose |
| | | private String awardName; |
| | | |
| | | @Expose |
| | | private ActivityAwardVO award; |
| | | |
| | | @Expose |
| | | private Long activityId; |
| | | @Expose |
| | | private Integer type; |
| | | @Expose |
| | | private String desc; |
| | | |
| | | |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | public void setDesc(String desc) { |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public Integer getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(Integer type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public Long getActivityId() { |
| | | return activityId; |
| | | } |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public String getTitle() { |
| | | return title; |
| | |
| | | this.title = title; |
| | | } |
| | | |
| | | public Long getAwardId() { |
| | | return awardId; |
| | | public ActivityAwardVO getAward() { |
| | | return award; |
| | | } |
| | | |
| | | public void setAwardId(Long awardId) { |
| | | this.awardId = awardId; |
| | | } |
| | | |
| | | public String getPicture() { |
| | | return picture; |
| | | } |
| | | |
| | | public void setPicture(String picture) { |
| | | this.picture = picture; |
| | | } |
| | | |
| | | public String getAwardName() { |
| | | return awardName; |
| | | } |
| | | |
| | | public void setAwardName(String awardName) { |
| | | this.awardName = awardName; |
| | | public void setAward(ActivityAwardVO award) { |
| | | this.award = award; |
| | | } |
| | | } |
| | |
| | | package com.ks.daylucky.pojo.VO; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | public class UserMsgVO { |
| | | private String icon; |
| | | private String name; |
| | | private List<UserMsgContentVO> contentList; |
| | | private String time; |
| | | private Date time; |
| | | |
| | | |
| | | public String getIcon() { |
| | |
| | | this.contentList = contentList; |
| | | } |
| | | |
| | | public String getTime() { |
| | | public Date getTime() { |
| | | return time; |
| | | } |
| | | |
| | | public void setTime(String time) { |
| | | public void setTime(Date time) { |
| | | this.time = time; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.service; |
| | | |
| | | import com.ks.daylucky.exception.ActivityDrawnRecieveNotifyInfoException; |
| | | import com.ks.daylucky.pojo.DO.ActivityDrawnRecieveNotifyInfo; |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | |
| | | public interface ActivityDrawnRecieveNotifyInfoService { |
| | | |
| | | |
| | | /** |
| | | * 添加通知 |
| | | * |
| | | * @param notifyInfo |
| | | * @throws ParamsException |
| | | * @throws ActivityDrawnRecieveNotifyInfoException |
| | | */ |
| | | void addNotify(ActivityDrawnRecieveNotifyInfo notifyInfo) throws ParamsException, ActivityDrawnRecieveNotifyInfoException; |
| | | |
| | | /** |
| | | * 获取需要显示的通知消息 |
| | | * |
| | | * @param appId |
| | | * @param uid |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | ActivityDrawnRecieveNotifyInfo getShowNotifyInfo(Long appId, Long uid, Long activityId); |
| | | |
| | | |
| | | /** |
| | | * 设置通知已经显示 |
| | | * |
| | | * @param id |
| | | */ |
| | | public void setNotifyShown(String id); |
| | | |
| | | |
| | | /** |
| | | * 根据主键获取 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | ActivityDrawnRecieveNotifyInfo selectByPrimaryKey(String id); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.service; |
| | | |
| | | import com.ks.daylucky.pojo.DO.ActivityExtraInfo; |
| | | import com.ks.daylucky.pojo.VO.ActivityAwardVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 活动附加信息服务 |
| | | */ |
| | | public interface ActivityExtraInfoService { |
| | | |
| | | |
| | | /** |
| | | * 添加信息 |
| | | * |
| | | * @param info |
| | | */ |
| | | public void add(ActivityExtraInfo info); |
| | | |
| | | /** |
| | | * 保存分享图 |
| | | * |
| | | * @param activityId |
| | | * @param shareImageLink |
| | | */ |
| | | public void saveShareImage(Long activityId, String shareImageLink); |
| | | |
| | | |
| | | /** |
| | | * 获取详情 |
| | | * |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | public ActivityExtraInfo getDetail(Long activityId); |
| | | |
| | | |
| | | /** |
| | | * 获取分享图 |
| | | * |
| | | * @param activityId |
| | | * @param appId |
| | | * @return |
| | | */ |
| | | public String getShareImageLink(Long activityId, List<ActivityAwardVO> voList, Long appId) throws Exception; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * 活动附加信息服务 |
| | | */ |
| | | public interface UserActivityExtraInfoService { |
| | | |
| | | |
| | | /** |
| | | * 添加信息 |
| | | * |
| | | * @param info |
| | | */ |
| | | public void add(UserActivityExtraInfo info); |
| | | |
| | | |
| | | /** |
| | | * 保存分享图 |
| | | * |
| | | * @param activityId |
| | | * @param uid |
| | | * @param shareImageLink |
| | | */ |
| | | public void saveShareImage(Long activityId, Long uid, String shareImageLink); |
| | | |
| | | |
| | | /** |
| | | * 获取详情 |
| | | * |
| | | * @param activityId |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public UserActivityExtraInfo getDetail(Long activityId, Long uid); |
| | | |
| | | |
| | | /** |
| | | * 获取分享图 |
| | | * |
| | | * @param activityId |
| | | * @param user |
| | | * @param appId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public String getShareImageLink(Long activityId, SimpleUser user, Long appId) throws Exception; |
| | | |
| | | |
| | | } |
| | |
| | | import com.beust.jcommander.ParameterException; |
| | | import com.ks.daylucky.exception.UserInfoException; |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.query.UserInfoQuery; |
| | | import com.ks.lucky.pojo.DO.BaseUser; |
| | | |
| | |
| | | */ |
| | | public Long addUserInfo(@Valid UserInfo userInfo) throws ParameterException, UserInfoException; |
| | | |
| | | public Map<Long,UserInfo> listUserInfoAsMap(BaseUser... users); |
| | | public Map<Long, UserInfo> listUserInfoAsMap(BaseUser... users); |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | public void updateUserInfo(UserInfo userInfo); |
| | | |
| | | |
| | | /** |
| | | * 获取简要用户信息 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public SimpleUser getSimpleUser(Long id); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.service.impl; |
| | | |
| | | import com.ks.daylucky.dao.ActivityDrawnRecieveNotifyInfoDao; |
| | | import com.ks.daylucky.exception.ActivityDrawnRecieveNotifyInfoException; |
| | | import com.ks.daylucky.pojo.DO.ActivityDrawnRecieveNotifyInfo; |
| | | import com.ks.daylucky.service.ActivityDrawnRecieveNotifyInfoService; |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardResult; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | |
| | | @Service |
| | | public class ActivityDrawnRecieveNotifyInfoServiceImpl implements ActivityDrawnRecieveNotifyInfoService { |
| | | |
| | | @Resource |
| | | private ActivityDrawnRecieveNotifyInfoDao activityDrawnRecieveNotifyInfoDao; |
| | | |
| | | @Validated |
| | | @Override |
| | | public void addNotify(@Valid ActivityDrawnRecieveNotifyInfo notifyInfo) throws ParamsException, ActivityDrawnRecieveNotifyInfoException { |
| | | if (notifyInfo.getCreateTime() == null) { |
| | | notifyInfo.setCreateTime(new Date()); |
| | | } |
| | | |
| | | String id = null; |
| | | switch (notifyInfo.getAwardResult().getState()) { |
| | | |
| | | case LuckyActivityAwardResult |
| | | .STATE_NOT_RECIEVE: |
| | | id = ActivityDrawnRecieveNotifyInfo.createId(notifyInfo.getAwardResult().getId(), ActivityDrawnRecieveNotifyInfo.TYPE_UNRECIEVE); |
| | | break; |
| | | |
| | | case LuckyActivityAwardResult |
| | | .STATE_OUT_OF_DATE: |
| | | id = ActivityDrawnRecieveNotifyInfo.createId(notifyInfo.getAwardResult().getId(), ActivityDrawnRecieveNotifyInfo.TYPE_OUTDATE); |
| | | break; |
| | | |
| | | default: |
| | | return; |
| | | } |
| | | //生成主键 |
| | | ActivityDrawnRecieveNotifyInfo oldInfo = activityDrawnRecieveNotifyInfoDao.get(id); |
| | | if (oldInfo != null) { |
| | | throw new ActivityDrawnRecieveNotifyInfoException(ActivityDrawnRecieveNotifyInfoException.CODE_EXIST, "通知已经存在"); |
| | | } |
| | | notifyInfo.setId(id); |
| | | activityDrawnRecieveNotifyInfoDao.save(notifyInfo); |
| | | } |
| | | |
| | | @Override |
| | | public ActivityDrawnRecieveNotifyInfo getShowNotifyInfo(Long appId, Long uid, Long activityId) { |
| | | |
| | | return activityDrawnRecieveNotifyInfoDao.getShowNotifyInfo(appId, uid, activityId); |
| | | } |
| | | |
| | | @Override |
| | | public void setNotifyShown(String id) { |
| | | ActivityDrawnRecieveNotifyInfo update = new ActivityDrawnRecieveNotifyInfo(); |
| | | update.setId(id); |
| | | update.setShown(true); |
| | | update.setShowTime(new Date()); |
| | | activityDrawnRecieveNotifyInfoDao.updateSelective(update); |
| | | } |
| | | |
| | | @Override |
| | | public ActivityDrawnRecieveNotifyInfo selectByPrimaryKey(String id) { |
| | | return activityDrawnRecieveNotifyInfoDao.get(id); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.service.impl; |
| | | |
| | | import com.ks.daylucky.dao.ActivityExtraInfoDao; |
| | | import com.ks.daylucky.pojo.DO.ActivityExtraInfo; |
| | | import com.ks.daylucky.pojo.VO.ActivityAwardVO; |
| | | import com.ks.daylucky.service.ActivityExtraInfoService; |
| | | import com.ks.daylucky.util.DrawImageManager; |
| | | import org.springframework.stereotype.Service; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 活动附加信息服务 |
| | | */ |
| | | @Service |
| | | public class ActivityExtraInfoServiceImpl implements ActivityExtraInfoService { |
| | | |
| | | @Resource |
| | | private ActivityExtraInfoDao activityExtraInfoDao; |
| | | |
| | | @Resource |
| | | private DrawImageManager drawImageManager; |
| | | |
| | | @Override |
| | | public void add(ActivityExtraInfo info) { |
| | | if (info.getCreateTime() == null) { |
| | | info.setCreateTime(new Date()); |
| | | } |
| | | activityExtraInfoDao.save(info); |
| | | } |
| | | |
| | | @Override |
| | | public void saveShareImage(Long activityId, String shareImageLink) { |
| | | ActivityExtraInfo old = getDetail(activityId); |
| | | if (old == null) { |
| | | //新增 |
| | | ActivityExtraInfo info = new ActivityExtraInfo(); |
| | | info.setActivityId(activityId); |
| | | info.setShareImageLink(shareImageLink); |
| | | add(info); |
| | | } else { |
| | | //修改 |
| | | ActivityExtraInfo update = new ActivityExtraInfo(); |
| | | update.setShareImageLink(shareImageLink); |
| | | update.setActivityId(activityId); |
| | | activityExtraInfoDao.updateSelective(update); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public ActivityExtraInfo getDetail(Long activityId) { |
| | | return activityExtraInfoDao.get(activityId); |
| | | } |
| | | |
| | | @Override |
| | | public String getShareImageLink(Long activityId, List<ActivityAwardVO> voList, Long appId) throws Exception { |
| | | ActivityExtraInfo extraInfo = getDetail(activityId); |
| | | if (extraInfo != null && !StringUtil.isNullOrEmpty(extraInfo.getShareImageLink())) { |
| | | return extraInfo.getShareImageLink(); |
| | | } |
| | | String result = drawImageManager.drawActivityShareImage(activityId, voList, appId); |
| | | saveShareImage(activityId, result); |
| | | return result; |
| | | } |
| | | } |
| | |
| | | if (maxJoinerCount != null) { |
| | | //获取最近的参与者列表 |
| | | List<SimpleUser> userList = new ArrayList<>(); |
| | | List<ActivitySimpleUser> list = luckyActivityJoinService.getJoinerList(activityId, 1, Constant.PAGE_SIZE); |
| | | List<ActivitySimpleUser> list = luckyActivityJoinService.getJoinerList(activityId, null,1, Constant.PAGE_SIZE); |
| | | if (list != null && list.size() > 0) { |
| | | Map<Long, UserInfo> userInfoMap = userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(list)); |
| | | for (ActivitySimpleUser info : list) { |
New file |
| | |
| | | package com.ks.daylucky.service.impl; |
| | | |
| | | import com.ks.daylucky.dao.UserActivityExtraInfoDao; |
| | | 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.service.UserActivityExtraInfoService; |
| | | import com.ks.daylucky.util.DrawImageManager; |
| | | import org.springframework.stereotype.Service; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 活动附加信息服务 |
| | | */ |
| | | @Service |
| | | public class UserActivityExtraInfoServiceImpl implements UserActivityExtraInfoService { |
| | | |
| | | @Resource |
| | | private UserActivityExtraInfoDao userActivityExtraInfoDao; |
| | | |
| | | @Resource |
| | | private DrawImageManager drawImageManager; |
| | | |
| | | @Override |
| | | public void add(UserActivityExtraInfo info) { |
| | | if (info.getCreateTime() == null) { |
| | | info.setCreateTime(new Date()); |
| | | } |
| | | userActivityExtraInfoDao.save(info); |
| | | } |
| | | |
| | | @Override |
| | | public void saveShareImage(Long activityId, Long uid, String shareImageLink) { |
| | | UserActivityExtraInfo old = getDetail(activityId, uid); |
| | | if (old != null) { |
| | | //修改 |
| | | UserActivityExtraInfo update = new UserActivityExtraInfo(); |
| | | update.setId(old.getId()); |
| | | update.setShareImageLink(shareImageLink); |
| | | userActivityExtraInfoDao.updateSelective(update); |
| | | } else { |
| | | //新增 |
| | | UserActivityExtraInfo info = new UserActivityExtraInfo(); |
| | | info.setId(UserActivityExtraInfo.createId(activityId, uid)); |
| | | info.setActivityId(activityId); |
| | | info.setShareImageLink(shareImageLink); |
| | | info.setUid(uid); |
| | | add(info); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public UserActivityExtraInfo getDetail(Long activityId, Long uid) { |
| | | String id = UserActivityExtraInfo.createId(activityId, uid); |
| | | return userActivityExtraInfoDao.get(id); |
| | | } |
| | | |
| | | @Override |
| | | public String getShareImageLink(Long activityId, SimpleUser user, Long appId) throws Exception { |
| | | UserActivityExtraInfo info = getDetail(activityId, user.getUid()); |
| | | if (info != null && !StringUtil.isNullOrEmpty(info.getShareImageLink())) { |
| | | return info.getShareImageLink(); |
| | | } |
| | | |
| | | String result = drawImageManager.drawAssistShareImage(activityId, user, appId); |
| | | saveShareImage(activityId, user.getUid(), result); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.ks.daylucky.mapper.UserInfoMapper; |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.DO.UserInfoExtra; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.query.UserInfoQuery; |
| | | import com.ks.daylucky.service.UserInfoExtraService; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | |
| | | userInfo.setUpdateTime(new Date()); |
| | | userInfoMapper.updateByPrimaryKeySelective(userInfo); |
| | | } |
| | | |
| | | @Override |
| | | public SimpleUser getSimpleUser(Long id) { |
| | | UserInfo user = userInfoMapper.selectByPrimaryKey(id); |
| | | if (user == null) { |
| | | return null; |
| | | } |
| | | return new SimpleUser(user.getId(), user.getNickName(), user.getPortrait()); |
| | | } |
| | | } |
| | |
| | | package com.ks.daylucky.service.impl.remote; |
| | | |
| | | import com.ks.daylucky.dao.UserMsgDao; |
| | | import com.ks.daylucky.exception.UserMsgException; |
| | | import com.ks.daylucky.mapper.UserMsgMapper; |
| | | import com.ks.daylucky.pojo.DO.UserMsg; |
| | | import com.ks.daylucky.query.UserMsgQuery; |
| | | import com.ks.daylucky.service.UserMsgService; |
| | |
| | | @Service |
| | | public class UserMsgServiceImpl implements UserMsgService { |
| | | @Resource |
| | | private UserMsgMapper userMsgMapper; |
| | | private UserMsgDao userMsgDao; |
| | | |
| | | @Validated |
| | | @Override |
| | |
| | | if (userMsg.getCreateTime() == null) { |
| | | userMsg.setCreateTime(new Date()); |
| | | } |
| | | userMsgMapper.insertSelective(userMsg); |
| | | userMsg.setId(UserMsg.createId(userMsg.getUid())); |
| | | |
| | | userMsgDao.save(userMsg); |
| | | } |
| | | |
| | | @Override |
| | |
| | | query.uid = uid; |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | query.sortList = Arrays.asList(new String[]{"create_time desc"}); |
| | | query.sortList = Arrays.asList(new String[]{"createTime desc"}); |
| | | |
| | | return userMsgMapper.list(query); |
| | | return userMsgDao.list(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countUserMsg(Long uid) { |
| | | UserMsgQuery query = new UserMsgQuery(); |
| | | query.uid = uid; |
| | | return userMsgMapper.count(query); |
| | | return userMsgDao.count(query); |
| | | } |
| | | |
| | | @Override |
| | | public List<UserMsg> getUserMsgList(UserMsgQuery query, int page, int pageSize) { |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | return userMsgMapper.list(query); |
| | | return userMsgDao.list(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countUserMsg(UserMsgQuery query) { |
| | | return userMsgMapper.count(query); |
| | | return userMsgDao.count(query); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(Long id) { |
| | | userMsgMapper.deleteByPrimaryKey(id); |
| | | userMsgDao.delete(id); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.util; |
| | | |
| | | import com.ks.daylucky.pojo.DO.AppConfig; |
| | | import com.ks.daylucky.pojo.DTO.ConfigKeyEnum; |
| | | import com.ks.daylucky.pojo.VO.ActivityAwardVO; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.service.AppConfigService; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.HttpUtil; |
| | | import org.yeshi.utils.entity.FileUploadResult; |
| | | import org.yeshi.utils.tencentcloud.COSManager; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.InputStream; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 画图管理 |
| | | */ |
| | | @Component |
| | | public class DrawImageManager { |
| | | @Resource |
| | | private AppConfigService appConfigService; |
| | | |
| | | |
| | | /** |
| | | * 画活动分享图 |
| | | * |
| | | * @param activityId |
| | | * @param voList |
| | | * @param appId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public String drawActivityShareImage(Long activityId, List<ActivityAwardVO> voList, Long appId) throws Exception { |
| | | AppConfig appConfig = appConfigService.getConfigCache(appId, ConfigKeyEnum.activityShareImageBg, null); |
| | | if (appConfig == null) { |
| | | throw new Exception("底图不存在"); |
| | | } |
| | | InputStream inputStream = HttpUtil.getAsInputStream(appConfig.getValue()); |
| | | if (inputStream == null) { |
| | | throw new Exception("底图读取错误"); |
| | | } |
| | | InputStream resultInput = ImageUtil.drawActivityShareImage(voList, inputStream); |
| | | FileUploadResult result = COSManager.getInstance().uploadFile(resultInput, String.format("/image/share/activity/%s_%s.jpg", activityId, System.currentTimeMillis())); |
| | | if (result == null) { |
| | | throw new Exception("上传图片出错"); |
| | | } |
| | | return result.getUrl(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 画助力分享图 |
| | | * |
| | | * @param activityId |
| | | * @param user |
| | | * @param appId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public String drawAssistShareImage(Long activityId, SimpleUser user, Long appId) throws Exception { |
| | | AppConfig appConfig = appConfigService.getConfigCache(appId, ConfigKeyEnum.assistShareImageBg, null); |
| | | if (appConfig == null) { |
| | | throw new Exception("底图不存在"); |
| | | } |
| | | InputStream inputStream = HttpUtil.getAsInputStream(appConfig.getValue()); |
| | | if (inputStream == null) { |
| | | throw new Exception("底图读取错误"); |
| | | } |
| | | InputStream resultInput = ImageUtil.drawActivityUserShareImage(user, inputStream); |
| | | FileUploadResult result = COSManager.getInstance().uploadFile(resultInput, String.format("/image/share/assist/%s_%s_%s.jpg", activityId, user.getUid(), System.currentTimeMillis())); |
| | | if (result == null) { |
| | | throw new Exception("上传图片出错"); |
| | | } |
| | | return result.getUrl(); |
| | | |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.util; |
| | | |
| | | import com.ks.daylucky.pojo.VO.ActivityAwardVO; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import org.yeshi.utils.FileUtil; |
| | | import org.yeshi.utils.HttpUtil; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import java.awt.*; |
| | | import java.awt.RenderingHints.Key; |
| | | import java.awt.geom.RoundRectangle2D; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.*; |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | public class ImageUtil { |
| | | |
| | | |
| | | private static Font getFont() throws FontFormatException, IOException { |
| | | InputStream fi = ImageUtil.class.getClassLoader().getResourceAsStream("font/msyh.ttf"); |
| | | Font font = Font.createFont(Font.PLAIN, fi); |
| | | return font; |
| | | } |
| | | |
| | | /** |
| | | * 画活动分享图 |
| | | * |
| | | * @param awardVOList |
| | | * @param bg |
| | | * @return |
| | | * @throws FontFormatException |
| | | * @throws IOException |
| | | */ |
| | | public static InputStream drawActivityShareImage(List<ActivityAwardVO> awardVOList, InputStream bg) throws FontFormatException, IOException { |
| | | Font font = getFont(); |
| | | font = font.deriveFont(30.0f); |
| | | int width = 750; |
| | | int height = 825; |
| | | final BufferedImage targetImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); |
| | | final Graphics2D g2d = (Graphics2D) targetImg.getGraphics(); |
| | | RenderingHints rh = new RenderingHints( |
| | | RenderingHints.KEY_TEXT_ANTIALIASING, |
| | | RenderingHints.VALUE_TEXT_ANTIALIAS_GASP); |
| | | g2d.setRenderingHints(rh); |
| | | g2d.setFont(font); |
| | | //画背景 |
| | | g2d.drawImage(ImageIO.read(bg), 0, 0, width, height, null); |
| | | //--画奖项-- |
| | | //计算奖项占高 |
| | | int lineSpaceHeight = 5; |
| | | int awardSpaceHeight = 23; |
| | | int totalHeight = 0; |
| | | int maxWidth = 608; |
| | | int paddintTop = 21; |
| | | int paddingBottom = 21; |
| | | for (ActivityAwardVO vo : awardVOList) { |
| | | totalHeight += computeStringHeight(g2d, font, vo.getTitle(), maxWidth, lineSpaceHeight); |
| | | } |
| | | |
| | | totalHeight += (awardVOList.size() - 1) * awardSpaceHeight + paddintTop + paddingBottom; |
| | | |
| | | |
| | | //画背景 |
| | | |
| | | g2d.fillRoundRect(20, 625 - totalHeight, 711, totalHeight, 16, 16); |
| | | |
| | | int startY = 625 - totalHeight+paddintTop; |
| | | //画奖品 |
| | | g2d.setColor(Color.decode("#333333")); |
| | | for (ActivityAwardVO vo : awardVOList) { |
| | | //画图标 |
| | | InputStream icon = HttpUtil.getAsInputStream(vo.getTypeIcon()); |
| | | BufferedImage iconImage = zoomInImage(ImageIO.read(icon), 28, 28); |
| | | g2d.drawImage(iconImage, 48, startY, iconImage.getWidth(), iconImage.getHeight(), null); |
| | | //画文字 |
| | | drawString(g2d, font, vo.getTitle(), maxWidth, lineSpaceHeight, 86, startY + font.getSize()-5); |
| | | startY += computeStringHeight(g2d, font, vo.getTitle(), maxWidth, lineSpaceHeight) + awardSpaceHeight; |
| | | } |
| | | |
| | | |
| | | g2d.dispose(); |
| | | |
| | | ByteArrayOutputStream aos = new ByteArrayOutputStream(); |
| | | ImageIO.write(targetImg, "JPEG", aos); |
| | | return new ByteArrayInputStream(aos.toByteArray()); |
| | | } |
| | | |
| | | /** |
| | | * 画活动用户分享图 |
| | | * |
| | | * @param user |
| | | * @param bg |
| | | * @return |
| | | * @throws FontFormatException |
| | | * @throws IOException |
| | | */ |
| | | public static InputStream drawActivityUserShareImage(SimpleUser user, InputStream bg) throws FontFormatException, IOException { |
| | | Font font = getFont(); |
| | | font = font.deriveFont(24.76f); |
| | | int width = 750; |
| | | int height = 825; |
| | | final BufferedImage targetImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); |
| | | final Graphics2D g2d = (Graphics2D) targetImg.getGraphics(); |
| | | RenderingHints rh = new RenderingHints( |
| | | RenderingHints.KEY_TEXT_ANTIALIASING, |
| | | RenderingHints.VALUE_TEXT_ANTIALIAS_GASP); |
| | | g2d.setRenderingHints(rh); |
| | | g2d.setFont(font); |
| | | |
| | | //画背景 |
| | | g2d.drawImage(ImageIO.read(bg), 0, 0, width, height, null); |
| | | |
| | | InputStream icon = HttpUtil.getAsInputStream(user.getPortrait()); |
| | | BufferedImage portrait = roundImage(zoomInImage(ImageIO.read(icon), 103, 103), 500); |
| | | |
| | | g2d.drawImage(portrait, null, (width - portrait.getWidth()) / 2, 35); |
| | | FontMetrics fm = g2d.getFontMetrics(font); |
| | | int nickNameWidth = fm.stringWidth(user.getNickName()); |
| | | g2d.drawString(user.getNickName(), (width - nickNameWidth) / 2, portrait.getHeight() + 35 + 8 + 25); |
| | | |
| | | g2d.dispose(); |
| | | ByteArrayOutputStream aos = new ByteArrayOutputStream(); |
| | | ImageIO.write(targetImg, "JPEG", aos); |
| | | return new ByteArrayInputStream(aos.toByteArray()); |
| | | } |
| | | |
| | | |
| | | private static int computeStringHeight(Graphics2D g2d, Font font, String content, int maxWidth, int spaceHeight) { |
| | | FontMetrics fm = g2d.getFontMetrics(font); |
| | | int start = 0; |
| | | int rows = 1; |
| | | for (int i = 0; i < content.length(); i++) { |
| | | if (fm.stringWidth(content.substring(start, i)) > maxWidth) { |
| | | start = i; |
| | | rows++; |
| | | } |
| | | } |
| | | |
| | | return font.getSize() * rows + (rows - 1) * spaceHeight; |
| | | } |
| | | |
| | | |
| | | private static void drawString(Graphics2D g2d, Font font, String content, int maxWidth, int spaceHeight, int startX, int startY) { |
| | | FontMetrics fm = g2d.getFontMetrics(font); |
| | | int start = 0; |
| | | List<String> rowsContentList = new ArrayList<>(); |
| | | for (int i = 0; i < content.length(); i++) { |
| | | if (fm.stringWidth(content.substring(start, i)) >= maxWidth) { |
| | | rowsContentList.add(content.substring(start, i)); |
| | | start = i; |
| | | } else if (i == content.length() - 1) {//结束 |
| | | rowsContentList.add(content.substring(start, i)); |
| | | } |
| | | } |
| | | |
| | | for (int i = 0; i < rowsContentList.size(); i++) { |
| | | g2d.drawString(rowsContentList.get(i), startX, startY + i * spaceHeight + font.getSize() * i); |
| | | } |
| | | } |
| | | |
| | | |
| | | private static int[] computeCropPosition(BufferedImage source, int width, int height) { |
| | | int[] cropParams = new int[4]; |
| | | int owidth = source.getWidth(); |
| | | int oheight = source.getHeight(); |
| | | if (oheight * width - owidth * height > 0) { |
| | | cropParams[0] = 0; |
| | | cropParams[1] = (oheight - height) / 2; |
| | | cropParams[2] = owidth; |
| | | cropParams[3] = cropParams[2] * height / width; |
| | | } else { |
| | | cropParams[0] = (owidth - width) / 2; |
| | | cropParams[1] = 0; |
| | | cropParams[3] = oheight; |
| | | cropParams[2] = cropParams[3] * width / height; |
| | | } |
| | | |
| | | return cropParams; |
| | | } |
| | | |
| | | public static BufferedImage crop(BufferedImage source, int startX, int startY, int w, int h) { |
| | | int width = source.getWidth(); |
| | | int height = source.getHeight(); |
| | | |
| | | if (startX <= -1) { |
| | | startX = 0; |
| | | } |
| | | if (startY <= -1) { |
| | | startY = 0; |
| | | } |
| | | if (w <= -1) { |
| | | w = width - 1; |
| | | } |
| | | if (h <= -1) { |
| | | h = height - 1; |
| | | } |
| | | BufferedImage result = new BufferedImage(w, h, source.getType()); |
| | | for (int y = startY; y < h + startY; y++) { |
| | | for (int x = startX; x < w + startX; x++) { |
| | | int rgb = source.getRGB(x, y); |
| | | result.setRGB(x - startX, y - startY, rgb); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public static BufferedImage zoomInImage(BufferedImage originalImage, int width, int height) { |
| | | int type = originalImage.getType(); |
| | | if (type == 0) |
| | | type = 5; |
| | | BufferedImage newImage = new BufferedImage(width, height, type); |
| | | Graphics g = newImage.getGraphics(); |
| | | g.drawImage(originalImage, 0, 0, width, height, null); |
| | | g.dispose(); |
| | | return newImage; |
| | | } |
| | | |
| | | |
| | | // 二维码 |
| | | public static BufferedImage qrCodeImage(Graphics2D g2d, BufferedImage originalImage, int pX, int pY, int width, |
| | | int height) { |
| | | g2d.drawImage(originalImage, pX, pY, width, height, null); |
| | | return originalImage; |
| | | } |
| | | |
| | | |
| | | public static BufferedImage roundImage(BufferedImage srcImage, int cornerRadius) { // 半径 |
| | | int width = srcImage.getWidth(); |
| | | int height = srcImage.getHeight(); |
| | | BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); |
| | | Graphics2D gs = image.createGraphics(); |
| | | HashMap<Key, Object> mapH = new HashMap<Key, Object>(); |
| | | mapH.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);// 抗锯齿 (抗锯齿总开关) |
| | | mapH.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);// 文字抗锯齿 |
| | | gs.setRenderingHints(mapH); |
| | | gs.setClip(new RoundRectangle2D.Double(0, 0, width, height, cornerRadius, cornerRadius)); |
| | | gs.drawImage(srcImage, 0, 0, null); |
| | | gs.dispose(); |
| | | return image; |
| | | } |
| | | |
| | | public static int saveToImgByInputStream(InputStream inputStream, String imgPath, String imgName) { |
| | | int stateInt = 1; |
| | | try { |
| | | File file = new File(imgPath, imgName);// 可以是任何图片格式.jpg,.png等 |
| | | FileOutputStream fos = new FileOutputStream(file); |
| | | |
| | | FileInputStream fis = (FileInputStream) inputStream; |
| | | |
| | | byte[] b = new byte[1024]; |
| | | int nRead = 0; |
| | | while ((nRead = fis.read(b)) != -1) { |
| | | fos.write(b, 0, nRead); |
| | | } |
| | | fos.flush(); |
| | | fos.close(); |
| | | fis.close(); |
| | | |
| | | } catch (Exception e) { |
| | | stateInt = 0; |
| | | e.printStackTrace(); |
| | | } finally { |
| | | } |
| | | return stateInt; |
| | | } |
| | | |
| | | public static int getTextLengthByWidth(Graphics2D g2d, Font font, String content, int maxWidth, int startPos) { |
| | | FontMetrics fm = g2d.getFontMetrics(font); |
| | | for (int i = startPos; i < content.length(); i++) { |
| | | if (fm.stringWidth(content.substring(0, i)) >= maxWidth) { |
| | | return i + 1; |
| | | } |
| | | } |
| | | return content.length(); |
| | | } |
| | | |
| | | public static int[] getImgWidthAndHeight(String imgUrl) throws MalformedURLException, IOException { |
| | | if (StringUtil.isNullOrEmpty(imgUrl)) { |
| | | return new int[]{0, 0}; |
| | | } |
| | | if (imgUrl.toLowerCase().endsWith("webp")) { |
| | | return getImgWidthAndHeightWithWebp(imgUrl); |
| | | } else { |
| | | return getImgWidthAndHeightWithPngAndJpg(imgUrl); |
| | | } |
| | | } |
| | | |
| | | public static int[] getImgWidthAndHeightWithPngAndJpg(String imgUrl) throws MalformedURLException, IOException { |
| | | InputStream murl = new URL(imgUrl).openStream(); |
| | | BufferedImage sourceImg = ImageIO.read(murl); |
| | | |
| | | int width = sourceImg.getWidth(); |
| | | int height = sourceImg.getHeight(); |
| | | return new int[]{width, height}; |
| | | } |
| | | |
| | | public static int[] getImgWidthAndHeightWithWebp(String imgUrl) throws MalformedURLException, IOException { |
| | | String cacheFile = FileUtil.getCacheDir(); |
| | | String targetPath = cacheFile + "/CACHE_DOWNLOAD_IMG_" + System.currentTimeMillis() + "_" |
| | | + (long) (Math.random() * 1000000000L); |
| | | HttpUtil.downloadFile(imgUrl, targetPath); |
| | | FileInputStream file = new FileInputStream(targetPath); |
| | | byte[] bytes = new byte[30]; |
| | | file.read(bytes, 0, bytes.length); |
| | | int width = ((int) bytes[27] & 0xff) << 8 | ((int) bytes[26] & 0xff); |
| | | int height = ((int) bytes[29] & 0xff) << 8 | ((int) bytes[28] & 0xff); |
| | | file.close(); |
| | | return new int[]{width, height}; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.util.factory; |
| | | |
| | | import com.ks.daylucky.pojo.DTO.msg.LuckyMsgContent; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.util.activity.ActivityUtil; |
| | | |
| | | public class LuckyMsgContentFactory { |
| | | |
| | | |
| | | /** |
| | | * 参与抽奖 |
| | | * |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | public static LuckyMsgContent createJoinSuccess(Long activityId) { |
| | | LuckyMsgContent msgContent = new LuckyMsgContent(); |
| | | msgContent.setLuckyMsgType(LuckyMsgContent.LuckyMsgType.joinSuccess); |
| | | msgContent.setActivityId(activityId); |
| | | msgContent.setDateNumber(ActivityUtil.getActivityDateNumber(activityId)); |
| | | msgContent.setRemarks("无"); |
| | | return msgContent; |
| | | } |
| | | |
| | | /** |
| | | * 未中奖 |
| | | * |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | public static LuckyMsgContent createNotDrawn(Long activityId) { |
| | | LuckyMsgContent msgContent = new LuckyMsgContent(); |
| | | msgContent.setLuckyMsgType(LuckyMsgContent.LuckyMsgType.notDrawn); |
| | | msgContent.setActivityId(activityId); |
| | | msgContent.setDateNumber(ActivityUtil.getActivityDateNumber(activityId)); |
| | | msgContent.setRemarks("无"); |
| | | msgContent.setOpenState("已开奖"); |
| | | msgContent.setDrawnState("很遗憾,未中奖"); |
| | | return msgContent; |
| | | } |
| | | |
| | | /** |
| | | * 中奖了 |
| | | * |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | public static LuckyMsgContent createDrawn(Long activityId, String awardName) { |
| | | LuckyMsgContent msgContent = new LuckyMsgContent(); |
| | | msgContent.setLuckyMsgType(LuckyMsgContent.LuckyMsgType.joinSuccess); |
| | | msgContent.setActivityId(activityId); |
| | | msgContent.setDateNumber(ActivityUtil.getActivityDateNumber(activityId)); |
| | | msgContent.setRemarks("无"); |
| | | msgContent.setOpenState("已开奖"); |
| | | msgContent.setAwardName(awardName); |
| | | msgContent.setDrawnState("恭喜你,中奖了!"); |
| | | return msgContent; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 中途结束/未满足开奖条件 |
| | | * |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | public static LuckyMsgContent createOpenFail(Long activityId) { |
| | | LuckyMsgContent msgContent = new LuckyMsgContent(); |
| | | msgContent.setLuckyMsgType(LuckyMsgContent.LuckyMsgType.openFail); |
| | | msgContent.setActivityId(activityId); |
| | | msgContent.setDateNumber(ActivityUtil.getActivityDateNumber(activityId)); |
| | | msgContent.setRemarks("无"); |
| | | msgContent.setOpenState("未能满足开奖条件,已结束。"); |
| | | return msgContent; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 好友助力 |
| | | * |
| | | * @param activityId |
| | | * @param user |
| | | * @param weight |
| | | * @return |
| | | */ |
| | | public static LuckyMsgContent createAssist(Long activityId, SimpleUser user, int weight) { |
| | | LuckyMsgContent msgContent = new LuckyMsgContent(); |
| | | msgContent.setLuckyMsgType(LuckyMsgContent.LuckyMsgType.assist); |
| | | msgContent.setActivityId(activityId); |
| | | msgContent.setDateNumber(ActivityUtil.getActivityDateNumber(activityId)); |
| | | msgContent.setRemarks("无"); |
| | | msgContent.setWeight(weight); |
| | | msgContent.setAssistUser(user); |
| | | return msgContent; |
| | | } |
| | | |
| | | /** |
| | | * 好友助力且参与 |
| | | * |
| | | * @param activityId |
| | | * @param user |
| | | * @param weight |
| | | * @return |
| | | */ |
| | | public static LuckyMsgContent createAssistAndJoin(Long activityId, SimpleUser user, int weight) { |
| | | LuckyMsgContent msgContent = new LuckyMsgContent(); |
| | | msgContent.setLuckyMsgType(LuckyMsgContent.LuckyMsgType.assistAndJoin); |
| | | msgContent.setActivityId(activityId); |
| | | msgContent.setDateNumber(ActivityUtil.getActivityDateNumber(activityId)); |
| | | msgContent.setRemarks("无"); |
| | | msgContent.setWeight(weight); |
| | | msgContent.setAssistUser(user); |
| | | return msgContent; |
| | | } |
| | | |
| | | /** |
| | | * 奖品过期未领 |
| | | * |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | public static LuckyMsgContent createReceiveOutDate(Long activityId) { |
| | | LuckyMsgContent msgContent = new LuckyMsgContent(); |
| | | msgContent.setLuckyMsgType(LuckyMsgContent.LuckyMsgType.receiveOutDate); |
| | | msgContent.setActivityId(activityId); |
| | | msgContent.setDateNumber(ActivityUtil.getActivityDateNumber(activityId)); |
| | | msgContent.setRemarks("无"); |
| | | msgContent.setReceiveState("本抽奖活动你中奖了,过期未领"); |
| | | msgContent.setOutDateAwardState("已原路退回赞助商"); |
| | | return msgContent; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.util.factory; |
| | | |
| | | import com.ks.daylucky.pojo.DO.UserMsg; |
| | | import com.ks.daylucky.pojo.DTO.msg.LuckyMsgContent; |
| | | |
| | | public class UserMsgFactory { |
| | | |
| | | public static UserMsg createLuckyMsg(Long uid, LuckyMsgContent content) { |
| | | UserMsg userMsg = new UserMsg(); |
| | | userMsg.setLuckyMsgContent(content); |
| | | userMsg.setMsgType(UserMsg.UserMsgType.lucky); |
| | | userMsg.setUid(uid); |
| | | return userMsg; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.util.factory.vo; |
| | | |
| | | import com.ks.daylucky.pojo.DO.UserMsg; |
| | | import com.ks.daylucky.pojo.DTO.msg.LuckyMsgContent; |
| | | import com.ks.daylucky.pojo.VO.UserMsgContentVO; |
| | | import com.ks.daylucky.pojo.VO.UserMsgVO; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class UserMsgVOFactory { |
| | | |
| | | public static UserMsgVO create(UserMsg msg) { |
| | | UserMsgVO vo = new UserMsgVO(); |
| | | vo.setIcon(""); |
| | | vo.setName(msg.getMsgType().getName()); |
| | | vo.setTime(msg.getCreateTime()); |
| | | if (msg.getMsgType() == UserMsg.UserMsgType.lucky) { |
| | | vo.setContentList(create(msg.getLuckyMsgContent())); |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | private static String getDateNumber(String dateNumber) { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append(" <div style=\"display: flex;justify-content: space-between;\">"); |
| | | builder.append("<span>" + dateNumber + "</span>"); |
| | | builder.append("<a style='color:#theme'>查看详情</a>"); |
| | | builder.append("</div>"); |
| | | return builder.toString(); |
| | | } |
| | | |
| | | private static List<UserMsgContentVO> create(LuckyMsgContent luckyMsgContent) { |
| | | LuckyMsgContent.LuckyMsgType luckyMsgType = luckyMsgContent.getLuckyMsgType(); |
| | | List<UserMsgContentVO> voList = new ArrayList<>(); |
| | | voList.add(new UserMsgContentVO("活动期号", getDateNumber(luckyMsgContent.getDateNumber()))); |
| | | |
| | | if (luckyMsgType == LuckyMsgContent.LuckyMsgType.joinSuccess) { |
| | | voList.add(new UserMsgContentVO("状态", "参与成功")); |
| | | } else if (luckyMsgType == LuckyMsgContent.LuckyMsgType.receiveOutDate) { |
| | | voList.add(new UserMsgContentVO("领取状态", luckyMsgContent.getReceiveState())); |
| | | voList.add(new UserMsgContentVO("奖品权益", luckyMsgContent.getOutDateAwardState())); |
| | | } else if (luckyMsgType == LuckyMsgContent.LuckyMsgType.assistAndJoin) { |
| | | voList.add(new UserMsgContentVO("助力状态", "助力好友<img src='" + luckyMsgContent.getAssistUser().getPortrait() + "'>成功参与了抽奖")); |
| | | voList.add(new UserMsgContentVO("幸运券数", String.format("+%s张", luckyMsgContent.getWeight()))); |
| | | } else if (luckyMsgType == LuckyMsgContent.LuckyMsgType.assist) { |
| | | voList.add(new UserMsgContentVO("助力状态", "好友<img src='" + luckyMsgContent.getAssistUser().getPortrait() + "'>助力成功")); |
| | | voList.add(new UserMsgContentVO("幸运券数", String.format("+%s张", luckyMsgContent.getWeight()))); |
| | | } else if (luckyMsgType == LuckyMsgContent.LuckyMsgType.openFail) { |
| | | voList.add(new UserMsgContentVO("开奖状态", luckyMsgContent.getOpenState())); |
| | | } else if (luckyMsgType == LuckyMsgContent.LuckyMsgType.notDrawn) { |
| | | voList.add(new UserMsgContentVO("开奖状态", luckyMsgContent.getOpenState())); |
| | | voList.add(new UserMsgContentVO("中奖状态", luckyMsgContent.getDrawnState())); |
| | | } else if (luckyMsgType == LuckyMsgContent.LuckyMsgType.drawn) { |
| | | voList.add(new UserMsgContentVO("开奖状态", luckyMsgContent.getOpenState())); |
| | | voList.add(new UserMsgContentVO("中奖状态", luckyMsgContent.getDrawnState())); |
| | | voList.add(new UserMsgContentVO("奖 品", luckyMsgContent.getAwardName())); |
| | | } |
| | | |
| | | voList.add(new UserMsgContentVO("备注", luckyMsgContent.getRemarks())); |
| | | return voList; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.util.mq; |
| | | |
| | | import com.ks.lucky.utils.LuckyCMQConstant; |
| | | import com.qcloud.cmq.Message; |
| | | import org.yeshi.utils.CMQUtil; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class CMQManager { |
| | | |
| | | |
| | | private static String secretId = "AKIDTlpgJhLjOozvd6QI2XnpfGbgV4NQJk25"; |
| | | private static String secretKey = "xhCSUHo55oHUQ6XicFcmfIgspX0EEzWo"; |
| | | private static CMQManager cmqManager; |
| | | private static CMQUtil cmqUtil; |
| | | /** |
| | | * 消息 |
| | | */ |
| | | public static String QUEUENAME_DAY_LUCKY_MSG = "day-lucky-msg"; |
| | | |
| | | /** |
| | | * 活动中奖通知 |
| | | */ |
| | | public static String QUEUENAME_DAY_LUCKY_ACTIVITY_DRAWN = "day-lucky-activity-drawn-notify"; |
| | | |
| | | |
| | | static { |
| | | cmqUtil = CMQUtil.getInstance(secretId, secretKey); |
| | | // 最大消息为1M |
| | | cmqUtil.createQueue(QUEUENAME_DAY_LUCKY_MSG, 1024 * 1024); |
| | | cmqUtil.createQueue(QUEUENAME_DAY_LUCKY_ACTIVITY_DRAWN, 1024 * 1024); |
| | | |
| | | try { |
| | | cmqUtil.subscribeTopic(LuckyCMQConstant.TOPIC_ACTIVITY_STATE_CHANGE, "msg_activity-state-change", QUEUENAME_DAY_LUCKY_MSG); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | try { |
| | | cmqUtil.subscribeTopic(LuckyCMQConstant.TOPIC_ASSIST, "msg_assist", QUEUENAME_DAY_LUCKY_MSG); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | |
| | | try { |
| | | cmqUtil.subscribeTopic(LuckyCMQConstant.TOPIC_ACTIVITY_DRAWN, "msg_activity_drawn", QUEUENAME_DAY_LUCKY_MSG); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | |
| | | try { |
| | | cmqUtil.subscribeTopic(LuckyCMQConstant.TOPIC_ACTIVITY_JOIN, "msg_activity_join", QUEUENAME_DAY_LUCKY_MSG); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | try { |
| | | cmqUtil.subscribeTopic(LuckyCMQConstant.TOPIC_ACTIVITY_DRAWN, "notify_activity_drawn", QUEUENAME_DAY_LUCKY_ACTIVITY_DRAWN); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | } |
| | | |
| | | public static CMQManager getInstance() { |
| | | if (cmqManager == null) { |
| | | cmqManager = new CMQManager(); |
| | | } |
| | | return cmqManager; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 活动消息消费 |
| | | * |
| | | * @param count |
| | | * @return |
| | | */ |
| | | public List<Message> consumeMsgMsg(int count) { |
| | | List<Message> list = cmqUtil.recieveMsg(count, QUEUENAME_DAY_LUCKY_MSG); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 删除活动消息 |
| | | * |
| | | * @param receiptHandle |
| | | */ |
| | | public void deleteMsgMsg(String receiptHandle) { |
| | | cmqUtil.deleteMsg(QUEUENAME_DAY_LUCKY_MSG, receiptHandle); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 活动消息消费 |
| | | * |
| | | * @param count |
| | | * @return |
| | | */ |
| | | public List<Message> consumeActivityDrawnMsg(int count) { |
| | | List<Message> list = cmqUtil.recieveMsg(count, QUEUENAME_DAY_LUCKY_ACTIVITY_DRAWN); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 删除活动消息 |
| | | * |
| | | * @param receiptHandle |
| | | */ |
| | | public void deleteActivityDrawnMsg(String receiptHandle) { |
| | | cmqUtil.deleteMsg(QUEUENAME_DAY_LUCKY_ACTIVITY_DRAWN, receiptHandle); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.util.mq.consumer; |
| | | |
| | | import com.ks.daylucky.pojo.DO.ActivityDrawnRecieveNotifyInfo; |
| | | import com.ks.daylucky.service.ActivityDrawnRecieveNotifyInfoService; |
| | | import com.ks.daylucky.util.mq.CMQManager; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardResult; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwards; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityDrawnMsgDTO; |
| | | import com.ks.lucky.remote.service.LuckyActivityAwardResultService; |
| | | import com.ks.lucky.remote.service.LuckyActivityAwardService; |
| | | import com.ks.lucky.utils.LuckyCMQConstant; |
| | | import com.ks.lucky.utils.mq.CMQConsumeRunner; |
| | | import com.qcloud.cmq.Message; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.mq.JobThreadExecutorServiceImpl; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Vector; |
| | | |
| | | public class ActivityDrawnNotifyConsumer implements CMQConsumeRunner { |
| | | |
| | | Logger logger = LoggerFactory.getLogger(ActivityDrawnNotifyConsumer.class); |
| | | |
| | | @Reference(version = "1.0.0") |
| | | private LuckyActivityAwardResultService luckyActivityAwardResultService; |
| | | |
| | | @Reference(version = "1.0.0") |
| | | private LuckyActivityAwardService luckyActivityAwardService; |
| | | |
| | | @Resource |
| | | private ActivityDrawnRecieveNotifyInfoService activityDrawnRecieveNotifyInfoService; |
| | | |
| | | @Override |
| | | public void start() { |
| | | new JobThreadExecutorServiceImpl().run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | List<Message> messageList = CMQManager.getInstance().consumeMsgMsg(16); |
| | | if (messageList != null) { |
| | | for (Message message : messageList) { |
| | | Vector<String> vectors = message.msgTag; |
| | | if (vectors.contains(LuckyCMQConstant.TAG_ACTIVITY_DRAWN)) { |
| | | |
| | | try { |
| | | //活动状态改变 |
| | | ActivityDrawnMsgDTO dto = JsonUtil.getSimpleGson().fromJson(message.msgBody, ActivityDrawnMsgDTO.class); |
| | | //获取详情 |
| | | |
| | | LuckyActivityAwardResult result = luckyActivityAwardResultService.getDetail(dto.getAwardResultId()); |
| | | LuckyActivityAwards award = luckyActivityAwardService.getAwardDetail(result.getAwardId()); |
| | | |
| | | String id = null; |
| | | switch (dto.getAwardResultState()) { |
| | | case LuckyActivityAwardResult.STATE_NOT_RECIEVE: |
| | | //插入待领取通知 |
| | | activityDrawnRecieveNotifyInfoService.addNotify(ActivityDrawnRecieveNotifyInfo.create(award, result, ActivityDrawnRecieveNotifyInfo.TYPE_UNRECIEVE)); |
| | | |
| | | break; |
| | | case LuckyActivityAwardResult.STATE_OUT_OF_DATE: |
| | | id = ActivityDrawnRecieveNotifyInfo.createId(result.getId(), ActivityDrawnRecieveNotifyInfo.TYPE_UNRECIEVE); |
| | | //删除待领取通知 |
| | | activityDrawnRecieveNotifyInfoService.setNotifyShown(id); |
| | | //添加过期通知 |
| | | activityDrawnRecieveNotifyInfoService.addNotify(ActivityDrawnRecieveNotifyInfo.create(award, result, ActivityDrawnRecieveNotifyInfo.TYPE_OUTDATE)); |
| | | break; |
| | | case LuckyActivityAwardResult.STATE_RECIEVED: |
| | | //删除待领取通知 |
| | | id = ActivityDrawnRecieveNotifyInfo.createId(result.getId(), ActivityDrawnRecieveNotifyInfo.TYPE_UNRECIEVE); |
| | | activityDrawnRecieveNotifyInfoService.setNotifyShown(id); |
| | | //删除过期通知 |
| | | id = ActivityDrawnRecieveNotifyInfo.createId(result.getId(), ActivityDrawnRecieveNotifyInfo.TYPE_OUTDATE); |
| | | activityDrawnRecieveNotifyInfoService.setNotifyShown(id); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | CMQManager.getInstance().deleteMsgMsg(message.receiptHandle); |
| | | } catch (Exception e) { |
| | | logger.error("通知消费出错:" + e.getMessage()); |
| | | } |
| | | } else { |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void destroy() { |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.util.mq.consumer; |
| | | |
| | | import com.ks.daylucky.exception.UserMsgException; |
| | | import com.ks.daylucky.pojo.DTO.UserMsgSettings; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.service.UserInfoExtraService; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.daylucky.service.UserMsgService; |
| | | import com.ks.daylucky.util.factory.LuckyMsgContentFactory; |
| | | import com.ks.daylucky.util.factory.UserMsgFactory; |
| | | import com.ks.daylucky.util.mq.CMQManager; |
| | | import com.ks.lucky.pojo.DO.*; |
| | | import com.ks.lucky.pojo.DTO.ActivitySimpleUser; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityAssistMsgDTO; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityDrawnMsgDTO; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityJoinMsgDTO; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityStateChangeMsgDTO; |
| | | import com.ks.lucky.remote.service.LuckyActivityAwardResultService; |
| | | import com.ks.lucky.remote.service.LuckyActivityAwardService; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinAssistService; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinService; |
| | | import com.ks.lucky.utils.LuckyCMQConstant; |
| | | import com.ks.lucky.utils.mq.CMQConsumeRunner; |
| | | import com.qcloud.cmq.Message; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.mq.JobThreadExecutorServiceImpl; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Vector; |
| | | |
| | | public class MsgConsumer implements CMQConsumeRunner { |
| | | |
| | | Logger logger = LoggerFactory.getLogger(MsgConsumer.class); |
| | | |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Reference(version = "1.0.0") |
| | | private LuckyActivityJoinAssistService luckyActivityJoinAssistService; |
| | | |
| | | @Reference(version = "1.0.0") |
| | | private LuckyActivityJoinService luckyActivityJoinService; |
| | | |
| | | @Reference(version = "1.0.0") |
| | | private LuckyActivityAwardResultService luckyActivityAwardResultService; |
| | | |
| | | @Reference(version = "1.0.0") |
| | | private LuckyActivityAwardService luckyActivityAwardService; |
| | | |
| | | @Resource |
| | | private UserMsgService userMsgService; |
| | | |
| | | private UserMsgSettings getUserMsgSetting(Long uid) { |
| | | return userInfoExtraService.getUserMsgSettings(uid); |
| | | } |
| | | |
| | | /** |
| | | * 获取有效的参与者 |
| | | * |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | private List<ActivitySimpleUser> getValidJoinerList(Long activityId) { |
| | | List<ActivitySimpleUser> list = new ArrayList<>(); |
| | | //查询所有参与者 |
| | | long count = luckyActivityJoinService.countJoiner(activityId, LuckyActivityJoinRecord.USER_TYPE_REAL); |
| | | int pageSize = 500; |
| | | int page = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | for (int i = 0; i < page; i++) { |
| | | List<ActivitySimpleUser> userList = luckyActivityJoinService.getJoinerList(activityId, LuckyActivityJoinRecord.USER_TYPE_REAL, i + 1, pageSize); |
| | | list.addAll(userList); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public void start() { |
| | | new JobThreadExecutorServiceImpl().run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | List<Message> messageList = CMQManager.getInstance().consumeMsgMsg(16); |
| | | if (messageList != null) { |
| | | for (Message message : messageList) { |
| | | Vector<String> vectors = message.msgTag; |
| | | if (vectors.contains(LuckyCMQConstant.TAG_ACTIVITY_STATE_CHANGE)) { |
| | | //活动状态改变 |
| | | ActivityStateChangeMsgDTO dto = JsonUtil.getSimpleGson().fromJson(message.msgBody, ActivityStateChangeMsgDTO.class); |
| | | List<ActivitySimpleUser> userList; |
| | | switch (dto.getState()) { |
| | | //开奖 |
| | | case LuckyActivity.STATE_OPENED: |
| | | //查询所有参与者 |
| | | userList = getValidJoinerList(dto.getActivityId()); |
| | | for (ActivitySimpleUser user : userList) { |
| | | //判断是否中奖 |
| | | UserMsgSettings settings = getUserMsgSetting(Long.parseLong(user.getUid())); |
| | | |
| | | LuckyActivityAwardResult result = luckyActivityAwardResultService.getResult(user.getAppId(), user.getUid(), dto.getActivityId()); |
| | | if (result != null) { |
| | | if (settings.getDrawnMsg()) { |
| | | LuckyActivityAwards awards = luckyActivityAwardService.getAwardDetail(result.getAwardId()); |
| | | |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(result.getUid()), LuckyMsgContentFactory.createDrawn(dto.getActivityId(), awards.getAwardName()))); |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加中奖消息出错", e.getMessage(), result.getId()); |
| | | } |
| | | } |
| | | } else { |
| | | if (settings.getNotDrawnMsg()) { |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(user.getUid()), LuckyMsgContentFactory.createNotDrawn(dto.getActivityId()))); |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加未中奖消息出错", e.getMessage(), user.getUid(), dto.getActivityId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | |
| | | case LuckyActivity.STATE_OPEN_FAIL: |
| | | userList = getValidJoinerList(dto.getActivityId()); |
| | | for (ActivitySimpleUser user : userList) { |
| | | //判断是否中奖 |
| | | UserMsgSettings settings = getUserMsgSetting(Long.parseLong(user.getUid())); |
| | | if (settings.getNotOpenActivityMsg()) { |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(user.getUid()), LuckyMsgContentFactory.createOpenFail(dto.getActivityId()))); |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加未开奖消息出错", e.getMessage(), user.getUid(), dto.getActivityId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | break; |
| | | } |
| | | |
| | | |
| | | } else if (vectors.contains(LuckyCMQConstant.TAG_ACTIVITY_JOIN)) { |
| | | ActivityJoinMsgDTO dto = JsonUtil.getSimpleGson().fromJson(message.msgBody, ActivityJoinMsgDTO.class); |
| | | UserMsgSettings settings = getUserMsgSetting(Long.parseLong(dto.getUid())); |
| | | if (settings.getJoinActivityMsg()) { |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(dto.getUid()), LuckyMsgContentFactory.createJoinSuccess(dto.getActivityId()))); |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加参与成功消息出错", e.getMessage(), dto.getUid(), dto.getActivityId()); |
| | | } |
| | | } |
| | | |
| | | //查询是否有助力别人 |
| | | LuckyActivityJoinAssist assist = luckyActivityJoinAssistService.getRecord(dto.getJoinId(), dto.getAppId(), dto.getUid(), ActivityJoinAssistEvent.assistJoin); |
| | | if (assist != null) { |
| | | //是否助力过别人 |
| | | LuckyActivityJoinRecord joinRecord = luckyActivityJoinService.getJoinRecord(assist.getJoinId()); |
| | | if (joinRecord != null) { |
| | | settings = getUserMsgSetting(Long.parseLong(joinRecord.getUid())); |
| | | if (settings.getAssistSuccessMsg()) { |
| | | SimpleUser user = userInfoService.getSimpleUser(Long.parseLong(dto.getUid())); |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(joinRecord.getUid()), LuckyMsgContentFactory.createAssistAndJoin(dto.getActivityId(), user, assist.getWeight()))); |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加助力成功且自己参加消息出错", e.getMessage(), dto.getUid(), dto.getActivityId()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } else if (vectors.contains(LuckyCMQConstant.TAG_ASSIST)) { |
| | | //助力 |
| | | ActivityAssistMsgDTO dto = JsonUtil.getSimpleGson().fromJson(message.msgBody, ActivityAssistMsgDTO.class); |
| | | UserMsgSettings settings = getUserMsgSetting(Long.parseLong(dto.getUid())); |
| | | if (settings.getAssistSuccessMsg()) { |
| | | LuckyActivityJoinRecord record = luckyActivityJoinService.getJoinInfo(dto.getActivityId(), dto.getAppId(), dto.getTargetUid()); |
| | | if (record != null) { |
| | | LuckyActivityJoinAssist assist = luckyActivityJoinAssistService.getRecord(record.getId(), dto.getAppId(), dto.getUid(), ActivityJoinAssistEvent.assist); |
| | | SimpleUser user = userInfoService.getSimpleUser(Long.parseLong(dto.getUid())); |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(dto.getTargetUid()), LuckyMsgContentFactory.createAssist(dto.getActivityId(), user, assist.getWeight()))); |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加助力成功消息出错", e.getMessage(), dto.getUid(), dto.getActivityId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } else if (vectors.contains(LuckyCMQConstant.TAG_ACTIVITY_DRAWN)) { |
| | | ActivityDrawnMsgDTO dto = JsonUtil.getSimpleGson().fromJson(message.msgBody, ActivityDrawnMsgDTO.class); |
| | | switch (dto.getAwardResultState()) { |
| | | case LuckyActivityAwardResult.STATE_OUT_OF_DATE: |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(dto.getUid()), LuckyMsgContentFactory.createReceiveOutDate(dto.getActivityId()))); |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加过期未领消息出错", e.getMessage(), dto.getUid(), dto.getActivityId()); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | } |
| | | CMQManager.getInstance().deleteMsgMsg(message.receiptHandle); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void destroy() { |
| | | |
| | | } |
| | | } |
| | |
| | | secretId: AKIDTlpgJhLjOozvd6QI2XnpfGbgV4NQJk25 |
| | | secretKey: xhCSUHo55oHUQ6XicFcmfIgspX0EEzWo |
| | | bucketName: daylucky |
| | | region: ap-nanjing |
| | | region: ap-nanjing |
| | | accessHost: https://daylucky-1255749512.cos.ap-nanjing.myqcloud.com |
New file |
| | |
| | | package com.ks; |
| | | |
| | | |
| | | import com.ks.daylucky.pojo.VO.ActivityAwardVO; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.util.ImageUtil; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.yeshi.utils.FileUtil; |
| | | |
| | | import java.awt.*; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.ArrayList; |
| | | |
| | | public class ImageTest { |
| | | |
| | | @Test |
| | | public void drawUser() { |
| | | SimpleUser user = new SimpleUser(4L, "小辉", "https://tfs.alipayobjects.com/images/partner/TB1UE8YcJdFDuNkUuLAXXXvvFXa"); |
| | | |
| | | try { |
| | | InputStream output = ImageUtil.drawActivityUserShareImage(user, new FileInputStream("C:\\Users\\Administrator\\Downloads\\图层 6.png")); |
| | | FileUtil.saveAsFile(output, "C:\\Users\\Administrator\\Downloads\\user.jpg"); |
| | | |
| | | } catch (FontFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void drawActivity() { |
| | | java.util.List<ActivityAwardVO> voList = new ArrayList<>(); |
| | | |
| | | |
| | | ActivityAwardVO vo = new ActivityAwardVO(); |
| | | vo.setTitle("奖品一:大额现金红包100,免费抽奖拼手气免费抽奖拼手"); |
| | | vo.setTypeIcon("https://daylucky-1255749512.cos.ap-nanjing.myqcloud.com/image/icon/icon_award_way_divide.png"); |
| | | voList.add(vo); |
| | | |
| | | vo = new ActivityAwardVO(); |
| | | vo.setTitle("奖品二:大额现金红包100,免费抽奖拼手气免费抽奖拼手,免费抽奖拼手气免费抽奖拼手,免费抽奖拼手气免费抽奖拼手"); |
| | | vo.setTypeIcon("https://daylucky-1255749512.cos.ap-nanjing.myqcloud.com/image/icon/icon_award_way_divide.png"); |
| | | voList.add(vo); |
| | | |
| | | vo = new ActivityAwardVO(); |
| | | vo.setTitle("奖品三:大额现金红包100"); |
| | | vo.setTypeIcon("https://daylucky-1255749512.cos.ap-nanjing.myqcloud.com/image/icon/icon_award_way_divide.png"); |
| | | voList.add(vo); |
| | | |
| | | |
| | | try { |
| | | InputStream output = ImageUtil.drawActivityShareImage(voList, new FileInputStream("C:\\Users\\Administrator\\Downloads\\图层 4.png")); |
| | | FileUtil.saveAsFile(output, "C:\\Users\\Administrator\\Downloads\\activity.jpg"); |
| | | |
| | | } catch (FontFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks; |
| | | |
| | | import com.ks.daylucky.dao.ActivityDrawnRecieveNotifyInfoDao; |
| | | import com.ks.daylucky.pojo.DO.ActivityDrawnRecieveNotifyInfo; |
| | | import com.ks.daylucky.service.ActivityDrawnRecieveNotifyInfoService; |
| | | import com.ks.lib.common.dao.MongodbBaseDao; |
| | | import com.ks.lib.common.exception.BaseException; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.yeshi.utils.generater.SpringComponentGenerater; |
| | | import org.yeshi.utils.generater.entity.ExceptionData; |
| | | import org.yeshi.utils.generater.entity.MongoDBDaoData; |
| | | import org.yeshi.utils.generater.entity.ServiceData; |
| | | |
| | | public class MongoTest { |
| | | |
| | | @Test |
| | | public void createDao() { |
| | | try { |
| | | SpringComponentGenerater.createMongoDao(new MongoDBDaoData.Builder().setBaseDaoClass(MongodbBaseDao.class).setDaoPackageName("com.ks.daylucky.dao").setEntityClass(ActivityDrawnRecieveNotifyInfo.class).create(), "D:\\workspace\\DayLucky\\service-daylucky\\src\\main\\java\\com\\ks\\daylucky\\dao\\"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void createService() { |
| | | try { |
| | | SpringComponentGenerater.createService(new ServiceData.Builder().setPackageName("com.ks.daylucky.service").setDaoClass(ActivityDrawnRecieveNotifyInfoDao.class).setEntityClass(ActivityDrawnRecieveNotifyInfo.class).build(), "D:\\workspace\\DayLucky\\service-daylucky\\src\\main\\java\\com\\ks\\daylucky\\service\\"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Test |
| | | public void createServiceImpl() { |
| | | try { |
| | | SpringComponentGenerater.createServiceImpl(new ServiceData.Builder().setPackageName("com.ks.daylucky.service.impl").setServiceClass(ActivityDrawnRecieveNotifyInfoService.class).setDaoClass(ActivityDrawnRecieveNotifyInfoDao.class).setEntityClass(ActivityDrawnRecieveNotifyInfo.class).build(), "D:\\workspace\\DayLucky\\service-daylucky\\src\\main\\java\\com\\ks\\daylucky\\service\\impl\\"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void createException() { |
| | | try { |
| | | SpringComponentGenerater.createException(new ExceptionData.Builder().setPackageName("com.ks.daylucky.exception").setBaseClass(BaseException.class).setEntityClass(ActivityDrawnRecieveNotifyInfo.class).build(), "D:\\workspace\\DayLucky\\service-daylucky\\src\\main\\java\\com\\ks\\daylucky\\exception\\"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ks.daylucky; |
| | | |
| | | import com.ks.daylucky.dao.UserMsgDao; |
| | | import com.ks.daylucky.mapper.*; |
| | | import com.ks.daylucky.pojo.DO.Announcement; |
| | | import com.ks.daylucky.pojo.DO.UserMsg; |
| | |
| | | private UserInfoMapper userInfoMapper; |
| | | |
| | | @Resource |
| | | private UserMsgMapper userMsgMapper; |
| | | private UserMsgDao userMsgMapper; |
| | | |
| | | @Test |
| | | public void scanRecord() { |
New file |
| | |
| | | package com.ks.daylucky; |
| | | |
| | | import com.ks.daylucky.exception.UserMsgException; |
| | | import com.ks.daylucky.service.UserMsgService; |
| | | import com.ks.daylucky.util.factory.LuckyMsgContentFactory; |
| | | import com.ks.daylucky.util.factory.UserMsgFactory; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @SpringBootTest |
| | | public class MsgTest { |
| | | @Resource |
| | | private UserMsgService userMsgService; |
| | | |
| | | @Test |
| | | public void addMsg() { |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(4L, LuckyMsgContentFactory.createJoinSuccess(7L))); |
| | | } catch (UserMsgException e) { |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ks.lucky.config; |
| | | |
| | | import com.ks.lucky.util.mq.CMQConsumeRunner; |
| | | import com.ks.lucky.util.mq.consumer.AcitivtyConsumer; |
| | | import com.ks.lucky.util.mq.consumer.AcitivtyDrawnRecieveOutDateConsumer; |
| | | import com.ks.lucky.utils.mq.CMQConsumeRunner; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.context.annotation.Bean; |
| | |
| | | |
| | | |
| | | @Bean(initMethod = "start", destroyMethod = "destroy") |
| | | public CMQConsumeRunner xxlJobExecutor() { |
| | | public CMQConsumeRunner activityConsumer() { |
| | | CMQConsumeRunner runner = new AcitivtyConsumer(); |
| | | return runner; |
| | | } |
| | | |
| | | @Bean(initMethod = "start", destroyMethod = "destroy") |
| | | public CMQConsumeRunner recieveOutDateConsumer() { |
| | | CMQConsumeRunner runner = new AcitivtyDrawnRecieveOutDateConsumer(); |
| | | return runner; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.ks.lucky.dao; |
| | | |
| | | import com.ks.lib.common.dao.MongodbBaseDao; |
| | | import com.ks.lib.common.util.MongoDBQueryUtil; |
| | | import com.ks.lucky.pojo.DO.LuckySponsorAd; |
| | | import com.ks.lucky.query.LuckySponsorAdQuery; |
| | | import com.ks.lucky.util.MongoDBQueryUtil; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
New file |
| | |
| | | package com.ks.lucky.pojo.DTO; |
| | | |
| | | /** |
| | | * 中奖过期消息 |
| | | */ |
| | | public class ActivityDrwanOutDateMsg { |
| | | private Long resultId; |
| | | |
| | | public ActivityDrwanOutDateMsg(Long resultId) { |
| | | this.resultId = resultId; |
| | | } |
| | | |
| | | public Long getResultId() { |
| | | return resultId; |
| | | } |
| | | |
| | | public void setResultId(Long resultId) { |
| | | this.resultId = resultId; |
| | | } |
| | | } |
| | |
| | | public String uid; |
| | | //中奖状态 |
| | | public List<Integer> drawStateList; |
| | | public Integer userType; |
| | | } |
| | |
| | | import com.ks.app.entity.AppInfo; |
| | | import com.ks.lucky.exception.LuckyActivityAwardException; |
| | | import com.ks.lucky.exception.LuckyActivityAwardResultException; |
| | | import com.ks.lucky.exception.LuckyMQException; |
| | | import com.ks.lucky.mapper.LuckyActivityAwardResultExtraMapper; |
| | | import com.ks.lucky.mapper.LuckyActivityAwardResultMapper; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardResult; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardResultExtra; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwards; |
| | | import com.ks.lucky.pojo.DO.LuckyMQ; |
| | | import com.ks.lucky.pojo.DTO.ActivityAwardParams; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityDrawnMsgDTO; |
| | | import com.ks.lucky.query.ActivityAwardResultQuery; |
| | | import com.ks.lucky.service.LuckyMQService; |
| | | import com.ks.lucky.util.Constant; |
| | | import com.ks.lucky.util.mq.CMQManager; |
| | | import com.ks.lucky.util.mq.LuckyMQFactory; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.yeshi.utils.StringUtil; |
| | |
| | | import org.yeshi.utils.entity.alipay.AlipayTransferAccount; |
| | | import org.yeshi.utils.entity.alipay.AlipayTransferInfo; |
| | | import org.yeshi.utils.exception.AlipayTransferException; |
| | | import org.yeshi.utils.generater.entity.ExceptionData; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.InputStream; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Component |
| | | public class LuckyActivityAwardResultManager { |
| | | |
| | | Logger logger = LoggerFactory.getLogger(LuckyActivityAwardResultManager.class); |
| | | |
| | | @Resource |
| | | private LuckyActivityAwardManager luckyActivityAwardManager; |
| | |
| | | @Resource |
| | | private LuckyActivityAwardResultExtraMapper luckyActivityAwardResultExtraMapper; |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private LuckyMQService luckyMQService; |
| | | |
| | | |
| | | /** |
| | |
| | | extra.setAwardResultId(result.getId()); |
| | | extra.setCreateTime(new Date()); |
| | | luckyActivityAwardResultExtraMapper.insertSelective(extra); |
| | | |
| | | //添加通知 |
| | | try { |
| | | CMQManager.getInstance().publishActivityDrawnMsg(ActivityDrawnMsgDTO.create(result)); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | public void setResultShow(Long activityId) { |
| | | luckyActivityAwardResultMapper.setStateByActivityId(activityId, LuckyActivityAwardResult.STATE_NOT_RECIEVE, "等待领取", new Date()); |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void setResultShow(Long activityId) throws LuckyMQException { |
| | | Date date = new Date(); |
| | | luckyActivityAwardResultMapper.setStateByActivityId(activityId, LuckyActivityAwardResult.STATE_NOT_RECIEVE, "等待领取", date); |
| | | ActivityAwardResultQuery query = new ActivityAwardResultQuery(); |
| | | query.activityId = activityId; |
| | | long count = luckyActivityAwardResultMapper.count(query); |
| | | query.count = (int) count; |
| | | |
| | | List<LuckyActivityAwardResult> resultList = luckyActivityAwardResultMapper.list(query); |
| | | if (resultList != null && resultList.size() > 0) { |
| | | for (LuckyActivityAwardResult result : resultList) { |
| | | //添加过期领取通知 |
| | | LuckyMQ mq = LuckyMQFactory.createActivityDrawnOutDate(result.getId(), new Date(date.getTime() + Constant.ACTIVITY_DRAWN_RECIEVE_VALID_TIME)); |
| | | luckyMQService.addMQ(mq); |
| | | |
| | | //添加通知 |
| | | try { |
| | | CMQManager.getInstance().publishActivityDrawnMsg(ActivityDrawnMsgDTO.create(result)); |
| | | } catch (Exception e) { |
| | | logger.error("发布活动中奖的订阅消息出错:", result.getId(), e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 使中奖过期 |
| | | * |
| | | * @param id |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void setResultOutDate(Long id) { |
| | | LuckyActivityAwardResult result = luckyActivityAwardResultMapper.selectByPrimaryKeyForUpdate(id); |
| | | if (result.getState() != LuckyActivityAwardResult.STATE_NOT_RECIEVE) { |
| | | return; |
| | | } |
| | | |
| | | LuckyActivityAwardResult update = new LuckyActivityAwardResult(); |
| | | update.setId(id); |
| | | update.setState(LuckyActivityAwardResult.STATE_OUT_OF_DATE); |
| | | update.setStateDesc("过期未领取"); |
| | | update.setUpdateTime(new Date()); |
| | | luckyActivityAwardResultMapper.updateByPrimaryKeySelective(update); |
| | | |
| | | result.setStateDesc(update.getStateDesc()); |
| | | result.setState(update.getState()); |
| | | //发布消息 |
| | | CMQManager.getInstance().publishActivityDrawnMsg(ActivityDrawnMsgDTO.create(result)); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ks.lucky.pojo.DO.LuckyActivityOpenInfo; |
| | | import com.ks.lucky.pojo.DO.LuckyMQ; |
| | | import com.ks.lucky.pojo.DTO.ActivityMQMsg; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityStateChangeMsgDTO; |
| | | import com.ks.lucky.service.LuckyMQService; |
| | | import com.ks.lucky.util.mq.CMQManager; |
| | | import com.ks.lucky.util.mq.LuckyMQFactory; |
| | |
| | | * @param state |
| | | * @param stateRemarks |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void setState(Long activityId, int state, String stateRemarks) { |
| | | LuckyActivity activity = new LuckyActivity(); |
| | | activity.setId(activityId); |
| | |
| | | activity.setStateRemarks(stateRemarks); |
| | | activity.setUpdateTime(new Date()); |
| | | luckyActivityMapper.updateByPrimaryKeySelective(activity); |
| | | CMQManager.getInstance().publishActivityStateChangeMsg(new ActivityStateChangeMsgDTO(activityId, state, stateRemarks, activity.getUpdateTime())); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public LuckyActivityAwardResult getUnRecievedAward(Long appId, String uid, Long activityId) { |
| | | ActivityAwardResultQuery query = new ActivityAwardResultQuery(); |
| | | query.state = LuckyActivityAwardResult.STATE_NOT_RECIEVE; |
| | | query.appId = appId; |
| | | query.uid = uid; |
| | | query.activityId = activityId; |
| | | query.count = 1; |
| | | |
| | | List<LuckyActivityAwardResult> list = luckyActivityAwardResultMapper.list(query); |
| | | if (list != null && list.size() > 0) { |
| | | return list.get(0); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public long countUnRecievedAward(Long appId, String uid) { |
| | | ActivityAwardResultQuery query = new ActivityAwardResultQuery(); |
| | | query.state = LuckyActivityAwardResult.STATE_NOT_RECIEVE; |
| | |
| | | return luckyActivityAwardResultMapper.count(query); |
| | | } |
| | | |
| | | @Override |
| | | public LuckyActivityAwardResult getDetail(Long id) { |
| | | return luckyActivityAwardResultMapper.selectByPrimaryKey(id); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.ks.lucky.pojo.DO.*; |
| | | import com.ks.lucky.pojo.DTO.ActivityAssistFriend; |
| | | import com.ks.lucky.pojo.DTO.ActivityFriendAssistInfo; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityAssistMsgDTO; |
| | | import com.ks.lucky.query.ActivityJoinAssistQuery; |
| | | import com.ks.lucky.query.ActivityJoinRecordQuery; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinAssistService; |
| | | import com.ks.lucky.service.impl.LuckyActivityJoinManager; |
| | | import com.ks.lucky.service.impl.LuckyActivityUserWeightRecordManager; |
| | | import com.ks.lucky.util.factory.LuckyActivityUserWeightRecordFactory; |
| | | import com.ks.lucky.util.mq.CMQManager; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | } catch (ParamsException e) { |
| | | throw new LuckyActivityJoinAssistException(1, "添加记录出错"); |
| | | } |
| | | |
| | | //助力消息 |
| | | CMQManager.getInstance().publishActivityAssistMsg(new ActivityAssistMsgDTO(activityId, appId, uid, targetUid, true, assist.getCreateTime())); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public LuckyActivityJoinAssist getRecord(@NotNull Long joinId, @NotEmpty Long appId, @NotEmpty String uid, @NotNull ActivityJoinAssistEvent eventKey) { |
| | | ActivityJoinAssistQuery query = new ActivityJoinAssistQuery(); |
| | | query.joinId = joinId; |
| | | query.appId = appId; |
| | | query.uid = uid; |
| | | query.eventKey = eventKey; |
| | | query.count = 1; |
| | | List<LuckyActivityJoinAssist> assistList = luckyActivityJoinAssistMapper.list(query); |
| | | if (assistList == null || assistList.size() == 0) { |
| | | return null; |
| | | } |
| | | return assistList.get(0); |
| | | } |
| | | |
| | | @Override |
| | | public List<LuckyActivityJoinAssist> getAssistRecordList(Long activityId, Long appId, String uid, int page, int pageSize) { |
| | | LuckyActivityJoinRecord record = luckyActivityJoinManager.getRecord(activityId, appId, uid); |
| | | if (record == null) { |
| | |
| | | import com.ks.lucky.mapper.LuckyActivityJoinRecordMapper; |
| | | import com.ks.lucky.pojo.DO.*; |
| | | import com.ks.lucky.pojo.DTO.*; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityJoinMsgDTO; |
| | | import com.ks.lucky.query.ActivityAwardQuery; |
| | | import com.ks.lucky.query.ActivityJoinRecordQuery; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinService; |
| | |
| | | import com.ks.lucky.service.impl.LuckyActivityOpenInfoManager; |
| | | import com.ks.lucky.service.impl.LuckyActivityUserWeightRecordManager; |
| | | import com.ks.lucky.util.factory.LuckyActivityUserWeightRecordFactory; |
| | | import com.ks.lucky.util.mq.CMQManager; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | throw new LuckyActivityJoinException(1, "添加记录出错"); |
| | | } |
| | | |
| | | CMQManager.getInstance().publishActivityJoinMsg(ActivityJoinMsgDTO.create(record)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ActivitySimpleUser> getJoinerList(Long activityId, int page, int count) { |
| | | public List<ActivitySimpleUser> getJoinerList(Long activityId,Integer userType, int page, int count) { |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | | query.activityId = activityId; |
| | | query.sortList = Arrays.asList(new String[]{"id asc"}); |
| | | query.userType=userType; |
| | | query.count = count; |
| | | query.start = (page - 1) * count; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public long countJoiner(Long activityId,Integer userType) { |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | | query.activityId = activityId; |
| | | query.userType=userType; |
| | | return luckyActivityJoinRecordMapper.count(query); |
| | | } |
| | | |
| | | @Override |
| | | public ActivityJoinStatisticInfo getActivityJoinerStatisticInfo(Long activityId, Long appId, String uid) { |
| | | ActivityJoinStatisticInfo info = new ActivityJoinStatisticInfo(); |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | |
| | | import com.ks.lucky.util.LuckyRunUtil; |
| | | import com.ks.lucky.util.mq.CMQManager; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.omg.PortableServer.THREAD_POLICY_ID; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | //设置中奖用户状态为中奖 |
| | | luckyActivityJoinManager.setActivityDrawnJoinerState(activityId); |
| | | |
| | | luckyActivityAwardResultManager.setResultShow(activityId); |
| | | try { |
| | | luckyActivityAwardResultManager.setResultShow(activityId); |
| | | } catch (LuckyMQException e) { |
| | | throw new LuckyActivityException(10, "添加MQ出错"); |
| | | } |
| | | } |
| | | |
| | | @Override |
New file |
| | |
| | | package com.ks.lucky.util; |
| | | |
| | | public class Constant { |
| | | |
| | | //奖品领取有效期为7天 |
| | | public final static long ACTIVITY_DRAWN_RECIEVE_VALID_TIME = 1000 * 60 * 60L * 24 * 7; |
| | | |
| | | |
| | | } |
| | |
| | | package com.ks.lucky.util.mq; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.ks.lucky.pojo.DTO.ActivityDrwanOutDateMsg; |
| | | import com.ks.lucky.pojo.DTO.ActivityMQMsg; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityAssistMsgDTO; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityDrawnMsgDTO; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityJoinMsgDTO; |
| | | import com.ks.lucky.pojo.DTO.mq.ActivityStateChangeMsgDTO; |
| | | import com.ks.lucky.utils.LuckyCMQConstant; |
| | | import com.qcloud.cmq.Message; |
| | | import org.yeshi.utils.CMQUtil; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | private static CMQManager cmqManager; |
| | | private static CMQUtil cmqUtil; |
| | | public static String QUEUENAME_LUCKY_ACTIVITY = "lucky-activity"; |
| | | /** |
| | | * 需要执行领奖过期 |
| | | */ |
| | | public static String QUEUENAME_LUCKY_ACTIVITY_DRAWN_OUTDATE_EXEC = "lucky-activity-drawn-outdate-exec"; |
| | | |
| | | |
| | | static { |
| | | cmqUtil = CMQUtil.getInstance(secretId, secretKey); |
| | | // 最大消息为1M |
| | | cmqUtil.createQueue(QUEUENAME_LUCKY_ACTIVITY, 1024 * 1024); |
| | | cmqUtil.createQueue(QUEUENAME_LUCKY_ACTIVITY_DRAWN_OUTDATE_EXEC, 1024 * 1024); |
| | | |
| | | //创建主题 |
| | | cmqUtil.createTopic(LuckyCMQConstant.TOPIC_ACTIVITY_STATE_CHANGE); |
| | | cmqUtil.createTopic(LuckyCMQConstant.TOPIC_ASSIST); |
| | | cmqUtil.createTopic(LuckyCMQConstant.TOPIC_ACTIVITY_DRAWN); |
| | | cmqUtil.createTopic(LuckyCMQConstant.TOPIC_ACTIVITY_JOIN); |
| | | } |
| | | |
| | | public static CMQManager getInstance() { |
| | |
| | | public void addActivityMsg(ActivityMQMsg msg) { |
| | | cmqUtil.sendMsg(QUEUENAME_LUCKY_ACTIVITY, new Gson().toJson(msg)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 活动消息消费 |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加活动过期消息 |
| | | * |
| | | * @param msg |
| | | */ |
| | | public void addActivityDrawnOutDateMsg(ActivityDrwanOutDateMsg msg) { |
| | | cmqUtil.sendMsg(QUEUENAME_LUCKY_ACTIVITY_DRAWN_OUTDATE_EXEC, new Gson().toJson(msg)); |
| | | } |
| | | |
| | | /** |
| | | * 消费活动中奖过期消息 |
| | | * |
| | | * @param count |
| | | * @return |
| | | */ |
| | | public Map<String, ActivityDrwanOutDateMsg> consumeActivityDrawnOutDateMsg(int count) { |
| | | List<Message> list = cmqUtil.recieveMsg(count, QUEUENAME_LUCKY_ACTIVITY_DRAWN_OUTDATE_EXEC); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | |
| | | Map<String, ActivityDrwanOutDateMsg> map = new HashMap<>(); |
| | | Gson gson = new Gson(); |
| | | for (Message msg : list) { |
| | | String result = msg.msgBody; |
| | | map.put(msg.receiptHandle, gson.fromJson(result, ActivityDrwanOutDateMsg.class)); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 删除活动中奖过期消息 |
| | | * |
| | | * @param receiptHandle |
| | | */ |
| | | public void deleteActivityDrawnOutDateMsg(String receiptHandle) { |
| | | cmqUtil.deleteMsg(QUEUENAME_LUCKY_ACTIVITY_DRAWN_OUTDATE_EXEC, receiptHandle); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发布活动状态改变的订阅消息 |
| | | * |
| | | * @param dto |
| | | */ |
| | | public void publishActivityStateChangeMsg(ActivityStateChangeMsgDTO dto) { |
| | | List<String> tagList = new ArrayList<>(); |
| | | tagList.add(LuckyCMQConstant.TAG_ACTIVITY_STATE_CHANGE); |
| | | cmqUtil.publishTopicMessage(LuckyCMQConstant.TOPIC_ACTIVITY_STATE_CHANGE, tagList, JsonUtil.getSimpleGson().toJson(dto)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发布活动助力的订阅消息 |
| | | * |
| | | * @param dto |
| | | */ |
| | | public void publishActivityAssistMsg(ActivityAssistMsgDTO dto) { |
| | | List<String> tagList = new ArrayList<>(); |
| | | tagList.add(LuckyCMQConstant.TAG_ASSIST); |
| | | cmqUtil.publishTopicMessage(LuckyCMQConstant.TOPIC_ASSIST, tagList, JsonUtil.getSimpleGson().toJson(dto)); |
| | | } |
| | | |
| | | /** |
| | | * 发布活动中奖消息到订阅消息 |
| | | * |
| | | * @param dto |
| | | */ |
| | | public void publishActivityDrawnMsg(ActivityDrawnMsgDTO dto) { |
| | | List<String> tagList = new ArrayList<>(); |
| | | tagList.add(LuckyCMQConstant.TAG_ACTIVITY_DRAWN); |
| | | cmqUtil.publishTopicMessage(LuckyCMQConstant.TOPIC_ACTIVITY_DRAWN, tagList, JsonUtil.getSimpleGson().toJson(dto)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 活动参与信息 |
| | | * @param dto |
| | | */ |
| | | public void publishActivityJoinMsg(ActivityJoinMsgDTO dto) { |
| | | List<String> tagList = new ArrayList<>(); |
| | | tagList.add(LuckyCMQConstant.TAG_ACTIVITY_JOIN); |
| | | cmqUtil.publishTopicMessage(LuckyCMQConstant.TOPIC_ACTIVITY_JOIN, tagList, JsonUtil.getSimpleGson().toJson(dto)); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.google.gson.Gson; |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import com.ks.lucky.pojo.DO.LuckyMQ; |
| | | import com.ks.lucky.pojo.DTO.ActivityDrwanOutDateMsg; |
| | | import com.ks.lucky.pojo.DTO.ActivityMQMsg; |
| | | |
| | | import java.util.Date; |
| | |
| | | mq.setTaskName("活动开奖"); |
| | | return mq; |
| | | } |
| | | |
| | | /** |
| | | * 活动奖品领取时间到期 |
| | | * |
| | | * @param resultId |
| | | * @param outDate |
| | | * @return |
| | | */ |
| | | |
| | | public static LuckyMQ createActivityDrawnOutDate(Long resultId, Date outDate) { |
| | | LuckyMQ mq = new LuckyMQ(); |
| | | mq.setState(LuckyMQ.STATE_NOT_SEND); |
| | | mq.setCreateTime(new Date()); |
| | | //设置开奖时间 |
| | | mq.setPreSendTime(outDate); |
| | | mq.setQueueContent(new Gson().toJson(new ActivityDrwanOutDateMsg(resultId))); |
| | | mq.setQueueName(CMQManager.QUEUENAME_LUCKY_ACTIVITY_DRAWN_OUTDATE_EXEC); |
| | | mq.setTaskId("activity-drawn-outdate-" + resultId); |
| | | mq.setTaskName("活动中奖领取时间到期"); |
| | | return mq; |
| | | } |
| | | } |
| | |
| | | import com.ks.lucky.pojo.DTO.ActivityMQMsg; |
| | | import com.ks.lucky.remote.service.LuckyActivityOpenService; |
| | | import com.ks.lucky.service.impl.LuckyActivityManager; |
| | | import com.ks.lucky.util.mq.CMQConsumeRunner; |
| | | import com.ks.lucky.util.mq.CMQManager; |
| | | import com.ks.lucky.utils.mq.CMQConsumeRunner; |
| | | import org.yeshi.utils.mq.JobThreadExecutorServiceImpl; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Iterator; |
| | |
| | | |
| | | @Override |
| | | public void start() { |
| | | while (true) { |
| | | Map<String, ActivityMQMsg> map = CMQManager.getInstance().consumeActivityMsg(16); |
| | | if (map != null) { |
| | | for (Iterator<String> its = map.keySet().iterator(); its.hasNext(); ) { |
| | | String handler = its.next(); |
| | | ActivityMQMsg msg = map.get(handler); |
| | | if (msg != null) { |
| | | switch (msg.getType()) { |
| | | case ActivityMQMsg.TYPE_EXEC_START: |
| | | //启动活动 |
| | | try { |
| | | luckyActivityManager.startUpActivity(msg.getActivityId()); |
| | | CMQManager.getInstance().deleteActivityMsg(handler); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyMQException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | new JobThreadExecutorServiceImpl().run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Map<String, ActivityMQMsg> map = CMQManager.getInstance().consumeActivityMsg(16); |
| | | if (map != null) { |
| | | for (Iterator<String> its = map.keySet().iterator(); its.hasNext(); ) { |
| | | String handler = its.next(); |
| | | ActivityMQMsg msg = map.get(handler); |
| | | if (msg != null) { |
| | | switch (msg.getType()) { |
| | | case ActivityMQMsg.TYPE_EXEC_START: |
| | | //启动活动 |
| | | try { |
| | | luckyActivityManager.startUpActivity(msg.getActivityId()); |
| | | CMQManager.getInstance().deleteActivityMsg(handler); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyMQException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | break; |
| | | case ActivityMQMsg.TYPE_EXEC_FINSIH: |
| | | //结束活动 |
| | | try { |
| | | luckyActivityManager.finishActivity(msg.getActivityId(), false, "定时结束"); |
| | | CMQManager.getInstance().deleteActivityMsg(handler); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyMQException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | break; |
| | | case ActivityMQMsg.TYPE_EXEC_FINSIH: |
| | | //结束活动 |
| | | try { |
| | | luckyActivityManager.finishActivity(msg.getActivityId(), false, "定时结束"); |
| | | CMQManager.getInstance().deleteActivityMsg(handler); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyMQException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | break; |
| | | break; |
| | | |
| | | |
| | | case ActivityMQMsg.TYPE_REACH_MIN_PERSON: |
| | | try { |
| | | luckyActivityOpenService.reachMinPerson(msg.getActivityId()); |
| | | CMQManager.getInstance().deleteActivityMsg(handler); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | break; |
| | | case ActivityMQMsg.TYPE_REACH_MIN_PERSON: |
| | | try { |
| | | luckyActivityOpenService.reachMinPerson(msg.getActivityId()); |
| | | CMQManager.getInstance().deleteActivityMsg(handler); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | break; |
| | | |
| | | case ActivityMQMsg.TYPE_REACH_MAX_PERSON: |
| | | try { |
| | | luckyActivityManager.finishActivity(msg.getActivityId(), false, "活动达到最大开奖人数"); |
| | | CMQManager.getInstance().deleteActivityMsg(handler); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyMQException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | case ActivityMQMsg.TYPE_REACH_MAX_PERSON: |
| | | try { |
| | | luckyActivityManager.finishActivity(msg.getActivityId(), false, "活动达到最大开奖人数"); |
| | | CMQManager.getInstance().deleteActivityMsg(handler); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyMQException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | break; |
| | | break; |
| | | |
| | | case ActivityMQMsg.TYPE_REACH_OPEN_TIME: |
| | | try { |
| | | luckyActivityManager.finishActivity(msg.getActivityId(), false, "活动达到开奖时间"); |
| | | CMQManager.getInstance().deleteActivityMsg(handler); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyMQException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | break; |
| | | case ActivityMQMsg.TYPE_REACH_OPEN_TIME: |
| | | try { |
| | | luckyActivityManager.finishActivity(msg.getActivityId(), false, "活动达到开奖时间"); |
| | | CMQManager.getInstance().deleteActivityMsg(handler); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyMQException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | break; |
| | | |
| | | case ActivityMQMsg.TYPE_OPEN_SHOW: |
| | | try { |
| | | luckyActivityOpenService.showOpenAward(msg.getActivityId()); |
| | | CMQManager.getInstance().deleteActivityMsg(handler); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | break; |
| | | case ActivityMQMsg.TYPE_OPEN_SHOW: |
| | | try { |
| | | luckyActivityOpenService.showOpenAward(msg.getActivityId()); |
| | | CMQManager.getInstance().deleteActivityMsg(handler); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | break; |
| | | |
| | | case ActivityMQMsg.TYPE_EXEC_OPEN: |
| | | preOpen(msg.getActivityId(), handler); |
| | | break; |
| | | case ActivityMQMsg.TYPE_EXEC_OPEN: |
| | | preOpen(msg.getActivityId(), handler); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.ks.lucky.util.mq.consumer; |
| | | |
| | | import com.ks.lucky.pojo.DTO.ActivityDrwanOutDateMsg; |
| | | import com.ks.lucky.service.impl.LuckyActivityAwardResultManager; |
| | | import com.ks.lucky.util.mq.CMQManager; |
| | | import com.ks.lucky.utils.mq.CMQConsumeRunner; |
| | | import org.yeshi.utils.mq.JobThreadExecutorServiceImpl; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 中奖领取过期 |
| | | */ |
| | | public class AcitivtyDrawnRecieveOutDateConsumer implements CMQConsumeRunner { |
| | | |
| | | @Resource |
| | | private LuckyActivityAwardResultManager luckyActivityAwardResultManager; |
| | | |
| | | |
| | | @Override |
| | | public void start() { |
| | | new JobThreadExecutorServiceImpl().run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Map<String, ActivityDrwanOutDateMsg> map = CMQManager.getInstance().consumeActivityDrawnOutDateMsg(16); |
| | | if (map != null) { |
| | | for (Iterator<String> its = map.keySet().iterator(); its.hasNext(); ) { |
| | | String handler = its.next(); |
| | | ActivityDrwanOutDateMsg msg = map.get(handler); |
| | | if (msg != null) { |
| | | //过期 |
| | | luckyActivityAwardResultManager.setResultOutDate(msg.getResultId()); |
| | | } |
| | | CMQManager.getInstance().deleteActivityDrawnOutDateMsg(handler); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void destroy() { |
| | | |
| | | } |
| | | } |
| | |
| | | <if test="query.activityId!=null">and activity_id=#{query.activityId}</if> |
| | | <if test="query.appId!=null">and app_id=#{query.appId}</if> |
| | | <if test="query.uid!=null">and uid=#{query.uid}</if> |
| | | <if test="query.userType!=null">and user_type=#{query.userType}</if> |
| | | <if test="query.drawStateList!=null"> |
| | | <foreach collection="query.drawStateList" item="state" open=" and (" close=")" separator=" or "> |
| | | draw_state=#{state} |