puzhibing
2024-01-24 8da101629c47cec91d68f785b0f5e829d4a9bab1
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
package com.ruoyi.shop.controller.management;
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.shop.domain.dto.*;
import com.ruoyi.shop.domain.pojo.shop.BankBranchCode;
import com.ruoyi.shop.domain.vo.*;
import com.ruoyi.shop.service.shop.*;
import com.ruoyi.system.api.domain.dto.MgtBaseGetDto;
import com.ruoyi.system.api.domain.poji.shop.Shop;
import com.ruoyi.system.api.domain.poji.sys.SysUser;
import com.ruoyi.system.api.domain.vo.MgtSimpleShopVo;
import com.ruoyi.system.api.service.RemoteUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * @author jqs34
 * @ClassName ShopController
 * @description: TODO
 * @date 2023年04月21日
 * @version: 1.0
 */
@Api(value = "管理台商户相关接口", tags = "管理台商户相关接口", description = "管理台商户相关接口")
@RestController
@RequestMapping("/mgt/shop")
public class MgtShopController {
 
    Logger logger = LoggerFactory.getLogger(MgtShopController.class);
 
    @Resource
    private ShopService shopService;
 
    @Resource
    private ShopRelTagService shopRelTagService;
 
    @Resource
    private ShopProportionService shopProportionService;
 
    @Resource
    private ShopSuggestService shopSuggestService;
 
    @Resource
    private ShopCertificateService shopCertificateService;
 
    @Resource
    private BankBranchCodeService bankBranchCodeService;
    @Resource
    private RemoteUserService sysUserService;
 
 
 
    @RequestMapping(value = "/listMgtShopSimpleVo", method = RequestMethod.POST)
    @ApiOperation(value = "获取简易商户列表")
    public R<List<MgtShopListSimpleVo>> listMgtShopSimpleVo(@RequestBody MgtShopListDto mgtShopListDto) {
        // 获取当前登陆人的可视权限
        SysUser sysUser = SecurityUtils.getSysUser();
        // 店铺ids
        List<Long> scope = new ArrayList<>();
        if (sysUser!=null){
            String dataScope = sysUser.getDataScope();
            if (!sysUser.getUserName().equals("admin")){
                if (org.springframework.util.StringUtils.hasLength(dataScope)){
                    switch (dataScope){
                        case "3":
                            // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺
                            // 根据用户id 查询同部门下所有员工id
                            List<Long> userIds = sysUserService.getUserIdsByDept(sysUser.getUserId()).getData();
                            // 店铺ids
                            List<Long> data = shopService.list(new QueryWrapper<Shop>()
                                    .in("belong_user_id", userIds)
                                    .eq("del_flag", 0))
                                    .stream().map(Shop::getShopId).collect(Collectors.toList());
                            scope.addAll(data);
                            break;
                        case "5":
                            // 仅个人数据 查询当前登陆人关联店铺下的用户
                            List<Long> longs = new ArrayList<>();
                            longs.add(sysUser.getUserId());
                            // 获取店铺ids
                            List<Long> data1 = shopService.list(new QueryWrapper<Shop>()
                                    .in("belong_user_id", longs)
                                    .eq("del_flag", 0))
                                    .stream().map(Shop::getShopId).collect(Collectors.toList());
                            scope.addAll(data1);
                            break;
                    }
                }
            }
        }
        List<MgtShopListSimpleVo> mgtShopListSimpleVoList = shopService.listMgtShopSimpleVo(mgtShopListDto,scope);
        return R.ok(mgtShopListSimpleVoList);
    }
 
