liujie
2025-11-25 b502ac4e96aca2ab29caa77187ab7673a853a797
Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/JiaYiXing2025
1个文件已添加
15个文件已修改
928 ■■■■■ 已修改文件
DriverJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/biz/DouGongBasicDataBiz.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/biz/DouGongBasicDataBiz.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/biz/DouGongRefundBiz.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/biz/DouGongWithdrawBiz.java 163 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/biz/FenZhangUtil.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/controller/DouGongNotifyController.java 146 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TCompanyWithdrawController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TPubWithdrawalController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderCrossCityController.java 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderLogisticsController.java 146 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderPrivateCarController.java 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/TOrderCrossCity.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/TOrderLogistics.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/biz/DouGongBasicDataBiz.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/biz/DouGongBasicDataBiz.java
@@ -1,6 +1,7 @@
package com.stylefeng.guns.modular.huifu.biz;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.huifu.bspay.sdk.opps.core.BasePay;
import com.huifu.bspay.sdk.opps.core.config.MerConfig;
@@ -174,6 +175,22 @@
            cardInfo.put("cert_validity_type", "1");
        }
        paramsInfo.put("card_info", cardInfo.toJSONString());
        // 结算卡信息
        JSONArray cashConfigArr = new JSONArray();
        JSONObject cashConfig = new JSONObject();
        /**
         * T1:下一工作日到银行账户;
         * D1:下一自然日到银行账户;
         * D0:当日到银行账户;默认D0;
         * DM:当日到账;到账资金不包括当天的交易资金;
         * 示例值:T1
         */
        cashConfig.put("cash_type", "D1");
        cashConfig.put("fix_amt", "0.00");
        cashConfig.put("weekday_fix_amt", "0.00");
        cashConfig.put("weekday_fee_rate", "0.00");
        cashConfigArr.add(cashConfig);
        paramsInfo.put("cash_config", cashConfigArr.toJSONString());
        log.info("用户业务入驻返回参数:{}", paramsInfo);
        // 3. 发起API调用
        Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/open", paramsInfo, null, false);;
@@ -228,6 +245,22 @@
            cardInfo.put("cert_validity_type", "1");
        }
        paramsInfo.put("card_info", cardInfo.toJSONString());
        // 结算卡信息
        JSONArray cashConfigArr = new JSONArray();
        JSONObject cashConfig = new JSONObject();
        /**
         * T1:下一工作日到银行账户;
         * D1:下一自然日到银行账户;
         * D0:当日到银行账户;默认D0;
         * DM:当日到账;到账资金不包括当天的交易资金;
         * 示例值:T1
         */
        cashConfig.put("cash_type", "D1");
        cashConfig.put("fix_amt", "0.00");
        cashConfig.put("weekday_fix_amt", "0.00");
        cashConfig.put("weekday_fee_rate", "0.00");
        cashConfigArr.add(cashConfig);
        paramsInfo.put("cash_config", cashConfigArr.toJSONString());
        log.info("用户业务入驻修改返回参数:{}", paramsInfo);
        // 3. 发起API调用
        Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/modify", paramsInfo, null, false);;
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/biz/DouGongBasicDataBiz.java
@@ -333,6 +333,22 @@
        cardInfo.put("area_id", enterpriseWithdrawal.getBankCardCityCode());
        cardInfo.put("branch_code", enterpriseWithdrawal.getBankBranchCode());
        paramsInfo.put("card_info", cardInfo.toJSONString());
        // 结算卡信息
        JSONArray cashConfigArr = new JSONArray();
        JSONObject cashConfig = new JSONObject();
        /**
         * T1:下一工作日到银行账户;
         * D1:下一自然日到银行账户;
         * D0:当日到银行账户;默认D0;
         * DM:当日到账;到账资金不包括当天的交易资金;
         * 示例值:T1
         */
        cashConfig.put("cash_type", "D1");
        cashConfig.put("fix_amt", "0.00");
        cashConfig.put("weekday_fix_amt", "0.00");
        cashConfig.put("weekday_fee_rate", "0.00");
        cashConfigArr.add(cashConfig);
        paramsInfo.put("cash_config", cashConfigArr.toJSONString());
        log.info("企业业务入驻返回参数:{}", paramsInfo);
        // 3. 发起API调用
        Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/open", paramsInfo, null, false);
@@ -375,6 +391,22 @@
        cardInfo.put("area_id", enterpriseWithdrawal.getBankCardCityCode());
        cardInfo.put("branch_code", enterpriseWithdrawal.getBankBranchCode());
        paramsInfo.put("card_info", cardInfo.toJSONString());
        // 结算卡信息
        JSONArray cashConfigArr = new JSONArray();
        JSONObject cashConfig = new JSONObject();
        /**
         * T1:下一工作日到银行账户;
         * D1:下一自然日到银行账户;
         * D0:当日到银行账户;默认D0;
         * DM:当日到账;到账资金不包括当天的交易资金;
         * 示例值:T1
         */
        cashConfig.put("cash_type", "D1");
        cashConfig.put("fix_amt", "0.00");
        cashConfig.put("weekday_fix_amt", "0.00");
        cashConfig.put("weekday_fee_rate", "0.00");
        cashConfigArr.add(cashConfig);
        paramsInfo.put("cash_config", cashConfigArr.toJSONString());
        log.info("企业业务入驻修改返回参数:{}", paramsInfo);
        // 3. 发起API调用
        Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/modify", paramsInfo, null, false);
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/biz/DouGongRefundBiz.java
New file
@@ -0,0 +1,86 @@
package com.stylefeng.guns.modular.huifu.biz;
import com.alibaba.fastjson.JSONObject;
import com.huifu.bspay.sdk.opps.core.BasePay;
import com.huifu.bspay.sdk.opps.core.config.MerConfig;
import com.huifu.bspay.sdk.opps.core.exception.BasePayException;
import com.huifu.bspay.sdk.opps.core.net.BasePayRequest;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;
import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * 斗拱提现业务
 * @author mitao
 * @date 2025/11/21
 */
