From 2147d023563a7c9d05d97547c00d6b0162c0644c Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 09 十一月 2020 18:37:24 +0800 Subject: [PATCH] 刷单风险规则优化 --- fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderServiceImpl.java | 30 ++++++++++++++++-------------- 1 files changed, 16 insertions(+), 14 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderServiceImpl.java index 162e62b..5e5e70f 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderServiceImpl.java @@ -46,6 +46,7 @@ import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetPayService; import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetService; import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService; +import com.yeshi.fanli.service.manger.msg.RocketMQManager; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.factory.RedPackDetailFactory; import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory; @@ -74,8 +75,8 @@ @Resource private RedPackBalanceService redPackBalanceService; - @Resource(name = "producer") - private Producer producer; + @Resource + private RocketMQManager rocketMQManager; @Resource private MQUnSendInfoService mqUnSendInfoService; @@ -91,12 +92,11 @@ @Resource private UserMoneyMsgNotificationService userMoneyMsgNotificationService; - + @Resource private RedPackForbidService redPackForbidService; - - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public void addOrder(BanLiShopOrder order) throws BanLiShopOrderException { // 鏌ヨ蹇呰鐨勫弬鏁版槸鍚︽坊鍔� @@ -181,7 +181,8 @@ msg.setKey(orderId + ""); long delayTime = System.currentTimeMillis() + (Constant.IS_TEST ? 1000 * 30L : 1000 * 60 * 10);// 10鍒嗛挓鍚庨�氱煡 msg.setStartDeliverTime(delayTime); - SendResult sendResult = producer.send(msg); + + SendResult sendResult = rocketMQManager.sendNormalMsg(msg, Constant.IS_TEST ? 1000 * 30L : 1000 * 60 * 10L, orderId + ""); if (sendResult == null) { MQUnSendInfo info = new MQUnSendInfo(); info.setBody(new String(msg.getBody())); @@ -224,7 +225,7 @@ banLiShopOrderMapper.updateByPrimaryKeySelective(order); } - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public void payOrderByHongBao(Long orderId) throws BanLiShopOrderException, RedPackBalanceException { BanLiShopOrder order = banLiShopOrderMapper.selectByPrimaryKeyForUpdate(orderId); @@ -329,6 +330,7 @@ return banLiShopOrderMapper.selectByPrimaryKeyForUpdate(id); } + @Transactional(rollbackFor = Exception.class) @Override public void invalidOrderByOrderId(Long id, String desc) { // 鍒ゆ柇璁㈠崟鏄惁瀛樺湪 @@ -347,9 +349,9 @@ if (isS)// 鏀粯鎴愬姛锛岄噸鏂板彂閫佹敮浠樻垚鍔熸秷鎭� { BanLiShopOrderMQMsg msg = new BanLiShopOrderMQMsg(order.getId(), order.getUid()); - Message message =MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, - OrderTopicTagEnum.banLiShopOrderPaid,msg); - producer.send(message); + Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, + OrderTopicTagEnum.banLiShopOrderPaid, msg); + rocketMQManager.sendNormalMsg(message, null); return; } @@ -379,8 +381,8 @@ if (order.getState() != BanLiShopOrder.STATE_PAID) throw new BanLiShopOrderException(1, "璁㈠崟鏈浜庡緟瀹℃牳鐘舵��"); - Message message =MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.banLiShopOrderRefund, - new BanLiShopOrderMQMsg(order.getId(), order.getUid())); + Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.banLiShopOrderRefund, + new BanLiShopOrderMQMsg(order.getId(), order.getUid())); try { orderTransactionProducer.send(message, new LocalTransactionExecuter() { @Override @@ -440,9 +442,9 @@ throw new BanLiShopOrderException(22, "鍟嗗搧宸蹭笅绾�"); } - if(redPackForbidService.verifyForbid(uid)) + if (redPackForbidService.verifyForbid(uid)) throw new BanLiShopOrderException(25, "绾㈠寘鍔熻兘宸茶灏佺"); - + if (pay.getHongBaoPrice() != null && pay.getHongBaoPrice().compareTo(new BigDecimal(0)) > 0) { BigDecimal money = redPackBalanceService.getBalance(uid); if (money.compareTo(pay.getHongBaoPrice()) < 0) { -- Gitblit v1.8.0