44323
2023-11-27 aa925d851857f50eff0556411366690d9a78a0e5
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package com.dsh.other.service.impl;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsh.other.entity.OperatorUser;
import com.dsh.other.entity.Store;
import com.dsh.other.mapper.StoreMapper;
import com.dsh.other.model.BaseVo;
import com.dsh.other.model.ProvinceAndCityVo;
import com.dsh.other.model.dto.siteDto.StoreInfoDto;
import com.dsh.other.service.StoreService;
import com.dsh.other.util.GDMapGeocodingUtil;
import com.dsh.other.util.ToolUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
/**
 * <p>
 * 门店信息 服务实现类
 * </p>
 *
 * @author jqs
 * @since 2023-06-14
 */
@Service
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements StoreService {
 
    @Autowired
    private StoreMapper storeMapper;
    @Autowired
    private GDMapGeocodingUtil gdMapGeocodingUtil;
 
 
    /**
     * 根据城市管理员id获取门店集合
     *
     * @param id
     * @return
     */
    @Override
    public List<Store> getStoreByCityManagerId(Integer id) {
        return storeMapper.getStoreByCityManagerId(id);
    }
 
    /**
     * 根据门店员工id获取门店集合
     *
     * @param id
     * @return
     */
    @Override
    public List<Store> getStoreByStoreStaffId(Integer id) {
        return storeMapper.getStoreByStoreStaffId(id);
    }
 
    @Override
    public String getOName(Integer operatorId) {
 
        return this.baseMapper.getOName(operatorId);
    }
 
    @Override
    public List<Map<String, Object>> game(Integer appUserId) {
        return this.baseMapper.game(appUserId);
    }
 
    @Override
    public OperatorUser queryByStoreId(Integer id) {
        return this.baseMapper.queryByStoreId(id);
    }
 
    @Override
    public StoreInfoDto getStoreInfo(Integer id) {
        return this.baseMapper.getStoreInfo(id);
    }
 
 
    /**
     * 获取列表数据
     *
     * @param provinceCode
     * @param cityCode
     * @return
     * @throws Exception
     */
    @Override
    public List<Store> queryStorsList(String provinceCode, String cityCode) throws Exception {
        QueryWrapper objectQueryWrapper = new QueryWrapper<Store>().eq("state", 1);
        if (ToolUtil.isNotEmpty(provinceCode)) {
            objectQueryWrapper.eq("provinceCode", provinceCode);
        }
        if (ToolUtil.isNotEmpty(cityCode)) {
            objectQueryWrapper.eq("cityCode", cityCode);
        }
        List<Store> list = this.list(objectQueryWrapper);
        return list;
    }
 
 
    /**
     * 获取列表数据
     *
     * @param lon
     * @param lat
     * @return
     * @throws Exception
     */
    @Override
    public List<BaseVo> queryStoreLists(String lon, String lat, String cityCode) throws Exception {
        List<BaseVo> list = new ArrayList<>();
        if (ToolUtil.isEmpty(lon) || ToolUtil.isEmpty(lat)) {
            return list;
        }
        if (ToolUtil.isNotEmpty(cityCode)) {
            List<Store> stores = this.queryStorsList(null, cityCode);
            for (Store store : stores) {
                BaseVo baseVo = new BaseVo();
                BeanUtils.copyProperties(store, baseVo);
                list.add(baseVo);
            }
        } else {
            Map<String, String> geocode = gdMapGeocodingUtil.geocode(lon, lat);
            if (null != geocode) {
                String provinceCode = geocode.get("provinceCode");
                String cityCode1 = geocode.get("cityCode");
 
                List<Store> stores = this.queryStorsList(provinceCode, cityCode1);
                for (Store store : stores) {
                    BaseVo baseVo = new BaseVo();
                    BeanUtils.copyProperties(store, baseVo);
                    list.add(baseVo);
                }
            }
        }
        return list;
    }
 
 
    /**
     * 获取开通省市
     *
     * @param pcode
     * @return
     * @throws Exception
     */
    @Override
    public List<ProvinceAndCityVo> queryProvinceAndCity(String pcode) throws Exception {
        if (ToolUtil.isEmpty(pcode)) {
            return this.baseMapper.queryProvince();
        }
        if (ToolUtil.isNotEmpty(pcode)) {
            return this.baseMapper.queryCity(pcode);
        }
        return null;
    }
 
 
    /**
     * 获取所有开通城市
     *
     * @return
     * @throws Exception
     */
    @Override
    public List<ProvinceAndCityVo> queryAllCity() throws Exception {
        return this.baseMapper.queryCity(null);
    }
 
 
    /**
     * 根据城市code获取城市列表
     *
     * @param cityCode
     * @return
     * @throws Exception
     */
    @Override
    public List<BaseVo> queryStoreByCityCode(String provinceCode, String cityCode) throws Exception {
        return this.baseMapper.queryStoreByCityCode(provinceCode, cityCode);
    }
 
 
}