|
@@ -17,6 +17,8 @@ import com.qs.mp.common.core.page.TableDataInfo;
|
|
|
import com.qs.mp.common.enums.BusinessType;
|
|
|
import com.qs.mp.common.enums.ChannelRoleEnum;
|
|
|
import com.qs.mp.common.enums.ErrorCodeEnum;
|
|
|
+import com.qs.mp.system.domain.SysUser;
|
|
|
+import com.qs.mp.system.domain.SysUserRole;
|
|
|
import com.qs.mp.system.service.ISysUserService;
|
|
|
import com.qs.mp.user.service.IUserTicketOrderService;
|
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
@@ -386,4 +388,71 @@ public class ChannelMgrController extends BaseApiController {
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 渠道转门店
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * 参数:{"channelId":"2439", parentId:"2438"}
|
|
|
+ * channelId当前渠道id
|
|
|
+ * parentId父渠道id
|
|
|
+ */
|
|
|
+ @Log(title = "渠道转门店", businessType = BusinessType.UPDATE)
|
|
|
+ @ApiOperation(value = "渠道转门店", notes = "渠道转门店")
|
|
|
+ @PostMapping("/transform")
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:channel:edit')")
|
|
|
+ public AjaxResult channelTransformToShop(@Validated @RequestBody ChannelParam channelParam) {
|
|
|
+ if (null == channelParam || null == channelParam.getChannelId()) {
|
|
|
+ return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
+ }
|
|
|
+ //修改当前渠道为门店,参考添加一级渠道
|
|
|
+ Channel channel = channelService.getById(channelParam.getChannelId());
|
|
|
+ if (null == channel || null == channel.getChannelId()) {
|
|
|
+ return AjaxResult.error("渠道'" + channel.getName() + "'转门店失败,渠道ID异常");
|
|
|
+ }
|
|
|
+ //判断当前渠道下有无子渠道
|
|
|
+ LambdaQueryWrapper<Channel> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ if (null != channelParam.getChannelId()) {
|
|
|
+ queryWrapper.eq(Channel::getParentId, channelParam.getChannelId());
|
|
|
+ }
|
|
|
+ queryWrapper.gt(Channel::getLevel, 0);
|
|
|
+ int channelCount = channelService.count(queryWrapper);
|
|
|
+ if (channelCount > 0) {
|
|
|
+ return AjaxResult.error("当前渠道存在子渠道不能转为门店!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改代理为门店
|
|
|
+ //查询上级代理信息
|
|
|
+ Channel parentChannel = channelService.getById(channelParam.getParentId());
|
|
|
+ boolean mobileChange = false; // 手机号码是否有变更
|
|
|
+ channel.setParentId(channelParam.getParentId());
|
|
|
+ channel.setLevel(2);
|
|
|
+ channel.setChannelNo(parentChannel.getChannelNo()+"."+channel.getChannelId());
|
|
|
+ //佣金比例暂定为0
|
|
|
+ channel.setCommRate(BigDecimal.ZERO);
|
|
|
+ /**
|
|
|
+ //校验佣金比例,不能高于其父经销商的佣金比例
|
|
|
+ if (null != channel.getParentId() && channel.getParentId() != 0) {
|
|
|
+ Channel parentChannel = channelService.getById(channel.getParentId());
|
|
|
+ if (null != parentChannel) {
|
|
|
+ if (null != parentChannel.getCommRate()
|
|
|
+ && channel.getCommRate().compareTo(parentChannel.getCommRate()) > 0) {
|
|
|
+ return AjaxResult.error("佣金比例不能高于父经销商的佣金比例");
|
|
|
+ }
|
|
|
+ channel.setLevel(parentChannel.getLevel() + 1);
|
|
|
+ channel.setChannelNo(parentChannel.getChannelNo() + ".");
|
|
|
+ } else {
|
|
|
+ return AjaxResult.error("父经销商不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ */
|
|
|
+ channelService.updateChannel(channel, mobileChange);
|
|
|
+
|
|
|
+ //修改用户信息及岗位、角色关联
|
|
|
+ channelService.alterUserPostAndRole(channel, ChannelRoleEnum.SALESITE);
|
|
|
+
|
|
|
+ return AjaxResult.success("渠道'" + channel.getName() + "'变更为门店成功");
|
|
|
+ }
|
|
|
}
|