Pu Zhibing
3 天以前 25cf266e99714ac5d428e66b40ce272325c91dd8
ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TReassignController.java
@@ -3,15 +3,12 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.beetl.ShiroExtUtil;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.core.shiro.ShiroUser;
import com.stylefeng.guns.core.util.ExcelUtil;
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.system.controller.util.Base64Util;
import com.stylefeng.guns.modular.system.dao.LineShiftDriverMapper;
import com.stylefeng.guns.modular.system.dao.OrderCancelMapper;
import com.stylefeng.guns.modular.system.model.*;
@@ -19,18 +16,15 @@
import com.stylefeng.guns.modular.system.util.HttpRequestUtil;
import com.stylefeng.guns.modular.system.util.PushURL;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.resp.AllocationResp;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
@@ -38,7 +32,10 @@
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 快车改派管理控制器
@@ -205,11 +202,11 @@
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        //page.setRecords(tReassignService.getPrivateCarReassignOrderList(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state));
        List<Map<String,Object>> list = tReassignService.getPrivateCarReassignOrderList(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state);
        if(!list.isEmpty()){
            Map<String,Object> map = new HashMap<>();
            map.put("insertTime","改派金额合计");
            map.put("money",tReassignService.getPrivateCarReassignOrderListMoney(ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state));
        List<Map<String, Object>> list = tReassignService.getPrivateCarReassignOrderList(page, ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, originalDriverName, originalDriverPhone, orderNum, nowDriverName, nowDriverPhone, orderState, state);
        if(!list.isEmpty()) {
            Map<String, Object> map = new HashMap<>();
            map.put("insertTime", "改派金额合计");
            map.put("money", tReassignService.getPrivateCarReassignOrderListMoney(ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, originalDriverName, originalDriverPhone, orderNum, nowDriverName, nowDriverPhone, orderState, state));
            list.add(map);
        }
        page.setRecords(list);
@@ -241,7 +238,7 @@
                beginTime = timeArray[0];
                endTime = timeArray[1];
            }
            List<Map<String,Object>> mapList = tReassignService.getPrivateCarReassignOrderListEx(ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state);
            List<Map<String, Object>> mapList = tReassignService.getPrivateCarReassignOrderListEx(ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, originalDriverName, originalDriverPhone, orderNum, nowDriverName, nowDriverPhone, orderState, state);
            String[][] values = new String[mapList.size()][];
            for (int i = 0; i < mapList.size(); i++) {
@@ -313,11 +310,11 @@
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        //page.setRecords(tReassignService.getCrossReassignOrderList(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state));
        List<Map<String,Object>> list = tReassignService.getCrossReassignOrderList(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state);
        List<Map<String, Object>> list = tReassignService.getCrossReassignOrderList(page, ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, originalDriverName, originalDriverPhone, orderNum, nowDriverName, nowDriverPhone, orderState, state);
        if(!list.isEmpty()){
            Map<String,Object> map = new HashMap<>();
            map.put("insertTime","改派金额合计");
            map.put("money",tReassignService.getCrossReassignOrderListMoney(ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state));
            map.put("insertTime", "改派金额合计");
            map.put("money", tReassignService.getCrossReassignOrderListMoney(ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, originalDriverName, originalDriverPhone, orderNum, nowDriverName, nowDriverPhone, orderState, state));
            list.add(map);
        }
        page.setRecords(list);
@@ -349,7 +346,7 @@
                beginTime = timeArray[0];
                endTime = timeArray[1];
            }
            List<Map<String,Object>> mapList = tReassignService.getCrossReassignOrderListEx(ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state);
            List<Map<String, Object>> mapList = tReassignService.getCrossReassignOrderListEx(ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, originalDriverName, originalDriverPhone, orderNum, nowDriverName, nowDriverPhone, orderState, state);
            String[][] values = new String[mapList.size()][];
            for (int i = 0; i < mapList.size(); i++) {
@@ -421,11 +418,11 @@
            endTime = timeArray[1];
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        List<Map<String,Object>> list = tReassignService.getSmallPieceLogisticsList(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state);
        List<Map<String, Object>> list = tReassignService.getSmallPieceLogisticsList(page, ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, originalDriverName, originalDriverPhone, orderNum, nowDriverName, nowDriverPhone, orderState, state);
        if(!list.isEmpty()){
            Map<String,Object> map = new HashMap<>();
            map.put("insertTime","改派金额合计");
            map.put("money",tReassignService.getSmallPieceLogisticsListMoney(ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state));
            map.put("insertTime", "改派金额合计");
            map.put("money", tReassignService.getSmallPieceLogisticsListMoney(ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, originalDriverName, originalDriverPhone, orderNum, nowDriverName, nowDriverPhone, orderState, state));
            list.add(map);
        }
        page.setRecords(list);
@@ -458,7 +455,7 @@
                beginTime = timeArray[0];
                endTime = timeArray[1];
            }
            List<Map<String,Object>> mapList = tReassignService.getSmallPieceLogisticsListEx(ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state);
            List<Map<String, Object>> mapList = tReassignService.getSmallPieceLogisticsListEx(ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, originalDriverName, originalDriverPhone, orderNum, nowDriverName, nowDriverPhone, orderState, state);
            String[][] values = new String[mapList.size()][];
            for (int i = 0; i < mapList.size(); i++) {
@@ -530,11 +527,11 @@
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        //page.setRecords(tReassignService.getTaxiReassignOrderList(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state));
        List<Map<String,Object>> list = tReassignService.getTaxiReassignOrderList(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state);
        List<Map<String, Object>> list = tReassignService.getTaxiReassignOrderList(page, ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, originalDriverName, originalDriverPhone, orderNum, nowDriverName, nowDriverPhone, orderState, state);
        if(!list.isEmpty()){
            Map<String,Object> map = new HashMap<>();
            map.put("insertTime","改派金额合计");
            map.put("money",tReassignService.getTaxiReassignOrderListMoney(ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state));
            map.put("insertTime", "改派金额合计");
            map.put("money", tReassignService.getTaxiReassignOrderListMoney(ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, originalDriverName, originalDriverPhone, orderNum, nowDriverName, nowDriverPhone, orderState, state));
            list.add(map);
        }
        page.setRecords(list);
@@ -566,7 +563,7 @@
                beginTime = timeArray[0];
                endTime = timeArray[1];
            }
            List<Map<String,Object>> mapList = tReassignService.getTaxiReassignOrderListEx(ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,originalDriverName,originalDriverPhone,orderNum,nowDriverName,nowDriverPhone,orderState,state);
            List<Map<String, Object>> mapList = tReassignService.getTaxiReassignOrderListEx(ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, originalDriverName, originalDriverPhone, orderNum, nowDriverName, nowDriverPhone, orderState, state);
            String[][] values = new String[mapList.size()][];
            for (int i = 0; i < mapList.size(); i++) {
@@ -689,17 +686,10 @@
    @RequestMapping(value = "/opt")
    @ResponseBody
    public Object opt(@RequestParam Integer tReassignId,@RequestParam Integer optType) {
        ShiroUser user = ShiroKit.getUser();
        ShiroUser user = ShiroExtUtil.getUser();
        TReassign tReassign = tReassignService.selectById(tReassignId);
        if (1 == optType){
            Integer originalDriverId = tReassign.getOriginalDriverId();
            String allocationReq = createAllocationReq(1, originalDriverId, 1, tReassign.getMoney());
            if("error".equals(allocationReq)){
                return ResultUtil.error("该司机未进件");
            }
            if(!"ok".equals(allocationReq)){
                return ResultUtil.error(allocationReq);
            }
            TDriver driver = itDriverService.selectById(originalDriverId);
            driver.setBalance(driver.getBalance().add(new BigDecimal(tReassign.getMoney())));
@@ -768,43 +758,6 @@
    private ITEnterpriseWithdrawalService tEnterpriseWithdrawalService;
    @Autowired
    private IUserWithdrawalService userWithdrawalService;
    public String createAllocationReq(Integer companyId,Integer userId,int type,double money){
        List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId));
        TDriver tUser = itDriverService.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));
        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();
        }
    }
    @Autowired
    private ITPubTransactionDetailsService itPubTransactionDetailsService;
