From d3db196ed2fe8b6c3905ff111d665d9fc2c951a3 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 10 十二月 2019 15:41:58 +0800 Subject: [PATCH] 返利比例与会员比例调整 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java | 71 ++++++++++++++++++++--------------- 1 files changed, 40 insertions(+), 31 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 c20246d..90c43a0 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 @@ -176,14 +176,12 @@ @Resource private UserSystemCouponActivateService userSystemCouponActivateService; - + @Resource(name = "producer") private Producer producer; - + @Resource private UserVIPInfoService userVIPInfoService; - - @Override public int insertSelective(UserSystemCoupon record) { @@ -298,8 +296,8 @@ userCoupon.setCreateTime(new Date()); userCoupon.setUpdateTime(new Date()); userSystemCouponMapper.insertSelective(userCoupon); - - if(coupon.getType() == CouponTypeEnum.freeCoupon) { + + if (coupon.getType() == CouponTypeEnum.freeCoupon) { userSystemCouponActivateService.addActivateRecord(userCoupon.getId()); } @@ -837,6 +835,22 @@ if (orderNo == null || orderNo.trim().length() == 0) throw new UserSystemCouponException(1, "璁㈠崟鍙蜂笉瀛樺湪"); + // 妫�鏌ヨ鍗曞彿鏄惁缁存潈 + List<CommonOrder> commonOrderList = commonOrderService.listBySourceTypeAndOrderId(sourceType, orderNo); + boolean weiquan = false; + if (commonOrderList != null) { + for (CommonOrder commonOrder : commonOrderList) { + if (commonOrder.getState() == CommonOrder.STATE_WQ) { + weiquan = true; + break; + } + } + } + + if (weiquan) { + throw new UserSystemCouponException(1, "浜诧紝寰堥仐鎲撅紝鍞悗缁存潈璁㈠崟涓嶈兘浣跨敤杩斿埄濂栧姳鍒竳"); + } + // 璁㈠崟 CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(uid, orderNo, CommonOrder.STATE_JS, sourceType); @@ -900,8 +914,7 @@ UserSystemCouponUseMQMsg mqMsg = new UserSystemCouponUseMQMsg(userSystemCoupon.getId(), order.getOrderId(), sourceType, systemCoupon.getType().name()); // 浜嬪姟娑堟伅 - Message msg =MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.useSystemCoupon, - mqMsg); + Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.useSystemCoupon, mqMsg); try { SendResult result = orderTransactionProducer.send(msg, new LocalTransactionExecuter() { @Override @@ -1884,7 +1897,7 @@ 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"); // 杩斿埄璁㈠崟 @@ -2084,18 +2097,17 @@ tips = tips.replace("{鍙d护}", token).replace("{涓嬭浇閾炬帴}", configService.get("app_down_link")); UserSystemCouponVO couponVO = createUserCouponVOo(userSystemCoupon, systemCoupon, giveRecord, tips); - + UserSystemCouponUseMQMsg msg = new UserSystemCouponUseMQMsg(); msg.setUserSystemCouponId(id); msg.setCouponType(type.name()); - Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.systemCouponDrawback, - msg); + Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.systemCouponDrawback, msg); try { producer.send(message); } catch (Exception e) { throw new UserSystemCouponException(1, "鍒涘缓璧犻�佷俊鎭け璐�"); } - + return couponVO; } @@ -2281,38 +2293,36 @@ sendBackGiveCoupon(list); } - @Override @RequestSerializableByKeyService(key = "#id") @Transactional(rollbackFor = Exception.class) public void sendBackByGiveId(Long couponId) { if (couponId == null) return; - + UserSystemCoupon userCoupon = userSystemCouponMapper.selectByPrimaryKey(couponId); if (userCoupon == null) return; - + 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) + + 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); - + // 鍙d护澶辨晥 tokenRecordService.invalidByCoupon(giveRecord.getId()); - Date now = new Date(); Date endTime = userCoupon.getEndTime(); @@ -2367,14 +2377,13 @@ msgOther.setReturnTime(sd.format(new Date())); userOtherMsgNotificationService.tokenGiveMsg(giveRecord.getGiveUid(), beiZhu, msgOther); } - - + @Override public void sendBackGiveCoupon(List<UserSystemCouponGiveRecord> overdueList) { for (UserSystemCouponGiveRecord record : overdueList) { - if (record.getState() != null && record.getState() != UserSystemCouponGiveRecord.STATE_INIT) + if (record.getState() != null && record.getState() != UserSystemCouponGiveRecord.STATE_INIT) continue; - + // 鏇存柊璧犻�佽褰� UserSystemCouponGiveRecord updateRecord = new UserSystemCouponGiveRecord(); updateRecord.setId(record.getId()); @@ -2567,9 +2576,9 @@ @Override @Transactional(rollbackFor = Exception.class) public void triggerFreeCouponActivate(Long uid, String orderNo, Integer source) { - if (uid == null || source == null || StringUtil.isNullOrEmpty(orderNo)) + if (uid == null || source == null || StringUtil.isNullOrEmpty(orderNo)) return; - + UserSystemCoupon coupon = userSystemCouponMapper.getNeedActivateCouponByType(uid, CouponTypeEnum.freeCoupon.name()); if (coupon == null) @@ -2579,14 +2588,14 @@ UserSystemCouponActivate couponActivate = userSystemCouponActivateService.selectForUpdate(id); if (couponActivate == null) return; - + // 楠岃瘉鍚岃鍗曟槸鍚﹀瓨鍦� String key = orderNo + "_" + source; String ordernos = couponActivate.getOrdernos(); if (!StringUtil.isNullOrEmpty(ordernos)) { String[] array = ordernos.split(","); if (array != null) - for (int i= 0; i < array.length; i ++) { + for (int i = 0; i < array.length; i++) { if (array[i].equals(key)) return; } @@ -2609,7 +2618,7 @@ } else { ordernos = ordernos + "," + key; } - + UserSystemCouponActivate updateActivate = new UserSystemCouponActivate(); updateActivate.setId(id); updateActivate.setState(state); -- Gitblit v1.8.0