@Slf4j
@Component
public class DouGongRefundBiz {
    @Autowired
    private HuiFuProperties huiFuProperties;
    @Value("${callbackPath}")
    private String callbackPath;
    /**
     * 交易退款接口
     *
     * @param reqSeqId 请求流水号,同一huifu_id下当天唯一
     * @param ordAmt 申请退款金额,单位元
     * @param orgReqDate 原交易请求日期,格式yyyyMMdd
     * @param orgReqSeqId 原交易请求流水号(三选一)
     * @param type 类型 1:小件物流;2:跨城出行
     * @return 请求结果
     */
    public Map<String, Object> refund(String reqSeqId, BigDecimal ordAmt, String orgReqDate, String orgReqSeqId, Integer type) throws Exception {
        log.info("开始调用斗拱退款接口, 退款金额: {}",  ordAmt);
        // 1. 数据初始化,填入对应的商户配置
        MerConfig merConfig = new MerConfig();
        merConfig.setProcutId(huiFuProperties.getProductId());
        merConfig.setSysId(huiFuProperties.getSysId());
        merConfig.setRsaPrivateKey(huiFuProperties.getRsaPrivateKey());
        merConfig.setRsaPublicKey(huiFuProperties.getRsaPublicKey());
        BasePay.initWithMerConfig(merConfig);
        // 构建业务参数data
        // 2.组装请求参数
        Map<String, Object> data = new HashMap<>();
        data.put("req_date", DateUtil.format(new Date(),"yyyyMMdd"));
        data.put("req_seq_id", reqSeqId);
        data.put("huifu_id", huiFuProperties.getSysId());
        data.put("ord_amt", ordAmt.setScale(2, RoundingMode.HALF_UP).toString());
        data.put("org_req_date", orgReqDate);
        // 三选一参数:org_hf_seq_id,org_party_order_id,org_req_seq_id
        data.put("org_req_seq_id", orgReqSeqId);
        String notifyUrl = type.equals(1) ? "/base/dougong/refund-logistics" : "/base/dougong/refund-crosscity";
        data.put("notify_url", callbackPath + notifyUrl);
        // 发送HTTP请求 - POST JSON格式
        Map<String, Object> response = BasePayRequest.requestBasePay("v4/trade/payment/scanpay/refund", data, null, false);
        log.info("斗拱退款接口响应内容: {}", JSONObject.toJSONString(response));
        return response;
    }
}
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/biz/DouGongWithdrawBiz.java
@@ -1,6 +1,10 @@
package com.stylefeng.guns.modular.huifu.biz;
import com.alibaba.fastjson.JSONObject;
import com.huifu.bspay.sdk.opps.core.BasePay;
import com.huifu.bspay.sdk.opps.core.config.MerConfig;
import com.huifu.bspay.sdk.opps.core.exception.BasePayException;
import com.huifu.bspay.sdk.opps.core.net.BasePayRequest;
import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -14,6 +18,7 @@
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.Signature;
@@ -21,6 +26,9 @@
import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
 * 斗拱提现业务
