fanli/src/main/java/com/yeshi/fanli/dto/mq/user/UserTopicTagEnum.java
@@ -2,7 +2,9 @@ import com.yeshi.fanli.dto.mq.user.body.IntegralTaskMQMsg; import com.yeshi.fanli.dto.mq.user.body.InterTokenMQMsg; import com.yeshi.fanli.dto.mq.user.body.InviteCodeActiveMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserRedPackGiftMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserRegisterMQMsg; @@ -19,7 +21,8 @@ userRegister(UserRegisterMQMsg.class),//注册 tokenOutOfDate(InterTokenMQMsg.class),//口令过期 redPackGiftDrawback(UserRedPackGiftMQMsg.class),// 红包赠送退回 userInfoUpdate(null); //用户信息修改 inviteCodeActive(InviteCodeActiveMQMsg.class),//邀请码激活 userInfoUpdate(UserInfoUpdateMQMsg.class); //用户信息修改 private final Class<?> clazz; fanli/src/main/java/com/yeshi/fanli/dto/mq/user/body/InviteCodeActiveMQMsg.java
New file @@ -0,0 +1,41 @@ package com.yeshi.fanli.dto.mq.user.body; import java.util.Date; import com.yeshi.fanli.dto.mq.BaseMQMsgBody; /** * 用户信息修改 * * @author Administrator * */ public class InviteCodeActiveMQMsg extends BaseMQMsgBody { private Long uid;// 用户ID private Date createTime;// 时间 public InviteCodeActiveMQMsg(Long uid, Date createTime) { this.uid = uid; this.createTime = createTime; } public InviteCodeActiveMQMsg() { } public Long getUid() { return uid; } public void setUid(Long uid) { this.uid = uid; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } } fanli/src/main/java/com/yeshi/fanli/dto/mq/user/body/UserInfoUpdateMQMsg.java
@@ -28,7 +28,20 @@ private Long uid;// 用户ID private UserInfoUpdateTypeEnum type;// 类型 private String value;// 值 private Date createTime;//时间 private Date createTime;// 时间 public UserInfoUpdateMQMsg(Long uid, UserInfoUpdateTypeEnum type, String value, Date createTime) { super(); this.uid = uid; this.type = type; this.value = value; this.createTime = createTime; } public UserInfoUpdateMQMsg() { super(); } public Long getUid() { return uid; fanli/src/main/java/com/yeshi/fanli/entity/elme/ElmeOrder.java
@@ -55,8 +55,18 @@ private Date createTime; @Column(name = "eo_update_time") private Date updateTime; @Column(name = "eo_state") private Integer state;//0-失效 1-有效 public Integer getState() { return state; } public void setState(Integer state) { this.state = state; } private Long uid; private BigDecimal hongbao; private Integer hbState; fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeOrderProcessServiceImpl.java
@@ -134,7 +134,7 @@ new BigDecimal(100))); if (elmeOrder.getIsSettle() == true) hongBao.setPreGetTime(new Date(elmeOrder.getOrderDate().getTime() + 1000 * 60 * 60 * 24 * 15L)); if (elmeOrder.getPayMoney().compareTo(new BigDecimal(0)) <= 0) if (elmeOrder.getPayMoney().compareTo(new BigDecimal(0)) <= 0||(elmeOrder.getState()!=null&&elmeOrder.getState()==0)) hongBao.setState(HongBaoV2.STATE_SHIXIAO); else { if (elmeOrder.getIsSettle() == true) { fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -263,6 +263,13 @@ elmeOrder.setIsSettle(true); else elmeOrder.setIsSettle(false); if (!taoBaoOrder.getOrderState().equalsIgnoreCase("订单失效")) elmeOrder.setState(1); else { elmeOrder.setState(0); elmeOrder.setPayMoney(new BigDecimal(0)); } elmeOrder.setTrackPid( String.format("mm_124933865_%s_%s", taoBaoOrder.getSourceMediaId(), taoBaoOrder.getAdPositionId())); if (!StringUtil.isNullOrEmpty(taoBaoOrder.getRelationId())) { @@ -284,7 +291,7 @@ } catch (ElmeOrderException e) { e.printStackTrace(); } } } } @@ -1194,9 +1201,9 @@ @Resource private ElmeOrderService elmeOrderService; @Resource private ElmeOrderProcessService elmeOrderProcessService; /** * 获取饿了么可以返利的红包 * fanli/src/main/java/com/yeshi/fanli/service/impl/order/UserOrderWeiQuanRecordServiceImpl.java
@@ -78,7 +78,7 @@ // (维权金额/结算金额) * 返利金额 BigDecimal wqmoney = weiQuanOrder.getMoney(); money = wqmoney.multiply(hongBaoV2.getMoney()).divide(hongBaoV2.getSettlement(), 2, BigDecimal.ROUND_DOWN); BigDecimal.ROUND_UP); // 大于返利金额 则等于返利金额 if (money.compareTo(hongBaoV2.getMoney()) > 0) fanli/src/main/java/com/yeshi/fanli/service/impl/user/SpreadUserImgServiceImpl.java
@@ -473,6 +473,5 @@ String rootPath=Thread.currentThread().getContextClassLoader().getResource("").getPath(); rootPath = rootPath.substring(1,rootPath.indexOf("WEB-INF")); return rootPath; } } } fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java
@@ -19,8 +19,15 @@ import org.yeshi.utils.entity.FileUploadResult; import org.yeshi.utils.tencentcloud.COSManager; import com.aliyun.openservices.ons.api.Message; import com.aliyun.openservices.ons.api.Producer; import com.google.gson.Gson; import com.yeshi.fanli.dao.mybatis.user.UserInfoExtraMapper; import com.yeshi.fanli.dao.mybatis.user.UserRankRecordMapper; import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum; import com.yeshi.fanli.dto.mq.user.body.InviteCodeActiveMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg.UserInfoUpdateTypeEnum; import com.yeshi.fanli.dto.wx.WXAccountInfoDTO; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserInfoExtra; @@ -43,6 +50,8 @@ import com.yeshi.fanli.util.InviteCodeFilterUtil; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.account.UserUtil; import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory; import com.yeshi.fanli.util.rocketmq.MQTopicName; import com.yeshi.fanli.util.wx.WXLoginUtil; import com.yeshi.fanli.vo.user.UserInfoExtraVO; @@ -78,6 +87,9 @@ @Resource private UserInviteRecordService userInviteRecordService; @Resource(name = "producer") private Producer producer; @Override public UserInfoExtraVO getRankInfo(Long uid) throws UserInfoExtraException, Exception { @@ -176,7 +188,7 @@ } else { extra.setUserInfo(new UserInfo(uid)); } // 更新等级 if (isupdateRank) { List<UserRank> listRank = userRankService.getAllRank(); @@ -276,7 +288,6 @@ userInfoExtraMapper.insertSelective(userInfoExtra); } @Override public UserInfoExtra saveUserInfoExtra(UserInfoExtra userInfoExtra) throws UserInfoExtraException { @@ -313,9 +324,9 @@ @Override @Transactional(rollbackFor = Exception.class) public String activateInviteCode(Long uid, String inviteCode) throws UserInfoExtraException { if (uid == null || inviteCode == null) if (uid == null || inviteCode == null) throw new UserInfoExtraException(1, "激活信息不能为空"); // 被邀请人信息 UserInfo invitee = userInfoService.selectByPKey(uid); if (invitee == null) @@ -331,7 +342,7 @@ UserInfo inviter = userInfoService.getUserInfoByInviteCode(inviteCode); if (inviter == null) throw new UserInfoExtraException(1, "上级邀请码不存在"); // 绑定关系 try { threeSaleSerivce.bindRelationshipByInviteCode(invitee, inviter); @@ -346,7 +357,7 @@ // 生成邀请码 String mycode = createInviteCode(uid); if (StringUtil.isNullOrEmpty(mycode)) if (StringUtil.isNullOrEmpty(mycode)) throw new UserInfoExtraException(1, "激活码生成失败"); UserInfoExtra userInfoExtra = new UserInfoExtra(); @@ -360,6 +371,12 @@ userInfoExtra.setCreateTime(new Date()); userInfoExtraMapper.insertSelective(userInfoExtra); } // 发送激活成功消息 Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive, new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date()))); producer.send(message); return mycode; } @@ -368,7 +385,7 @@ public void activationInviteWX(WXAccountInfoDTO wxAccount, Long uid, String code) throws UserInfoExtraException { if (uid == null || code == null) throw new UserInfoExtraException(1, "激活信息不完整"); UserInfo invitee = userInfoService.selectByPKey(uid); if (invitee == null) throw new UserInfoExtraException(1, "用户不存在"); @@ -458,9 +475,9 @@ // 生成邀请码 String inviteCode = createInviteCode(uid); if (StringUtil.isNullOrEmpty(inviteCode)) if (StringUtil.isNullOrEmpty(inviteCode)) throw new UserInfoExtraException(1, "激活码生成失败"); UserInfoExtra userInfoExtra = new UserInfoExtra(); userInfoExtra.setUserInfo(invitee); userInfoExtra.setInviteCode(inviteCode); @@ -472,6 +489,10 @@ userInfoExtra.setCreateTime(new Date()); userInfoExtraMapper.insertSelective(userInfoExtra); } // 发送激活成功消息 Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive, new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date()))); producer.send(message); } @Override @@ -571,10 +592,11 @@ } // 生成邀请码 String inviteCode = createInviteCode(uid);; if (StringUtil.isNullOrEmpty(inviteCode)) String inviteCode = createInviteCode(uid); ; if (StringUtil.isNullOrEmpty(inviteCode)) throw new UserInfoExtraException(1, "激活码生成失败"); UserInfoExtra userInfoExtra = new UserInfoExtra(); userInfoExtra.setUserInfo(invitee); userInfoExtra.setInviteCode(inviteCode); @@ -617,12 +639,12 @@ public void updateGoldCoin(Long id, Integer goldCoin) { userInfoExtraMapper.updateGoldCoin(id, goldCoin); } @Override public void addGoldCoinByUid(Long uid, Integer goldCoin) { userInfoExtraMapper.addGoldCoinByUid(uid, goldCoin); } @Override public void updateByPrimaryKeySelective(UserInfoExtra record) { userInfoExtraMapper.updateByPrimaryKeySelective(record); @@ -640,17 +662,17 @@ // vip邀请码优先 if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip())) return userInfoExtra.getInviteCodeVip(); if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) return userInfoExtra.getInviteCode(); // 是否满足生产邀请码 int relationshipNum = threeSaleSerivce.getSuccessRelationshipNum(uid); if (relationshipNum > 0) { try { String inviteCode = createInviteCode(uid); if (!StringUtil.isNullOrEmpty(inviteCode)) { UserInfoExtra extra= new UserInfoExtra(); UserInfoExtra extra = new UserInfoExtra(); extra.setId(userInfoExtra.getId()); extra.setInviteCode(inviteCode); userInfoExtraMapper.updateByPrimaryKeySelective(extra); @@ -666,12 +688,13 @@ /** * 生产邀请码 * * @param uid * @return */ private String createInviteCode(Long uid) { String inviteCode = null; for (int i = 1; i <= 5; i ++) { for (int i = 1; i <= 5; i++) { inviteCode = UserUtil.getInviteCode(i, uid); long countCode = userInfoExtraMapper.countByInviteCode(inviteCode); if (countCode <= 0) @@ -679,8 +702,7 @@ } return inviteCode; } @Override public long countByRankId(Long rankId) { return userInfoExtraMapper.countByRankId(rankId); @@ -724,11 +746,11 @@ public UserInfo getUserByInviteCode(String inviteCode) throws UserInfoExtraException { if (StringUtil.isNullOrEmpty(inviteCode)) throw new UserInfoExtraException(1, "邀请码不能为空"); UserInfo inviter = userInfoService.getUserInfoByInviteCode(inviteCode); if (inviter == null) throw new UserInfoExtraException(1, "上级邀请码不存在"); return inviter; } @@ -787,35 +809,39 @@ public void updateInviteCodeVip(String inviteCodeVip, Long uid) throws UserInfoExtraException { if (inviteCodeVip == null || inviteCodeVip.length() < 4 || inviteCodeVip.length() > 12) throw new UserInfoExtraException(1, "邀请码必须为4到12位"); UserInfoExtra extra = getUserInfoExtra(uid); if (extra == null) throw new UserInfoExtraException(2, "用户信息不存在"); if (StringUtil.isNullOrEmpty(extra.getInviteCode())) throw new UserInfoExtraException(3, "邀请码尚未激活"); if (!StringUtil.isNullOrEmpty(extra.getInviteCodeVip())) throw new UserInfoExtraException(4, "只能修改一次"); // 转换成大写 inviteCodeVip = inviteCodeVip.toUpperCase(); // 验证特殊码 if(InviteCodeFilterUtil.isSpecialCode(inviteCodeVip)) if (InviteCodeFilterUtil.isSpecialCode(inviteCodeVip)) throw new UserInfoExtraException(5, "邀请码已存在"); if (inviteCodeVip.equalsIgnoreCase(extra.getInviteCode())) throw new UserInfoExtraException(5, "不能为原邀请码"); long count = userInfoExtraMapper.countByInviteCode(inviteCodeVip); if (count > 0) throw new UserInfoExtraException(6, "邀请码已存在"); UserInfoExtra update = new UserInfoExtra(); update.setId(extra.getId()); update.setInviteCodeVip(inviteCodeVip); update.setUpdateTime(new Date()); userInfoExtraMapper.updateByPrimaryKeySelective(update); //发送邀请码更改成功的消息 Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userInfoUpdate, new Gson().toJson(new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.inviteCode, inviteCodeVip, new Date()))); producer.send(message); } } fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoModifyRecordServiceImpl.java
@@ -14,6 +14,8 @@ import com.yeshi.fanli.dao.mybatis.user.UserInfoModifyRecordMapper; import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum; import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg.UserInfoUpdateTypeEnum; import com.yeshi.fanli.entity.bus.user.BindingAccount; import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; import com.yeshi.fanli.entity.bus.user.UserInfo; @@ -108,9 +110,16 @@ mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_ALIPAY, value, new Date()); } Message message =MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userAccountBinding,mqMsg); Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userAccountBinding, mqMsg); producer.send(message); } else {// 修改 if (type == ModifyTypeEnum.portrait) { Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userInfoUpdate, new Gson().toJson(new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.portrait, value, new Date()))); producer.send(message); } } } } catch (Exception e) { fanli/src/main/java/com/yeshi/fanli/service/inter/user/SpreadUserImgService.java
@@ -25,6 +25,7 @@ /** * 用户分享图的数量 * * @param uid * @return */ @@ -53,17 +54,20 @@ String getUserSpreadImg(Long uid, String bgImg, int erCodePostionX, int erCodePostionY, int erCodeSize); /** * 根据图片画二维码 * 根据图片画二维码 * * @param uid * @param bgImg * @param inviteCode * @return * @throws Exception */ String drawInviteQrCodeNew(String bgImg, Long uid, String portrait, Integer pX, Integer pY, Integer size, String inviteCode) throws Exception; String drawInviteQrCodeNew(String bgImg, Long uid, String portrait, Integer pX, Integer pY, Integer size, String inviteCode) throws Exception; /** * 邀请图片 问候 * * @param bgImg * @param uid * @param portrait @@ -73,12 +77,12 @@ * @return * @throws Exception */ public String getInviteImgToGreet(String bgImg, Long uid, String portrait, String inviteCode, String content, Date date) throws Exception; public String getInviteImgToGreet(String bgImg, Long uid, String portrait, String inviteCode, String content, Date date) throws Exception; /** * 获取用户要求图列表 * * @param uid * @param page * @param count @@ -86,5 +90,4 @@ * @return */ public List<String> getUserSpreadImgToPage(Long uid, int page, int count, HttpServletRequest request); } fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/InvitePictureChangeMessageListener.java
New file @@ -0,0 +1,62 @@ package com.yeshi.fanli.util.rocketmq.consumer.user; import javax.annotation.Resource; import org.springframework.stereotype.Component; import com.aliyun.openservices.ons.api.Action; import com.aliyun.openservices.ons.api.ConsumeContext; import com.aliyun.openservices.ons.api.Message; import com.aliyun.openservices.ons.api.MessageListener; import com.google.gson.Gson; import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum; import com.yeshi.fanli.dto.mq.user.body.InviteCodeActiveMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg.UserInfoUpdateTypeEnum; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.user.SpreadUserImgService; import com.yeshi.fanli.util.rocketmq.MQTopicName; /** * 用户邀请图改变 * * @author Administrator * */ @Component public class InvitePictureChangeMessageListener implements MessageListener { @Resource private SpreadUserImgService spreadUserImgService; @Override public Action consume(Message message, ConsumeContext context) { LogHelper.mqInfo("consumer-InvitePictureChangeMessageListener", message.getMsgID(), message.getTopic(), message.getTag(), new String(message.getBody())); String tag = message.getTag(); if (tag == null) tag = ""; if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(message.getTopic())) { if (tag.equalsIgnoreCase(UserTopicTagEnum.inviteCodeActive.name())) {// 邀请码激活 InviteCodeActiveMQMsg inviteCodeActiveMQMsg = new Gson().fromJson(new String(message.getBody()), InviteCodeActiveMQMsg.class); if (inviteCodeActiveMQMsg != null && inviteCodeActiveMQMsg.getUid() != null) spreadUserImgService.deleteImgUrl(inviteCodeActiveMQMsg.getUid()); return Action.CommitMessage; } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userInfoUpdate.name())) {// 订单统计 UserInfoUpdateMQMsg userInfoUpdateMQMsg = new Gson().fromJson(new String(message.getBody()), UserInfoUpdateMQMsg.class); if (userInfoUpdateMQMsg != null && (userInfoUpdateMQMsg.getType() == UserInfoUpdateTypeEnum.portrait || userInfoUpdateMQMsg.getType() == UserInfoUpdateTypeEnum.inviteCode)) { if (userInfoUpdateMQMsg.getUid() != null) spreadUserImgService.deleteImgUrl(userInfoUpdateMQMsg.getUid()); } return Action.CommitMessage; } } return Action.CommitMessage; } } fanli/src/main/resource/rocket/consumer.xml
@@ -98,7 +98,8 @@ <key> <bean class="com.aliyun.openservices.ons.api.bean.Subscription"> <property name="topic" value="TOPIC_ORDER" /> <property name="expression" value="orderStatistic||orderFanLiActual||orderStatisticDelay||orderFanLiSeparateByOrderNo" /> <property name="expression" value="orderStatistic||orderFanLiActual||orderStatisticDelay||orderFanLiSeparateByOrderNo" /> </bean> </key> </entry> @@ -147,8 +148,8 @@ </map> </property> </bean> <!-- 订单到账消息订阅 --> <bean id="orderMoneyRecievedMessageListener" class="com.yeshi.fanli.util.rocketmq.consumer.order.OrderMoneyRecievedMessageListener"></bean> @@ -179,6 +180,37 @@ </property> </bean> <!-- 邀请图修改消息订阅 --> <bean id="invitePictureChangeMessageListener" class="com.yeshi.fanli.util.rocketmq.consumer.user.InvitePictureChangeMessageListener"></bean> <!-- Group ID 订阅同一个 Topic,可以创建多个 ConsumerBean --> <bean id="invitePictureChangeConsumer" class="com.aliyun.openservices.ons.api.bean.ConsumerBean" init-method="start" destroy-method="shutdown"> <property name="properties"> <!--消费者配置信息 --> <props> <prop key="AccessKey">${rocketmq.AccessKey}</prop> <prop key="SecretKey">${rocketmq.SecretKey}</prop> <prop key="GROUP_ID">GID_INVITE_PICTURE</prop> <prop key="NAMESRV_ADDR">${rocketmq.NAMESRV_ADDR}</prop> <prop key="ConsumeThreadNums">50</prop> </props> </property> <property name="subscriptionTable"> <map> <!-- 邀请码激活,用户信息修改 --> <entry value-ref="invitePictureChangeMessageListener"> <key> <bean class="com.aliyun.openservices.ons.api.bean.Subscription"> <property name="topic" value="TOPIC_USER" /> <property name="expression" value="inviteCodeActive||userInfoUpdate" /> </bean> </key> </entry> </map> </property> </bean> </beans>