From 1fd8f11537bb74c1f7e611e35a766cbbd34eff05 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 07 十二月 2019 18:14:43 +0800 Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java | 72 ++++++++++++++--------------------- 1 files changed, 29 insertions(+), 43 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java index 9ae2f27..723029b 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java @@ -26,7 +26,6 @@ import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter; import com.aliyun.openservices.ons.api.transaction.TransactionProducer; import com.aliyun.openservices.ons.api.transaction.TransactionStatus; -import com.google.gson.Gson; import com.yeshi.fanli.dao.mybatis.user.UserSystemCouponMapper; import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum; import com.yeshi.fanli.dto.mq.user.body.UserSystemCouponUseMQMsg; @@ -75,6 +74,7 @@ import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService; import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; +import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.util.RedisManager; @@ -84,6 +84,7 @@ import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService; import com.yeshi.fanli.util.factory.UserMoneyDetailFactory; import com.yeshi.fanli.util.factory.msg.MsgOtherSystemGiveDTOFactory; +import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory; import com.yeshi.fanli.util.rocketmq.MQTopicName; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.vo.msg.ClientTextStyleVO; @@ -178,6 +179,9 @@ @Resource(name = "producer") private Producer producer; + + @Resource + private UserVIPInfoService userVIPInfoService; @@ -249,6 +253,8 @@ } else { coupon = systemCouponService.getCouponByTypeAndPercent(couponType, percent); } + } else if (couponType.equals(CouponTypeEnum.freeCouponGive.name())) { + coupon = systemCouponService.getCouponByType(couponType); } if (coupon == null) { @@ -896,8 +902,8 @@ UserSystemCouponUseMQMsg mqMsg = new UserSystemCouponUseMQMsg(userSystemCoupon.getId(), order.getOrderId(), sourceType, systemCoupon.getType().name()); // 浜嬪姟娑堟伅 - Message msg = new Message(MQTopicName.TOPIC_USER.name(), UserTopicTagEnum.useSystemCoupon.name(), - new Gson().toJson(mqMsg).getBytes()); + Message msg =MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.useSystemCoupon, + mqMsg); try { SendResult result = orderTransactionProducer.send(msg, new LocalTransactionExecuter() { @Override @@ -1876,18 +1882,20 @@ jumpBtn.put("params", jumpLink); jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("web")); } else if (CouponTypeEnum.rebatePercentCoupon == type) { - // 鍙娇鐢ㄣ�� 鍙禒閫� - userCouponVO.setState(UserSystemCoupon.STATE_USE_GIVE); - - // 璁㈠崟鍒楄〃 - jumpLink.put("state", "2"); // 宸叉敹璐� - jumpLink.put("showNav", false); // 涓嶆樉绀轰笂鏂圭粺璁′俊鎭� - jumpLink.put("type", "1"); // 杩斿埄璁㈠崟 - jumpLink.put("title", "杩斿埄璁㈠崟"); // 鏍囬鍚� - jumpLink.put("goodsType", "0"); // 璁㈠崟鏉ユ簮 - jumpBtn = new HashMap<String, Object>(); - jumpBtn.put("params", jumpLink); - jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("order_screen_list")); + if (userVIPInfoService.isVIP(uid)) { // 浼氬憳鍙彲璧犻�� + userCouponVO.setState(UserSystemCoupon.STATE_GIVE_ONLY); + } else {// 鍙娇鐢� 鍙禒閫� + userCouponVO.setState(UserSystemCoupon.STATE_USE_GIVE); + + jumpLink.put("state", "2"); // 宸叉敹璐� + jumpLink.put("showNav", false); // 涓嶆樉绀轰笂鏂圭粺璁′俊鎭� + jumpLink.put("type", "1"); // 杩斿埄璁㈠崟 + jumpLink.put("title", "杩斿埄璁㈠崟"); // 鏍囬鍚� + jumpLink.put("goodsType", "0"); // 璁㈠崟鏉ユ簮 + jumpBtn = new HashMap<String, Object>(); + jumpBtn.put("params", jumpLink); + jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("order_screen_list")); + } } } else if (UserSystemCoupon.STATE_IN_USE == state && give) { userCouponVO.setCouponEffect("璧犻�佷腑"); @@ -2082,8 +2090,8 @@ 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()); + Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.systemCouponDrawback, + msg); try { producer.send(message); } catch (Exception e) { @@ -2446,34 +2454,16 @@ } @Override - public boolean getIncludeExchange(Long uid) { + public boolean getValidRebateCoupon(Long uid) { // 杩囨湡鍒� updateInvalidSate(uid); - - String percent = configService.get("exchange_rebate_percent"); - if (StringUtil.isNullOrEmpty(percent)) - percent = "35"; - List<UserSystemCoupon> listCoupon = userSystemCouponMapper.getIncludeExchange(uid, Integer.parseInt(percent), - CouponTypeEnum.rebatePercentCoupon.name()); + + List<UserSystemCouponVO> listCoupon = userSystemCouponMapper.getValidByUidAndType(uid, CouponTypeEnum.rebatePercentCoupon.name()); if (listCoupon == null || listCoupon.size() == 0) return false; return true; } - @Override - public boolean getIncludeNotExchange(Long uid) { - // 杩囨湡鍒� - updateInvalidSate(uid); - - String percent = configService.get("exchange_rebate_percent"); - if (StringUtil.isNullOrEmpty(percent)) - percent = "35"; - List<UserSystemCouponVO> listCoupon = userSystemCouponMapper.getIncludeNotExchange(uid, - Integer.parseInt(percent), CouponTypeEnum.rebatePercentCoupon.name()); - if (listCoupon == null || listCoupon.size() == 0) - return false; - return true; - } @Override public List<UserSystemCouponVO> listIncludeNotExchange(Long uid) throws Exception { @@ -2483,12 +2473,8 @@ // 閫�鍥炲埜 sendBackTimeOutCoupon(uid); - String percent = configService.get("exchange_rebate_percent"); - if (StringUtil.isNullOrEmpty(percent)) - percent = "35"; - List<UserSystemCouponVO> listCoupon = userSystemCouponMapper.getIncludeNotExchange(uid, - Integer.parseInt(percent), CouponTypeEnum.rebatePercentCoupon.name()); + List<UserSystemCouponVO> listCoupon = userSystemCouponMapper.getValidByUidAndType(uid, CouponTypeEnum.rebatePercentCoupon.name()); if (listCoupon == null || listCoupon.size() == 0) return null; -- Gitblit v1.8.0