@@ -32,32 +40,10 @@
public class DouGongWithdrawBiz {
    @Autowired
    private HuiFuProperties huiFuProperties;
    @Autowired
    private RestTemplate restTemplate;
    @Value("${callbackPath}")
    private static String callbackPath;
    private String callbackPath;
    private static final String ENCASHMENT_URL = "https://api.huifu.com/v2/trade/settlement/encashment";
    /**
     * 请求参数
     * req_date    请求日期    String    8    Y    格式yyyyMMdd;示例值:20210917
     * req_seq_id    请求流水号    String    128    Y    示例值:2021091708126665001
     * cash_amt    取现金额    String    14    Y    单位元,需保留小数点后两位,示例值:1.00
     * huifu_id    取现方ID号    String    32    Y    提现发起方的汇付ID。支持已配置取现规则的商户、用户。
     * 示例值:6666000109812123
     * acct_id    账户号    String    32    N    可指定账户号,仅支持基本户、现金户,不填默认为基本户;
     * 示例值:F00598600
     * into_acct_date_type    到账日期类型    String    3    Y    D0:当日到账;当日交易资金当天可取现到账;
     * T1:次工作日到账;
     * D1:次自然日到账;
     * DM:当日到账;到账资金不包括当天的交易资金;
     * 示例值:D0
     * token_no    取现卡序列号    String    20    Y    绑定取现卡后可获取取现卡序列号;示例值:10004053462
     * enchashment_channel    取现渠道    String    2    N    00:汇付(为空默认); 10:中信e账通;示例值:00
     * remark    备注    String    100    N    示例值:备注
     * notify_url    异步通知地址    String    128    N    示例值:http://service.example.com/to/path
     */
    /**
     * 主动取现接口
     *
@@ -67,104 +53,39 @@
     * @param type 提现类型 1:企业 2:用户/司机
     * @return 请求结果
     */
    public JSONObject encashment(String reqSeqId,BigDecimal cashAmt, String huifuId, String tokenNo, Integer type) {
        try {
            log.info("开始调用斗拱提现接口,取现方ID: {}, 取现金额: {}", huifuId, cashAmt);
    public Map<String,Object> encashment(String reqSeqId,BigDecimal cashAmt, String huifuId, String tokenNo, Integer type) throws Exception {
        log.info("开始调用斗拱提现接口,取现方ID: {}, 取现金额: {}", huifuId, cashAmt);
        // 1. 数据初始化,填入对应的商户配置
        MerConfig merConfig = new MerConfig();
        merConfig.setProcutId(huiFuProperties.getProductId());
        merConfig.setSysId(huiFuProperties.getSysId());
        merConfig.setRsaPrivateKey(huiFuProperties.getRsaPrivateKey());
        merConfig.setRsaPublicKey(huiFuProperties.getRsaPublicKey());
        BasePay.initWithMerConfig(merConfig);
        // 2.组装请求参数
        Map<String, Object> data = new HashMap<>();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
        String reqDate = dateFormat.format(new Date());
            // 构建业务参数data
            JSONObject data = new JSONObject();
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
            String reqDate = dateFormat.format(new Date());
            data.put("req_date", reqDate);
            data.put("req_seq_id", reqSeqId);
            data.put("cash_amt", cashAmt.toString());
            data.put("huifu_id", huifuId);
            /**
             * D0:当日到账;当日交易资金当天可取现到账;
             * T1:次工作日到账;
             * D1:次自然日到账;
             * DM:当日到账;到账资金不包括当天的交易资金;
             * 示例值:D0
             */
            data.put("into_acct_date_type", "D1");
            data.put("token_no", tokenNo);
            String notifyUrl = type.equals(1) ? "/base/dougong/ent/encashment" : "/base/dougong/user/encashment";
            data.put("notify_url", callbackPath + notifyUrl);
            String dataStr = data.toJSONString();
            log.info("业务参数data: {}", dataStr);
            // 构建完整请求参数
            JSONObject requestJson = new JSONObject();
            requestJson.put("sys_id", huiFuProperties.getHuifuId()); // 使用配置中的huifuId作为sys_id
            requestJson.put("product_id", huiFuProperties.getProductId());
            requestJson.put("data", dataStr);
            // 生成签名 - 对整个报文进行签名
            String signData = requestJson.toJSONString();
            log.info("待签名报文: {}", signData);
            String signature = sign(signData, huiFuProperties.getRsaPrivateKey());
            if (signature == null) {
                log.error("签名生成失败");
                return createErrorResult("签名生成失败");
            }
            requestJson.put("sign", signature);
            // 发送HTTP请求 - POST JSON格式
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
            HttpEntity<String> requestEntity = new HttpEntity<>(requestJson.toJSONString(), headers);
            log.info("发送斗拱提现请求到: {}", ENCASHMENT_URL);
            ResponseEntity<String> response = restTemplate.exchange(
                ENCASHMENT_URL,
                HttpMethod.POST,
                requestEntity,
                String.class
            );
            log.info("斗拱提现接口响应状态: {}, 响应内容: {}", response.getStatusCode(), response.getBody());
            // 解析响应
            JSONObject result = JSONObject.parseObject(response.getBody());
            return result;
        } catch (Exception e) {
            log.error("调用斗拱提现接口异常: {}", e.getMessage(), e);
            return createErrorResult("调用接口异常: " + e.getMessage());
        }
    }
    /**
     * 创建错误结果
     */
    private JSONObject createErrorResult(String errorMsg) {
        JSONObject result = new JSONObject();
        result.put("resp_code", "9999");
        result.put("resp_desc", errorMsg);
        result.put("success", false);
        return result;
    }
    public static String sign(String data, String privateKeyBase64) {
        // Base64 --> Key
        try {
            byte[] bytes = Base64.getDecoder().decode(privateKeyBase64);
            PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(bytes);
            KeyFactory keyFactory;
            keyFactory = KeyFactory.getInstance("RSA");
            PrivateKey privateKey = keyFactory.generatePrivate(keySpec);
            // Sign
            Signature signature = Signature.getInstance("SHA256WithRSA");
            signature.initSign(privateKey);
            signature.update(data.getBytes("UTF-8"));
            return Base64.getEncoder().encodeToString(signature.sign());
        } catch (Exception e) {
            return null;
        }
        data.put("req_date", reqDate);
        data.put("req_seq_id", reqSeqId);
        data.put("cash_amt", cashAmt.setScale(2, RoundingMode.HALF_UP).toString());
        data.put("huifu_id", huifuId);
        /**
         * D0:当日到账;当日交易资金当天可取现到账;
         * T1:次工作日到账;
         * D1:次自然日到账;
         * DM:当日到账;到账资金不包括当天的交易资金;
         * 示例值:D0
         */
        data.put("into_acct_date_type", "D1");
        data.put("token_no", tokenNo);
        String notifyUrl = type.equals(1) ? "/base/dougong/ent/encashment" : "/base/dougong/user/encashment";
        data.put("notify_url", callbackPath + notifyUrl);
        String dataStr = JSONObject.toJSONString(data);
        log.info("业务参数data: {}", dataStr);
        Map<String, Object> response = BasePayRequest.requestBasePay("v2/trade/settlement/encashment", data, null, false);
        log.info("斗拱提现接口响应内容: {}", JSONObject.toJSONString(response));
        return response;
    }
}
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/biz/FenZhangUtil.java
@@ -5,6 +5,7 @@
import com.huifu.bspay.sdk.opps.core.net.BasePayRequest;
import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -18,7 +19,7 @@
public class FenZhangUtil {
    @Autowired
    private static HuiFuProperties huiFuProperties;
    private HuiFuProperties huiFuProperties;
//    public static void main(String[] args) throws Exception {
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/controller/DouGongNotifyController.java
@@ -5,11 +5,19 @@
import com.huifu.bspay.sdk.opps.core.utils.RsaUtils;
import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties;
import com.stylefeng.guns.modular.system.model.TCompanyWithdraw;
import com.stylefeng.guns.modular.system.model.TDriver;
import com.stylefeng.guns.modular.system.model.TEnterpriseWithdrawal;
import com.stylefeng.guns.modular.system.model.TOrderCrossCity;
import com.stylefeng.guns.modular.system.model.TOrderLogistics;
import com.stylefeng.guns.modular.system.model.TPubWithdrawal;
import com.stylefeng.guns.modular.system.model.TUser;
import com.stylefeng.guns.modular.system.service.ITCompanyWithdrawService;
import com.stylefeng.guns.modular.system.service.ITDriverService;
import com.stylefeng.guns.modular.system.service.ITEnterpriseWithdrawalService;
import com.stylefeng.guns.modular.system.service.ITOrderCrossCityService;
import com.stylefeng.guns.modular.system.service.ITOrderLogisticsService;
import com.stylefeng.guns.modular.system.service.ITPubWithdrawalService;
import com.stylefeng.guns.modular.system.service.ITUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -18,8 +26,12 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.Objects;
/**
@@ -28,14 +40,28 @@
 */
@Slf4j
@RestController
@RequestMapping("/base/dougong/")
@RequestMapping("/base/dougong")
public class DouGongNotifyController {
    @Autowired
    private HuiFuProperties huiFuProperties;
    @Autowired
    private ITCompanyWithdrawService companyWithdrawService;
    @Autowired
    private ITPubWithdrawalService pubWithdrawalService;
    @Autowired
    private ITOrderCrossCityService orderCrossCityService;
    @Autowired
    private ITOrderLogisticsService orderLogisticsService;
    @Autowired
    private ITUserService userService;
    @Autowired
    private ITDriverService driverService;
    /**
     * 斗拱主动取现接口企业回调
@@ -43,10 +69,10 @@
     * @param response
     */
    @PostMapping("/ent/encashment")
    public ResponseEntity<String> entEncashment(HttpServletRequest request, HttpServletResponse response) {
    public void entEncashment(HttpServletRequest request, HttpServletResponse response) {
        String sign =request.getParameter("sign");
        String resp_data = request.getParameter("resp_data");
        log.info("斗拱企业提现响应内容:{}", resp_data);
        log.info("斗拱企业提现回调响应内容:{}", resp_data);
        // 使用汇付公钥验签
        resp_data =  resp_data.replaceAll("& #40;", "(").replaceAll("& #41;",")");
        boolean verify = RsaUtils.verify(resp_data, huiFuProperties.getRsaPublicKey(), sign);
@@ -57,7 +83,7 @@
            String transStat = respDataJson.getString("trans_stat");//S:成功 F:失败 P:处理中;示例值:S
            TCompanyWithdraw companyWithdraw = companyWithdrawService.selectOne(new EntityWrapper<TCompanyWithdraw>().eq("reqSeqId", reqSeqId).or().eq("hfSeqId", hfSeqId).last("limit 1"));
            if (Objects.isNull(companyWithdraw)) {
                return ResponseEntity.ok("");
                return;
            }
            if ("S".equalsIgnoreCase(transStat)) {
                companyWithdraw.setStatus(1);
@@ -66,9 +92,15 @@
            }
            companyWithdrawService.updateById(companyWithdraw);
            log.info("更新企业提现记录成功,更新内容“{}", JSONObject.toJSON(companyWithdraw));
            return ResponseEntity.ok("RECV_ORD_ID_" + reqSeqId);
            PrintWriter writer = null;
            try {
                writer = response.getWriter();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            writer.print("200");
            writer.close();
        }
        return null;
    }
    /**
     * 斗拱主动取现接口回调
@@ -76,10 +108,10 @@
     * @param response
     */
    @PostMapping("/user/encashment")
    public ResponseEntity<String> userEncashment(HttpServletRequest request, HttpServletResponse response) {
    public void userEncashment(HttpServletRequest request, HttpServletResponse response) {
        String sign =request.getParameter("sign");
        String resp_data = request.getParameter("resp_data");
        log.info("斗拱企业提现响应内容:{}", resp_data);
        log.info("斗拱用户提现回调响应内容:{}", resp_data);
        // 使用汇付公钥验签
        resp_data =  resp_data.replaceAll("& #40;", "(").replaceAll("& #41;",")");
        boolean verify = RsaUtils.verify(resp_data, huiFuProperties.getRsaPublicKey(), sign);
@@ -90,17 +122,109 @@
            String transStat = respDataJson.getString("trans_stat");//S:成功 F:失败 P:处理中;示例值:S
            TPubWithdrawal pubWithdrawal = pubWithdrawalService.selectOne(new EntityWrapper<TPubWithdrawal>().eq("reqSeqId", reqSeqId).or().eq("hfSeqId", hfSeqId).last("limit 1"));
            if (Objects.isNull(pubWithdrawal)) {
                return ResponseEntity.ok("");
                return;
            }
            if ("S".equalsIgnoreCase(transStat)) {
                pubWithdrawal.setState(2);
            } else if ("F".equalsIgnoreCase(transStat)) {
                pubWithdrawal.setState(3);
                if (pubWithdrawal.getUserType() == 1) {
                    TUser tUser = userService.selectById(pubWithdrawal.getUserId());
                    tUser.setBalance(tUser.getBalance().add(pubWithdrawal.getMoney()));
                    userService.updateById(tUser);
                } else {
                    TDriver driver = driverService.selectById(pubWithdrawal.getUserId());
                    driver.setLaveBusinessMoney(new BigDecimal(driver.getLaveBusinessMoney()).add(pubWithdrawal.getMoney()).doubleValue());
                    driverService.updateById(driver);
                }
            }
            pubWithdrawalService.updateById(pubWithdrawal);
            log.info("更新用户/司机提现记录成功,更新内容“{}", JSONObject.toJSON(pubWithdrawal));
            return ResponseEntity.ok("RECV_ORD_ID_" + reqSeqId);
            PrintWriter writer = null;
            try {
                writer = response.getWriter();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            writer.print("200");
            writer.close();
        }
        return null;
    }
    /**
     * 斗拱主动取现接口回调
     * @param request
     * @param response
     */
    @PostMapping("/refund-logistics")
    public void refundLogistics(HttpServletRequest request, HttpServletResponse response) {
        String sign =request.getParameter("sign");
        String resp_data = request.getParameter("resp_data");
        log.info("斗拱用户提现回调响应内容:{}", resp_data);
        // 使用汇付公钥验签
        resp_data =  resp_data.replaceAll("& #40;", "(").replaceAll("& #41;",")");
        boolean verify = RsaUtils.verify(resp_data, huiFuProperties.getRsaPublicKey(), sign);
        if(verify){
            JSONObject respDataJson = JSONObject.parseObject(resp_data);
            String reqSeqId = respDataJson.getString("req_seq_id");
            String orgReqSeqId = respDataJson.getString("org_req_seq_id");
            String transStat = respDataJson.getString("trans_stat");//S:成功 F:失败 P:处理中;示例值:S
            TOrderLogistics orderLogistics = orderLogisticsService.selectOne(new EntityWrapper<TOrderLogistics>()
                    .eq("refundReqSeqId", reqSeqId).or().eq("outTradeNo", orgReqSeqId).last("limit 1"));
            if (Objects.isNull(orderLogistics)) {
                return;
            }
            if ("S".equalsIgnoreCase(transStat)) {
                orderLogistics.setState(10);
            }
            orderLogisticsService.updateById(orderLogistics);
            log.info("更新小件物流取消订单状态成功,更新内容“{}", JSONObject.toJSON(orderLogistics));
            PrintWriter writer = null;
            try {
                writer = response.getWriter();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            writer.print("200");
            writer.close();
        }
    }
    /**
     * 斗拱主动取现接口回调
     * @param request
     * @param response
     */
    @PostMapping("/refund-crosscity")
    public void refundCrossCity(HttpServletRequest request, HttpServletResponse response) {
        String sign =request.getParameter("sign");
        String resp_data = request.getParameter("resp_data");
        log.info("斗拱用户提现回调响应内容:{}", resp_data);
        // 使用汇付公钥验签
        resp_data =  resp_data.replaceAll("& #40;", "(").replaceAll("& #41;",")");
        boolean verify = RsaUtils.verify(resp_data, huiFuProperties.getRsaPublicKey(), sign);
        if(verify){
            JSONObject respDataJson = JSONObject.parseObject(resp_data);
            String reqSeqId = respDataJson.getString("req_seq_id");
            String orgReqSeqId = respDataJson.getString("org_req_seq_id");
            String transStat = respDataJson.getString("trans_stat");//S:成功 F:失败 P:处理中;示例值:S
            TOrderCrossCity orderCrossCity = orderCrossCityService.selectOne(new EntityWrapper<TOrderCrossCity>()
                    .eq("refundReqSeqId", reqSeqId).or().eq("outTradeNo", orgReqSeqId).last("limit 1"));
            if (Objects.isNull(orderCrossCity)) {
                return;
            }
            if ("S".equalsIgnoreCase(transStat)) {
                orderCrossCity.setState(10);
            }
            orderCrossCityService.updateById(orderCrossCity);
            log.info("更新跨城订单取消订单状态成功,更新内容“{}", JSONObject.toJSON(orderCrossCity));
            PrintWriter writer = null;
            try {
                writer = response.getWriter();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            writer.print("200");
            writer.close();
        }
    }
}
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TCompanyWithdrawController.java
@@ -35,6 +35,7 @@
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 控制器
@@ -184,8 +185,8 @@
            }
            String reqSeqId = RequestSeqUtil.extractPrefix("TX");
            JSONObject result = douGongWithdrawBiz.encashment(reqSeqId, BigDecimal.valueOf(withdrawalReq.getAmount()), companyId.get(0).getHuifuId(), companyId.get(0).getTokenNo(), 1);
            if (!result.get("resp_code").equals("00000000") || !result.getBoolean("success")) {
            Map<String,Object> result = douGongWithdrawBiz.encashment(reqSeqId, BigDecimal.valueOf(withdrawalReq.getAmount()), companyId.get(0).getHuifuId(), companyId.get(0).getTokenNo(), 1);
            if (!result.get("resp_code").equals("00000000")) {
                return new ErrorTip(500, "操作失败,异常原因:"+result.get("resp_desc"));
            }
            tCompanyWithdraw.setReqSeqId(reqSeqId);
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
@@ -14,6 +14,7 @@
import com.stylefeng.guns.core.util.WoUtil;
import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample;
import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq;
import com.stylefeng.guns.modular.huifu.biz.FenZhangUtil;
import com.stylefeng.guns.modular.system.controller.util.Base64Util;
import com.stylefeng.guns.modular.system.dao.DriverPunishMapper;
import com.stylefeng.guns.modular.system.dao.DriverTrainMapper;
@@ -2073,7 +2074,7 @@
    @Autowired
    private IUserWithdrawalService userWithdrawalService;
    public String createAllocationReq(Integer companyId,Integer userId,int type,double money){
    public String createAllocationReq(Integer companyId,Integer userId,int type,double money) throws Exception {
        List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId));
        TDriver tUser = tDriverService.selectById(userId);
        List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone()));
@@ -2081,33 +2082,41 @@
            return "error";
        }
        AllocationReq allocationReq= new AllocationReq();
        allocationReq.setOutOrderNo(ToolUtil.getRandomString(32));
        //AllocationReq allocationReq= new AllocationReq();
        //allocationReq.setOutOrderNo(ToolUtil.getRandomString(32));
        Map<String, Object> result;
        if(type==1){
            allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode()));
            //allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            //allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            //
            //allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode()));
            result = FenZhangUtil.fenzhang(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId());
        }else {
            allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode()));
            //allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            //allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            //allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode()));
            result = FenZhangUtil.payFromUser(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId());
        }
        money=money*100;
        allocationReq.setAmount((int)money);
        allocationReq.setProductName("分账");
        allocationReq.setProductCount(1);
        allocationReq.setOrderNo(ToolUtil.getRandomString(32));
        allocationReq.setOrderAmount(1l);
        try {
            AllocationResp allocationResp = AllocationExample.create(allocationReq);
            System.out.println(allocationResp);
        if ("00000000".equals(result.get("respCode").toString())) {
            return "ok";
        } catch (UpyztException e) {
            e.printStackTrace();
            return e.getMessage();
        } else {
            return result.get("respDesc").toString();
        }
        //money=money*100;
        //allocationReq.setAmount((int)money);
        //allocationReq.setProductName("分账");
        //allocationReq.setProductCount(1);
        //allocationReq.setOrderNo(ToolUtil.getRandomString(32));
        //allocationReq.setOrderAmount(1l);
        //try {
        //    AllocationResp allocationResp = AllocationExample.create(allocationReq);
        //    System.out.println(allocationResp);
        //    return "ok";
        //} catch (UpyztException e) {
        //    e.printStackTrace();
        //    return e.getMessage();
        //}
    }
}
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TPubWithdrawalController.java
@@ -183,8 +183,8 @@
                        try {
                            log.info("用户提现创建=========");
                            String reqSeqId = RequestSeqUtil.generate("TX");
                            JSONObject result = douGongWithdrawBiz.encashment(reqSeqId, tPubWithdrawal.getMoney(), userWithdrawals.get(0).getHuiFuId(), userWithdrawals.get(0).getTokenNo(), 2);
                            if (!result.get("resp_code").equals("00000000") || !result.getBoolean("success")) {
                            Map<String,Object> result = douGongWithdrawBiz.encashment(reqSeqId, tPubWithdrawal.getMoney(), userWithdrawals.get(0).getHuiFuId(), userWithdrawals.get(0).getTokenNo(), 2);
                            if (!result.get("resp_code").equals("00000000")) {
                                return new ErrorTip(500, "操作失败,异常原因:"+result.get("resp_desc"));
                            }
@@ -195,7 +195,7 @@
                            //tPubWithdrawal.setWithdrawId(withdrawalResp.getWithdrawalId());
                            tPubWithdrawalService.updateById(tPubWithdrawal);
                            //log.info("用户提现创建信息========="+withdrawalResp.toString());
                            log.info("用户提现创建信息:{}", result.toJSONString());
                            log.info("用户提现创建信息:{}", JSONObject.toJSONString(result));
                            log.info("用户提现创建成功=========");
                        } catch (Exception e) {
                            log.info("用户提现创建失败=========");
@@ -236,8 +236,8 @@
                    try {
                        log.info("司机提现创建=========");
                        String reqSeqId = RequestSeqUtil.generate("TX");
                        JSONObject result = douGongWithdrawBiz.encashment(reqSeqId, tPubWithdrawal.getMoney(), userWithdrawal.getHuiFuId(), userWithdrawal.getTokenNo(), 2);
                        if (!result.get("resp_code").equals("00000000") || !result.getBoolean("success")) {
                        Map<String,Object> result = douGongWithdrawBiz.encashment(reqSeqId, tPubWithdrawal.getMoney(), userWithdrawal.getHuiFuId(), userWithdrawal.getTokenNo(), 2);
                        if (!result.get("resp_code").equals("00000000")) {
                            return new ErrorTip(500, "操作失败,异常原因:"+result.get("resp_desc"));
                        }
@@ -248,7 +248,7 @@
                        //tPubWithdrawal.setWithdrawId(withdrawalResp.getWithdrawalId());
                        tPubWithdrawalService.updateById(tPubWithdrawal);
                        //log.info("司机提现创建信息========="+withdrawalResp.toString());
                        log.info("司机提现创建信息:{}", result.toJSONString());
                        log.info("司机提现创建信息:{}", JSONObject.toJSONString(result));
                        log.info("司机提现创建成功=========");
                    } catch (Exception e) {
                        log.info("司机提现创建失败=========");
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderCrossCityController.java
@@ -8,10 +8,14 @@
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.shiro.ShiroUser;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.core.util.RequestSeqUtil;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample;
import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq;
import com.stylefeng.guns.modular.huifu.biz.DouGongRefundBiz;
import com.stylefeng.guns.modular.huifu.biz.FenZhangUtil;
import com.stylefeng.guns.modular.system.controller.general.TDriverController;
import com.stylefeng.guns.modular.system.controller.util.Base64Util;
import com.stylefeng.guns.modular.system.controller.util.GetOpenBodySig;
@@ -71,6 +75,9 @@
    @Value("${filePath}")
    private String filePath;
    @Autowired
    private DouGongRefundBiz douGongRefundBiz;
    /**
     * 跳转到跨城出行订单首页
@@ -210,6 +217,7 @@
        if(orderCrossCity.getState() > 5 && orderCrossCity.getState() != 11 && orderCrossCity.getState() != 7){
            return ResultUtil.error("订单状态不在可取消范围内");
        }
        Integer orgState = orderCrossCity.getState();
        orderCrossCity.setState(10);
        tOrderCrossCityService.updateById(orderCrossCity);
@@ -279,10 +287,20 @@
                }
                if(query.getPayType() == 1){//微信
                    Map<String, String> map = payMoneyUtil.wxRefund(query.getCode(), tOrderCrossCityId + "_3", query.getAmount().toString(), query.getAmount().toString(), "/base/cancleOrderWXPay");
                    if(!"SUCCESS".equals(map.get("return_code"))){
                        return ResultUtil.error(map.get("return_msg"));
                    //Map<String, String> map = payMoneyUtil.wxRefund(query.getCode(), tOrderCrossCityId + "_3", query.getAmount().toString(), query.getAmount().toString(), "/base/cancleOrderWXPay");
                    //if(!"SUCCESS".equals(map.get("return_code"))){
                    //    return ResultUtil.error(map.get("return_msg"));
                    //}
                    String refundReqSeqId = RequestSeqUtil.generate("TK");
                    Map<String, Object> refund = douGongRefundBiz.refund(refundReqSeqId, BigDecimal.valueOf(query.getAmount()), DateUtil.format(query.getInsertTime(), "yyyyMMdd"), orderCrossCity.getOutTradeNo(), 1);
                    orderCrossCity.setRefundReqSeqId(refundReqSeqId);
                    orderCrossCity.setState(orgState);
                    if ("00000000".equals(refund.get("resp_code")) && "S".equals(refund.get("trans_stat"))) {
                        orderCrossCity.setState(10);
                    }else if (!"00000000".equals(refund.get("resp_code"))) {
                        return ResultUtil.error("订单取消失败:" + refund.get("resp_desc").toString());
                    }
                    tOrderCrossCityService.updateById(orderCrossCity);
                }else if(query.getPayType()==4){
                    // TODO 退款
                    TUser userInfo = userService.selectById(orderCrossCity.getUserId());
@@ -302,10 +320,20 @@
                    String billNo = orderCrossCity.getBillNo();
//                    cancleMoney(orderCrossCity.getPayMoney(),billNo);
                }else{//支付宝
                    Map<String, String> map = payMoneyUtil.aliRefund(query.getCode(), query.getAmount().toString());
                    if(!"10000".equals(map.get("code"))){
                        return ResultUtil.error(map.get("msg"));
                    //Map<String, String> map = payMoneyUtil.aliRefund(query.getCode(), query.getAmount().toString());
                    //if(!"10000".equals(map.get("code"))){
                    //    return ResultUtil.error(map.get("msg"));
                    //}
                    String refundReqSeqId = RequestSeqUtil.generate("TK");
                    Map<String, Object> refund = douGongRefundBiz.refund(refundReqSeqId, BigDecimal.valueOf(query.getAmount()), DateUtil.format(query.getInsertTime(), "yyyyMMdd"), orderCrossCity.getOutTradeNo(), 1);
                    orderCrossCity.setRefundReqSeqId(refundReqSeqId);
                    orderCrossCity.setState(orgState);
                    if ("00000000".equals(refund.get("resp_code")) && "S".equals(refund.get("trans_stat"))) {
                        orderCrossCity.setState(10);
                    }else if (!"00000000".equals(refund.get("resp_code"))) {
                        return ResultUtil.error("订单取消失败:" + refund.get("resp_desc").toString());
                    }
                    tOrderCrossCityService.updateById(orderCrossCity);
                    //添加交易明细
                    transactionDetailsService.saveData(orderCrossCity.getUserId(), "跨城出行取消退款", query.getAmount(), 1, 1, 1, 3, tOrderCrossCityId);
                }
@@ -399,7 +427,7 @@
    @Autowired
    private IUserWithdrawalService userWithdrawalService;
    public String createAllocationReq(Integer companyId,Integer userId,int type,double money){
    public String createAllocationReq(Integer companyId,Integer userId,int type,double money) throws Exception {
        List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId));
        TDriver tUser = tDriverService.selectById(userId);
        List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone()));
@@ -407,69 +435,85 @@
            return "error";
        }
        AllocationReq allocationReq= new AllocationReq();
        allocationReq.setOutOrderNo(ToolUtil.getRandomString(32));
        //AllocationReq allocationReq= new AllocationReq();
        //allocationReq.setOutOrderNo(ToolUtil.getRandomString(32));
        Map<String, Object> result;
        if(type==1){
            allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode()));
            //allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            //allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            //
            //allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode()));
            result = FenZhangUtil.fenzhang(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId());
        }else {
            allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode()));
            //allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            //allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            //allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode()));
            result = FenZhangUtil.payFromUser(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId());
        }
        money=money*100;
        allocationReq.setAmount((int)money);
        allocationReq.setProductName("分账");
        allocationReq.setProductCount(1);
        allocationReq.setOrderNo(ToolUtil.getRandomString(32));
        allocationReq.setOrderAmount(1l);
        try {
            AllocationResp allocationResp = AllocationExample.create(allocationReq);
            System.out.println(allocationResp);
        if ("00000000".equals(result.get("respCode").toString())) {
            return "ok";
        } catch (UpyztException e) {
            e.printStackTrace();
            return e.getMessage();
        } else {
            return result.get("respDesc").toString();
        }
        //money=money*100;
        //allocationReq.setAmount((int)money);
        //allocationReq.setProductName("分账");
        //allocationReq.setProductCount(1);
        //allocationReq.setOrderNo(ToolUtil.getRandomString(32));
        //allocationReq.setOrderAmount(1l);
        //try {
        //    AllocationResp allocationResp = AllocationExample.create(allocationReq);
        //    System.out.println(allocationResp);
        //    return "ok";
        //} catch (UpyztException e) {
        //    e.printStackTrace();
        //    return e.getMessage();
        //}
    }
    public String createAllocationReqUser(Integer companyId,Integer userId,int type,double money){
    public String createAllocationReqUser(Integer companyId,Integer userId,int type,double money) throws Exception {
        List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId));
        TUser tUser = userService.selectById(userId);
        List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone()));
        if(userWithdrawals.size()==0){
            return "error";
        }
        AllocationReq allocationReq= new AllocationReq();
        allocationReq.setOutOrderNo(ToolUtil.getRandomString(32));
        //AllocationReq allocationReq= new AllocationReq();
        //allocationReq.setOutOrderNo(ToolUtil.getRandomString(32));
        Map<String, Object> result;
        if(type==1){
            allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode()));
            //allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            //allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            //
            //allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode()));
            result = FenZhangUtil.fenzhang(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId());
        }else {
            allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode()));
            //allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            //allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            //allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode()));
            result = FenZhangUtil.payFromUser(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId());
        }
        money=money*100;
        allocationReq.setAmount((int)money);
        allocationReq.setProductName("分账");
        allocationReq.setProductCount(1);
        allocationReq.setOrderNo(ToolUtil.getRandomString(32));
        allocationReq.setOrderAmount(1l);
        try {
            AllocationResp allocationResp = AllocationExample.create(allocationReq);
            System.out.println(allocationResp);
        if ("00000000".equals(result.get("respCode").toString())) {
            return "ok";
        } catch (UpyztException e) {
            e.printStackTrace();
            return e.getMessage();
        } else {
            return result.get("respDesc").toString();
        }
        //money=money*100;
        //allocationReq.setAmount((int)money);
        //allocationReq.setProductName("分账");
        //allocationReq.setProductCount(1);
        //allocationReq.setOrderNo(ToolUtil.getRandomString(32));
        //allocationReq.setOrderAmount(1l);
        //try {
        //    AllocationResp allocationResp = AllocationExample.create(allocationReq);
        //    System.out.println(allocationResp);
        //    return "ok";
        //} catch (UpyztException e) {
        //    e.printStackTrace();
        //    return e.getMessage();
        //}
    }
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderLogisticsController.java
@@ -13,6 +13,7 @@
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample;
import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq;
import com.stylefeng.guns.modular.huifu.biz.DouGongRefundBiz;
import com.stylefeng.guns.modular.huifu.biz.FenZhangUtil;
import com.stylefeng.guns.modular.system.controller.util.Base64Util;
import com.stylefeng.guns.modular.system.dao.OrderCancelMapper;
@@ -22,6 +23,8 @@
import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.resp.AllocationResp;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@@ -33,10 +36,14 @@
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
 * 小件物流订单控制器
@@ -79,6 +86,8 @@
    private PayMoneyUtil payMoneyUtil;
    @Autowired
    private IUserCouponRecordService userCouponRecordService;
    @Autowired
    private DouGongRefundBiz douGongRefundBiz;
    /**
     * 跳转到小件物流订单首页
@@ -152,6 +161,7 @@
        try{
            ShiroUser user = ShiroKit.getUser();
            TOrderLogistics tOrderLogistics = tOrderLogisticsService.selectById(tOrderLogisticsId);
            Integer orgState = tOrderLogistics.getState();
            tOrderLogistics.setState(10);
            //已支付的情况下进行退款操作
@@ -184,14 +194,38 @@
                        List<PaymentRecord> querys = paymentRecordService.query_(1, tOrderLogistics.getUserId(), 1, tOrderLogistics.getId(), tOrderLogistics.getType(), tOrderLogistics.getPayType(), 2);
                        System.out.println(querys);
                        boolean b = false;
                        List<Integer> orderIds = querys.stream().map(PaymentRecord::getOrderId).collect(Collectors.toList());
                        Map<Integer, TOrderLogistics> orderLogisticsMap = Collections.emptyMap();
                        if (CollectionUtils.isNotEmpty(orderIds)) {
                            orderLogisticsMap = tOrderLogisticsService.selectList(new EntityWrapper<TOrderLogistics>()
                                            .in("id", orderIds).isNotNull("outTradeNo"))
                                    .stream().collect(Collectors.toMap(TOrderLogistics::getId, Function.identity()));
                        }
                        for (PaymentRecord query : querys) {
                            System.out.println("支付方式:"+query.getPayType());
                            if(query.getPayType() == 1){//微信
                                Map<String, String> map = payMoneyUtil.wxRefund(query.getCode(), tOrderLogistics.getId() + "_" + tOrderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), query.getAmount().toString(), query.getAmount().toString(), "/base/cancleOrderWXPay");
                                System.out.println("map:"+map);
                                if(!"SUCCESS".equals(map.get("return_code"))){
                                    return ResultUtil.error(map.get("return_msg"));
                                //Map<String, String> map = payMoneyUtil.wxRefund(query.getCode(), tOrderLogistics.getId() + "_" + tOrderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), query.getAmount().toString(), query.getAmount().toString(), "/base/cancleOrderWXPay");
                                //System.out.println("map:"+map);
                                //if(!"SUCCESS".equals(map.get("return_code"))){
                                //    return ResultUtil.error(map.get("return_msg"));
                                //}
                                TOrderLogistics orderLogistics = orderLogisticsMap.get(query.getOrderId());
                                if (Objects.isNull(orderLogistics)) {
                                    log.error("小件物流取消订单退款失败,未找到对应的斗拱支付订单,orderId={}", query.getOrderId());
                                    continue;
                                }
                                String refundReqSeqId = RequestSeqUtil.generate("TK");
                                Map<String, Object> refund = douGongRefundBiz.refund(refundReqSeqId, BigDecimal.valueOf(query.getAmount()), DateUtil.format(query.getInsertTime(), "yyyyMMdd"), orderLogistics.getOutTradeNo(), 1);
                                orderLogistics.setRefundReqSeqId(refundReqSeqId);
                                orderLogistics.setState(orgState);
                                tOrderLogistics.setState(orgState);
                                if ("00000000".equals(refund.get("resp_code")) && "S".equals(refund.get("trans_stat"))) {
                                    orderLogistics.setState(10);
                                    tOrderLogistics.setState(10);
                                }else if (!"00000000".equals(refund.get("resp_code"))) {
                                    return ResultUtil.error("订单取消失败:" + refund.get("resp_desc").toString());
                                }
                                tOrderLogisticsService.updateById(orderLogistics);
                            }
                        }
                    }
@@ -283,60 +317,78 @@
        AllocationReq allocationReq= new AllocationReq();
        allocationReq.setOutOrderNo(ToolUtil.getRandomString(32));
        if(type==1){
            allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode()));
        }else {
            allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode()));
        }
        money=money*100;
        allocationReq.setAmount((int)money);
        allocationReq.setProductName("分账");
        allocationReq.setProductCount(1);
        allocationReq.setOrderNo(ToolUtil.getRandomString(32));
        allocationReq.setOrderAmount(1l);
        try {
            AllocationResp allocationResp = AllocationExample.create(allocationReq);
            System.out.println(allocationResp);
            return "ok";
        } catch (UpyztException e) {
            e.printStackTrace();
            return e.getMessage();
            Map<String, Object> result;
            if(type==1){
                //allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
                //allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
                //
                //allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode()));
                result = FenZhangUtil.fenzhang(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId());
            }else {
                //allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
                //allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
                //allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode()));
                result = FenZhangUtil.payFromUser(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId());
            }
            if ("00000000".equals(result.get("respCode").toString())) {
                return "ok";
            } else {
                return result.get("respDesc").toString();
            }
        } catch (Exception e) {
            log.error("分账异常", e);
            throw new RuntimeException(e);
        }
        //money=money*100;
        //allocationReq.setAmount((int)money);
        //allocationReq.setProductName("分账");
        //allocationReq.setProductCount(1);
        //allocationReq.setOrderNo(ToolUtil.getRandomString(32));
        //allocationReq.setOrderAmount(1l);
        //try {
        //    AllocationResp allocationResp = AllocationExample.create(allocationReq);
        //    System.out.println(allocationResp);
        //    return "ok";
        //} catch (UpyztException e) {
        //    e.printStackTrace();
        //    return e.getMessage();
        //}
    }
    public String createAllocationReqUser(Integer companyId,Integer userId,int type,double money) throws Exception {
    public String createAllocationReqUser(Integer companyId,Integer userId,int type,double money) {
        List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId));
        TUser tUser = userService.selectById(userId);
        List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone()));
        if(userWithdrawals.size()==0){
            return "error";
        }
        AllocationReq allocationReq= new AllocationReq();
        allocationReq.setOutOrderNo(ToolUtil.getRandomString(32));
        Map<String, Object> result;
        if(type==1){
        //AllocationReq allocationReq= new AllocationReq();
        //allocationReq.setOutOrderNo(ToolUtil.getRandomString(32));
        try {
            Map<String, Object> result;
            if(type==1){
            //allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            //allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            //
            //allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode()));
            result = FenZhangUtil.fenzhang(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId());
        }else {
            //allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
            //allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
            //allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode()));
            result = FenZhangUtil.payFromUser(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId());
        }
        if ("00000000".equals(result.get("respCode").toString())) {
            return "ok";
        } else {
            return result.get("respDesc").toString();
                //allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
                //allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
                //
                //allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode()));
                result = FenZhangUtil.fenzhang(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId());
            }else {
                //allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId());
                //allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId());
                //allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode()));
                result = FenZhangUtil.payFromUser(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId());
            }
            if ("00000000".equals(result.get("respCode").toString())) {
                return "ok";
            } else {
                return result.get("respDesc").toString();
            }
        } catch (Exception e) {
            log.error("分账异常", e);
            throw new RuntimeException(e);
        }
        //money=money*100;
        //allocationReq.setAmount((int)money);
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderPrivateCarController.java
@@ -12,6 +12,7 @@
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.huifu.biz.DouGongRefundBiz;
import com.stylefeng.guns.modular.system.dao.OrderCancelMapper;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/TOrderCrossCity.java
@@ -297,7 +297,32 @@
    private String payOrderId;
    private String billNo;
    /**
     * 斗拱交易流水号
     */
    private String outTradeNo;
    /**
     * 斗拱退款流水号
     */
    private String refundReqSeqId;
    public String getRefundReqSeqId() {
        return refundReqSeqId;
    }
    public void setRefundReqSeqId(String refundReqSeqId) {
        this.refundReqSeqId = refundReqSeqId;
    }
    public String getOutTradeNo() {
        return outTradeNo;
    }
    public void setOutTradeNo(String outTradeNo) {
        this.outTradeNo = outTradeNo;
    }
    public String getBillNo() {
        return billNo;
    }
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/TOrderLogistics.java
@@ -307,6 +307,29 @@
     */
    private BigDecimal timeOutMoney;
    private String outTradeNo;
    /**
     * 斗拱退款流水号
     */
    private String refundReqSeqId;
    public String getRefundReqSeqId() {
        return refundReqSeqId;
    }
    public void setRefundReqSeqId(String refundReqSeqId) {
        this.refundReqSeqId = refundReqSeqId;
    }
    public String getOutTradeNo() {
        return outTradeNo;
    }
    public void setOutTradeNo(String outTradeNo) {
        this.outTradeNo = outTradeNo;
    }
    public Integer getId() {
        return id;
ManagementJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java
@@ -59,7 +59,7 @@
    /**
     * 每隔一分钟去处理的定时任务
     */
    @Scheduled(fixedRate = 1000 * 60)
    //@Scheduled(fixedRate = 1000 * 60)
    public void taskMinute() {
        try {
            List<TEnterpriseWithdrawal> isAudit = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("isAudit", 1));
UserJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/huifu/biz/DouGongBasicDataBiz.java
@@ -1,24 +1,32 @@
package com.stylefeng.guns.modular.huifu.biz;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.huifu.bspay.sdk.opps.core.BasePay;
import com.huifu.bspay.sdk.opps.core.config.MerConfig;
import com.huifu.bspay.sdk.opps.core.exception.BasePayException;
import com.huifu.bspay.sdk.opps.core.net.BasePayRequest;
import com.huifu.bspay.sdk.opps.core.utils.RsaUtils;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.account.req.UserWithdrawalReq;
import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties;
import com.stylefeng.guns.core.util.RequestSeqUtil;
import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties;
import com.stylefeng.guns.modular.system.model.UserWithdrawal;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;
import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * 斗拱进件业务
@@ -177,6 +185,22 @@
            cardInfo.put("cert_validity_type", "1");
        }
        paramsInfo.put("card_info", cardInfo.toJSONString());
        // 结算卡信息
        JSONArray cashConfigArr = new JSONArray();
        JSONObject cashConfig = new JSONObject();
        /**
         * T1:下一工作日到银行账户;
         * D1:下一自然日到银行账户;
         * D0:当日到银行账户;默认D0;
         * DM:当日到账;到账资金不包括当天的交易资金;
         * 示例值:T1
         */
        cashConfig.put("cash_type", "D1");
        cashConfig.put("fix_amt", "0.00");
        cashConfig.put("weekday_fix_amt", "0.00");
        cashConfig.put("weekday_fee_rate", "0.00");
        cashConfigArr.add(cashConfig);
        paramsInfo.put("cash_config", cashConfigArr.toJSONString());
        log.info("用户业务入驻返回参数:{}", paramsInfo);
        // 3. 发起API调用
        Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/open", paramsInfo, null, false);;
@@ -204,8 +228,6 @@
        paramsInfo.put("req_seq_id", RequestSeqUtil.generateForHuiFu());
        // 请求日期
        paramsInfo.put("req_date", DateUtil.format(new Date(),"yyyyMMdd"));
        // 渠道商/商户汇付Id
        paramsInfo.put("upper_huifu_id", huiFuProperties.getUpperHuifuId());
        // 结算卡信息
        JSONObject cardInfo = new JSONObject();
        cardInfo.put("card_type", "1");
@@ -231,7 +253,25 @@
            cardInfo.put("cert_validity_type", "1");
        }
        paramsInfo.put("card_info", cardInfo.toJSONString());
        // 结算卡信息
        JSONArray cashConfigArr = new JSONArray();
        JSONObject cashConfig = new JSONObject();
        /**
         * T1:下一工作日到银行账户;
         * D1:下一自然日到银行账户;
         * D0:当日到银行账户;默认D0;
         * DM:当日到账;到账资金不包括当天的交易资金;
         * 示例值:T1
         */
        cashConfig.put("switch_state", "1");
        cashConfig.put("cash_type", "D1");
        cashConfig.put("fix_amt", "0.00");
        cashConfig.put("weekday_fix_amt", "0.00");
        cashConfig.put("weekday_fee_rate", "0.00");
        cashConfigArr.add(cashConfig);
        paramsInfo.put("cash_config", cashConfigArr.toJSONString());
        log.info("用户业务入驻修改返回参数:{}", paramsInfo);
        // 3. 发起API调用
        Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/modify", paramsInfo, null, false);;
        log.info("用户业务入驻修改返回参数:{}", response);