Pu Zhibing
7 天以前 638e7deedf01e2fa276d38f2215003e43996c54f
DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java
@@ -1,24 +1,17 @@
package com.stylefeng.guns.modular.system.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.account.controller.AppOrderController;
import com.stylefeng.guns.modular.account.model.TEnterpriseWithdrawal;
import com.stylefeng.guns.modular.account.service.ITEnterpriseWithdrawalService;
import com.stylefeng.guns.modular.account.service.UserWithdrawalService;
import com.stylefeng.guns.modular.account.unionpay.GetOpenBodySig;
import com.stylefeng.guns.modular.account.unionpay.QrCodeConfiguration;
import com.stylefeng.guns.modular.account.unionpay.Util;
import com.stylefeng.guns.modular.account.util.Base64Util;
import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample;
import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq;
import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity;
import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService;
import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics;
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService;
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsSpreadService;
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
import com.stylefeng.guns.modular.system.dao.DispatchMapper;
@@ -29,7 +22,6 @@
import com.stylefeng.guns.modular.system.util.*;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
import com.unionpay.upyzt.resp.AllocationResp;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -239,10 +231,6 @@
                    jgPushUtil.push(2,"有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId());
                }
                // TODO 司机云闪付 改派余额支付,司机电子账簿转账到平台
                if(BigDecimal.ZERO.compareTo(new BigDecimal(aDouble)) < 0){
                    cloudPay(reassign.getOriginalDriverId(),aDouble,Util.getMerOrderId(qrCodeConfiguration.getMsgSrcId()));
                }
            }
            if(reassign.getPayType() == 4){
@@ -255,44 +243,6 @@
        return resultUtil;
    }
    private void cloudPay(Integer uid,Double total_fee,String transaction_id) {
        System.out.println(uid+"======"+total_fee+"====="+transaction_id);
        Driver driver = driverService.selectById(uid);
        if(Objects.isNull(driver)){
            throw new RuntimeException("该司机不存在!"+uid);
        }
        // 查询平台账户
        Company company = companyService.selectOne(new EntityWrapper<Company>()
                .eq("type", 1)
                .last("LIMIT 1"));
        System.out.println("查询平台账户==============="+company);
        // 查询平台开户信息
        TEnterpriseWithdrawal enterpriseWithdrawal = enterpriseWithdrawalService.selectOne(new EntityWrapper<TEnterpriseWithdrawal>()
                .eq("companyId", company.getId())); //  替换为公司id
        System.out.println("查询平台开户信息==============="+enterpriseWithdrawal);
        // TODO 司机进件信息
        UserWithdrawal driverWith = userWithdrawalService.selectOne(new EntityWrapper<UserWithdrawal>()
                .eq("phone", driver.getPhone())
                .last("LIMIT 1"));
        try {
            AllocationReq allocationReq = new AllocationReq();
            allocationReq.setOutOrderNo(transaction_id);
            allocationReq.setPayBalanceAcctId(driverWith.getBalanceAcctId()); // 发送方
            allocationReq.setRecvBalanceAcctId(enterpriseWithdrawal.getBalanceAcctId()); // 接收方
            BigDecimal multiply = new BigDecimal(100).multiply(new BigDecimal(total_fee));
            allocationReq.setAmount(multiply.intValue()); // 金额
            allocationReq.setPassword(Base64Util.decode(enterpriseWithdrawal.getTransactionAuthorizationCode())); // 密码
            allocationReq.setOrderNo(transaction_id);
            allocationReq.setOrderAmount(multiply.longValue());
            allocationReq.setProductName("订单改派");
            allocationReq.setProductCount(1);
            AllocationResp allocationResp = AllocationExample.create(allocationReq);
            System.err.println("司机分账信息:"+allocationResp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private ResultUtil placeAnOrder(BigDecimal amount, Integer type,Integer orderType,Integer reassignId) throws Exception {
        Reassign reassign = reassignMapper.selectById(reassignId);