MrShi
9 天以前 e0a7b836464d6fcc037d46f845b8faf39cb5b13e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.doumee.config.wx;
 
import com.alibaba.fastjson.JSONObject;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.Constants;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.HttpsUtil;
import com.doumee.dao.business.WithdrawalOrdersMapper;
import com.doumee.dao.business.model.Orders;
import com.doumee.dao.business.model.WithdrawalOrders;
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 org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
 
/**
 * 微信小程序-公共方法
 */
@Service
@Slf4j
public class WxMiniUtilService {
 
    @Autowired
    private WithdrawalOrdersMapper withdrawalOrdersMapper;
 
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
 
    @Autowired
    private WxPayProperties wxPayProperties;
 
    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
    public boolean wxRefund(WithdrawalOrders withdrawalOrders,Orders orders) {
//        // 发送退款请求
//        withdrawalOrders.setCreateTime(new Date());
//        withdrawalOrdersMapper.insert(withdrawalOrders);
//        CreateRequest request = new CreateRequest();
//        request.setOutTradeNo(orders.getOutTradeNo());
//        request.setOutRefundNo(withdrawalOrders.getId().toString());
//        request.setSubMchid(WxMiniConfig.wxProperties.getSubMchId());
//        request.setNotifyUrl(WxMiniConfig.wxProperties.getRefundNotifyUrl());
//        AmountReq amountReq = new AmountReq();
//        amountReq.setTotal(1L);//withdrawalOrders.getAmount());
//        amountReq.setRefund(1L);//withdrawalOrders.getAmount());
//        amountReq.setCurrency("CNY");
//        request.setAmount(amountReq);
//        try {
//            log.error("=============="+JSONObject.toJSONString(request));
//            com.wechat.pay.java.service.refund.model.Refund response = WxMiniConfig.wxPayService.refund(request);
//            log.error("=============="+JSONObject.toJSONString(response));
//            if ("SUCCESS".equals(response.getStatus().name())
//                    || "PROCESSING".equals(response.getStatus().name()) ) {
//                return  true;
//            }else{
//                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,退款申请失败哦!");
//            }
//        }catch (Exception e){
//            e.printStackTrace();
//            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,退款申请失败!");
//        }
        return false;
    }
 
 
 
}