|
@@ -2,8 +2,10 @@ package com.qs.mp.web.controller.api.channel;
|
|
|
|
|
|
import cn.jsms.api.ValidSMSResult;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.qs.mp.channel.domain.Channel;
|
|
|
import com.qs.mp.channel.domain.param.PromoterCreateParam;
|
|
|
+import com.qs.mp.channel.domain.param.PromoterEditParam;
|
|
|
import com.qs.mp.channel.domain.param.PromoterQueryParam;
|
|
|
import com.qs.mp.channel.service.IChannelService;
|
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
@@ -17,6 +19,7 @@ import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiResponse;
|
|
|
import io.swagger.annotations.ApiResponses;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.checkerframework.checker.units.qual.C;
|
|
@@ -41,6 +44,42 @@ public class PromoterController extends BaseApiController {
|
|
|
@Autowired
|
|
|
private IChannelService channelService;
|
|
|
|
|
|
+ @PostMapping("/edit")
|
|
|
+ @ApiOperation("编辑推广员信息")
|
|
|
+ public AjaxResult edit(@Validated @RequestBody PromoterEditParam param) {
|
|
|
+ Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
+ Channel channel = channelService.getById(channelId);
|
|
|
+ if (channel == null) {
|
|
|
+ return AjaxResult.error("门店信息不正确");
|
|
|
+ }
|
|
|
+
|
|
|
+ int count = channelService.count(
|
|
|
+ new LambdaQueryWrapper<Channel>().eq(Channel::getChannelId, param.getChannelId())
|
|
|
+ .eq(Channel::getParentId, channelId));
|
|
|
+
|
|
|
+ if (count <= 0) {
|
|
|
+ return AjaxResult.error("您没有权限编辑该推广员信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getCommRate().compareTo(channel.getCommRate()) > 0) {
|
|
|
+ return AjaxResult.error("佣金比例不能大于门店的佣金比例");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getCommRate().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ return AjaxResult.error("佣金比例不能小于0");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新推广员信息
|
|
|
+ channelService.update(new LambdaUpdateWrapper<Channel>()
|
|
|
+ .set(Channel::getWorkNo, param.getWorkNo())
|
|
|
+ .set(Channel::getName, param.getName())
|
|
|
+ .set(Channel::getCommRate, param.getCommRate())
|
|
|
+ .eq(Channel::getChannelId, param.getChannelId()));
|
|
|
+
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@PostMapping("/delete/{id}")
|
|
|
@ApiOperation("删除推广员")
|
|
|
@ApiImplicitParams(
|
|
@@ -49,7 +88,8 @@ public class PromoterController extends BaseApiController {
|
|
|
public AjaxResult delete(@PathVariable("id") Long id) {
|
|
|
Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
int count = channelService.count(
|
|
|
- new LambdaQueryWrapper<Channel>().eq(Channel::getChannelId, id).eq(Channel::getParentId, channelId));
|
|
|
+ new LambdaQueryWrapper<Channel>().eq(Channel::getChannelId, id)
|
|
|
+ .eq(Channel::getParentId, channelId));
|
|
|
if (count <= 0) {
|
|
|
return AjaxResult.error("您没有权限删除该推广员");
|
|
|
}
|