yujian
2019-11-12 be3e3b04394c15c2e0ca6e74082455a4f877495d
红包版本区分
12个文件已修改
166 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ConfigController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConfigControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponGiveRecordMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponGiveRecordMapper.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponGiveRecordServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponGiveRecordService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/coupon/SystemCouponMessageListener.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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 {
@@ -45,7 +50,6 @@
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
    private TokenRecordService tokenRecordService;
    
@@ -55,6 +59,8 @@
    @Resource
    private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
    
    @Resource(name = "producer")
    private Producer producer;
    
    @Override
    public RedPackGiveRecord selectByPrimaryKey(Long id) {
@@ -65,7 +71,6 @@
    public void updateByPrimaryKeySelective(RedPackGiveRecord record) {
        redPackGiveRecordMapper.updateByPrimaryKeySelective(record);
    }
    
    @Override
    @RequestSerializableByKeyService(key = "#id")
@@ -91,7 +96,8 @@
        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");
@@ -100,10 +106,10 @@
        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)
@@ -156,8 +162,8 @@
        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 {
@@ -165,9 +171,21 @@
        } catch (Exception e) {
            throw new RedPackGiveRecordException(1, "红包创建失败");
        }
        return tips;
        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)
@@ -186,7 +204,8 @@
        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, "红包领取失败");
        }        
@@ -198,13 +217,13 @@
            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,"更新提现明细出错");
        }
        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,29 +2277,9 @@
    
    @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();
    public void sendBackByGiveId(Long couponId) {
        if (couponId == null) 
            return;
        
@@ -2292,6 +2291,23 @@
        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();
        if (endTime != null && endTime.getTime() < now.getTime()) {
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 = "无";
            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,7 +43,6 @@
                    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) {