liujie
2025-11-25 b502ac4e96aca2ab29caa77187ab7673a853a797
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();
        //}
    }