|
@@ -3,6 +3,9 @@ package com.qs.mp.web.controller.api.admin;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.qs.mp.admin.domain.Goods;
|
|
|
|
+import com.qs.mp.admin.domain.vo.GoodsListVO;
|
|
|
|
+import com.qs.mp.admin.service.IGoodsService;
|
|
import com.qs.mp.channel.domain.Channel;
|
|
import com.qs.mp.channel.domain.Channel;
|
|
import com.qs.mp.channel.domain.param.ChannelParam;
|
|
import com.qs.mp.channel.domain.param.ChannelParam;
|
|
import com.qs.mp.channel.domain.vo.ChannelVO;
|
|
import com.qs.mp.channel.domain.vo.ChannelVO;
|
|
@@ -11,6 +14,7 @@ import com.qs.mp.channel.service.IChannelUserRelService;
|
|
import com.qs.mp.common.constant.UserConstants;
|
|
import com.qs.mp.common.constant.UserConstants;
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
import com.qs.mp.common.core.page.TableDataInfo;
|
|
import com.qs.mp.common.core.page.TableDataInfo;
|
|
|
|
+import com.qs.mp.common.enums.ChannelRoleEnum;
|
|
import com.qs.mp.common.enums.ErrorCodeEnum;
|
|
import com.qs.mp.common.enums.ErrorCodeEnum;
|
|
import com.qs.mp.system.domain.SysUser;
|
|
import com.qs.mp.system.domain.SysUser;
|
|
import com.qs.mp.system.service.ISysUserService;
|
|
import com.qs.mp.system.service.ISysUserService;
|
|
@@ -45,53 +49,35 @@ import org.springframework.web.bind.annotation.RestController;
|
|
public class GoodsMgrController extends BaseApiController {
|
|
public class GoodsMgrController extends BaseApiController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private IChannelService channelService;
|
|
|
|
-
|
|
|
|
|
|
+ private IGoodsService goodsService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
- private IChannelUserRelService channelUserRelService;
|
|
|
|
-
|
|
|
|
|
|
+ private IChannelService channelService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
- private ISysUserService userService;
|
|
|
|
-
|
|
|
|
|
|
+ private ISysUserService sysUserService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private MapperFacade mapperFacade;
|
|
private MapperFacade mapperFacade;
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取我的下级渠道列表信息,支持翻页
|
|
* 获取我的下级渠道列表信息,支持翻页
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@PostMapping("/list")
|
|
@PostMapping("/list")
|
|
- public TableDataInfo listChannel(@RequestBody Channel channel) {
|
|
|
|
- List<ChannelVO> list = new ArrayList<ChannelVO>();
|
|
|
|
|
|
+ public TableDataInfo list(@RequestBody Goods goods) {
|
|
|
|
+ List<GoodsListVO> list = new ArrayList<GoodsListVO>();
|
|
startPage();
|
|
startPage();
|
|
- QueryWrapper<Channel> queryWrapper = new QueryWrapper<>();
|
|
|
|
- if(null!=channel && null != channel.getParentId()) {
|
|
|
|
- queryWrapper.eq("t1.parent_id", channel.getParentId());
|
|
|
|
- }
|
|
|
|
- queryWrapper.gt("t1.level", 0);
|
|
|
|
- queryWrapper.likeRight(null != channel && StringUtils.isNotBlank(channel.getMobile()), "t1.mobile", channel.getMobile());
|
|
|
|
- queryWrapper.likeRight(null != channel && StringUtils.isNotBlank(channel.getName()), "t1.name", channel.getName());
|
|
|
|
- queryWrapper.orderByAsc("t1.channel_id");
|
|
|
|
- list = channelService.selectChannelVoList(queryWrapper);
|
|
|
|
- if(null != list && list.size() > 0) {
|
|
|
|
- for(ChannelVO channelVO : list) {
|
|
|
|
- if(null != channelVO && StringUtils.isNotBlank(channelVO.getChannelNo())) {
|
|
|
|
- int siteCnt = channelService.getChannelSiteCnt(channelVO.getChannelNo());
|
|
|
|
- int userCnt = channelUserRelService.getChannelTotalUserCnt(channelVO.getChannelNo());
|
|
|
|
- channelVO.setSiteCnt(siteCnt);
|
|
|
|
- channelVO.setUserCnt(userCnt);
|
|
|
|
- // 查询用户信息
|
|
|
|
- // SysUser sysUser = userService.selectUserById(channelVO.getUserId());
|
|
|
|
- // channelVO.setSysUser(sysUser);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ List<Goods> goodsList = goodsService.list(new LambdaQueryWrapper<Goods>());
|
|
|
|
+ List<GoodsListVO> goodsListVOList = mapperFacade.mapAsList(goodsList, GoodsListVO.class);
|
|
|
|
+ TableDataInfo res = getDataTable(goodsList);
|
|
|
|
+ res.setRows(goodsListVOList);
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 新增子渠道信息
|
|
* 新增子渠道信息
|
|
* @param
|
|
* @param
|
|
@@ -121,7 +107,7 @@ public class GoodsMgrController extends BaseApiController {
|
|
if(null != channel.getParentId() && channel.getParentId() != 0) {
|
|
if(null != channel.getParentId() && channel.getParentId() != 0) {
|
|
Channel parentChannel = channelService.getById(channel.getParentId());
|
|
Channel parentChannel = channelService.getById(channel.getParentId());
|
|
if(null != parentChannel) {
|
|
if(null != parentChannel) {
|
|
- if(null != parentChannel.getCommRate()
|
|
|
|
|
|
+ if(null != parentChannel.getCommRate()
|
|
&& channel.getCommRate().compareTo(parentChannel.getCommRate()) > 0) {
|
|
&& channel.getCommRate().compareTo(parentChannel.getCommRate()) > 0) {
|
|
return AjaxResult.error("佣金比例不能高于父渠道的佣金比例");
|
|
return AjaxResult.error("佣金比例不能高于父渠道的佣金比例");
|
|
}
|
|
}
|
|
@@ -130,18 +116,18 @@ public class GoodsMgrController extends BaseApiController {
|
|
}else {
|
|
}else {
|
|
return AjaxResult.error("父渠道不存在");
|
|
return AjaxResult.error("父渠道不存在");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}else {
|
|
}else {
|
|
channel.setLevel(1);
|
|
channel.setLevel(1);
|
|
channel.setChannelNo("");
|
|
channel.setChannelNo("");
|
|
}
|
|
}
|
|
// 3.插入数据
|
|
// 3.插入数据
|
|
try {
|
|
try {
|
|
- channelService.saveChannel(channel,"channel");
|
|
|
|
|
|
+ channelService.saveChannel(channel, ChannelRoleEnum.CHANNEL);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
return AjaxResult.error("渠道'" + channel.getName() + "'新增失败" + e.getMessage());
|
|
return AjaxResult.error("渠道'" + channel.getName() + "'新增失败" + e.getMessage());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return AjaxResult.success("渠道'" + channel.getName() + "'新增成功");
|
|
return AjaxResult.success("渠道'" + channel.getName() + "'新增成功");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -153,7 +139,7 @@ public class GoodsMgrController extends BaseApiController {
|
|
@ApiOperation(value = "编辑子渠道信息", notes = "渠道端编辑子渠道")
|
|
@ApiOperation(value = "编辑子渠道信息", notes = "渠道端编辑子渠道")
|
|
@PostMapping("/update")
|
|
@PostMapping("/update")
|
|
public AjaxResult channelUpdate(@Validated @RequestBody ChannelParam channelParam) {
|
|
public AjaxResult channelUpdate(@Validated @RequestBody ChannelParam channelParam) {
|
|
- if (null == channelParam || null == channelParam.getChannelId()) {
|
|
|
|
|
|
+ /*if (null == channelParam || null == channelParam.getChannelId()) {
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
}
|
|
}
|
|
Channel channel = mapperFacade.map(channelParam, Channel.class);
|
|
Channel channel = mapperFacade.map(channelParam, Channel.class);
|
|
@@ -187,7 +173,7 @@ public class GoodsMgrController extends BaseApiController {
|
|
// 3.校验佣金比例,不能高于其父渠道的佣金比例,不能低于其子渠道的最大佣金比例
|
|
// 3.校验佣金比例,不能高于其父渠道的佣金比例,不能低于其子渠道的最大佣金比例
|
|
Channel parentChannel = channelService.getById(oldChannel.getParentId());
|
|
Channel parentChannel = channelService.getById(oldChannel.getParentId());
|
|
if(null != parentChannel) {
|
|
if(null != parentChannel) {
|
|
- if(null != parentChannel.getCommRate()
|
|
|
|
|
|
+ if(null != parentChannel.getCommRate()
|
|
&& channel.getCommRate().compareTo(parentChannel.getCommRate()) > 0) {
|
|
&& channel.getCommRate().compareTo(parentChannel.getCommRate()) > 0) {
|
|
return AjaxResult.error("佣金比例不能高于父渠道的佣金比例");
|
|
return AjaxResult.error("佣金比例不能高于父渠道的佣金比例");
|
|
}
|
|
}
|
|
@@ -212,10 +198,11 @@ public class GoodsMgrController extends BaseApiController {
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
return AjaxResult.error(e.getMessage());
|
|
return AjaxResult.error(e.getMessage());
|
|
}
|
|
}
|
|
- return AjaxResult.success("渠道'" + channel.getName() + "'编辑成功");
|
|
|
|
|
|
+ return AjaxResult.success("渠道'" + channel.getName() + "'编辑成功");*/
|
|
|
|
+ return AjaxResult.success();
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 停用、启用渠道
|
|
* 停用、启用渠道
|
|
* @param
|
|
* @param
|
|
@@ -245,5 +232,5 @@ public class GoodsMgrController extends BaseApiController {
|
|
}
|
|
}
|
|
return AjaxResult.success("操作成功");
|
|
return AjaxResult.success("操作成功");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|