Helius
2021-08-05 fdb91cc72f7cbe8c095a1ce6442c9259ff01ff06
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
package com.xzx.gc.user.controller;
 
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.xzx.gc.common.Result;
import com.xzx.gc.common.constant.CommonEnum;
import com.xzx.gc.common.constant.Constants;
import com.xzx.gc.common.dto.log.OperationAppLog;
import com.xzx.gc.common.request.BaseController;
import com.xzx.gc.entity.*;
import com.xzx.gc.model.JsonResult;
import com.xzx.gc.model.order.AreaDto;
import com.xzx.gc.model.order.SysConfigDto;
import com.xzx.gc.model.query.SettingMoneyQuery;
import com.xzx.gc.user.mapper.ConfigMapper;
import com.xzx.gc.user.mapper.FenceMapper;
import com.xzx.gc.user.service.*;
import com.xzx.gc.util.PreventManyCommit;
import com.xzx.gc.util.SessionUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * @author:andylei
 * @title
 * @Description
 * @date 2018/11/22/022
 * @修改历史
 */
@Api(tags = "合伙人区域管理")
@RestController
public class PartnerGaodeController extends BaseController {
 
 
    @Autowired
    private SessionUtil sessionUtil;
 
    @Autowired
    private CityPartnerService cityPartnerService;
 
    @Autowired
    private OtherUserService otherUserService;
    @Autowired
    private PartnerGaodeService partnerGaodeService;
    @Autowired
    private AddressLevelService addressLevelService;
 
 
    @PostMapping("/admin/front/partnerGaode/queryPartnerCityById.json")
    @ApiOperation(value="账户管理优化(查询回收人所属城市)", notes="test: 仅0有正确返回")
    public JsonResult<Map<String,Object>> queryPartnerCityById(){
        CoreUser currentUser = sessionUtil.getCurrentUser();
        CityPartner partner = cityPartnerService.queryById(currentUser.getId());
        List<Map<String,String>> list = cityPartnerService.queryPartnerCityById(partner);
        Map<String,Object> map = new HashMap<>();
        map.put("data",list);
        map.put("code",0);
        return JsonResult.success(map);
    }
 
    @PostMapping( "/admin/front/partnerGaode/queryAreaObj.json")
    @ApiOperation(value="账户管理优化(查询回收人所属城市)", notes="test: 仅0有正确返回")
    public JsonResult<Map<String,Object>> queryAreaObj(){
        CoreUser currentUser = sessionUtil.getCurrentUser();
        CityPartner partner = cityPartnerService.queryById(currentUser.getId());
        List<Map<String,Object>> list = cityPartnerService.queryAreaObj(partner);
        Map<String,Object> map = new HashMap<>();
        map.put("data",list);
        map.put("code",0);
        return JsonResult.success(map);
    }
 
    @ApiOperation(value = "查看合伙人所属的区域",notes = "可能是市或者区")
    @PostMapping(value = "/partnerGaode/selectArea")
    public Result<List<AreaDto>> selectArea(HttpServletRequest request){
 
        List<AreaDto> list=new ArrayList();
        OtherUserInfo byId = otherUserService.findById(getUserId(request));
        String partnerId = byId.getPartnerId();
 
        if(StrUtil.isBlank(partnerId)){
            return Result.error(-1,"当前用户没分配合伙人");
        }
 
        List<PartnerGaode> byPartnerId = partnerGaodeService.findByPartnerId(partnerId);
 
        if(CollUtil.isNotEmpty(byPartnerId)){
            String townIds=byPartnerId.stream().map(x->x.getTownId()).collect(Collectors.joining(","));
            //按多个区域对应
            List<AddressLevelInfo> byTownIds = addressLevelService.findByTownIds(townIds);
            for (AddressLevelInfo byTownId : byTownIds) {
                AreaDto areaDto=new AreaDto();
                areaDto.setAreaName(byTownId.getLevel3Name());
                areaDto.setAreaId(byTownId.getLevel3Id());
                areaDto.setLevel(3);
                list.add(areaDto);
            }
 
        }
        return Result.success(list);
 
 
    }
 
}