fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ConfigController.java
@@ -15,6 +15,7 @@ import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.homemodule.FloatAD; import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture; import com.yeshi.fanli.entity.bus.homemodule.FloatAD.FloatADTypeEnum; import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState; import com.yeshi.fanli.entity.bus.user.UserActiveLog; import com.yeshi.fanli.entity.config.AppHomeFloatImg; @@ -106,8 +107,7 @@ // 无新人弹框 则查询默认 FloatAD floatAD = floatADService.getEffectiveFloatAD(FloatAD.POSITION_INDEX, 0); if (floatAD != null) { if (floatAD != null && floatAD.getTypeEnum() != FloatADTypeEnum.newUserRedPack) { JSONObject detail = new JSONObject(); detail.put("img", floatAD.getPicture()); detail.put("jumpDetail", floatAD.getJumpDetail()); fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConfigControllerV2.java
@@ -110,7 +110,7 @@ // 无新人弹框 则查询默认 FloatAD floatAD = floatADService.getEffectiveFloatAD(FloatAD.POSITION_INDEX, 0); if (floatAD != null) { if (floatAD != null && floatAD.getTypeEnum() != FloatADTypeEnum.newUserRedPack) { JSONObject detail = new JSONObject(); detail.put("img", floatAD.getPicture()); detail.put("jumpDetail", floatAD.getJumpDetail()); fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponGiveRecordMapper.java
@@ -43,6 +43,13 @@ */ UserSystemCouponGiveRecord getByReceiveId(@Param("receiveId") Long receiveId); /** * 查询券赠送信息 * @param count * @return */ UserSystemCouponGiveRecord getByCouponId(@Param("couponId") Long couponId); /** * 查询赠送记录 fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponGiveRecordMapper.xml
@@ -66,6 +66,14 @@ LIMIT 1 </select> <select id="getByCouponId" resultMap="BaseResultMap"> SELECT * FROM yeshi_ec_user_system_coupon_give_record WHERE cgr_state = 0 AND cgr_coupon_id = #{couponId} ORDER BY cgr_give_time desc LIMIT 1 </select> <select id="overdueList" resultMap="BaseResultMap"> SELECT * FROM yeshi_ec_user_system_coupon_give_record d WHERE d.`cgr_state` = 0 AND d.`cgr_end_time` IS NOT NULL AND d.`cgr_end_time` <![CDATA[<]]> NOW() fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java
@@ -53,6 +53,10 @@ throw new FloatADException(1, "跳转参数非JSON格式"); } FloatADTypeEnum typeEnum = record.getTypeEnum(); if (typeEnum == null) throw new FloatADException(1, "类型不能为空"); if (!StringUtil.isNullOrEmpty(jumpType)) { List<JumpDetailV2> listByType = jumpDetailV2Service.listByType(jumpType); if (listByType !=null && listByType.size() > 0) { fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java
@@ -10,8 +10,12 @@ import org.springframework.transaction.annotation.Transactional; import org.yeshi.utils.DateUtil; 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.redpack.RedPackGiveRecordMapper; import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum; import com.yeshi.fanli.dto.mq.user.body.UserRedPackGiftMQMsg; import com.yeshi.fanli.dto.msg.MsgRedPackGiveContentDTO; import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum; import com.yeshi.fanli.entity.bus.user.TokenRecord; @@ -32,6 +36,7 @@ import com.yeshi.fanli.util.TokenUtil; import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService; import com.yeshi.fanli.util.factory.RedPackDetailFactory; import com.yeshi.fanli.util.rocketmq.MQTopicName; @Service public class RedPackGiveRecordServiceImpl implements RedPackGiveRecordService { @@ -41,58 +46,59 @@ @Resource private RedPackConfigService redPackConfigService; @Resource private RedPackBalanceService redPackBalanceService; @Resource private TokenRecordService tokenRecordService; @Resource private RedPackDetailService redPackDetailService; @Resource private UserMoneyMsgNotificationService userMoneyMsgNotificationService; @Resource(name = "producer") private Producer producer; @Override public RedPackGiveRecord selectByPrimaryKey(Long id) { return redPackGiveRecordMapper.selectByPrimaryKey(id); } @Override public void updateByPrimaryKeySelective(RedPackGiveRecord record) { redPackGiveRecordMapper.updateByPrimaryKeySelective(record); } @Override @RequestSerializableByKeyService(key = "#id") @Transactional(rollbackFor = Exception.class) public void overdueByPrimaryKey(Long id) throws Exception { if (id == null) return; RedPackGiveRecord giveRecord = redPackGiveRecordMapper.selectByPrimaryKey(id); if (giveRecord == null) return; if (giveRecord.getState() != null && giveRecord.getState() != RedPackGiveRecord.STATE_INIT ) if (giveRecord.getState() != null && giveRecord.getState() != RedPackGiveRecord.STATE_INIT) return; // 赠送记录失效 RedPackGiveRecord updateRecord = new RedPackGiveRecord(); updateRecord.setId(giveRecord.getId()); updateRecord.setState(RedPackGiveRecord.STATE_OVERDUE); redPackGiveRecordMapper.updateByPrimaryKeySelective(updateRecord); // 口令失效 tokenRecordService.invalidByRedPack(id); // 退回红包 redPackBalanceService.addRedPack(giveRecord.getGiveUid(), giveRecord.getAmount(), RedPackDetailFactory.createGiveOthersFail(giveRecord)); redPackBalanceService.addRedPack(giveRecord.getGiveUid(), giveRecord.getAmount(), RedPackDetailFactory.createGiveOthersFail(giveRecord)); // 退回消息 SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm"); MsgRedPackGiveContentDTO givedto = new MsgRedPackGiveContentDTO(); @@ -100,11 +106,11 @@ givedto.setMoney("¥" + giveRecord.getAmount().setScale(2)); givedto.setTime(sd.format(new Date())); givedto.setGiveTime(sd.format(giveRecord.getGiveTime())); userMoneyMsgNotificationService.redPackMsg(giveRecord.getGiveUid(), MsgTypeMoneyTypeEnum.redPackGiveBack, new Gson().toJson(givedto), "请到我的-红包查看"); userMoneyMsgNotificationService.redPackMsg(giveRecord.getGiveUid(), MsgTypeMoneyTypeEnum.redPackGiveBack, new Gson().toJson(givedto), "请到我的-红包查看"); } @Override @Transactional(rollbackFor = Exception.class) public String giving(Long uid, BigDecimal amount) throws RedPackGiveRecordException { @@ -115,14 +121,14 @@ String giveMax = redPackConfigService.getValueByKey("give_money_max"); if (amount.compareTo(new BigDecimal(giveMin)) < 0 || amount.compareTo(new BigDecimal(giveMax)) > 0) throw new RedPackGiveRecordException(1, "赠送金额至少" + giveMin + "元至多" + giveMax + "元"); BigDecimal balance = null; try { balance = redPackBalanceService.getBalance(uid); } catch (RedPackBalanceException e1) { throw new RedPackGiveRecordException(1, e1.getMsg()); } if (balance == null || amount.compareTo(balance) > 0) throw new RedPackGiveRecordException(1, "余额不足"); @@ -156,55 +162,68 @@ while (tips.contains("{APP名称}")) { tips = tips.replace("{APP名称}", projectChineseName); } tips = tips.replace("{口令}", token).replace("{下载链接}", redPackConfigService.getValueByKey("app_down_link")).replace("{面额}", amount.setScale(2).toString()); tips = tips.replace("{口令}", token).replace("{下载链接}", redPackConfigService.getValueByKey("app_down_link")) .replace("{面额}", amount.setScale(2).toString()); // 减少红包 try { redPackBalanceService.subRedPack(uid, amount, RedPackDetailFactory.createGiveOthers(giveRecord)); } catch (Exception e) { throw new RedPackGiveRecordException(1, "红包创建失败"); } UserRedPackGiftMQMsg msg = new UserRedPackGiftMQMsg(); msg.setId(giveRecord.getId()); msg.setUid(uid); Message message = new Message(MQTopicName.TOPIC_USER.name(), UserTopicTagEnum.redPackGiftDrawback.name(), new Gson().toJson(msg).getBytes()); try { producer.send(message); } catch (Exception e) { throw new RedPackGiveRecordException(1, "红包创建失败"); } return tips; } @Override @Transactional(rollbackFor = Exception.class) public RedPackGiveRecord receiveFriendsGive(Long uid, Long id) throws RedPackGiveRecordException{ public RedPackGiveRecord receiveFriendsGive(Long uid, Long id) throws RedPackGiveRecordException { RedPackGiveRecord giveRecord = redPackGiveRecordMapper.selectByPrimaryKey(id); if (giveRecord == null || giveRecord.getState() != RedPackGiveRecord.STATE_INIT) throw new RedPackGiveRecordException(1, "赠送记录失效或已被领取"); Date now = new Date(); Date endTime = giveRecord.getEndTime(); if (endTime != null && endTime.getTime() < now.getTime()) throw new RedPackGiveRecordException(1, "红包已失效了"); giveRecord.setReceiveUid(uid); giveRecord.setReceiveTime(now); giveRecord.setState(RedPackGiveRecord.STATE_RECEIVE); // 领取人增加红包 try { redPackBalanceService.addRedPack(uid, giveRecord.getAmount(), RedPackDetailFactory.createGiveOthersReceive(giveRecord)); redPackBalanceService.addRedPack(uid, giveRecord.getAmount(), RedPackDetailFactory.createGiveOthersReceive(giveRecord)); } catch (Exception e) { throw new RedPackGiveRecordException(1, "红包领取失败"); } } // 更新赠送记录 redPackGiveRecordMapper.updateByPrimaryKey(giveRecord); try { String identifyCode = StringUtil.Md5(RedPackDetailTypeEnum.giveOthers.name() + ":" + giveRecord.getId()); RedPackDetail redPackDetail = redPackDetailService.getByIdentifyCode(identifyCode); RedPackDetail updateDetail = RedPackDetailFactory.createGiveOthersSucceed(redPackDetail.getId(), giveRecord); RedPackDetail updateDetail = RedPackDetailFactory.createGiveOthersSucceed(redPackDetail.getId(), giveRecord); redPackDetailService.updateByPrimaryKeySelective(updateDetail); } catch (Exception e) { throw new RedPackGiveRecordException(1,"更新提现明细出错"); throw new RedPackGiveRecordException(1, "更新提现明细出错"); } return giveRecord; } } fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponGiveRecordServiceImpl.java
@@ -83,4 +83,9 @@ public long countGiveRecord(String type, Integer state) { return userSystemCouponGiveRecordMapper.countGiveRecord(type, state); } @Override public UserSystemCouponGiveRecord getByCouponId(Long couponId) { return userSystemCouponGiveRecordMapper.getByCouponId(couponId); } } fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -21,6 +21,7 @@ import org.yeshi.utils.entity.DateInfo; import com.aliyun.openservices.ons.api.Message; import com.aliyun.openservices.ons.api.Producer; import com.aliyun.openservices.ons.api.SendResult; import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter; import com.aliyun.openservices.ons.api.transaction.TransactionProducer; @@ -174,6 +175,11 @@ @Resource private UserSystemCouponActivateService userSystemCouponActivateService; @Resource(name = "producer") private Producer producer; @Override public int insertSelective(UserSystemCoupon record) { @@ -2071,7 +2077,20 @@ } tips = tips.replace("{口令}", token).replace("{下载链接}", configService.get("app_down_link")); return createUserCouponVOo(userSystemCoupon, systemCoupon, giveRecord, tips); UserSystemCouponVO couponVO = createUserCouponVOo(userSystemCoupon, systemCoupon, giveRecord, tips); UserSystemCouponUseMQMsg msg = new UserSystemCouponUseMQMsg(); msg.setUserSystemCouponId(id); msg.setCouponType(type.name()); Message message = new Message(MQTopicName.TOPIC_USER.name(), UserTopicTagEnum.systemCouponDrawback.name(), new Gson().toJson(msg).getBytes()); try { producer.send(message); } catch (Exception e) { throw new UserSystemCouponException(1, "创建赠送信息失败"); } return couponVO; } private UserSystemCouponVO createUserCouponVOo(UserSystemCoupon userSystemCoupon, SystemCoupon systemCoupon, @@ -2258,30 +2277,10 @@ @Override @RequestSerializableByKeyService(key = "#giveid") @RequestSerializableByKeyService(key = "#id") @Transactional(rollbackFor = Exception.class) public void sendBackByGiveId(Long giveid) { if (giveid == null) return; UserSystemCouponGiveRecord giveRecord = userSystemCouponGiveRecordService.selectByPrimaryKey(giveid); if (giveRecord == null) return; if (giveRecord.getState() != null && giveRecord.getState() != UserSystemCouponGiveRecord.STATE_INIT) return; // 更新赠送记录 UserSystemCouponGiveRecord updateRecord = new UserSystemCouponGiveRecord(); updateRecord.setId(giveid); updateRecord.setState(UserSystemCouponGiveRecord.STATE_OVERDUE); userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateRecord); // 口令失效 tokenRecordService.invalidByCoupon(giveid); Long couponId = giveRecord.getCouponId(); if (couponId == null) public void sendBackByGiveId(Long couponId) { if (couponId == null) return; UserSystemCoupon userCoupon = userSystemCouponMapper.selectByPrimaryKey(couponId); @@ -2291,6 +2290,23 @@ Integer state = userCoupon.getState(); if (state != UserSystemCoupon.STATE_IN_USE) return; UserSystemCouponGiveRecord giveRecord = userSystemCouponGiveRecordService.getByCouponId(couponId); if (giveRecord == null) return; if (giveRecord.getState() != null && giveRecord.getState() != UserSystemCouponGiveRecord.STATE_INIT) return; // 更新赠送记录 UserSystemCouponGiveRecord updateRecord = new UserSystemCouponGiveRecord(); updateRecord.setId(giveRecord.getId()); updateRecord.setState(UserSystemCouponGiveRecord.STATE_OVERDUE); userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateRecord); // 口令失效 tokenRecordService.invalidByCoupon(giveRecord.getId()); Date now = new Date(); Date endTime = userCoupon.getEndTime(); fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponGiveRecordService.java
@@ -55,6 +55,14 @@ * @return */ public UserSystemCouponGiveRecord getByReceiveId(Long receiveId); /** * 查询券赠送信息 * @param couponId * @return */ public UserSystemCouponGiveRecord getByCouponId(Long couponId); /** fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java
@@ -728,11 +728,11 @@ items.add(new CommonMsgItemVO(new ClientTextStyleVO("失败原因", COLOR_TITLE), contentList)); String handle = dto.getHandle(); if (StringUtil.isNullOrEmpty(handle)) handle = "无"; contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO(handle, COLOR_CONTENT)); items.add(new CommonMsgItemVO(new ClientTextStyleVO("处理", COLOR_TITLE), contentList)); if (!StringUtil.isNullOrEmpty(handle)) { contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO(handle, COLOR_CONTENT)); items.add(new CommonMsgItemVO(new ClientTextStyleVO("处理", COLOR_TITLE), contentList)); } contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu(), fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/coupon/SystemCouponMessageListener.java
@@ -43,8 +43,7 @@ if (orderMoneyRecievedMQMsgDTO.getOrderFirst() != null && orderMoneyRecievedMQMsgDTO.getOrderFirst() == true) { // 首次到账返利 // TODO 业务代码添加 // 激活免单券 userSystemCouponService.triggerFreeCouponActivate(orderMoneyRecievedMQMsgDTO.getUid()); @@ -57,8 +56,11 @@ if (UserTopicTagEnum.systemCouponDrawback.name().equalsIgnoreCase(tag)) {// 券退回 UserSystemCouponUseMQMsg userSystemCouponUseMQMsg = new Gson().fromJson(new String(message.getBody()), UserSystemCouponUseMQMsg.class); //TODO处理券退回 //处理券退回 userSystemCouponService.sendBackByGiveId(userSystemCouponUseMQMsg.getUserSystemCouponId()); // 业务代码执行成功后返回 return Action.CommitMessage; } } return Action.CommitMessage; fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java
@@ -17,7 +17,9 @@ import com.yeshi.fanli.dto.mq.user.body.IntegralTaskMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg; import com.yeshi.fanli.dto.mq.user.body.UserRedPackGiftMQMsg; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService; import com.yeshi.fanli.service.inter.redpack.RedPackWinInviteService; import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.util.Constant; @@ -37,6 +39,9 @@ @Resource private RedPackWinInviteService redPackWinInviteService; @Resource private RedPackGiveRecordService redPackGiveRecordService; @Override public Action consume(Message message, ConsumeContext context) { @@ -94,7 +99,15 @@ inviteSucceedReward = true; uid = integralTaskMQMsg.getUid(); } else if (tag.equalsIgnoreCase(UserTopicTagEnum.redPackGiftDrawback.name())) {// 红包赠送 // TODO 红包赠送到期未领取 UserRedPackGiftMQMsg userRedPackGiftMQMsg = new Gson().fromJson(new String(message.getBody()), UserRedPackGiftMQMsg.class); // 红包赠送到期未领取 try { redPackGiveRecordService.overdueByPrimaryKey(userRedPackGiftMQMsg.getId()); } catch (Exception e) { e.printStackTrace(); } return Action.CommitMessage; } if (inviteSucceedReward) {