    @RequestMapping(value = "/pageMgtShop", method = RequestMethod.POST)
    @ApiOperation(value = "分页获取商户列表")
    public R<Page<MgtShopPageVo>> pageMgtShop(@RequestBody MgtShopPageDto mgtShopPageDto) {
        // 获取当前登陆人的可视权限
        SysUser sysUser = SecurityUtils.getSysUser();
        // 店铺ids
        List<Long> scope = new ArrayList<>();
        if (sysUser!=null){
            String dataScope = sysUser.getDataScope();
            if (!sysUser.getUserName().equals("admin")){
                if (org.springframework.util.StringUtils.hasLength(dataScope)){
                    switch (dataScope){
                        case "3":
                            // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺
                            // 根据用户id 查询同部门下所有员工id
                            List<Long> userIds = sysUserService.getUserIdsByDept(sysUser.getUserId()).getData();
                            // 店铺ids
                            List<Long> data = shopService.list(new QueryWrapper<Shop>()
                                    .in("belong_user_id", userIds)
                                    .eq("del_flag", 0))
                                    .stream().map(Shop::getShopId).collect(Collectors.toList());
                            scope.addAll(data);
                            break;
                        case "5":
                            // 仅个人数据 查询当前登陆人关联店铺下的用户
                            List<Long> longs = new ArrayList<>();
                            longs.add(sysUser.getUserId());
                            // 获取店铺ids
                            List<Long> data1 = shopService.list(new QueryWrapper<Shop>()
                                    .in("belong_user_id", longs)
                                    .eq("del_flag", 0))
                                    .stream().map(Shop::getShopId).collect(Collectors.toList());
                            scope.addAll(data1);
                            break;
                    }
                }
            }
        }
        Page<MgtShopPageVo> page = new Page<>();
        page.setSize(mgtShopPageDto.getPageSize());
        page.setCurrent(mgtShopPageDto.getPageNum());
        List<MgtShopPageVo> mgtShopPageVoList = shopService.pageMgtShop(page,mgtShopPageDto,scope);
        return R.ok(page.setRecords(mgtShopPageVoList));
    }
 
    @RequestMapping(value = "/exportPageMgtShop", method = RequestMethod.POST)
    @ApiOperation(value = "导出商户列表")
    public void exportPageMgtShop(MgtShopPageDto mgtShopPageDto, HttpServletResponse response) {
        Page<MgtShopPageVo> page = new Page<>();
        if(mgtShopPageDto.getPageSize() > 5000){
            page.setSize(5000);
            page.setCurrent(1);
        }else{
            page.setSize(mgtShopPageDto.getPageSize());
            page.setCurrent(mgtShopPageDto.getPageNum());
        }
        // 获取当前登陆人的可视权限
        SysUser sysUser = SecurityUtils.getSysUser();
        // 店铺ids
        List<Long> scope = new ArrayList<>();
        if (sysUser!=null){
            String dataScope = sysUser.getDataScope();
            if (!sysUser.getUserName().equals("admin")){
                if (org.springframework.util.StringUtils.hasLength(dataScope)){
                    switch (dataScope){
                        case "3":
                            // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺
                            // 根据用户id 查询同部门下所有员工id
                            List<Long> userIds = sysUserService.getUserIdsByDept(sysUser.getUserId()).getData();
                            // 店铺ids
                            List<Long> data = shopService.list(new QueryWrapper<Shop>()
                                    .in("belong_user_id", userIds)
                                    .eq("del_flag", 1))
                                    .stream().map(Shop::getShopId).collect(Collectors.toList());
                            scope.addAll(data);
                            break;
                        case "5":
                            // 仅个人数据 查询当前登陆人关联店铺下的用户
                            List<Long> longs = new ArrayList<>();
                            longs.add(sysUser.getUserId());
                            // 获取店铺ids
                            List<Long> data1 = shopService.list(new QueryWrapper<Shop>()
                                    .in("belong_user_id", longs)
                                    .eq("del_flag", 1))
                                    .stream().map(Shop::getShopId).collect(Collectors.toList());
                            scope.addAll(data1);
                            break;
                    }
                }
            }
        }
        List<MgtShopPageVo> mgtShopPageVoList = shopService.pageMgtShop(page,mgtShopPageDto,scope);
        ExcelUtil<MgtShopPageVo> util = new ExcelUtil<MgtShopPageVo>(MgtShopPageVo.class);
        util.exportExcel(response, mgtShopPageVoList, "商户列表");
    }
 
