1
chenye
2023-07-11 f975b6d0832b447654aaf2372ce72f71ebb7f095
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
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.MgtShopPageDto;
import com.ruoyi.shop.domain.dto.MgtShopTaskPageDto;
import com.ruoyi.shop.domain.vo.MgtShopPageVo;
import com.ruoyi.shop.domain.vo.MgtShopTaskRecordPageVo;
import com.ruoyi.shop.service.shop.ShopService;
import com.ruoyi.system.api.domain.poji.shop.Shop;
import com.ruoyi.system.api.domain.vo.MerHomeShopTotalVo;
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 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")
public class StaffController {
 
    @Resource
    private ShopService shopService;
    @Resource
    private RemoteUserService sysUserService;
    @Resource
    private RemoteSysStaffService remoteSysStaffService;
 
    /**
     * 未完成实际统计
     * @return
     */
    @RequestMapping(value = "/getStaffHomeTotal", method = RequestMethod.POST)
    @ApiOperation(value = "获取员工端商铺统计(首页)")
    public R<MerHomeShopTotalVo> getStaffHomeTotal() {
        Long userId = SecurityUtils.getUserId();
        MerHomeShopTotalVo merHomeShopTotalVo = shopService.getStaffHomeTotal(userId);
        return R.ok(merHomeShopTotalVo);
    }
 
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ApiOperation(value = "获取商户端商业统计")
    public R getShopByUserId(@RequestBody MgtShopPageDto mgtShopPageDto) {
        Long userId = SecurityUtils.getUserId();
        if (remoteSysStaffService.isLeader()) {
            Long deptId = sysUserService.getSysUser(userId).getData().getDeptId();
            List<Long> userIds = remoteSysStaffService.getUserIds(deptId).getData();
            if(userIds.size()==0){
                return R.ok("未关联商户");
            }
            mgtShopPageDto.setIds(userIds);
        } else {
            mgtShopPageDto.setBelongUserId(userId);
        }
        Page<MgtShopPageVo> page = new Page<>();
        page.setSize(mgtShopPageDto.getPageSize());
        page.setCurrent(mgtShopPageDto.getPageNum());
        List<MgtShopPageVo> mgtShopPageVoList = shopService.pageMgtShop(page,mgtShopPageDto);
        return R.ok(page.setRecords(mgtShopPageVoList));
    }
 
    @RequestMapping(value = "/editShop", method = RequestMethod.POST)
    @ApiOperation(value = "修改商户")
    public R<Boolean> editShopStatus(Shop shop) {
        return R.ok(shopService.updateById(shop));
    }
}