| | |
| | | import com.icbc.api.utils.IcbcSignature; |
| | | import com.icbc.api.utils.WebUtils; |
| | | import com.ruoyi.system.config.ICBCConfig; |
| | | import com.ruoyi.system.enums.BigGiftPackageOrderStatusEnum; |
| | | import com.ruoyi.system.enums.PhysicalGoodsOrderStatusEnum; |
| | | import com.ruoyi.system.model.TBigGiftPackageOrder; |
| | | import com.ruoyi.system.model.TPhysicalGoodsOrder; |
| | | import com.ruoyi.system.service.*; |
| | |
| | | String payOrderCode = bizContent.getString("out_trade_no"); |
| | | String returnCode = bizContent.getString("return_code"); |
| | | msgId = bizContent.getString("msg_id"); |
| | | |
| | | String orderId = bizContent.getString("order_id"); |
| | | // 验签 |
| | | if (validateSignature(request, icbcConfig.getNotifyUrlMethod() + "/big-gift/pay-notify")) { |
| | | signResult = true; |
| | |
| | | |
| | | // 处理每个订单 |
| | | for (TBigGiftPackageOrder order : orders) { |
| | | processBigGiftPayment(order); |
| | | processBigGiftPayment(order, orderId); |
| | | } |
| | | } else { |
| | | log.error("支付订单号{}【工商银行】大礼包支付失败,错误信息:{}", payOrderCode, bizContent.getString("return_msg")); |
| | | //更新订单状态为已取消 |
| | | orders.forEach(item->item.setStatus(6)); |
| | | orders.forEach(item->item.setStatus(BigGiftPackageOrderStatusEnum.CANCELED.getCode())); |
| | | bigGiftPackageOrderService.updateBatchById(orders); |
| | | } |
| | | } else { |
| | |
| | | } |
| | | |
| | | // 更新订单状态为"完成支付" |
| | | order.setStatus(3); |
| | | order.setStatus(BigGiftPackageOrderStatusEnum.PAID.getCode()); |
| | | order.setFinalPaymentTime(LocalDateTime.now()); |
| | | order.setFinalPaymentSerialNumber(finalPayOrderCode); |
| | | order.setFinalPaymentThirdSerialNumber(orderId); |
| | | order.setPaymentPrice(order.getPaymentPrice().add(order.getFinalPayment())); |
| | | bigGiftPackageOrderService.updateById(order); |
| | | log.info("订单{}状态更新为完成支付", order.getCode()); |
| | | |
| | |
| | | } |
| | | |
| | | // 更新订单状态为"完成支付" |
| | | order.setStatus(2); |
| | | order.setStatus(PhysicalGoodsOrderStatusEnum.PAID.getCode()); |
| | | order.setPaymentTime(LocalDateTime.now()); |
| | | order.setPaymentSerialNumber(orderId); |
| | | physicalGoodsOrderService.updateById(order); |
| | |
| | | |
| | | } else { |
| | | log.error("订单{}【工商银行】实物商品支付失败,错误信息:{}", orderCode, bizContent.getString("return_msg")); |
| | | order.setStatus(5); |
| | | order.setStatus(PhysicalGoodsOrderStatusEnum.CANCELED.getCode()); |
| | | physicalGoodsOrderService.updateById(order); |
| | | } |
| | | } else { |
| | |
| | | /** |
| | | * 处理大礼包支付(定金或全款) |
| | | */ |
| | | private void processBigGiftPayment(TBigGiftPackageOrder order) { |
| | | private void processBigGiftPayment(TBigGiftPackageOrder order, String orderId) { |
| | | Integer paymentType = order.getPaymentType(); |
| | | |
| | | if (paymentType == 1) { |
| | | // 订金+尾款模式,更新状态为"已付订金" |
| | | order.setStatus(2); |
| | | order.setStatus(BigGiftPackageOrderStatusEnum.DEPOSIT_PAID.getCode()); |
| | | order.setDepositTime(LocalDateTime.now()); |
| | | order.setDepositPaymentSerialNumber(order.getPayOrderCode()); |
| | | order.setDepositPaymentThirdSerialNumber(orderId); |
| | | bigGiftPackageOrderService.updateById(order); |
| | | log.info("订单{}状态更新为已付订金,不计算分佣", order.getCode()); |
| | | } else if (paymentType == 2) { |
| | | // 全款模式,更新状态为"完成支付" |
| | | order.setStatus(3); |
| | | order.setStatus(BigGiftPackageOrderStatusEnum.PAID.getCode()); |
| | | order.setDepositTime(LocalDateTime.now()); |
| | | order.setDepositPaymentSerialNumber(order.getPayOrderCode()); |
| | | order.setDepositPaymentThirdSerialNumber(orderId); |
| | | bigGiftPackageOrderService.updateById(order); |
| | | log.info("订单{}状态更新为完成支付", order.getCode()); |
| | | |