|
@@ -446,9 +446,22 @@ public class SaleSiteMgrController extends BaseApiController {
|
|
|
if (channel == null) {
|
|
|
return AjaxResult.error("门店信息不存在");
|
|
|
}
|
|
|
+ //手机号是否重复校验
|
|
|
+ if (!saleSiteEditParam.getMobile().equals(channel.getMobile())) {
|
|
|
+
|
|
|
+ int mobileCount = channelService.count(
|
|
|
+ new LambdaQueryWrapper<Channel>().eq(Channel::getMobile, channel.getMobile()));
|
|
|
+ if (mobileCount > 0) {
|
|
|
+ return AjaxResult.error("手机号码" + channel.getMobile() + "已注册!");
|
|
|
+ }
|
|
|
+ if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(channel.getMobile()))) {
|
|
|
+ return AjaxResult.error("手机号码" + channel.getMobile() + "已注册!");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
boolean rtn = channelService.update(new LambdaUpdateWrapper<Channel>()
|
|
|
.set(Channel::getName, saleSiteEditParam.getName())
|
|
|
+ .set(Channel::getMobile, saleSiteEditParam.getMobile())
|
|
|
.set(saleSiteEditParam.getCommFlag() != null, Channel::getCommFlag, saleSiteEditParam.getCommFlag())
|
|
|
.eq(Channel::getChannelId, saleSiteEditParam.getChannelId()));
|
|
|
|
|
@@ -610,4 +623,64 @@ public class SaleSiteMgrController extends BaseApiController {
|
|
|
return AjaxResult.success(channelVO);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 门店转渠道
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * 参数:{"channelId":"2439", parentId:"2438"}
|
|
|
+ * channelId当前门店id
|
|
|
+ * parentId父渠道id
|
|
|
+ */
|
|
|
+ @Log(title = "门店转渠道", businessType = BusinessType.UPDATE)
|
|
|
+ @ApiOperation(value = "门店转渠道", notes = "门店转渠道")
|
|
|
+ @PostMapping("/transform")
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:salesite: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异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改门店为渠道
|
|
|
+ //查询上级代理信息
|
|
|
+ Channel parentChannel = channelService.getById(channelParam.getParentId());
|
|
|
+ boolean mobileChange = false; // 手机号码是否有变更
|
|
|
+ channel.setParentId(channelParam.getParentId());
|
|
|
+ channel.setLevel(0);
|
|
|
+ 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() + "'变更为渠道成功");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|