| | |
| | | import com.yeshi.fanli.dao.mybatis.shop.BanLiShopOrderMapper;
|
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.order.body.BanLiShopOrderMQMsg;
|
| | | import com.yeshi.fanli.dto.msg.MsgRedPackUseContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
|
| | | import com.yeshi.fanli.entity.mq.MQUnSendInfo;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoods;
|
| | |
| | | import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackDetailException;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopOrderException;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.mq.MQUnSendInfoService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsClassService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetPayService;
|
| | |
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.factory.RedPackDetailFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | | import com.yeshi.fanli.util.shop.BanLiShopOrderUtil;
|
| | | import com.yeshi.fanli.util.wx.BanLiShopWXPayUtil;
|
| | |
| | | @Resource(name = "transactionManager")
|
| | | private DataSourceTransactionManager transactionManager;
|
| | |
|
| | | @Transactional
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | | |
| | | @Resource
|
| | | private RedPackForbidService redPackForbidService;
|
| | | |
| | |
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | @Override
|
| | | public void addOrder(BanLiShopOrder order) throws BanLiShopOrderException {
|
| | | // 查询必要的参数是否添加
|
| | |
| | |
|
| | | private void sendPlaceOrderMsg(Long orderId, Long uid) {
|
| | |
|
| | | Message msg = new Message(MQTopicName.TOPIC_ORDER.name(), OrderTopicTagEnum.banLiShopOrderDelay.name(),
|
| | | new Gson().toJson(new BanLiShopOrderMQMsg(orderId, uid)).getBytes());
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.banLiShopOrderDelay,
|
| | | new BanLiShopOrderMQMsg(orderId, uid));
|
| | | msg.setKey(orderId + "");
|
| | | long delayTime = System.currentTimeMillis() + (Constant.IS_TEST ? 1000 * 30L : 1000 * 60 * 10);// 10分钟后通知
|
| | | msg.setStartDeliverTime(delayTime);
|
| | |
| | | banLiShopOrderMapper.updateByPrimaryKeySelective(order);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | @Override
|
| | | public void payOrderByHongBao(Long orderId) throws BanLiShopOrderException, RedPackBalanceException {
|
| | | BanLiShopOrder order = banLiShopOrderMapper.selectByPrimaryKeyForUpdate(orderId);
|
| | |
| | | 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());
|
| | | Message message =MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER,
|
| | | OrderTopicTagEnum.banLiShopOrderPaid,msg);
|
| | | producer.send(message);
|
| | | return;
|
| | | }
|
| | |
| | | if (order.getState() != BanLiShopOrder.STATE_PAID)
|
| | | throw new BanLiShopOrderException(1, "订单未处于待审核状态");
|
| | |
|
| | | Message message = new Message(MQTopicName.TOPIC_ORDER.name(), OrderTopicTagEnum.banLiShopOrderRefund.name(),
|
| | | new Gson().toJson(new BanLiShopOrderMQMsg(order.getId(), order.getUid())).getBytes());
|
| | | Message message =MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.banLiShopOrderRefund,
|
| | | new BanLiShopOrderMQMsg(order.getId(), order.getUid()));
|
| | | try {
|
| | | orderTransactionProducer.send(message, new LocalTransactionExecuter() {
|
| | | @Override
|
| | |
| | | update.setUpdateTime(new Date());
|
| | | update.setRejectTime(new Date());
|
| | | banLiShopOrderMapper.updateByPrimaryKeySelective(update);
|
| | | // 消息发送
|
| | | MsgRedPackUseContentDTO dto = new MsgRedPackUseContentDTO();
|
| | | dto.setGoodsSetName(order.getOrderGoods().getSetName());
|
| | | dto.setHongBao(order.getHongBaoPayment());
|
| | | dto.setMoney(order.getMoneyPayment());
|
| | | dto.setReason(msg);
|
| | | dto.setTime(new Date());
|
| | | userMoneyMsgNotificationService.redPackMsg(order.getUid(), MsgTypeMoneyTypeEnum.redPackUseFail,
|
| | | new Gson().toJson(dto), null);
|
| | | transactionManager.commit(transactionStatus);
|
| | | } catch (Exception e) {
|
| | | transactionManager.rollback(transactionStatus);
|
| | |
| | | throw new BanLiShopOrderException(22, "商品已下线");
|
| | | }
|
| | |
|
| | | if(redPackForbidService.verifyForbid(uid))
|
| | | throw new BanLiShopOrderException(25, "红包功能已被封禁");
|
| | | |
| | | if (pay.getHongBaoPrice() != null && pay.getHongBaoPrice().compareTo(new BigDecimal(0)) > 0) {
|
| | | BigDecimal money = null;
|
| | | try {
|
| | | money = redPackBalanceService.getBalance(uid);
|
| | | } catch (RedPackBalanceException e) {
|
| | | throw new BanLiShopOrderException(25, "红包功能异常");
|
| | | }
|
| | | BigDecimal money = redPackBalanceService.getBalance(uid);
|
| | | if (money.compareTo(pay.getHongBaoPrice()) < 0) {
|
| | | throw new BanLiShopOrderException(24, "红包余额不足");
|
| | | }
|