puzhibing
2023-12-07 aa0131b1efb96c9f52371160b3a1e6823db3656a
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
package com.ruoyi.shop.controller.staff;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.shop.domain.dto.*;
import com.ruoyi.shop.domain.vo.*;
import com.ruoyi.shop.service.shop.ShopService;
import com.ruoyi.system.api.domain.dto.StaffBaseGetDto;
import com.ruoyi.system.api.domain.poji.sys.SysUser;
import com.ruoyi.system.api.service.RemoteSysStaffService;
import com.ruoyi.system.api.service.RemoteUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
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 java.util.List;
 
 
@Api(value = "员工端商户接口", tags = "员工端商户接口", description = "员工端商户接口")
@RestController
@RequestMapping("/staff/shop")
@Log4j2
public class StaffShopController {
 
    @Resource
    private ShopService shopService;
    @Resource
    private RemoteUserService sysUserService;
    @Resource
    private RemoteSysStaffService remoteSysStaffService;
 
    /**
     * 未完成实际统计
     * @return
     */
    @RequestMapping(value = "/getStaffHomeTotal", method = RequestMethod.POST)
    @ApiOperation(value = "获取员工端商铺统计(首页)")
    public R<StaffHomeShopTotalVo> getStaffHomeTotal() {
        Long userId = SecurityUtils.getUserId();
        StaffHomeShopTotalVo staffHomeShopTotalVo = shopService.getStaffHomeTotal(userId);
        return R.ok(staffHomeShopTotalVo);
    }
 
    @RequestMapping(value = "/listStaffShop", method = RequestMethod.POST)
    @ApiOperation(value = "分页获取员工端商户列表")
    public R<Page<StaffShopPageVo>> listStaffShop(@RequestBody StaffShopPageDto staffShopPageDto) {
        Long userId = SecurityUtils.getUserId();
//        if (remoteSysStaffService.isLeader()) {
//            List<Long> userIds = sysUserService.getUserIdsByDept(userId).getData();
//            userIds.add(userId);
//            staffShopPageDto.setUserIdList(userIds);
//        } else {
//            staffShopPageDto.setBelongUserId(userId);
//        }
 
        // TODO: 2023/12/5 统一改成使用权限来控制数据
        R<SysUser> sysUser = sysUserService.getSysUser(userId);
        if(sysUser.getCode() != 200){
            return R.fail(sysUser.getMsg());
        }
        //员工端数据权限(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)
        //2/4暂未使用
        String dataScopeEmployee = sysUser.getData().getDataScopeEmployee();
        if(dataScopeEmployee.equals("1")){
            staffShopPageDto.setUserIdList(null);
        }
        if(dataScopeEmployee.equals("3")){
            List<Long> userIds = sysUserService.getUserIdsByDept(userId).getData();
            userIds.add(userId);
            staffShopPageDto.setUserIdList(userIds);
        }
        if(dataScopeEmployee.equals("5")){
            staffShopPageDto.setBelongUserId(userId);
        }
 
        Page<StaffShopPageVo> page = new Page<>();
        page.setSize(staffShopPageDto.getPageSize());
        page.setCurrent(staffShopPageDto.getPageNum());
        List<StaffShopPageVo> staffShopPageVoList = shopService.pageStaffShop(page,staffShopPageDto);
        return R.ok(page.setRecords(staffShopPageVoList));
    }
 
    @RequestMapping(value = "/getStaffSimpleTotal", method = RequestMethod.POST)
    @ApiOperation(value = "获取员工端商铺数量统计")
    public R<StaffShopSimpleTotalVo> getStaffSimpleTotal() {
        Long userId = SecurityUtils.getUserId();
        StaffShopSimpleTotalVo staffShopSimpleTotalVo = shopService.getStaffSimpleTotal(userId);
        return R.ok(staffShopSimpleTotalVo);
    }
 
    @RequestMapping(value = "/getStaffShopInfo", method = RequestMethod.POST)
    @ApiOperation(value = "获取员工端商户信息")
    public R<StaffShopInfoGetVo> getStaffShopInfo(@RequestBody StaffBaseGetDto staffBaseGetDto) {
        Long userId = SecurityUtils.getUserId();
        StaffShopInfoGetVo staffShopInfoGetVo = shopService.getStaffShopInfo(Long.valueOf(staffBaseGetDto.getId()));
        return R.ok(staffShopInfoGetVo);
    }
 
 
    @RequestMapping(value = "/editShopEstimate", method = RequestMethod.POST)
    @ApiOperation(value = "修改店铺评估")
    public R editShopEstimate(@RequestBody StaffShopEstimateEditDto staffShopEstimateEditDto) {
        Long userId = SecurityUtils.getUserId();
        staffShopEstimateEditDto.setUserId(userId);
        shopService.editShopEstimate(staffShopEstimateEditDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/editExtendContacts", method = RequestMethod.POST)
    @ApiOperation(value = "修改店铺扩展联系人")
    public R editExtendContacts(@RequestBody StaffShopECEditDto staffShopECEditDto) {
        Long userId = SecurityUtils.getUserId();
        staffShopECEditDto.setUserId(userId);
        shopService.editExtendContacts(staffShopECEditDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/editShopCustomStatus", method = RequestMethod.POST)
    @ApiOperation(value = "修改店铺状态")
    public R editShopCustomStatus(@RequestBody StaffShopCCEditDto staffShopCCEditDto) {
        Long userId = SecurityUtils.getUserId();
        staffShopCCEditDto.setUserId(userId);
        shopService.editShopCustomStatus(staffShopCCEditDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/editShopDetail", method = RequestMethod.POST)
    @ApiOperation(value = "修改店铺详细资料")
    public R editShopDetail(@RequestBody StaffShopDetailDto staffShopDetailDto) {
        Long userId = SecurityUtils.getUserId();
        staffShopDetailDto.setUserId(userId);
        shopService.editShopDetail(staffShopDetailDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/getShopDetail", method = RequestMethod.POST)
    @ApiOperation(value = "获取店铺详细资料")
    public R<StaffShopDetailVo> getShopDetail(@RequestBody StaffBaseGetDto staffBaseGetDto) {
        Long userId = SecurityUtils.getUserId();
        staffBaseGetDto.setUserId(userId);
        StaffShopDetailVo staffShopDetailVo = shopService.getShopDetail(Long.valueOf(staffBaseGetDto.getId()));
        return R.ok(staffShopDetailVo);
    }
}