无关风月
2025-04-03 f4744cf0f465478f06a9ebbc2e4966bf096a06e2
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
package com.dsh.other.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.other.entity.HomeModule;
import com.dsh.other.entity.StoreConfig;
import com.dsh.other.feignclient.communityWorldCup.WorldCupClient;
import com.dsh.other.feignclient.communityWorldCup.WorldCupStoreClient;
import com.dsh.other.feignclient.communityWorldCup.model.WorldCup;
import com.dsh.other.feignclient.communityWorldCup.model.WorldCupStore;
import com.dsh.other.model.StoreConfigVo;
import com.dsh.other.service.IHomeModuleService;
import com.dsh.other.service.StoreConfigService;
import com.dsh.other.util.ResultUtil;
import com.dsh.other.util.ToolUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * @author zhibing.pu
 * @date 2023/6/24 16:11
 */
@RestController
@RequestMapping("")
public class StoreConfigController {
 
    @Autowired
    private StoreConfigService storeConfigService;
 
    @Autowired
    private IHomeModuleService homeModuleService;
 
    @Resource
    private WorldCupStoreClient worldCupStoreClient;
 
    @Resource
    private WorldCupClient worldCupClient;
 
 
 
 
 
 
    @ResponseBody
    @PostMapping("/base/store/queryStoreConfig")
    @ApiOperation(value = "获取门店模块配置【2.0】", tags = {"APP-加入玩湃"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "门店id", name = "storeId", dataType = "int", required = true),
    })
    public ResultUtil<List<StoreConfigVo>> queryStoreConfig(Integer storeId) {
        if (null == storeId) {
            return ResultUtil.paranErr("storeId");
        }
        try {
            List<StoreConfig> list = storeConfigService.list(new QueryWrapper<StoreConfig>().eq("storeId", storeId)
                    .orderByAsc("sort").eq("isOpen", 1));
            HomeModule homeModule = homeModuleService.getOne(new QueryWrapper<HomeModule>().eq("isOpen", 1));
            List<StoreConfigVo> listVo = new ArrayList<>();
            if(null != homeModule){
                StoreConfigVo vo = new StoreConfigVo();
                vo.setType(0);
                vo.setIsOpen(homeModule.getIsOpen());
                vo.setIsTop(homeModule.getIsTop());
                vo.setSort(homeModule.getSort());
                vo.setBackgroundImage(homeModule.getBackgroundImage());
                vo.setDisplayType(homeModule.getDisplayType());
                listVo.add(vo);
            }
            for (StoreConfig storeConfig : list) {
                StoreConfigVo storeConfigVo = new StoreConfigVo();
                storeConfigVo.setIsTop(0);
                BeanUtils.copyProperties(storeConfig, storeConfigVo);
                if (!StringUtils.hasLength(storeConfig.getBackgroundImage())) {
                    switch (storeConfigVo.getType()) {
                        case 1: {
                            storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/8b7073a4d33d4eea9f0d173cb4db92a7.png");
                            break;
                        }
                        case 2: {
                            storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/f60f1622ae184475ad703ec60bbcbeff.png");
                            break;
                        }
                        case 3: {
                            storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/08c5eca72fca4d479d21905d25870ef8.png");
                            break;
                        }
                        case 4: {
                            storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/8602be35e6cf4f76819b7b2d7b588efc.png");
                            break;
                        }
                        case 5: {
                            storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/694f84a1e2ba4d2c919f4f4ffaadece2.png");
                            break;
                        }
                        case 6: {
                            storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/81a83d229fea46a78be6a3ec1d5b7d6e.png");
                            break;
                        }
                        case 7: {
                            storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/312763e7565c48f2a16021c162c76018.png");
                            break;
                        }
                        case 8: {
                            storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/0771fb3bd4de43c08492d0912209e51f.png");
                            break;
                        }
 
                    }
                }
 
                listVo.add(storeConfigVo);
            }
 
            List<WorldCupStore> worldCupStoreList = worldCupStoreClient.getWorldCupStoreList(storeId);
            for (WorldCupStore worldCupStore : worldCupStoreList) {
                WorldCup worldCup = worldCupClient.getWorldCup(worldCupStore.getWorldCupId());
                StoreConfigVo storeConfigVo = new StoreConfigVo();
                storeConfigVo.setIsTop(0);
                storeConfigVo.setId(worldCupStore.getWorldCupId());
                storeConfigVo.setBackgroundImage(ToolUtil.isNotEmpty(worldCupStore.getBackgroundImage()) ? worldCupStore.getBackgroundImage() : worldCup.getHomeBackdropImg());
                storeConfigVo.setType(9);
                storeConfigVo.setIsOpen(worldCupStore.getIsOpen());
                storeConfigVo.setDisplayType(worldCupStore.getDisplayType());
                storeConfigVo.setSort(worldCupStore.getSort());
                listVo.add(storeConfigVo);
            }
 
 
            //排序
            Collections.sort(listVo, new Comparator<StoreConfigVo>() {
                @Override
                public int compare(StoreConfigVo o1, StoreConfigVo o2) {
                    return o1.getSort().compareTo(o2.getSort());
                }
            });
            //排序
            Collections.sort(listVo, new Comparator<StoreConfigVo>() {
                @Override
                public int compare(StoreConfigVo o1, StoreConfigVo o2) {
                    return o1.getIsTop().compareTo(o2.getIsTop()) * -1;
                }
            });
            for (int i = 0; i < listVo.size(); i++) {
                listVo.get(i).setSort(i + 1);
            }
            return ResultUtil.success(listVo);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
 
 
 
 
}