| | |
| | | import com.ruoyi.common.core.enums.OrderStatusEnum; |
| | | import com.ruoyi.common.core.enums.PaymentMethodEnum; |
| | | import com.ruoyi.common.core.enums.PointStatusEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.order.domain.Paylog; |
| | | import com.ruoyi.order.mapper.OrderAuctionBondMapper; |
| | |
| | | import com.ruoyi.order.util.tencent.common.XMLParser; |
| | | import com.ruoyi.order.util.tencent.protocol.AppPayReqData; |
| | | import com.ruoyi.order.util.tencent.protocol.UnifiedorderReqData; |
| | | import com.ruoyi.system.api.domain.GoodsSku; |
| | | import com.ruoyi.system.api.domain.Order; |
| | | import com.ruoyi.system.api.domain.OrderAuctionBond; |
| | | import com.ruoyi.system.api.domain.*; |
| | | import com.ruoyi.system.api.domain.dto.BondDTO; |
| | | import com.ruoyi.system.api.domain.dto.MemberPointsDTO; |
| | | import com.ruoyi.system.api.domain.dto.RefundDTO; |
| | |
| | | private OrderAuctionBondMapper orderAuctionBondMapper; |
| | | |
| | | @Resource |
| | | private GoodsSkuClient GoodsSkuClient; |
| | | private GoodsSkuClient goodsSkuClient; |
| | | |
| | | @Resource |
| | | private PaylogMapper paylogMapper; |
| | | |
| | | @Override |
| | | public R<Map<String, Object>> getPayInfo(Integer uid, Integer type, String orderNO,String openId, HttpServletRequest request) { |
| | |
| | | String body; |
| | | try { |
| | | if(judgeContainsStr(orderNO)){ |
| | | |
| | | |
| | | if (orderNO.contains("BO")) { |
| | | LambdaQueryWrapper<OrderAuctionBond> wrapper1= Wrappers.lambdaQuery(); |
| | | wrapper1.eq(OrderAuctionBond::getOrderNo,orderNO); |
| | |
| | | one1.setPaymentMethod(PaymentMethodEnum.WECHAT); |
| | | orderAuctionBondMapper.updateById(one1); |
| | | |
| | | if (one1.getBond().compareTo(new BigDecimal(0))==0){ |
| | | one1.setBoundStatus(BondStatusEnum.PAID); |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | returnMap.put("Type",1); |
| | | return R.ok(returnMap); |
| | | } |
| | | |
| | | |
| | | }else{ |
| | | LambdaQueryWrapper<Order> wrapper1= Wrappers.lambdaQuery(); |
| | | wrapper1.eq(Order::getOrderNo,orderNO); |
| | |
| | | page1.setOrderStatus(OrderStatusEnum.TO_BE_SHIPPED); |
| | | page1.setPaymentMethod(PaymentMethodEnum.WECHAT); |
| | | page1.setPayTime(LocalDateTime.now()); |
| | | OrderMapper.updateById(page1); |
| | | |
| | | |
| | | if(page1.getOrderNo().contains("SP")){ |
| | | GoodsSku goodsSku =new GoodsSku(); |
| | | goodsSku.setId(page1.getGoodsSkuId()); |
| | | goodsSku.setSoldQuantity(page1.getGoodsQuantity()); |
| | | GoodsSkuClient.updGoods(goodsSku, SecurityConstants.INNER); |
| | | goodsSkuClient.updGoods(goodsSku, SecurityConstants.INNER); |
| | | } |
| | | |
| | | if(page1.getOrderNo().contains("MS")){ |
| | | GoodsSku goodsSku =new GoodsSku(); |
| | | goodsSku.setId(page1.getGoodsSkuId()); |
| | | goodsSku.setSoldQuantity(page1.getGoodsQuantity()); |
| | | GoodsSkuClient.updGoodsSeckill1(goodsSku, SecurityConstants.INNER); |
| | | goodsSkuClient.updGoodsSeckill1(goodsSku, SecurityConstants.INNER); |
| | | } |
| | | |
| | | MemberPointsDTO memberPointsDTO=new MemberPointsDTO(); |
| | | memberPointsDTO.setMemberId(page1.getMemberId()); |
| | | memberPointsDTO.setPointsType(1); |
| | | memberPointsDTO.setPointsStatus(PointStatusEnum.INCREASE); |
| | | memberPointsDTO.setPoints(page1.getPoints()); |
| | | memberClient.addMemberPoints(memberPointsDTO); |
| | | |
| | | if(page1.getOrderNo().contains("TG")){ |
| | | GoodsGroupPurchase goodsSeckiGoodsGroupPurchaseOne = goodsSkuClient.getGoodsSeckiGoodsGroupPurchaseOne(page1.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | GoodsGroupPurchaseInfo goodsSeckiGoodsGroupPurchaseInfo = goodsSkuClient.getGoodsSeckiGoodsGroupPurchaseInfo(page1.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | if (goodsSeckiGoodsGroupPurchaseInfo!=null){ |
| | | goodsSkuClient.updgoodsGroupPurchaseInfo(goodsSeckiGoodsGroupPurchaseInfo, SecurityConstants.INNER); |
| | | page1.setGroupNo(goodsSeckiGoodsGroupPurchaseInfo.getMubre()); |
| | | }else{ |
| | | UUID uuid = UUID.randomUUID(); |
| | | GoodsGroupPurchaseInfo goodsGroupPurchaseInfo=new GoodsGroupPurchaseInfo(); |
| | | goodsGroupPurchaseInfo.setGroupSize(goodsSeckiGoodsGroupPurchaseOne.getGroupSize()); |
| | | goodsGroupPurchaseInfo.setCurrentNumber(1); |
| | | goodsGroupPurchaseInfo.setMubre(uuid.toString()); |
| | | goodsGroupPurchaseInfo.setGroupPurchaseId(page1.getGoodsSkuId()); |
| | | goodsGroupPurchaseInfo.setGroupStatus(0); |
| | | goodsSkuClient.updgoodsGroupPurchaseInfo(goodsGroupPurchaseInfo, SecurityConstants.INNER); |
| | | page1.setGroupNo(uuid.toString()); |
| | | } |
| | | } |
| | | OrderMapper.updateById(page1); |
| | | |
| | | if (page1.getPoints()!=0){ |
| | | MemberPointsDTO memberPointsDTO=new MemberPointsDTO(); |
| | | memberPointsDTO.setMemberId(page1.getMemberId()); |
| | | memberPointsDTO.setPointsType(1); |
| | | memberPointsDTO.setPointsStatus(PointStatusEnum.INCREASE); |
| | | memberPointsDTO.setPoints(page1.getPoints()); |
| | | memberClient.addMemberPoints(memberPointsDTO); |
| | | } |
| | | |
| | | updMembeOneDTO MembeOneDTO=new updMembeOneDTO(); |
| | | MembeOneDTO.setType(1); |
| | | MembeOneDTO.setMemberId(page1.getMemberId()); |
| | |
| | | GoodsSku goodsSku =new GoodsSku(); |
| | | goodsSku.setId(page1.getGoodsSkuId()); |
| | | goodsSku.setSoldQuantity(page1.getGoodsQuantity()); |
| | | GoodsSkuClient.updGoods(goodsSku, SecurityConstants.INNER); |
| | | goodsSkuClient.updGoods(goodsSku, SecurityConstants.INNER); |
| | | } |
| | | |
| | | if(page1.getOrderNo().contains("MS")){ |
| | | GoodsSku goodsSku =new GoodsSku(); |
| | | goodsSku.setId(page1.getGoodsSkuId()); |
| | | goodsSku.setSoldQuantity(page1.getGoodsQuantity()); |
| | | GoodsSkuClient.updGoodsSeckill1(goodsSku, SecurityConstants.INNER); |
| | | goodsSkuClient.updGoodsSeckill1(goodsSku, SecurityConstants.INNER); |
| | | } |
| | | |
| | | |
| | |
| | | return this.alipay(orderNO, subject, body, price, request); |
| | | } if (type == 2){ |
| | | // 微信预下单 |
| | | return this.wxpay(2, orderNO, body, openId, price, request); |
| | | return this.wxpay(2 ,orderNO, body, openId, price, request); |
| | | } |
| | | }else{ |
| | | LambdaQueryWrapper<Order> wrapper1= Wrappers.lambdaQuery(); |
| | |
| | | return this.alipay(orderNO, subject, body, price, request); |
| | | } if (type == 2) { |
| | | // 微信预下单 |
| | | return this.wxpay(2,page1.getOrderTimeSx(), orderNO, body,openId, price, request); |
| | | return this.wxpay(2, orderNO, body,openId, price, request); |
| | | } |
| | | } |
| | | |
| | |
| | | wrapper1.eq(OrderAuctionBond::getOrderNo,paylog1.getOutTradeNo()); |
| | | wrapper1.eq(OrderAuctionBond::getDelFlag,0); |
| | | OrderAuctionBond one1 = orderAuctionBondMapper.selectOne(wrapper1); |
| | | |
| | | if (one1.getOrderTimeSx().isAfter(LocalDateTime.now())){ |
| | | boolean bo = refundForAlipay(paylog1.getOutTradeNo(), paylog1.getTradeNo(), paylog1.getPayMoney()); |
| | | } |
| | | |
| | | |
| | | one1.setBoundStatus(BondStatusEnum.PAID); |
| | | orderAuctionBondMapper.updateById(one1); |
| | | |
| | | |
| | | }else{ |
| | | LambdaQueryWrapper<Order> wrapper1= Wrappers.lambdaQuery(); |
| | | wrapper1.eq(Order::getOrderNo,paylog1.getOutTradeNo()); |
| | |
| | | GoodsSku goodsSku =new GoodsSku(); |
| | | goodsSku.setId(page1.getGoodsSkuId()); |
| | | goodsSku.setSoldQuantity(page1.getGoodsQuantity()); |
| | | GoodsSkuClient.updGoods(goodsSku, SecurityConstants.INNER); |
| | | goodsSkuClient.updGoods(goodsSku, SecurityConstants.INNER); |
| | | } |
| | | |
| | | if(page1.getOrderNo().contains("MS")){ |
| | | GoodsSku goodsSku =new GoodsSku(); |
| | | goodsSku.setId(page1.getGoodsSkuId()); |
| | | goodsSku.setSoldQuantity(page1.getGoodsQuantity()); |
| | | GoodsSkuClient.updGoodsSeckill1(goodsSku, SecurityConstants.INNER); |
| | | goodsSkuClient.updGoodsSeckill1(goodsSku, SecurityConstants.INNER); |
| | | } |
| | | |
| | | if(page1.getOrderNo().contains("TG")){ |
| | | GoodsGroupPurchase goodsSeckiGoodsGroupPurchaseOne = goodsSkuClient.getGoodsSeckiGoodsGroupPurchaseOne(page1.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | GoodsGroupPurchaseInfo goodsSeckiGoodsGroupPurchaseInfo = goodsSkuClient.getGoodsSeckiGoodsGroupPurchaseInfo(page1.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | if (goodsSeckiGoodsGroupPurchaseInfo!=null){ |
| | | goodsSkuClient.updgoodsGroupPurchaseInfo(goodsSeckiGoodsGroupPurchaseInfo, SecurityConstants.INNER); |
| | | page1.setGroupNo(goodsSeckiGoodsGroupPurchaseInfo.getMubre()); |
| | | }else{ |
| | | UUID uuid = UUID.randomUUID(); |
| | | GoodsGroupPurchaseInfo goodsGroupPurchaseInfo=new GoodsGroupPurchaseInfo(); |
| | | goodsGroupPurchaseInfo.setGroupSize(goodsSeckiGoodsGroupPurchaseOne.getGroupSize()); |
| | | goodsGroupPurchaseInfo.setCurrentNumber(1); |
| | | goodsGroupPurchaseInfo.setMubre(uuid.toString()); |
| | | goodsGroupPurchaseInfo.setGroupPurchaseId(page1.getGoodsSkuId()); |
| | | goodsGroupPurchaseInfo.setGroupStatus(0); |
| | | goodsSkuClient.updgoodsGroupPurchaseInfo(goodsGroupPurchaseInfo, SecurityConstants.INNER); |
| | | page1.setGroupNo(uuid.toString()); |
| | | } |
| | | } |
| | | |
| | | page1.setOrderStatus(OrderStatusEnum.TO_BE_SHIPPED); |
| | | page1.setPayTime(LocalDateTime.now()); |
| | | OrderMapper.updateById(page1); |
| | | |
| | | if (page1.getPoints()!=0){ |
| | | MemberPointsDTO memberPointsDTO=new MemberPointsDTO(); |
| | | memberPointsDTO.setMemberId(page1.getMemberId()); |
| | | memberPointsDTO.setPointsType(1); |
| | | memberPointsDTO.setPointsStatus(PointStatusEnum.INCREASE); |
| | | memberPointsDTO.setPoints(page1.getPoints()); |
| | | memberClient.addMemberPoints(memberPointsDTO); |
| | | } |
| | | updMembeOneDTO MembeOneDTO=new updMembeOneDTO(); |
| | | MembeOneDTO.setType(1); |
| | | MembeOneDTO.setMemberId(page1.getMemberId()); |
| | |
| | | wrapper1.eq(OrderAuctionBond::getOrderNo,paylog.getOutTradeNo()); |
| | | wrapper1.eq(OrderAuctionBond::getDelFlag,0); |
| | | OrderAuctionBond one1 = orderAuctionBondMapper.selectOne(wrapper1); |
| | | if (one1.getOrderTimeSx().isAfter(LocalDateTime.now())){ |
| | | String refundMoney = SinataUtil.doubleRetainTwo(paylog.getPayMoney() * 100d); |
| | | Integer refundFee = Integer.parseInt(refundMoney.substring(0, refundMoney.length() - 3)); |
| | | String money = SinataUtil.doubleRetainTwo(paylog.getPayMoney() * 100d); |
| | | Integer totalFee = Integer.parseInt(money.substring(0, money.length() - 3)); |
| | | refundFee = Integer.parseInt(money.substring(0, money.length() - 3)); |
| | | |
| | | String regEx = "[^0-9]"; |
| | | Pattern p = Pattern.compile(regEx); |
| | | Matcher m = p.matcher(paylog.getOutTradeNo()); |
| | | String ma = m.replaceAll("").trim(); |
| | | refundForWxpay(4, paylog.getTradeNo(), paylog.getOutTradeNo(), "R" + ma, totalFee, refundFee, "2"); |
| | | } |
| | | |
| | | one1.setBoundStatus(BondStatusEnum.PAID); |
| | | one1.setPaymentMethod(PaymentMethodEnum.WECHAT); |
| | | orderAuctionBondMapper.updateById(one1); |
| | |
| | | GoodsSku goodsSku =new GoodsSku(); |
| | | goodsSku.setId(page1.getGoodsSkuId()); |
| | | goodsSku.setSoldQuantity(page1.getGoodsQuantity()); |
| | | GoodsSkuClient.updGoods(goodsSku, SecurityConstants.INNER); |
| | | goodsSkuClient.updGoods(goodsSku, SecurityConstants.INNER); |
| | | } |
| | | |
| | | if(page1.getOrderNo().contains("MS")){ |
| | | GoodsSku goodsSku =new GoodsSku(); |
| | | goodsSku.setId(page1.getGoodsSkuId()); |
| | | goodsSku.setSoldQuantity(page1.getGoodsQuantity()); |
| | | GoodsSkuClient.updGoodsSeckill1(goodsSku, SecurityConstants.INNER); |
| | | goodsSkuClient.updGoodsSeckill1(goodsSku, SecurityConstants.INNER); |
| | | } |
| | | |
| | | if(page1.getOrderNo().contains("TG")){ |
| | | GoodsGroupPurchase goodsSeckiGoodsGroupPurchaseOne = goodsSkuClient.getGoodsSeckiGoodsGroupPurchaseOne(page1.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | GoodsGroupPurchaseInfo goodsSeckiGoodsGroupPurchaseInfo = goodsSkuClient.getGoodsSeckiGoodsGroupPurchaseInfo(page1.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | if (goodsSeckiGoodsGroupPurchaseInfo!=null){ |
| | | goodsSkuClient.updgoodsGroupPurchaseInfo(goodsSeckiGoodsGroupPurchaseInfo, SecurityConstants.INNER); |
| | | page1.setGroupNo(goodsSeckiGoodsGroupPurchaseInfo.getMubre()); |
| | | }else{ |
| | | UUID uuid = UUID.randomUUID(); |
| | | GoodsGroupPurchaseInfo goodsGroupPurchaseInfo=new GoodsGroupPurchaseInfo(); |
| | | goodsGroupPurchaseInfo.setGroupSize(goodsSeckiGoodsGroupPurchaseOne.getGroupSize()); |
| | | goodsGroupPurchaseInfo.setCurrentNumber(1); |
| | | goodsGroupPurchaseInfo.setMubre(uuid.toString()); |
| | | goodsGroupPurchaseInfo.setGroupStatus(0); |
| | | goodsSkuClient.updgoodsGroupPurchaseInfo(goodsGroupPurchaseInfo, SecurityConstants.INNER); |
| | | page1.setGroupNo(uuid.toString()); |
| | | } |
| | | } |
| | | if (page1.getPoints()!=0){ |
| | | MemberPointsDTO memberPointsDTO=new MemberPointsDTO(); |
| | | memberPointsDTO.setMemberId(page1.getMemberId()); |
| | | memberPointsDTO.setPointsType(1); |
| | | memberPointsDTO.setPointsStatus(PointStatusEnum.INCREASE); |
| | | memberPointsDTO.setPoints(page1.getPoints()); |
| | | memberClient.addMemberPoints(memberPointsDTO); |
| | | } |
| | | updMembeOneDTO MembeOneDTO=new updMembeOneDTO(); |
| | | MembeOneDTO.setType(1); |
| | | MembeOneDTO.setMemberId(page1.getMemberId()); |
| | |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static R<Map<String, Object>> wxpay(Integer apptype,LocalDateTime sx,String outTradeNo, String body,String openId, Double price, |
| | | public static R<Map<String, Object>> wxpay(Integer apptype,String outTradeNo, String body,String openId, Double price, |
| | | HttpServletRequest request) { |
| | | // 获取预支付接口返回参数 |
| | | Map<String, Object> map1 = new HashMap<String, Object>(); |
| | |
| | | paraMap.put("body", body); |
| | | //设置请求参数(商户订单号) |
| | | paraMap.put("out_trade_no", outTradeNo); |
| | | if (sx!=null){ |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); |
| | | paraMap.put("time_expire",sx.format(formatter)); |
| | | } |
| | | //设置请求参数(总金额) |
| | | |
| | | String money=SinataUtil.doubleRetainTwo(price*100d); |
| | |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public void refund1(RefundDTO refundDTOS) { |
| | | |
| | | LambdaQueryWrapper<Paylog> paylogEntityWrapper = Wrappers.lambdaQuery(); |
| | | paylogEntityWrapper.eq(Paylog::getOutTradeNo, refundDTOS.getOrderNo()); |
| | | Paylog paylog = paylogMapper.selectOne(paylogEntityWrapper); |
| | | |
| | | |
| | | if (paylog.getPayType() ==1) {//支付宝 |
| | | //获取支付信息 |
| | | |
| | | if (paylog != null) { |
| | | boolean bo = this.refundForAlipay(paylog.getOutTradeNo(), paylog.getTradeNo(), paylog.getPayMoney()); |
| | | if (!bo) { |
| | | System.out.println("支付宝退款失败"); |
| | | } |
| | | } |
| | | |
| | | } else if (paylog.getPayType() ==2) {//微信 |
| | | //获取支付信息 |
| | | if (paylog != null) { |
| | | String refundMoney = SinataUtil.doubleRetainTwo(paylog.getPayMoney() * 100d); |
| | | Integer refundFee = Integer.parseInt(refundMoney.substring(0, refundMoney.length() - 3)); |
| | | String money = SinataUtil.doubleRetainTwo(paylog.getPayMoney() * 100d); |
| | | Integer totalFee = Integer.parseInt(money.substring(0, money.length() - 3)); |
| | | refundFee = Integer.parseInt(money.substring(0, money.length() - 3)); |
| | | |
| | | String regEx = "[^0-9]"; |
| | | Pattern p = Pattern.compile(regEx); |
| | | Matcher m = p.matcher(refundDTOS.getOrderNo()); |
| | | String ma = m.replaceAll("").trim(); |
| | | boolean bo = this.refundForWxpay(4, paylog.getTradeNo(), paylog.getOutTradeNo(), "R" + ma, totalFee, refundFee, "2"); |
| | | if (!bo) { |
| | | System.out.println("微信退款失败"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | private Boolean handleRefund(Paylog paylog, BigDecimal amount, |
| | | String orderNo) { |
| | | boolean res = false; |