xiaoyong931011
2022-08-31 1a66508ad3d73dcc456162c553b03f2208570b51
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
package cc.mrbird.febs.mall.controller;
 
import cc.mrbird.febs.common.annotation.ControllerEndpoint;
import cc.mrbird.febs.common.controller.BaseController;
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
import cc.mrbird.febs.mall.dto.AdminLeaderAddDto;
import cc.mrbird.febs.mall.dto.AdminLeaderUpdateDto;
import cc.mrbird.febs.mall.dto.ApiApplayLeaderDto;
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper;
import cc.mrbird.febs.mall.service.IAdminMallTeamLeaderService;
import cc.mrbird.febs.mall.vo.AdminLeaderBonusSettingVo;
import cc.mrbird.febs.mall.vo.AdminRangeSettingVo;
import cc.mrbird.febs.mall.vo.AdminSelectListLeaderVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
 
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/admin/leader")
public class AdminMallTeamLeaderController extends BaseController {
 
 
    private final IAdminMallTeamLeaderService iAdminMallTeamLeaderService;
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
 
    /**
     * 团长信息--列表
     */
    @GetMapping("leaderList")
    public FebsResponse getLeaderList(MallTeamLeader mallTeamLeader, QueryRequest request) {
        Map<String, Object> data = getDataTable(iAdminMallTeamLeaderService.getLeaderListInPage(mallTeamLeader, request));
        return new FebsResponse().success().data(data);
    }
 
    /**
     * 团长信息--审核
     */
    @PostMapping("leaderUpdate")
    @ControllerEndpoint(operation = "团长信息--审核", exceptionMessage = "审核失败")
    public FebsResponse leaderUpdate(@Valid AdminLeaderUpdateDto adminLeaderUpdateDto) {
        return iAdminMallTeamLeaderService.leaderUpdate(adminLeaderUpdateDto);
    }
 
 
    /**
     * 团长信息--新增
     */
    @PostMapping("addLeader")
    @ControllerEndpoint(operation = "团长信息--新增", exceptionMessage = "新增失败")
    public FebsResponse addLeader(@Valid AdminLeaderAddDto adminLeaderAddDto) {
        return iAdminMallTeamLeaderService.addLeader(adminLeaderAddDto);
    }
 
    /**
     * 团长信息--下拉列表
     */
    @GetMapping("selectList")
    public List<AdminSelectListLeaderVo> selectList(MallTeamLeader mallTeamLeader) {
        return iAdminMallTeamLeaderService.selectList(mallTeamLeader);
    }
 
    /**
     * 团长信息--取消团长
     */
    @GetMapping("leaderCancel/{id}")
    @ControllerEndpoint(operation = "团长信息--取消团长", exceptionMessage = "取消团长失败")
    public FebsResponse leaderCancel(@NotNull(message = "{required}") @PathVariable Long id) {
        return iAdminMallTeamLeaderService.leaderCancel(id);
    }
 
    /**
     * 团长信息-商品库存编辑
     */
    @GetMapping("/leaderGoodsUpdate")
    public FebsResponse leaderGoodsUpdate(QueryRequest request, MallLeaderStock mallLeaderStock, Integer parentId) {
        if (parentId == null) {
            ViewMallTeamLeaderController.idLeaderGoodsUpdate = 0;
        }
        mallLeaderStock.setTeamLeaderId(ViewMallTeamLeaderController.idLeaderGoodsUpdate);
        Map<String, Object> dataTable = getDataTable(iAdminMallTeamLeaderService.leaderGoodsUpdate(request, mallLeaderStock));
        return new FebsResponse().success().data(dataTable);
    }
 
 
 
    /**
     * 团长每日分成设置 -- 更新
     */
    @PostMapping(value = "/leaderBonusSetUpdate")
    public FebsResponse leaderBonusSetUpdate(AdminLeaderBonusSettingVo adminLeaderBonusSettingVo) {
        Integer bonusSwitch = adminLeaderBonusSettingVo.getBonusSwitch();
        DataDictionaryCustom bonusSwitchDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.BONUS_SWITCH.getType(), DataDictionaryEnum.BONUS_SWITCH.getCode());
        bonusSwitchDic.setValue(bonusSwitch.toString());
        dataDictionaryCustomMapper.updateById(bonusSwitchDic);
 
        Double bonusPercent = adminLeaderBonusSettingVo.getBonusPercent();
        if(1 <= bonusPercent || 0 >= bonusPercent){
            return new FebsResponse().fail().message("请输入合适的百分比小数");
        }
        DataDictionaryCustom bonusPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.BONUS_PERCENT.getType(), DataDictionaryEnum.BONUS_PERCENT.getCode());
        bonusPercentDic.setValue(bonusPercent.toString());
        dataDictionaryCustomMapper.updateById(bonusPercentDic);
        return new FebsResponse().success();
    }
 
}