liujie
7 天以前 729a5a0592cac7750e8b476c5fcb25bfc3ff8d25
DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -6,12 +6,8 @@
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.core.util.ToolUtil;
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.util.Base64Util;
import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample;
import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq;
import com.stylefeng.guns.modular.smallLogistics.dao.OrderLogisticsMapper;
import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics;
import com.stylefeng.guns.modular.smallLogistics.model.OrderLogisticsSpread;
@@ -23,15 +19,11 @@
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.*;
import com.stylefeng.guns.modular.system.warpper.MerchantCouponListWarpper;
import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.resp.AllocationResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@@ -56,28 +48,28 @@
    @Autowired
    private ChinaMobileUtil chinaMobileUtil;
    @Autowired
    private PushUtil pushUtil;
    @Autowired
    private ISystemNoticeService systemNoticeService;
    @Autowired
    private IOrderLogisticsSpreadService orderLogisticsSpreadService;
    @Autowired
    private RedisUtil redisUtil;
    @Resource
    private RedisTemplate<String, Object> redisTemplate;
    @Autowired
    private ICompanyService companyService;
    @Autowired
    private IIncomeService incomeService;
    @Autowired
    private ALiSendSms aLiSendSms;
    @Resource
    private UserInfoMapper userInfoMapper;
@@ -142,24 +134,24 @@
        orderLogistics.setSnatchOrderTime(new Date());
        //调用高德创建轨迹
        String s = gdFalconUtil.selectTerminal(driver.getPhone());
        String track = gdFalconUtil.createTrack(s);
        orderLogistics.setTrackId(track);
//        String s = gdFalconUtil.selectTerminal(driver.getPhone());
//        String track = gdFalconUtil.createTrack(s);
//        orderLogistics.setTrackId(track);
        //调用移动的小号接口
        Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderLogistics.getRecipientPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000));
        if(String.valueOf(map.get("code")).equals("200")){
            orderLogistics.setTelX(map.get("telX"));
            orderLogistics.setBindId(map.get("bindId"));
        }
        UserInfo userInfo = userInfoMapper.selectById(orderLogistics.getUserId());
//        Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderLogistics.getRecipientPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000));
//        if(String.valueOf(map.get("code")).equals("200")){
//            orderLogistics.setTelX(map.get("telX"));
//            orderLogistics.setBindId(map.get("bindId"));
//        }
//        UserInfo userInfo = userInfoMapper.selectById(orderLogistics.getUserId());
        Map<String, String> map1 = chinaMobileUtil.midAxbBindSend(userInfo.getPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000));
        System.out.println("二次绑定信息:"+map1);
        if(String.valueOf(map1.get("code")).equals("200")){
            orderLogistics.setTelXOne(map1.get("telX"));
            orderLogistics.setBindIdOne(map1.get("bindId"));
        }
//        Map<String, String> map1 = chinaMobileUtil.midAxbBindSend(userInfo.getPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000));
//        System.out.println("二次绑定信息:"+map1);
//        if(String.valueOf(map1.get("code")).equals("200")){
//            orderLogistics.setTelXOne(map1.get("telX"));
//            orderLogistics.setBindIdOne(map1.get("bindId"));
//        }
        this.updateById(orderLogistics);
@@ -330,13 +322,13 @@
                        }
                        merchantActivityService.updateBatchById(merchantActivities);
                    }
                    String value = redisUtil.getValue("merchantVoucher");
                    String value = (String) redisTemplate.opsForValue().get("merchantVoucher");
                    JSONObject jsonObject = JSON.parseObject(value);
                    if(null == jsonObject){
                        jsonObject = new JSONObject();
                    }
                    jsonObject.put(userInfo.getPhone(), listWarppers);
                    redisUtil.setStrValue("merchantVoucher", jsonObject.toJSONString());
                    redisTemplate.opsForValue().set("merchantVoucher", jsonObject.toJSONString());
                }
                break;
@@ -402,59 +394,12 @@
                income.setObjectId(orderLogistics.getCompanyId());
                incomeService.insert(income);
                // TODO 司机云闪付 超时扣款 司机电子余额转账到平台
                // 超时扣款 司机电子余额转账到平台
                divideAccounts(orderLogistics.getDriverId(),timeOutMoney,orderLogistics.getOrderNum());
            }
        }
        this.updateById(orderLogistics);
        return ResultUtil.success();
    }
    /**
     * 分账
     */
    private void divideAccounts(Integer driverId,double amount,String orderNum){
        try{
            // 查询平台开户信息
            TEnterpriseWithdrawal enterpriseWithdrawal = enterpriseWithdrawalService.selectOne(new EntityWrapper<TEnterpriseWithdrawal>()
                    .eq("companyId", 1)
                    .last("LIMIT 1"));
            if(Objects.isNull(enterpriseWithdrawal)){
                throw new RuntimeException("平台开户信息为空");
            }
            // 司机开户信息
            Driver driver = driverService.selectById(driverId);
            if(Objects.isNull(driver)){
                throw new RuntimeException("司机信息不存在");
            }
            // TODO 司机进件信息
            UserWithdrawal driverWith = userWithdrawalService.selectOne(new EntityWrapper<UserWithdrawal>()
                    .eq("phone", driver.getPhone())
                    .last("LIMIT 1"));
            if(Objects.isNull(driverWith)){
                throw new RuntimeException("司机开户信息为空");
            }
            AllocationReq allocationReq = new AllocationReq();
            allocationReq.setOutOrderNo(orderNum);
            allocationReq.setPayBalanceAcctId(driverWith.getBalanceAcctId()); // 发送方
            allocationReq.setRecvBalanceAcctId(enterpriseWithdrawal.getBalanceAcctId()); // 接收方
            BigDecimal multiply = new BigDecimal(100).multiply(BigDecimal.valueOf(amount));
            allocationReq.setAmount(multiply.intValue()); // 金额
            allocationReq.setPassword(Base64Util.decode(enterpriseWithdrawal.getTransactionAuthorizationCode())); // 密码
            allocationReq.setOrderNo(orderNum);
            allocationReq.setOrderAmount((long) multiply.intValue());
            allocationReq.setProductName("小件物流超时扣款");
            allocationReq.setProductCount(1);
            AllocationResp allocationResp = AllocationExample.create(allocationReq);
            System.err.println("小件物流超时扣款:"+allocationResp);
        }catch (UpyztException e){
            e.printStackTrace();
        }
    }
@@ -539,8 +484,8 @@
        orderLogistics.setArriveTime(date);
        orderLogistics.setStartServiceTime(date);
        orderLogistics.setBoardingTime(date);
        String value = redisUtil.getValue("DRIVER" + uid);
        String value = (String) redisTemplate.opsForValue().get("DRIVER" + uid);
        if(ToolUtil.isNotEmpty(value)){
            String[] split = value.split(",");
            Map<String, String> geocode1 = gdMapGeocodingUtil.geocode(split[0], split[1]);
@@ -550,9 +495,9 @@
        }
        //调用高德创建轨迹
        String s = gdFalconUtil.selectTerminal(driver.getPhone());
        String track = gdFalconUtil.createTrack(s);
        orderLogistics.setTrackId(track);
//        String s = gdFalconUtil.selectTerminal(driver.getPhone());
//        String track = gdFalconUtil.createTrack(s);
//        orderLogistics.setTrackId(track);
        //调用移动的小号接口 TODO 车载端使用真实号码
//        Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderTaxi.getStartLon().toString(), orderTaxi.getStartLat().toString());