xiaoyong931011
2022-09-13 28681434422184b33a3338417f681ca1837bc91e
src/main/java/cc/mrbird/febs/mall/controller/AdminMallTeamLeaderController.java
@@ -4,20 +4,24 @@
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.AdminLeaderAddFenceDto;
import cc.mrbird.febs.mall.dto.AdminLeaderUpdateDto;
import cc.mrbird.febs.mall.entity.MallGoodsCategory;
import cc.mrbird.febs.mall.entity.MallTeamLeader;
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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
@@ -30,6 +34,7 @@
    private final IAdminMallTeamLeaderService iAdminMallTeamLeaderService;
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
    /**
     * 团长信息--列表
@@ -45,8 +50,36 @@
     */
    @PostMapping("leaderUpdate")
    @ControllerEndpoint(operation = "团长信息--审核", exceptionMessage = "审核失败")
    public FebsResponse leaderUpdate(@Valid AdminLeaderUpdateDto adminLeaderUpdateDto) {
        return iAdminMallTeamLeaderService.leaderUpdate(adminLeaderUpdateDto);
    public FebsResponse leaderUpdate(@Valid MallTeamLeader mallTeamLeader) {
        return iAdminMallTeamLeaderService.leaderUpdate(mallTeamLeader);
    }
    /**
     * 团长-开启返利
     */
    @GetMapping("startProfit/{id}")
    @ControllerEndpoint(operation = "团长-开启返利", exceptionMessage = "操作失败")
    public FebsResponse startProfit(@NotNull(message = "{required}") @PathVariable Long id) {
        return iAdminMallTeamLeaderService.startProfit(id);
    }
    /**
     * 团长-关闭返利
     */
    @GetMapping("closeProfit/{id}")
    @ControllerEndpoint(operation = "团长-关闭返利", exceptionMessage = "操作失败")
    public FebsResponse closeProfit(@NotNull(message = "{required}") @PathVariable Long id) {
        return iAdminMallTeamLeaderService.closeProfit(id);
    }
    /**
     * 团长信息--新增
     */
    @PostMapping("addLeader")
    @ControllerEndpoint(operation = "团长信息--新增", exceptionMessage = "新增失败")
    public FebsResponse addLeader(@Valid AdminLeaderAddDto adminLeaderAddDto) {
        return iAdminMallTeamLeaderService.addLeader(adminLeaderAddDto);
    }
    /**
@@ -57,4 +90,58 @@
        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 = Double.parseDouble(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();
    }
    /**
     * 团长--设置电子围栏
     */
    @PostMapping("addFence")
    @ControllerEndpoint(operation = "团长信息--设置电子围栏", exceptionMessage = "设置失败")
    public FebsResponse addFence(@Valid AdminLeaderAddFenceDto adminLeaderAddFenceDto) {
        return iAdminMallTeamLeaderService.addFence(adminLeaderAddFenceDto);
    }
}