| | |
| | | package com.ks.daylucky.util.mq.consumer; |
| | | |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.ks.app.entity.AppInfo; |
| | | import com.ks.app.util.AlipayAppUtil; |
| | | import com.ks.daylucky.exception.UserMsgException; |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.DO.UserMsg; |
| | | import com.ks.daylucky.pojo.DTO.UserMsgSettings; |
| | | import com.ks.daylucky.pojo.DTO.msg.LuckyMsgContent; |
| | | 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.service.impl.AlipayTemplateMsgManager; |
| | | import com.ks.daylucky.service.impl.AppManager; |
| | | import com.ks.daylucky.util.UserInfoUtil; |
| | | import com.ks.daylucky.util.activity.ActivityUtil; |
| | | import com.ks.daylucky.util.LoggerUtil; |
| | | import com.ks.daylucky.util.factory.LuckyMsgContentFactory; |
| | | import com.ks.daylucky.util.factory.UserMsgFactory; |
| | | import com.ks.daylucky.util.mq.CMQManager; |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.alipay.AlipayXcxUtil; |
| | | import org.yeshi.utils.exception.AlipayXcxException; |
| | | import org.yeshi.utils.mq.JobThreadExecutorServiceImpl; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | new JobThreadExecutorServiceImpl().run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | logger.info("读取消息队列数据"); |
| | | LoggerUtil.mqLogger.info("接收消息 {}", MsgConsumer.class.getSimpleName()); |
| | | List<Message> messageList = CMQManager.getInstance().consumeMsgMsg(16); |
| | | if (messageList != null) { |
| | | for (Message message : messageList) { |
| | |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(result.getUid()), LuckyMsgContentFactory.createDrawn(dto.getActivityId(), activity.getCreateTime(), awards.getAwardName()))); |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加中奖消息出错", e.getMessage(), result.getId()); |
| | | logger.error("添加中奖消息出错 awardResultId-{}", result.getId(), e); |
| | | } |
| | | |
| | | //发送中奖模板消息 |
| | |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(user.getUid()), LuckyMsgContentFactory.createNotDrawn(dto.getActivityId(), activity.getCreateTime()))); |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加未中奖消息出错", e.getMessage(), user.getUid(), dto.getActivityId()); |
| | | logger.error("添加未中奖消息出错 activityId-{} uid-{} ", dto.getActivityId(),user.getUid(),e); |
| | | } |
| | | |
| | | //发送未中奖模板消息 |
| | | alipayTemplateMsgManager.sendUnDrawnMsg(activity, Long.parseLong(result.getUid())); |
| | | } |
| | |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(user.getUid()), LuckyMsgContentFactory.createOpenFail(dto.getActivityId(), activity.getCreateTime()))); |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加未开奖消息出错", e.getMessage(), user.getUid(), dto.getActivityId()); |
| | | logger.error("添加未开奖消息出错 activityId-{} uid-{}", dto.getActivityId(), user.getUid(), e); |
| | | } |
| | | } |
| | | } |
| | |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(dto.getUid()), LuckyMsgContentFactory.createJoinSuccess(dto.getActivityId(), activity.getCreateTime()))); |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加参与成功消息出错", e.getMessage(), dto.getUid(), dto.getActivityId()); |
| | | logger.error("添加参与成功消息出错 activityId-{} uid-{}", dto.getActivityId(), dto.getUid(), e); |
| | | } |
| | | } |
| | | |
| | |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(dto.getTargetUid()), LuckyMsgContentFactory.createAssistAndJoin(dto.getActivityId(), activity.getCreateTime(), user, assist.getWeight()))); |
| | | } |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加助力成功消息出错", e.getMessage(), dto.getUid(), dto.getActivityId()); |
| | | logger.error("添加助力成功消息出错:activityId-{} uid-{}", dto.getActivityId(), dto.getUid(), e); |
| | | } |
| | | } |
| | | } |
| | |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(Long.parseLong(dto.getUid()), LuckyMsgContentFactory.createReceiveOutDate(dto.getActivityId(), activity.getCreateTime()))); |
| | | } catch (UserMsgException e) { |
| | | logger.error("添加过期未领消息出错", e.getMessage(), dto.getUid(), dto.getActivityId()); |
| | | logger.error("添加过期未领消息出错:", dto.getActivityId(), dto.getUid(), e); |
| | | } |
| | | |
| | | break; |