@@ -818,18 +771,11 @@
    public Object optCross(@RequestParam Integer tReassignId,@RequestParam Integer optType) {
        try {
            TReassign tReassign = tReassignService.selectById(tReassignId);
            ShiroUser user = ShiroKit.getUser();
            ShiroUser user = ShiroExtUtil.getUser();
            if (1 == optType){
                Integer originalDriverId = tReassign.getOriginalDriverId();
                String allocationReq = createAllocationReq(1, originalDriverId, 1, tReassign.getMoney());
                if("error".equals(allocationReq)){
                    return ResultUtil.error("该司机未进件");
                }
                if(!"ok".equals(allocationReq)){
                    return ResultUtil.error(allocationReq);
                }
                TDriver driver = itDriverService.selectById(originalDriverId);
                driver.setBalance(driver.getBalance().add(new BigDecimal(tReassign.getMoney())));
@@ -988,17 +934,10 @@
    @ResponseBody
    public Object optSmall(@RequestParam Integer tReassignId,@RequestParam Integer optType) {
        try {
            ShiroUser user = ShiroKit.getUser();
            ShiroUser user = ShiroExtUtil.getUser();
            TReassign tReassign = tReassignService.selectById(tReassignId);
            if (1 == optType){
                Integer originalDriverId = tReassign.getOriginalDriverId();
                String allocationReq = createAllocationReq(1, originalDriverId, 1, tReassign.getMoney());
                if("error".equals(allocationReq)){
                    return ResultUtil.error("该司机未进件");
                }
                if(!"ok".equals(allocationReq)){
                    return ResultUtil.error(allocationReq);
                }
                TDriver driver = itDriverService.selectById(originalDriverId);
                driver.setBalance(driver.getBalance().add(new BigDecimal(tReassign.getMoney())));
@@ -1124,18 +1063,11 @@
    @RequestMapping(value = "/optTaxi")
    @ResponseBody
    public Object optTaxi(@RequestParam Integer tReassignId,@RequestParam Integer optType) {
        ShiroUser user = ShiroKit.getUser();
        ShiroUser user = ShiroExtUtil.getUser();
        TReassign tReassign = tReassignService.selectById(tReassignId);
        if (1 == optType){
            Integer originalDriverId = tReassign.getOriginalDriverId();
            String allocationReq = createAllocationReq(1, originalDriverId, 1, tReassign.getMoney());
            if("error".equals(allocationReq)){
                return ResultUtil.error("该司机未进件");
            }
            if(!"ok".equals(allocationReq)){
                return ResultUtil.error(allocationReq);
            }
            TDriver driver = itDriverService.selectById(originalDriverId);
            driver.setBalance(driver.getBalance().add(new BigDecimal(tReassign.getMoney())));