From 26f41e1a5c34a3e36c9e73c237e3643e707924ce Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 18 一月 2020 11:36:51 +0800 Subject: [PATCH] 商城订单失效退还红包 --- fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderPayServiceImpl.java | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 50 insertions(+), 7 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderPayServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderPayServiceImpl.java index 16202d2..3aa632a 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderPayServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderPayServiceImpl.java @@ -73,10 +73,10 @@ @Resource private UserMoneyMsgNotificationService userMoneyMsgNotificationService; - + @Resource private ConfigService configService; - + @Resource private AdminUserService adminUserService; @@ -132,7 +132,7 @@ } } - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public void payOrderByMoney(Long orderId, BigDecimal money) throws BanLiShopOrderException { BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKeyForUpdate(orderId); @@ -176,7 +176,7 @@ */ private void paySuccess(BanLiShopOrder order) { ThreadUtil.run(new Runnable() { - + @Override public void run() { long[] targetUids = new long[] { 3L, 4L }; @@ -191,11 +191,10 @@ } } }); - - + } - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public void refund(Long orderId) throws BanLiShopOrderException { // 璁㈠崟閫�娆� @@ -392,4 +391,48 @@ } } + @Transactional(rollbackFor = Exception.class) + @Override + public void invalidOrderByOrderId(Long orderId, String stateDesc) throws BanLiShopOrderException { + + BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKeyForUpdate(orderId); + if (order == null) + return; + // 閫�娆� + if (order.getState() == BanLiShopOrder.STATE_NO_PAY) {// 鐘舵�佽繕鏄湭鏀粯 + // 閫�娆剧孩鍖� + if (order.getHongBaoPaymentState() != null + && order.getHongBaoPaymentState() == BanLiShopOrder.PAY_STATE_PAID) { + BanLiShopGoods goods = banLiShopGoodsService.selectByPrimaryKey(order.getGoods().getId()); + BanLiShopGoodsClass goodsClass = banLiShopGoodsClassService + .selectByPrimaryKey(goods.getGoodsClass().getId()); + BanLiShopGoodsSets set = banLiShopGoodsSetService.selectByPrimaryKey(order.getGoodsSet().getId()); + // 绾㈠寘閫�娆� + RedPackDetail detail = null; + try { + detail = RedPackDetailFactory.createShopOrderDrawBack(orderId, order.getUid(), goodsClass.getName(), + set.getName(), order.getHongBaoPayment()); + } catch (RedPackDetailException e) { + e.printStackTrace(); + } + + if (detail == null) + throw new BanLiShopOrderException(4, "绾㈠寘璇︽儏澶辫触"); + try { + redPackBalanceService.addRedPack(order.getUid(), order.getHongBaoPayment(), detail); + } catch (RedPackBalanceException e) { + throw new BanLiShopOrderException(5, "绾㈠寘閫�娆惧け璐�"); + } + + BanLiShopOrder update = new BanLiShopOrder(order.getId()); + update.setHongBaoPaymentState(BanLiShopOrder.PAY_STATE_REFUND); + update.setUpdateTime(new Date()); + banLiShopOrderService.udpateSelectiveByPrimaryKey(update); + } + + banLiShopOrderService.invalidOrderByOrderId(orderId, stateDesc); + } + + } + } -- Gitblit v1.8.0