puzhibing
2023-06-13 7860e5cb6db60aeb82c640651998f8294635df5b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package com.dsh.guns.modular.system.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsh.course.feignClient.activity.CompanyClient;
import com.dsh.course.feignClient.activity.model.CompanyInfoRes;
import com.dsh.course.mapper.CityMapper;
import com.dsh.course.mapper.TSystemPriceMapper;
import com.dsh.guns.config.UserExt;
import com.dsh.guns.modular.system.model.TOpenCity;
import com.dsh.guns.modular.system.model.TSystemPrice;
import com.dsh.guns.modular.system.model.TSystemPriceService;
import com.dsh.guns.modular.system.service.ITOpenCityService;
import com.dsh.guns.modular.system.service.ITSystemPriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
/**
 * <p>
 * 服务价格规则 服务实现类
 * </p>
 *
 * @author 吕雪
 * @since 2020-08-29
 */
@Service
public class TSystemPriceServiceImpl extends ServiceImpl<TSystemPriceMapper, TSystemPrice> implements ITSystemPriceService {
 
    @Resource
    private CompanyClient companyClient;
    @Resource
    private CityMapper cityMapper;
 
    @Autowired
    private ITOpenCityService openCityService;
 
 
 
    @Override
    public List<Map<String, Object>> getSpecialPriceList(Page<Map<String, Object>> page, Integer companyId, String name, Integer state) {
        Integer language = UserExt.getLanguage();
        List<Map<String, Object>> specialPriceList = this.baseMapper.getSpecialPriceList(page, companyId, name, state,language);
        for (Map<String, Object> stringObjectMap : specialPriceList) {
            Integer openCityId = (Integer)stringObjectMap.get("openCityId");
            TOpenCity openCity = openCityService.getBaseMapper().selectById(openCityId);
            if(null != openCity){
                if(language==1){
                    stringObjectMap.put("city", openCity.getChineseName());
                }else if(language==2){
                    stringObjectMap.put("city", openCity.getEnglishName());
                }else {
                    stringObjectMap.put("city", openCity.getIndonesianName());
                }
            }
        }
        return specialPriceList;
    }
 
    @Override
    public void saveService(Integer type, Integer openCityId, Integer type1,String json2,String code,Integer userId,String remark) {
        this.baseMapper.saveService(type, openCityId,type1, json2,code,userId,remark,UserExt.getUser().getObjectId());
    }
 
    @Override
    public List<Map<String, Object>> getServicePriceList(Page<Map<String, Object>> page ,String time, String company, String phone, String account, Integer state) {
        String sTime=null;
        String eTime=null;
        if(time !=null && !"".equals(time)){
            sTime=time.split(" - ")[0]+" 00:01";
            eTime=time.split(" - ")[1]+" 23:59";
        }
        List<Integer> cid =new ArrayList<>();
        List<Map<String, Object>> servicePriceList =null;
        if(company!=null && company!="") {
            cid = companyClient.queryIdByName(company);
            if(cid.size()==0){
                cid.add(-1);
            }
            servicePriceList = this.baseMapper.getServicePriceList1(page,sTime, eTime, company, phone, account, state,cid);
        }else {
 
            servicePriceList = this.baseMapper.getServicePriceList(page,sTime, eTime, company, phone, account, state);
        }
        for (Map<String, Object> stringObjectMap : servicePriceList) {
            Integer objectId = (Integer) stringObjectMap.get("objectId");
            if(objectId!=null){
                CompanyInfoRes companyInfoRes = companyClient.queryById(objectId);
                stringObjectMap.put("company",companyInfoRes.getName());
            }else {
                stringObjectMap.put("company","");
            }
            Integer openCityId =  (Integer) stringObjectMap.get("openCityId");
            TOpenCity openCity = openCityService.getBaseMapper().selectById(openCityId);
            if(null != openCity){
                if(UserExt.getLanguage()==1){
                    stringObjectMap.put("chineseName",openCity.getChineseName());
                }else if(UserExt.getLanguage()==2){
                    stringObjectMap.put("chineseName",openCity.getEnglishName());
                }else {
                    stringObjectMap.put("chineseName",openCity.getIndonesianName());
                }
            }
        }
 
        return servicePriceList ;
    }
 
    @Override
    public List<TSystemPriceService> getService(String tSystemPriceId) {
 
        return this.baseMapper.getService(tSystemPriceId);
    }
 
    @Override
    public void updateCheck(String id, Integer check) {
        this.baseMapper.updateCheck(id,check);
        if(check==2){
            List<TSystemPriceService> service = this.baseMapper.getService(id);
            if(service.get(0).getOrderType()==4){
 
                this.baseMapper.delete(new LambdaQueryWrapper<TSystemPrice>().eq(TSystemPrice::getOpenCityId, service.get(0).getOpenCityId()).eq(TSystemPrice::getUserType, service.get(0).getUserType()).eq(TSystemPrice::getCompanyId, service.get(0).getCompanyId()).eq(TSystemPrice::getOrderType, 4));
            }else {
                this.baseMapper.delete(new LambdaQueryWrapper<TSystemPrice>().eq(TSystemPrice::getOpenCityId, service.get(0).getOpenCityId()).eq(TSystemPrice::getUserType, service.get(0).getUserType()).eq(TSystemPrice::getCompanyId, service.get(0).getCompanyId()).eq(TSystemPrice::getOrderType, 4).eq(TSystemPrice::getServerCarModelId,service.get(0).getServerCarModelId()));
 
            }
            for (TSystemPriceService tSystemPriceService : service) {
                TSystemPrice tSystemPrice = new TSystemPrice();
                tSystemPrice.setCompanyId(tSystemPriceService.getCompanyId());
                tSystemPrice.setState(1);
                tSystemPrice.setType(tSystemPriceService.getType());
                tSystemPrice.setOrderType(tSystemPriceService.getOrderType());
                tSystemPrice.setUserType(tSystemPriceService.getUserType());
                tSystemPrice.setContent(tSystemPriceService.getContent());
                tSystemPrice.setCityId(tSystemPriceService.getCityId());
                tSystemPrice.setOpenCityId(tSystemPriceService.getOpenCityId());
                tSystemPrice.setServerCarModelId(tSystemPriceService.getServerCarModelId());
                this.baseMapper.insert(tSystemPrice);
            }
 
        }
    }
 
    @Override
    public void updateState(String tSystemPriceId) {
        this.baseMapper.updateCheck(tSystemPriceId,4);
 
    }
 
    @Override
    public void saveMotoService(Integer openCityId, Integer serverCarModelId, Integer type, String json1, Integer i,  String randomNumber,Integer userId) {
        this.baseMapper.saveMotoService(openCityId,serverCarModelId,type,json1,i,randomNumber,userId,UserExt.getUser().getObjectId());
    }
}