    @RequestMapping(value = "/createMgtShop", method = RequestMethod.POST)
    @Log(title = "商户管理", businessType = BusinessType.UPDATE,operContent = "编辑商户")
    @ApiOperation(value = "平台编辑商户")
    public R createMgtShop(@Validated @RequestBody MgtEditShopDto mgtEditShopDto) {
        Long userId = SecurityUtils.getUserId();
        mgtEditShopDto.setUserId(userId);
        shopService.createShop(mgtEditShopDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/getMgtShopInfo", method = RequestMethod.POST)
    @ApiOperation(value = "获取商户详情")
    public R<MgtShopInfoVo> getMgtShopInfo(@RequestBody MgtBaseGetDto mgtBaseGetDto) {
        MgtShopInfoVo mgtShopInfoVo = shopService.getMgtShopInfo(Long.valueOf(mgtBaseGetDto.getId()));
        return R.ok(mgtShopInfoVo);
    }
 
    @RequestMapping(value = "/getMgtShopTag", method = RequestMethod.POST)
    @ApiOperation(value = "获取商户标签")
    public R<List<MgtShopTagVo>> getMgtShopTag(@RequestBody MgtBaseGetDto mgtBaseGetDto) {
        List<MgtShopTagVo> mgtShopInfoVoList = shopRelTagService.listShopTagVo(mgtBaseGetDto);
        return R.ok(mgtShopInfoVoList);
    }
 
    @RequestMapping(value = "/editMgtShopTag", method = RequestMethod.POST)
    @Log(title = "商户管理", businessType = BusinessType.UPDATE,operContent = "修改商户标签")
    @ApiOperation(value = "修改商户标签")
    public R editMgtShopTag(@RequestBody MgtEditShopTagDto mgtEditShopTagDto) {
        shopService.editShopTag(mgtEditShopTagDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/transferMgtShop", method = RequestMethod.POST)
    @Log(title = "商户管理", businessType = BusinessType.UPDATE,operContent = "转移客户")
    @ApiOperation(value = "转移客户")
    public R transferMgtShop(@RequestBody MgtTransferShopDto mgtTransferShopDto) {
        shopService.transferMgtShop(mgtTransferShopDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/terminateMgtCooperation", method = RequestMethod.POST)
    @Log(title = "商户管理", businessType = BusinessType.UPDATE,operContent = "终止合作")
    @ApiOperation(value = "终止合作")
    public R terminateMgtCooperation(@RequestBody MgtTerminateCooperationDto mgtTerminateCooperationDto) {
        Long userId = SecurityUtils.getUserId();
        mgtTerminateCooperationDto.setUserId(userId);
        shopService.terminateMgtCooperation(mgtTerminateCooperationDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/frozenMgtShop", method = RequestMethod.POST)
    @Log(title = "商户管理", businessType = BusinessType.UPDATE,operContent = "终止合作")
    @ApiOperation(value = "冻结商户")
    public R frozenMgtShop(@RequestBody MgtFrozenShopDto mgtFrozenShopDto) {
        Long userId = SecurityUtils.getUserId();
        mgtFrozenShopDto.setUserId(userId);
        shopService.frozenMgtShop(mgtFrozenShopDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/changeMgtCooperationTime", method = RequestMethod.POST)
    @Log(title = "商户管理", businessType = BusinessType.UPDATE,operContent = "修改合作时间")
    @ApiOperation(value = "修改合作时间")
    public R changeMgtCooperationTime(@RequestBody MgtChangeCoopDto mgtChangeCoopDto) {
        Long userId = SecurityUtils.getUserId();
        mgtChangeCoopDto.setUserId(userId);
        shopService.changeCooperationTime(mgtChangeCoopDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/pageMgtShopProportion", method = RequestMethod.POST)
    @ApiOperation(value = "分页获取商户分成列表")
    public R<Page<MgtShopProportionPageVo>> pageMgtShopProportion(@RequestBody MgtShopProportionPageDto mgtShopProportionPageDto) {
        Page<MgtShopProportionPageVo> page = new Page<>();
        page.setSize(mgtShopProportionPageDto.getPageSize());
        page.setCurrent(mgtShopProportionPageDto.getPageNum());
        List<MgtShopProportionPageVo> mgtShopProportionPageVoList = shopService.pageMgtShopProportion(page,mgtShopProportionPageDto);
        return R.ok(page.setRecords(mgtShopProportionPageVoList));
    }
 
    @RequestMapping(value = "/editMgtShopProportion", method = RequestMethod.POST)
    @Log(title = "商户管理", businessType = BusinessType.UPDATE,operContent = "修改商户分成")
    @ApiOperation(value = "修改商户分成")
    public R editMgtShopProportion(@RequestBody MgtShopProportionEditDto mgtShopProportionEditDto) {
        mgtShopProportionEditDto.setUserId(SecurityUtils.getUserId());
        shopProportionService.editMgtShopProportion(mgtShopProportionEditDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/pageMgtShopSuggest", method = RequestMethod.POST)
    @ApiOperation(value = "平台获取商户建议列表")
    public R<Page<MgtShopSuggestPageVo>> pageMgtShopSuggest(@RequestBody MgtShopSuggestPageDto mgtShopSuggestPageDto) {
        Long userId = SecurityUtils.getUserId();
        mgtShopSuggestPageDto.setUserId(userId);
        Page<MgtShopSuggestPageVo> page = new Page<>();
        page.setSize(mgtShopSuggestPageDto.getPageSize());
        page.setCurrent(mgtShopSuggestPageDto.getPageNum());
        List<MgtShopSuggestPageVo> mgtShopSuggestPageVoList = shopSuggestService.pageMgtShopSuggest(page,mgtShopSuggestPageDto);
        return R.ok(page.setRecords(mgtShopSuggestPageVoList));
    }
 
    @RequestMapping(value = "/exportPageMgtShopSuggest", method = RequestMethod.POST)
    @ApiOperation(value = "导出商户建议列表")
    public void exportPageMgtShopSuggest(MgtShopSuggestPageDto mgtShopSuggestPageDto, HttpServletResponse response) {
        Long userId = SecurityUtils.getUserId();
        mgtShopSuggestPageDto.setUserId(userId);
        Page<MgtShopSuggestPageVo> page = new Page<>();
        if(mgtShopSuggestPageDto.getPageSize() > 5000){
            page.setSize(5000);
            page.setCurrent(1);
        }else{
            page.setSize(mgtShopSuggestPageDto.getPageSize());
            page.setCurrent(mgtShopSuggestPageDto.getPageNum());
        }
        List<MgtShopSuggestPageVo> mgtShopSuggestPageVoList = shopSuggestService.pageMgtShopSuggest(page,mgtShopSuggestPageDto);
        ExcelUtil<MgtShopSuggestPageVo> util = new ExcelUtil<MgtShopSuggestPageVo>(MgtShopSuggestPageVo.class);
        util.exportExcel(response, mgtShopSuggestPageVoList, "商户建议列表");
    }
 
    @RequestMapping(value = "/mgtReplayShopSuggest", method = RequestMethod.POST)
    @Log(title = "商户建议管理", businessType = BusinessType.UPDATE,operContent = "回复商户建议")
    @ApiOperation(value = "平台回复建议")
    public R mgtReplayShopSuggest(@RequestBody MgtReplayShopSuggestDto mgtReplayShopSuggestDto) {
        Long userId = SecurityUtils.getUserId();
        mgtReplayShopSuggestDto.setUserId(userId);
        shopSuggestService.mgtReplayShopSuggest(mgtReplayShopSuggestDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/listMgtShopSuggestTag", method = RequestMethod.POST)
    @ApiOperation(value = "获取商户建议标签")
    public R<List<MgtShopSuggestTagVo>> listMgtShopSuggestTag(@RequestBody MgtBaseGetDto mgtBaseGetDto) {
        List<MgtShopSuggestTagVo> mgtShopSuggestTagVoList = shopSuggestService.listMgtShopSuggestTag(Long.valueOf(mgtBaseGetDto.getId()));
        return R.ok(mgtShopSuggestTagVoList);
    }
 
    @RequestMapping(value = "/mgtEditShopSuggestTag", method = RequestMethod.POST)
    @Log(title = "商户建议管理", businessType = BusinessType.UPDATE,operContent = "编辑商户建议标签")
    @ApiOperation(value = "平台编辑商户建议标签")
    public R mgtEditShopSuggestTag(@RequestBody MgtTagShopSuggestDto mgtTagShopSuggestDto) {
        Long userId = SecurityUtils.getUserId();
        mgtTagShopSuggestDto.setUserId(userId);
        shopSuggestService.mgtEditShopSuggestTag(mgtTagShopSuggestDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/pageMgtShopCertificate", method = RequestMethod.POST)
    @ApiOperation(value = "平台获取商户证书审核列表")
    public R<Page<MgtShopCertificatePageVo>> pageMgtShopCertificate(@RequestBody MgtShopCertificatePageDto mgtShopCertificatePageDto) {
        Long userId = SecurityUtils.getUserId();
        mgtShopCertificatePageDto.setUserId(userId);
        Page<MgtShopCertificatePageVo> page = new Page<>();
        page.setSize(mgtShopCertificatePageDto.getPageSize());
        page.setCurrent(mgtShopCertificatePageDto.getPageNum());
        List<MgtShopCertificatePageVo> mgtShopCertificatePageVoList = shopCertificateService.pageMgtShopCertificate(page,mgtShopCertificatePageDto);
        return R.ok(page.setRecords(mgtShopCertificatePageVoList));
    }
 
    @RequestMapping(value = "/mgtAuditShopCertificate", method = RequestMethod.POST)
    @Log(title = "商户证书管理", businessType = BusinessType.UPDATE,operContent = "审核商户证书")
    @ApiOperation(value = "平台审核商户证书")
    public R mgtAuditShopCertificate(@RequestBody MgtAuditShopCertificateDto mgtAuditShopCertificateDto) {
        Long userId = SecurityUtils.getUserId();
        mgtAuditShopCertificateDto.setUserId(userId);
        shopCertificateService.mgtAuditShopCertificate(mgtAuditShopCertificateDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/pageMgtShopByCityCode", method = RequestMethod.POST)
    @ApiOperation(value = "通过市code分页获取商户列表")
    public R<Page<MgtSimpleShopVo>> pageMgtShopByCityCode(@RequestBody MgtShopByCodePageDto mgtShopByCodePageDto) {
        Page<MgtSimpleShopVo> page = new Page<>();
        page.setSize(mgtShopByCodePageDto.getPageSize());
        page.setCurrent(mgtShopByCodePageDto.getPageNum());
        List<MgtSimpleShopVo> mgtSimpleShopVoList = shopService.pageMgtShopByCityCode(page,mgtShopByCodePageDto);
        return R.ok(page.setRecords(mgtSimpleShopVoList));
    }
 
    @RequestMapping(value = "/pageMgtShopAuth", method = RequestMethod.POST)
    @ApiOperation(value = "分页获取商户进件列表")
    public R<Page<MgtShopAuthPageVo>> pageMgtShopAuth(@RequestBody MgtShopAuthPageDto mgtShopAuthPageDto) {
        Page<MgtShopAuthPageVo> page = new Page<>();
        page.setSize(mgtShopAuthPageDto.getPageSize());
        page.setCurrent(mgtShopAuthPageDto.getPageNum());
        // 获取当前登陆人的可视权限
        SysUser sysUser = SecurityUtils.getSysUser();
        // 店铺ids
        List<Long> scope = new ArrayList<>();
        if (sysUser!=null){
            String dataScope = sysUser.getDataScope();
            if (!sysUser.getUserName().equals("admin")){
                if (org.springframework.util.StringUtils.hasLength(dataScope)){
                    switch (dataScope){
                        case "3":
                            // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺
                            // 根据用户id 查询同部门下所有员工id
                            List<Long> userIds = sysUserService.getUserIdsByDept(sysUser.getUserId()).getData();
                            // 店铺ids
                            List<Long> data = shopService.list(new QueryWrapper<Shop>()
                                    .in("belong_user_id", userIds)
                                    .eq("del_flag", 0))
                                    .stream().map(Shop::getShopId).collect(Collectors.toList());
                            scope.addAll(data);
                            break;
                        case "5":
                            // 仅个人数据 查询当前登陆人关联店铺下的用户
                            List<Long> longs = new ArrayList<>();
                            longs.add(sysUser.getUserId());
                            // 获取店铺ids
                            List<Long> data1 = shopService.list(new QueryWrapper<Shop>()
                                    .in("belong_user_id", longs)
                                    .eq("del_flag", 0))
                                    .stream().map(Shop::getShopId).collect(Collectors.toList());
                            scope.addAll(data1);
                            break;
                    }
                }
            }
        }
        List<MgtShopAuthPageVo> mgtShopAuthPageVoList = shopService.pageMgtShopAuth(page,mgtShopAuthPageDto,scope);
        return R.ok(page.setRecords(mgtShopAuthPageVoList));
    }
 
    @RequestMapping(value = "/mgtShopAuth", method = RequestMethod.POST)
    @Log(title = "商户进件管理", businessType = BusinessType.UPDATE,operContent = "商户进件")
    @ApiOperation(value = "平台商户进件")
    public R mgtShopAuth(@Validated @RequestBody MgtShopAuthDto mgtShopAuthDto) {
        Long userId = SecurityUtils.getUserId();
        mgtShopAuthDto.setUserId(userId);
        shopService.mgtShopAuth(mgtShopAuthDto);
        return R.ok();
    }
 
 
    @RequestMapping(value = "/getMgtShopAuth", method = RequestMethod.POST)
    @ApiOperation(value = "获取商户进件信息")
    public R<MgtShopAuthGetVo> getMgtShopAuth(@RequestBody MgtShopAuthGetDto mgtShopAuthGetDto) {
        MgtShopAuthGetVo shopAuthGetVo = shopService.getMgtShopAuth(mgtShopAuthGetDto.getAuthId());
        return R.ok(shopAuthGetVo);
    }
 
    @RequestMapping(value = "/getMgtShopAuthCode", method = RequestMethod.POST)
    @ApiOperation(value = "获取商户进件验证信息")
    public R<MgtShopAuthCodeVo> getMgtShopAuthCode(@RequestBody MgtShopAuthGetDto mgtShopAuthGetDto) {
        MgtShopAuthCodeVo mgtShopAuthCodeVo = shopService.getMgtShopAuthCode(mgtShopAuthGetDto.getAuthId());
        return R.ok(mgtShopAuthCodeVo);
    }
 
    @RequestMapping(value = "/mgtAddProfitSharingReceiver", method = RequestMethod.POST)
    @Log(title = "商户进件管理", businessType = BusinessType.UPDATE,operContent = "商户添加分账方")
    @ApiOperation(value = "平台商户添加分账方")
    public R mgtAddProfitSharingReceiver(@RequestBody MgtShopAuthGetDto mgtShopAuthGetDto){
        Long userId = SecurityUtils.getUserId();
        mgtShopAuthGetDto.setUserId(userId);
        shopService.addProfitSharingReceiver(mgtShopAuthGetDto);
        return R.ok();
    }
 
 
    @RequestMapping(value = "/pageMgtShopHFTXAuth", method = RequestMethod.POST)
    @ApiOperation(value = "分页获取商户进件列表(汇付天下)")
    public R<Page<MgtShopHFTXAuthPageVo>> pageMgtShopHFTXAuth(@RequestBody MgtShopHFTXAuthPageDto mgtShopAuthPageDto) {
        // 获取当前登陆人的可视权限
        SysUser sysUser = SecurityUtils.getSysUser();
        // 店铺ids
        List<Long> scope = new ArrayList<>();
        if (sysUser!=null){
            String dataScope = sysUser.getDataScope();
            if (!sysUser.getUserName().equals("admin")){
                if (org.springframework.util.StringUtils.hasLength(dataScope)){
                    switch (dataScope){
                        case "3":
                            // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺
                            // 根据用户id 查询同部门下所有员工id
                            List<Long> userIds = sysUserService.getUserIdsByDept(sysUser.getUserId()).getData();
                            // 店铺ids
                            List<Long> data = shopService.list(new QueryWrapper<Shop>()
                                    .in("belong_user_id", userIds)
                                    .eq("del_flag", 0))
                                    .stream().map(Shop::getShopId).collect(Collectors.toList());
                            scope.addAll(data);
                            break;
                        case "5":
                            // 仅个人数据 查询当前登陆人关联店铺下的用户
                            List<Long> longs = new ArrayList<>();
                            longs.add(sysUser.getUserId());
                            // 获取店铺ids
                            List<Long> data1 = shopService.list(new QueryWrapper<Shop>()
                                    .in("belong_user_id", longs)
                                    .eq("del_flag", 0))
                                    .stream().map(Shop::getShopId).collect(Collectors.toList());
                            scope.addAll(data1);
                            break;
                    }
                }
            }
        }
        Page<MgtShopHFTXAuthPageVo> page = new Page<>();
        page.setSize(mgtShopAuthPageDto.getPageSize());
        page.setCurrent(mgtShopAuthPageDto.getPageNum());
        List<MgtShopHFTXAuthPageVo> mgtShopHFTXAuthPageVos = shopService.pageMgtShopHFTXAuth(page, mgtShopAuthPageDto,scope);
        return R.ok(page.setRecords(mgtShopHFTXAuthPageVos));
    }
 
 
    @RequestMapping(value = "/mgtShopHFTXAuth", method = RequestMethod.POST)
    @Log(title = "商户进件管理", businessType = BusinessType.UPDATE,operContent = "商户进件")
    @ApiOperation(value = "平台商户进件(汇付天下)")
    public R mgtShopHFTXAuth(@RequestBody MgtShopHFTXAuthDto mgtShopHFTXAuthDto) {
        Long userId = SecurityUtils.getUserId();
        mgtShopHFTXAuthDto.setUserId(userId);
        shopService.mgtShopHFTXAuth(mgtShopHFTXAuthDto);
        return R.ok();
    }
 
 
    @RequestMapping(value = "/merchantBasicdataNotify", method = RequestMethod.POST)
    @Log(title = "商户进件回调通知(汇付天下)", businessType = BusinessType.UPDATE,operContent = "商户进件")
    public void merchantBasicdataNotify(MerchantBasicDataNotifyDto dto, HttpServletResponse response){
        R<String> r = shopService.merchantBasicdataNotify(dto);
        if(r.getCode() == 200){
            response.setStatus(200);
            PrintWriter out = null;
            try {
                out = response.getWriter();
                out.print("RECV_ORD_ID_" + r.getData());
                out.flush();
            } catch (IOException e) {
                e.printStackTrace();
            }finally {
                out.close();
            }
        }
    }
 
 
 
 
    @RequestMapping(value = "/getMgtShopHFTXAuthInfo", method = RequestMethod.POST)
    @ApiOperation(value = "获取商户进件信息(汇付天下)")
    public R<MgtShopHFTXAuthGetVo> getMgtShopHFTXAuthInfo(@Validated @RequestBody MgtShopHFTXAuthGetDto mgtShopHFTXAuthGetDto){
        MgtShopHFTXAuthGetVo mgtShopHFTXAuthInfo = shopService.getMgtShopHFTXAuthInfo(mgtShopHFTXAuthGetDto.getShopId());
        return R.ok(mgtShopHFTXAuthInfo);
    }
 
 
    @RequestMapping(value = "/setMgtShopShareRatio", method = RequestMethod.POST)
    @ApiOperation(value = "设置分账比例(汇付天下)")
    public R setMgtShopShareRatio(@Validated @RequestBody MgtShopShareRatioSetDto mgtShopShareRatioSetDto){
        return shopService.setMgtShopShareRatio(mgtShopShareRatioSetDto);
    }
 
 
    @RequestMapping(value = "/getMerchantBasicDataSettlement", method = RequestMethod.POST)
    @ApiOperation(value = "获取提现记录(汇付天下)")
    public R<List<MerchantBasicdataSettlementVo>> getMerchantBasicDataSettlement(@Validated @RequestBody MerchantBasicdataSettlementDto mgtShopShareRatioSetDto){
        return shopService.getMerchantBasicDataSettlement(mgtShopShareRatioSetDto);
    }
 
 
    @RequestMapping(value = "/getBankList", method = RequestMethod.POST)
    @ApiOperation(value = "获取银行列表(汇付天下)")
    public R<List<Map<String, String>>> getBankList(@Validated @RequestBody BankListGetDto dto){
        List<Map<String, String>> bankList = bankBranchCodeService.getBankList(dto.getName());
        return R.ok(bankList);
    }
 
 
    @RequestMapping(value = "/getBankBranchCode", method = RequestMethod.POST)
    @ApiOperation(value = "获取银行分行列表(汇付天下)")
    public R<List<Map<String, String>>> getBankBranchCode(@Validated @RequestBody BankBranchCodeGetDto dto){
        List<Map<String, String>> bankBranchCode = bankBranchCodeService.getBankBranchCode(dto.getBankNumber());
        return R.ok(bankBranchCode);
    }
}