Pu Zhibing
2025-08-08 73963b4d040c1addd64193ed13ebd3795ff755f1
ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TSystemPriceController.java
@@ -1,5 +1,8 @@
package com.stylefeng.guns.modular.system.controller.specialTrain;
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
@@ -8,11 +11,12 @@
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.model.SystemPriceCity;
import com.stylefeng.guns.modular.system.model.TRegion;
import com.stylefeng.guns.modular.system.model.TServerCarmodel;
import com.stylefeng.guns.modular.system.model.TSystemPrice;
import com.stylefeng.guns.modular.system.service.ITServerCarmodelService;
import com.stylefeng.guns.modular.system.service.ITSystemPriceService;
import com.stylefeng.guns.modular.system.service.IUserService;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.PushMinistryOfTransportUtil;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import net.sf.json.JSONObject;
@@ -28,6 +32,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
@@ -52,19 +57,82 @@
    private PushMinistryOfTransportUtil pushMinistryOfTransportUtil;
    
    @Autowired
    private IUserService userService;
    @Resource
    private ITRegionService tRegionService;
    @Autowired
    private ShiroExtUtil shiroExtUtil;
    
    @Value("${pushMinistryOfTransport}")
    private boolean pushMinistryOfTransport;
    @Autowired
    private ISystemPriceCityService systemPriceCityService;
    /**
     * 跳转到列表页
     * @return
     */
    @RequestMapping("/showSystemPriceCity")
    public String showSystemPriceCity(){
        return PREFIX + "systemPriceCity.html";
    }
    /**
     * 跳转到添加价格
     * @return
     */
    @RequestMapping("/systemPriceCity_add")
    public String systemPriceCity_add(Model model){
        List<TServerCarmodel> tServerCarmodels = tServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 1).eq("state", 1));
        model.addAttribute("serverCarModelList", tServerCarmodels);
        List<TRegion> provinceList = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
        model.addAttribute("provinceList",provinceList);
        return PREFIX + "systemPriceCity_add.html";
    }
    /**
     * 跳转到修改价格城市
     * @return
     */
    @RequestMapping("/systemPriceCity_update")
    public String systemPriceCity_update(Integer id, Model model){
        SystemPriceCity systemPriceCity = systemPriceCityService.selectById(id);
        model.addAttribute("item", systemPriceCity);
        //省
        List<TRegion> provinceList = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
        model.addAttribute("provinceList",provinceList);
        //市
        TRegion code = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", systemPriceCity.getAreaCode()));
        List<TRegion> cityList = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", code.getId()));
        model.addAttribute("cityList",cityList);
        //区
        model.addAttribute("areaList", null);
        if(ToolUtil.isNotEmpty(systemPriceCity.getProvinceCode())){
            code = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", systemPriceCity.getCityCode()));
            List<TRegion> areaList = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", code.getId()));
            model.addAttribute("areaList",areaList);
        }
        List<TServerCarmodel> tServerCarmodels = tServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 1).eq("state", 1));
        List<TSystemPrice> tSystemPrices = tSystemPriceService.selectList(new EntityWrapper<TSystemPrice>().eq("systemPriceCityId", id).eq("state", 1).eq("type", 1));
        tServerCarmodels.forEach(s->{
            Optional<TSystemPrice> first = tSystemPrices.stream().filter(p -> p.getServerCarModelId().equals(s.getId())).findFirst();
            if(first.isPresent()){
                TSystemPrice tSystemPrice = first.get();
                s.setObject(Base64.encode(JSON.toJSONString(tSystemPrice)));
            }
        });
        model.addAttribute("serverCarModelList", tServerCarmodels);
        TSystemPrice systemPrice = tSystemPriceService.selectOne(new EntityWrapper<TSystemPrice>().eq("systemPriceCityId", id).eq("state", 1).eq("type", 2));
        model.addAttribute("zcPrice", Base64.encode(systemPrice.getContent()));
        return PREFIX + "systemPriceCity_edit.html";
    }
    
    
    /**
     * 跳转到快车价格设置首页
     */
    @RequestMapping("/special")
    public String index() {
    public String index(Integer id) {
        return PREFIX + "tSystemPrice.html";
    }
@@ -91,11 +159,10 @@
     @RequestMapping("/taxi")
    public String taxi(Model model) {
         Integer id = shiroExtUtil.getUser().getId();
         TSystemPrice one = tSystemPriceService.selectOne(new EntityWrapper<TSystemPrice>().eq("type", 2).eq("companyId", id));
         if (SinataUtil.isNotEmpty(one)) {
             JSONObject json1 = JSONObject.fromObject(one.getContent());
    public String taxi(String price, Model model) {
         if(ToolUtil.isNotEmpty(price)){
             price = Base64.decodeStr(price);
             JSONObject json1 = JSONObject.fromObject(price);
             model.addAttribute("json", json1);
         }
         return PREFIX + "taxiSet.html";
@@ -104,25 +171,39 @@
     * 跳转到添加快车价格设置
     */
    @RequestMapping("/tSystemPrice_add")
    public String tSystemPriceAdd(Model model) {
        //查询所有快车车型
        List<TSystemPrice> tSystemPrices = tSystemPriceService.selectList(new EntityWrapper<TSystemPrice>().eq("type", 1).eq("companyId", shiroExtUtil.getUser().getObjectId()).ne("state", 3));
        List<TServerCarmodel> modelList = tServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 1).eq("state", 1));
        List<TServerCarmodel> serverCarmodels = new ArrayList<>();
        for (TServerCarmodel tsc : modelList) {
            boolean b = true;
            for (TSystemPrice tsp : tSystemPrices) {
                if (tsc.getId() == tsp.getServerCarModelId()) {
                    b = false;
                    break;
                }
            }
            if (b) {
                serverCarmodels.add(tsc);
            }
    public String tSystemPriceAdd(Integer id, String price, Model model) {
        model.addAttribute("item", null);
        model.addAttribute("content", null);
        model.addAttribute("contentPutOne", null);
        model.addAttribute("contentNotOne", null);
        model.addAttribute("contentPutTwo", null);
        model.addAttribute("contentNotTwo", null);
        model.addAttribute("contentPutThree", null);
        model.addAttribute("contentNotThree", null);
        model.addAttribute("contentExclusive", null);
        model.addAttribute("contentPrice", null);
        if(ToolUtil.isNotEmpty(price)){
            String s = Base64.decodeStr(price);
            TSystemPrice tSystemPrice = JSON.parseObject(s, TSystemPrice.class);
            model.addAttribute("item",tSystemPrice);
            LogObjectHolder.me().set(tSystemPrice);
            JSONObject json = JSONObject.fromObject(tSystemPrice.getContent());
            model.addAttribute("content",json);
            model.addAttribute("contentPutOne", JSONObject.fromObject(tSystemPrice.getContentPutOne()));
            model.addAttribute("contentNotOne", JSONObject.fromObject(tSystemPrice.getContentNotOne()));
            model.addAttribute("contentPutTwo", JSONObject.fromObject(tSystemPrice.getContentPutTwo()));
            model.addAttribute("contentNotTwo", JSONObject.fromObject(tSystemPrice.getContentNotTwo()));
            model.addAttribute("contentPutThree", JSONObject.fromObject(tSystemPrice.getContentPutThree()));
            model.addAttribute("contentNotThree", JSONObject.fromObject(tSystemPrice.getContentNotThree()));
            model.addAttribute("contentExclusive", JSONObject.fromObject(tSystemPrice.getContentExclusive()));
            model.addAttribute("contentPrice", JSONObject.fromObject(tSystemPrice.getContentPrice()));
        }
        model.addAttribute("modelList",serverCarmodels);
        return PREFIX + "tSystemPrice_add.html";
        TServerCarmodel tServerCarmodel = tServerCarmodelService.selectById(id);
        model.addAttribute("modelList", tServerCarmodel);
        return PREFIX + "tSystemPrice_edit.html";
    }
    /**
@@ -167,7 +248,25 @@
        return PREFIX + "tSystemPrice_edit.html";
    }
    /**
     * 获取价格列表设置
     * @param name
     * @param time
     * @return
     */
    @RequestMapping(value = "/queryList")
    @ResponseBody
    public Object queryList(String condition, String insertTime){
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        page.setRecords(systemPriceCityService.queryList(page, condition, insertTime));
        return super.packForBT(page);
    }
    /**
     * 获取快车价格设置列表
     */
@@ -184,29 +283,58 @@
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(TSystemPrice tSystemPrice) {
        //判断当前公司是否添加过该快车车型价格配置
        int count = tSystemPriceService.selectCount(new EntityWrapper<TSystemPrice>()
                .eq("type", 1)
                .eq("serverCarModelId", tSystemPrice.getServerCarModelId())
                .eq("companyId", shiroExtUtil.getUser().getObjectId())
                .last(" and not FIND_IN_SET(state,'3')"));
        if (count > 0) {
            TServerCarmodel one = tServerCarmodelService.selectById(tSystemPrice.getServerCarModelId());
            return new ErrorTip(500, "【" + one.getName() + "】已存在,请重新选择");
    public Object add(SystemPriceCity systemPriceCity, String zcPrice, String czcPrice) {
        if(ToolUtil.isNotEmpty(systemPriceCity.getProvinceCode())){
            TRegion tRegion = tRegionService.selectById(systemPriceCity.getProvinceCode());
            systemPriceCity.setProvinceCode(tRegion.getCode());
        }
        tSystemPrice.setCompanyId(shiroExtUtil.getUser().getObjectId());
        tSystemPrice.setType(1);
        if(ToolUtil.isNotEmpty(systemPriceCity.getCityCode())){
            TRegion tRegion = tRegionService.selectById(systemPriceCity.getCityCode());
            systemPriceCity.setCityCode(tRegion.getCode());
        }
        if(ToolUtil.isNotEmpty(systemPriceCity.getAreaCode())){
            TRegion tRegion = tRegionService.selectById(systemPriceCity.getAreaCode());
            systemPriceCity.setAreaCode(tRegion.getCode());
        }
        SystemPriceCity one = null;
        if(null != systemPriceCity.getProvinceCode()){
            one = systemPriceCityService.selectOne(new EntityWrapper<SystemPriceCity>().eq("areaCode", systemPriceCity.getAreaCode())
                    .eq("cityCode", systemPriceCity.getCityCode()).eq("provinceCode", systemPriceCity.getProvinceCode()).ne("flag", 3));
        }
        if(null == one){
            one = systemPriceCityService.selectOne(new EntityWrapper<SystemPriceCity>().eq("areaCode", systemPriceCity.getAreaCode())
                    .eq("cityCode", systemPriceCity.getCityCode()).ne("flag", 3));
            if(null == one){
                one = systemPriceCityService.selectOne(new EntityWrapper<SystemPriceCity>().eq("areaCode", systemPriceCity.getAreaCode())
                        .ne("flag", 3));
                if(null != one){
                    return new ErrorTip(500, "不能重复添加城市");
                }
            }else{
                return new ErrorTip(500, "不能重复添加城市");
            }
        }else{
            return new ErrorTip(500, "不能重复添加城市");
        }
        systemPriceCityService.insert(systemPriceCity);
        //解析专车的价格配置
        JSONArray jsonArray = JSON.parseArray(zcPrice);
        for (int i = 0; i < jsonArray.size(); i++) {
            TSystemPrice tSystemPrice = jsonArray.getObject(i, TSystemPrice.class);
            tSystemPrice.setSystemPriceCityId(systemPriceCity.getId());
            tSystemPrice.setType(1);
            tSystemPrice.setState(1);
            tSystemPriceService.insert(tSystemPrice);
        }
        //解析出出租车价格设置
        TSystemPrice tSystemPrice = new TSystemPrice();
        tSystemPrice.setContent(czcPrice);
        tSystemPrice.setSystemPriceCityId(systemPriceCity.getId());
        tSystemPrice.setType(2);
        tSystemPrice.setState(1);
        tSystemPriceService.insert(tSystemPrice);
        new Thread(new Runnable() {
            @Override
            public void run() {
                if (pushMinistryOfTransport) {//上传数据
                    pushMinistryOfTransportUtil.baseInfoCompanyFare(tSystemPrice.getId());
                }
            }
        }).start();
        return SUCCESS_TIP;
    }
@@ -219,7 +347,6 @@
            TSystemPrice tSystemPrice = new TSystemPrice();
            tSystemPrice.setContent(content);
            tSystemPrice.setType(2);
            tSystemPrice.setCompanyId(id);
            tSystemPriceService.insert(tSystemPrice);
        } else {
            tSystemPrice1.setContent(content);
@@ -234,29 +361,60 @@
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TSystemPrice tSystemPrice) {
        TSystemPrice obj = tSystemPriceService.selectById(tSystemPrice.getId());
        if (obj.getServerCarModelId() != tSystemPrice.getServerCarModelId()){
            //判断当前公司是否添加过该快车车型价格配置
            int count = tSystemPriceService.selectCount(new EntityWrapper<TSystemPrice>()
                    .eq("type", 1)
                    .eq("serverCarModelId", tSystemPrice.getServerCarModelId())
                    .eq("companyId", shiroExtUtil.getUser().getObjectId())
                    .last(" and not FIND_IN_SET(state,'3')"));
            if (count > 0){
                TServerCarmodel one = tServerCarmodelService.selectById(tSystemPrice.getServerCarModelId());
                return new ErrorTip(500, "【"+one.getName()+"】已存在,请重新选择");
            }
    public Object update(SystemPriceCity systemPriceCity, String zcPrice, String czcPrice) {
        if(ToolUtil.isNotEmpty(systemPriceCity.getProvinceCode())){
            TRegion tRegion = tRegionService.selectById(systemPriceCity.getProvinceCode());
            systemPriceCity.setProvinceCode(tRegion.getCode());
        }
        tSystemPriceService.updateById(tSystemPrice);
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(pushMinistryOfTransport) {//上传数据
                    pushMinistryOfTransportUtil.baseInfoCompanyFare(tSystemPrice.getId());
        if(ToolUtil.isNotEmpty(systemPriceCity.getCityCode())){
            TRegion tRegion = tRegionService.selectById(systemPriceCity.getCityCode());
            systemPriceCity.setCityCode(tRegion.getCode());
        }
        if(ToolUtil.isNotEmpty(systemPriceCity.getAreaCode())){
            TRegion tRegion = tRegionService.selectById(systemPriceCity.getAreaCode());
            systemPriceCity.setAreaCode(tRegion.getCode());
        }
        SystemPriceCity one = null;
        if(null != systemPriceCity.getProvinceCode()){
            one = systemPriceCityService.selectOne(new EntityWrapper<SystemPriceCity>().eq("areaCode", systemPriceCity.getAreaCode())
                    .eq("cityCode", systemPriceCity.getCityCode()).eq("provinceCode", systemPriceCity.getProvinceCode()).ne("flag", 3));
        }
        if(null == one){
            one = systemPriceCityService.selectOne(new EntityWrapper<SystemPriceCity>().eq("areaCode", systemPriceCity.getAreaCode())
                    .eq("cityCode", systemPriceCity.getCityCode()).ne("flag", 3));
            if(null == one){
                one = systemPriceCityService.selectOne(new EntityWrapper<SystemPriceCity>().eq("areaCode", systemPriceCity.getAreaCode())
                        .ne("flag", 3));
                if(null != one && !systemPriceCity.getId().equals(one.getId())){
                    return new ErrorTip(500, "不能重复添加城市");
                }
            }else if(!systemPriceCity.getId().equals(one.getId())){
                return new ErrorTip(500, "不能重复添加城市");
            }
        }).start();
        }else if(!systemPriceCity.getId().equals(one.getId())){
            return new ErrorTip(500, "不能重复添加城市");
        }
        systemPriceCityService.updateById(systemPriceCity);
        //删除历史数据
        tSystemPriceService.delete(new EntityWrapper<TSystemPrice>().eq("systemPriceCityId", systemPriceCity.getId()));
        //解析专车的价格配置
        JSONArray jsonArray = JSON.parseArray(zcPrice);
        for (int i = 0; i < jsonArray.size(); i++) {
            TSystemPrice tSystemPrice = jsonArray.getObject(i, TSystemPrice.class);
            tSystemPrice.setSystemPriceCityId(systemPriceCity.getId());
            tSystemPrice.setType(1);
            tSystemPrice.setState(1);
            tSystemPriceService.insert(tSystemPrice);
        }
        //解析出出租车价格设置
        TSystemPrice tSystemPrice = new TSystemPrice();
        tSystemPrice.setContent(czcPrice);
        tSystemPrice.setSystemPriceCityId(systemPriceCity.getId());
        tSystemPrice.setType(2);
        tSystemPrice.setState(1);
        tSystemPriceService.insert(tSystemPrice);
        return SUCCESS_TIP;
    }
@@ -265,16 +423,10 @@
     */
    @RequestMapping(value = "/opt")
    @ResponseBody
    public Object opt(Integer optType,Integer tSystemPriceId) {
        TSystemPrice systemPrice = new TSystemPrice();
        if (1 == optType){  //冻结
            systemPrice.setState(2);
        }else if (2 == optType){  //解冻
            systemPrice.setState(1);
        }else if (3 == optType){  //删除
            systemPrice.setState(3);
        }
        tSystemPriceService.update(systemPrice,new EntityWrapper<TSystemPrice>().eq("id",tSystemPriceId));
    public Object opt(Integer id) {
        SystemPriceCity systemPriceCity = systemPriceCityService.selectById(id);
        systemPriceCity.setFlag(3);
        systemPriceCityService.updateById(systemPriceCity);
        return SUCCESS_TIP;
    }
@@ -293,7 +445,6 @@
            one = new TSystemPrice();
            one.setState(1);
            one.setType(5);
            one.setCompanyId(shiroExtUtil.getUser().getObjectId());
            one.setContent(json1);
            tSystemPriceService.insert(one);
        }
@@ -306,7 +457,6 @@
            two = new TSystemPrice();
            two.setState(1);
            two.setType(4);
            two.setCompanyId(shiroExtUtil.getUser().getObjectId());
            two.setContent(json2);
            tSystemPriceService.insert(two);
        }