jiangping
2023-12-20 1f257db0a97b5beb71e8ff3c14fda603bf2b4004
server/services/src/main/java/com/doumee/core/wx/WxMiniUtilService.java
@@ -16,6 +16,7 @@
import com.doumee.dao.system.model.SystemDictData;
import com.wechat.pay.java.service.refund.model.AmountReq;
import com.wechat.pay.java.service.refund.model.CreateRequest;
import com.wechat.pay.java.service.refund.model.QueryByOutRefundNoRequest;
import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import okhttp3.Request;
@@ -82,7 +83,9 @@
        amountReq.setCurrency("CNY");
        request.setAmount(amountReq);
        try {
            log.error("=============="+JSONObject.toJSONString(request));
            com.wechat.pay.java.service.refund.model.Refund response = WxMiniConfig.refundService.create(request);
            log.error("=============="+JSONObject.toJSONString(response));
            if ("SUCCESS".equals(response.getStatus().name())
                    || "PROCESSING".equals(response.getStatus().name()) ) {
                return  true;
@@ -94,6 +97,27 @@
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,退款申请失败!");
        }
    }
    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
    public com.wechat.pay.java.service.refund.model.Refund isSuucessRefund(String outTradeNo) {
        // 发送退款请求
        QueryByOutRefundNoRequest request = new QueryByOutRefundNoRequest();
        request.setOutRefundNo(outTradeNo);
        request.setSubMchid(WxMiniConfig.wxProperties.getSubMchId());
        try {
            log.error("=============="+JSONObject.toJSONString(request));
            com.wechat.pay.java.service.refund.model.Refund response = WxMiniConfig.refundService.queryByOutRefundNo(request);
            log.error("=============="+JSONObject.toJSONString(response));
            if ("SUCCESS".equals(response.getStatus().name())
                    || "PROCESSING".equals(response.getStatus().name()) ) {
                return  response;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return  null;
    }
    public Refund wxRefundOld(RefundDTO refundDTO) {
        // 发送退款请求
@@ -194,6 +218,7 @@
        body.put("scene", locks.getSiteId() + "/" +locks.getCode() );
        // 正式版为 "release",体验版为 "trial",开发版为 "develop"。默认是正式版。
        body.put("env_version", "release");
        body.put("env_version", "trial");
        // 透明,根据你的场景自行设置body参数
        body.put("is_hyaline", false);
        body.put("check_path", false);