111
k94314517
2023-11-08 7f2749f8bb57290104636f50de4824ad1f13cdd5
server/services/src/main/java/com/doumee/core/wx/WxMiniUtilService.java
@@ -38,7 +38,7 @@
    private TransactionsMapper transactionsMapper;
    @Transactional(rollbackFor = Exception.class)
    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
    public Refund wxRefund(RefundDTO refundDTO) {
        try {
            // 发送退款请求
@@ -46,10 +46,10 @@
            WxPayRefundRequest request = new WxPayRefundRequest();
            request.setOutTradeNo(refundDTO.getOrderId());
            request.setOutRefundNo(refNum);
            request.setTotalFee(BaseWxPayRequest.yuanToFen(refundDTO.getTotalAmount().toString()));
            request.setRefundFee(BaseWxPayRequest.yuanToFen(refundDTO.getRefundAmount().toString()));
            System.out.println("实际总金额" + BaseWxPayRequest.yuanToFen(refundDTO.getTotalAmount().toString()));
            System.out.println("实际退款金额" + BaseWxPayRequest.yuanToFen(refundDTO.getRefundAmount().toString()));
            request.setTotalFee(refundDTO.getTotalAmount().intValue());
            request.setRefundFee(refundDTO.getRefundAmount().intValue());
            System.out.println("实际总金额" + refundDTO.getTotalAmount());
            System.out.println("实际退款金额" + refundDTO.getRefundAmount());
//            request.setTotalFee(1);
//            request.setRefundFee(1);
            WxPayRefundResult response = WxMiniConfig.wxPayService.refund(request);
@@ -62,7 +62,9 @@
                refund.setMoney(refundDTO.getRefundAmount());
                refund.setOnlineOrderid(refNum);
                refund.setPayWay(Constants.ZERO);
                refund.setStatus(Constants.TWO);
                refund.setDoneDate(new Date());
                refund.setCreator(refundDTO.getCreator());
                refund.setType(refundDTO.getType());
                refund.setObjId(refundDTO.getOrderId());
                refund.setReason(refundDTO.getReason());
@@ -76,12 +78,25 @@
                transactions.setIsdeleted(Constants.ZERO);
                transactions.setOrderId(refundDTO.getOrderId());
                transactions.setMoney(refundDTO.getRefundAmount());
                transactions.setType(refundDTO.getType()==Constants.TRANSACTIONS_TYPE.REFUND.getKey()?Constants.TRANSACTIONS_TYPE.PLATFORMREFUND.getKey():Constants.REFUND_TYPE.BACK.getKey());
                transactions.setPreOrderid(refundDTO.getOrderId());
                transactions.setOnlineOrderid(refNum);
                transactions.setDoneDate(new Date());
                transactions.setTitle(Constants.TRANSACTIONS_TYPE.get(transactions.getType()).getName());
                transactions.setContent(Constants.TRANSACTIONS_TYPE.get(transactions.getType()).getInfo());
                if(refund.getType().equals(Constants.REFUND_TYPE.PLAT_AUTO.getKey())||refund.getType().equals(Constants.REFUND_TYPE.PLAT_FORCE.getKey())){
                    //平台自动退款 或 强制退款
                    transactions.setType(Constants.TRANSACTIONS_TYPE.REFUND.getKey());
                    transactions.setTitle(Constants.REFUND_TYPE.PLAT_AUTO.getInfo());
                    transactions.setContent(Constants.REFUND_TYPE.PLAT_AUTO.getInfo());
                }else if(refund.getType().equals(Constants.REFUND_TYPE.NORMAL.getKey())){
                    //用户主动退款
                    transactions.setType(Constants.TRANSACTIONS_TYPE.REFUND.getKey());
                    transactions.setTitle(Constants.REFUND_TYPE.NORMAL.getInfo());
                    transactions.setContent(Constants.REFUND_TYPE.NORMAL.getInfo());
                }else if(refund.getType().equals(Constants.REFUND_TYPE.BACK.getKey())){
                    //结算后退款
                    transactions.setType(Constants.TRANSACTIONS_TYPE.REFUND.getKey());
                    transactions.setTitle(Constants.REFUND_TYPE.BACK.getInfo());
                    transactions.setContent(Constants.REFUND_TYPE.BACK.getInfo());
                }
                transactions.setBalance(BigDecimal.ZERO);
                transactions.setObjId(refund.getId());
                transactions.setObjType(Constants.ONE);