From ca3e865a9e3c22fc24c7ca4b67ad8c25d3f2ef18 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 12 十一月 2019 11:01:31 +0800 Subject: [PATCH] 口令过期消息队列 --- fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderServiceImpl.java | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 53 insertions(+), 3 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 375866f..b3c27e0 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 @@ -10,6 +10,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.DefaultTransactionDefinition; +import org.yeshi.utils.exception.WXOrderException; import com.aliyun.openservices.ons.api.Message; import com.aliyun.openservices.ons.api.Producer; @@ -45,6 +46,7 @@ import com.yeshi.fanli.util.factory.RedPackDetailFactory; import com.yeshi.fanli.util.rocketmq.MQTopicName; import com.yeshi.fanli.util.shop.BanLiShopOrderUtil; +import com.yeshi.fanli.util.wx.BanLiShopWXPayUtil; @Service public class BanLiShopOrderServiceImpl implements BanLiShopOrderService { @@ -138,6 +140,10 @@ order.setOrderNo(orderNo); banLiShopOrderMapper.updateByPrimaryKeySelective(update); + // 澧炲姞閿�閲� + banLiShopGoodsSetService.addSalesCount(order.getGoodsSet().getId(), 1); + banLiShopGoodsService.addSalesCount(order.getGoods().getId(), 1); + // 璁㈠崟娣诲姞鎴愬姛 ,寤舵椂閫氱煡鍚庣画 sendPlaceOrderMsg(order.getId(), order.getUid()); } @@ -151,6 +157,7 @@ orderGoods.setSetName(set.getName()); orderGoods.setState(set.getState()); orderGoods.setZkPrice(set.getZkPrice()); + orderGoods.setPicture(goods.getSquarePicture()); banLiShopOrderGoodsMapper.insertSelective(orderGoods); return orderGoods; } @@ -183,12 +190,12 @@ @Override public List<BanLiShopOrder> listByUid(Long uid, int page, int pageSize) { - return banLiShopOrderMapper.listByUid(null, uid, (page - 1) * pageSize, pageSize); + return banLiShopOrderMapper.listByUidAndState(null, uid, (page - 1) * pageSize, pageSize); } @Override public long countByUid(Long uid) { - return banLiShopOrderMapper.countByUid(null, uid); + return banLiShopOrderMapper.countByUidAndState(null, uid); } @Override @@ -319,6 +326,28 @@ // 鍒ゆ柇鏄惁澶勪簬鏈粯娆� if (order.getState() == BanLiShopOrder.STATE_NO_PAY) { + /** + * 鏌ヨ鏄惁宸茬粡寰俊鏀粯 + */ + if (order.getMoneyPayment() != null) { + try { + boolean isS = BanLiShopWXPayUtil.isPaySuccess(order.getOrderNo()); + if (isS)// 鏀粯鎴愬姛锛岄噸鏂板彂閫佹敮浠樻垚鍔熸秷鎭� + { + BanLiShopOrderMQMsg msg = new BanLiShopOrderMQMsg(order.getId(), order.getUid()); + Message message = new Message(MQTopicName.TOPIC_ORDER.name(), + OrderTopicTagEnum.banLiShopOrderPaid.name(), new Gson().toJson(msg).getBytes()); + producer.send(message); + return; + } + + } catch (WXOrderException e) { + e.printStackTrace(); + } catch (Exception e) { + + } + } + BanLiShopOrder update = new BanLiShopOrder(); update.setId(id); update.setStateDesc(desc); @@ -364,6 +393,7 @@ update.setState(BanLiShopOrder.STATE_REJECT); update.setStateDesc(msg); update.setUpdateTime(new Date()); + update.setRejectTime(new Date()); banLiShopOrderMapper.updateByPrimaryKeySelective(update); transactionManager.commit(transactionStatus); } catch (Exception e) { @@ -390,7 +420,12 @@ } if (pay.getHongBaoPrice() != null && pay.getHongBaoPrice().compareTo(new BigDecimal(0)) > 0) { - BigDecimal money = redPackBalanceService.getBalance(uid); + BigDecimal money = null; + try { + money = redPackBalanceService.getBalance(uid); + } catch (RedPackBalanceException e) { + throw new BanLiShopOrderException(25, "绾㈠寘鍔熻兘寮傚父"); + } if (money.compareTo(pay.getHongBaoPrice()) < 0) { throw new BanLiShopOrderException(24, "绾㈠寘浣欓涓嶈冻"); } @@ -422,4 +457,19 @@ return order; } + @Override + public BanLiShopOrder selectByOrderNo(String orderNo) { + return banLiShopOrderMapper.selectByOrderNo(orderNo); + } + + @Override + public List<BanLiShopOrder> listByUidAndState(Long uid, List<Integer> stateList, int page, int pageSize) { + return banLiShopOrderMapper.listByUidAndState(stateList, uid, (page - 1) * pageSize, pageSize); + } + + @Override + public long countByUidAndState(Long uid, List<Integer> stateList) { + return banLiShopOrderMapper.countByUidAndState(stateList, uid); + } + } -- Gitblit v1.8.0