|
@@ -3,8 +3,11 @@ package com.qs.mp.web.controller.api.admin;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.qs.mp.admin.domain.vo.TicketCntVO;
|
|
|
+import com.qs.mp.admin.service.ITicketService;
|
|
|
import com.qs.mp.channel.domain.Channel;
|
|
|
import com.qs.mp.channel.domain.ChannelOrder;
|
|
|
+import com.qs.mp.channel.domain.ChannelOrderDetail;
|
|
|
import com.qs.mp.channel.domain.ChannelUserRel;
|
|
|
import com.qs.mp.channel.domain.param.ChannelParam;
|
|
|
import com.qs.mp.channel.domain.param.SaleSiteParam;
|
|
@@ -20,8 +23,11 @@ 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.common.enums.UserTicketOrderStatusEnum;
|
|
|
import com.qs.mp.system.domain.SysUser;
|
|
|
import com.qs.mp.system.service.ISysUserService;
|
|
|
+import com.qs.mp.user.domain.UserTicketOrder;
|
|
|
+import com.qs.mp.user.service.IUserTicketOrderService;
|
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -31,6 +37,7 @@ import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -61,9 +68,15 @@ public class SaleSiteMgrController extends BaseApiController {
|
|
|
|
|
|
@Autowired
|
|
|
private IChannelOrderService channelOrderService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserTicketOrderService userTicketOrderService;
|
|
|
|
|
|
@Autowired
|
|
|
private ISysUserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ITicketService ticketService;
|
|
|
|
|
|
@Autowired
|
|
|
private MapperFacade mapperFacade;
|
|
@@ -76,7 +89,7 @@ public class SaleSiteMgrController extends BaseApiController {
|
|
|
*/
|
|
|
@PostMapping("/list")
|
|
|
@PreAuthorize("@ss.hasPermi('business:salesite:list')")
|
|
|
- public TableDataInfo listChannel(@RequestBody Channel channel) {
|
|
|
+ public TableDataInfo listSite(@RequestBody Channel channel) {
|
|
|
List<ChannelVO> list = new ArrayList<ChannelVO>();
|
|
|
startPage();
|
|
|
QueryWrapper<Channel> queryWrapper = new QueryWrapper<>();
|
|
@@ -91,9 +104,26 @@ public class SaleSiteMgrController extends BaseApiController {
|
|
|
queryWrapper.eq(null != channel && null != channel.getAreaId(), "t1.area_id", channel.getAreaId());
|
|
|
queryWrapper.orderByDesc("t1.channel_id");
|
|
|
list = channelService.selectChannelVoList(queryWrapper);
|
|
|
+ List<Long> channelIds = new ArrayList<Long>();
|
|
|
if(null != list && list.size() > 0) {
|
|
|
for(ChannelVO channelVO : list) {
|
|
|
- if(null != channelVO && StringUtils.isNotBlank(channelVO.getChannelNo())) {
|
|
|
+ if(null != channelVO && null != channelVO.getChannelId()
|
|
|
+ && StringUtils.isNotBlank(channelVO.getChannelNo())) {
|
|
|
+ channelIds.add(channelVO.getChannelId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<TicketCntVO> cntList = new ArrayList<TicketCntVO>();
|
|
|
+ if(null != channelIds && channelIds.size() > 0) {
|
|
|
+ QueryWrapper<ChannelOrderDetail> ticketCntQueryWrapper = new QueryWrapper<ChannelOrderDetail>();
|
|
|
+ ticketCntQueryWrapper.in("t1.channel_id", channelIds);
|
|
|
+ cntList = ticketService.listTicketCnt(ticketCntQueryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null != list && list.size() > 0) {
|
|
|
+ for(ChannelVO channelVO : list) {
|
|
|
+ if(null != channelVO && null != channelVO.getChannelId()
|
|
|
+ && StringUtils.isNotBlank(channelVO.getChannelNo())) {
|
|
|
// int siteCnt = channelService.getChannelSiteCnt(channelVO.getChannelNo());
|
|
|
LambdaQueryWrapper<ChannelUserRel> userCntQueryWrapper = new LambdaQueryWrapper<ChannelUserRel>();
|
|
|
userCntQueryWrapper.eq(ChannelUserRel::getChannelId, channelVO.getChannelId());
|
|
@@ -102,12 +132,70 @@ public class SaleSiteMgrController extends BaseApiController {
|
|
|
// 查询用户信息
|
|
|
//SysUser sysUser = userService.selectUserById(channelVO.getUserId());
|
|
|
// channelVO.setSysUser(sysUser);
|
|
|
+ channelVO.setParentsName(getParentsName(channelVO.getChannelNo()));
|
|
|
+ // 统计盲票库存, 销量
|
|
|
+ if(null != cntList && cntList.size() > 0) {
|
|
|
+ List<TicketCntVO> voList = cntList.stream().filter(item -> item.getChannelId().equals(channelVO.getChannelId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if(null != voList && voList.size() > 0) {
|
|
|
+ TicketCntVO ticketCnt = voList.get(0);
|
|
|
+ channelVO.setOffLineQtyCnt(null != ticketCnt?ticketCnt.getOffLineQtyCnt():0);
|
|
|
+ channelVO.setOffLineSaleCnt(null != ticketCnt?ticketCnt.getOffLineSaleCnt():0);
|
|
|
+ channelVO.setOnLineSaleCnt(null != ticketCnt?ticketCnt.getOnLineSaleCnt():0);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
+
|
|
|
+ // 获取上级渠道迭代
|
|
|
+ private String getParentsName(String channelNo) {
|
|
|
+ if(StringUtils.isNotBlank(channelNo)) {
|
|
|
+ String[] noArray = channelNo.split("\\.");
|
|
|
+ if(null != noArray && noArray.length > 0) {
|
|
|
+ List<String> noList = new ArrayList<String>();
|
|
|
+ String parentNo = "";
|
|
|
+ for (int i = 0; i < noArray.length; i++) {
|
|
|
+ if(null != noArray[i] && StringUtils.isNotBlank(noArray[i])) {
|
|
|
+ parentNo += (i>0?".":"")+noArray[i];
|
|
|
+ if(StringUtils.isNotBlank(parentNo) && !parentNo.equals(channelNo)) {
|
|
|
+ noList.add(parentNo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(noList.size() > 0 ) {
|
|
|
+ LambdaQueryWrapper<Channel> queryWrapper = new LambdaQueryWrapper<Channel>();
|
|
|
+ queryWrapper.gt(Channel::getLevel, 0);
|
|
|
+ queryWrapper.in(Channel::getChannelNo,noList);
|
|
|
+ queryWrapper.orderByAsc(Channel::getLevel);
|
|
|
+ List<Channel> list = channelService.list(queryWrapper);
|
|
|
+ if(null != list && list.size() >0) {
|
|
|
+ String names = list.stream().map(Channel::getName).collect(Collectors.joining(" > "));
|
|
|
+ return names;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询所有渠道列表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/listAll")
|
|
|
+ // @PreAuthorize("@ss.hasPermi('business:salesite:list')")
|
|
|
+ public AjaxResult listAllSite() {
|
|
|
+ List<Channel> list = new ArrayList<Channel>();
|
|
|
+ LambdaQueryWrapper<Channel> queryWrapper = new LambdaQueryWrapper<Channel>();
|
|
|
+ queryWrapper.eq(Channel::getLevel, 0);
|
|
|
+ queryWrapper.orderByDesc(Channel::getChannelId);
|
|
|
+ list = channelService.list(queryWrapper);
|
|
|
+ return AjaxResult.success(list);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 新增经销商信息
|
|
@@ -118,7 +206,7 @@ public class SaleSiteMgrController extends BaseApiController {
|
|
|
@ApiOperation(value = "新增经销商信息", notes = "经销商端新增经销商")
|
|
|
@PostMapping("/create")
|
|
|
@PreAuthorize("@ss.hasPermi('business:salesite:add')")
|
|
|
- public AjaxResult channelCreate(@Validated @RequestBody SaleSiteParam channelParam) {
|
|
|
+ public AjaxResult siteCreate(@Validated @RequestBody SaleSiteParam channelParam) {
|
|
|
if (channelParam.getChannelId() != null && channelParam.getChannelId() != 0) {
|
|
|
return AjaxResult.error("该经销商已存在");
|
|
|
}
|
|
@@ -173,7 +261,7 @@ public class SaleSiteMgrController extends BaseApiController {
|
|
|
@ApiOperation(value = "编辑经销商信息", notes = "经销商端编辑经销商")
|
|
|
@PostMapping("/update")
|
|
|
@PreAuthorize("@ss.hasPermi('business:salesite:edit')")
|
|
|
- public AjaxResult channelUpdate(@Validated @RequestBody ChannelParam channelParam) {
|
|
|
+ public AjaxResult siteUpdate(@Validated @RequestBody ChannelParam channelParam) {
|
|
|
if (null == channelParam || null == channelParam.getChannelId()) {
|
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
}
|
|
@@ -236,7 +324,7 @@ public class SaleSiteMgrController extends BaseApiController {
|
|
|
@ApiOperation(value = "停用、启用经销商信息", notes = "经销商管理编辑经销商")
|
|
|
@PostMapping("/status")
|
|
|
@PreAuthorize("@ss.hasPermi('business:salesite:edit')")
|
|
|
- public AjaxResult channelStatus(@RequestBody JSONObject jsonObject) {
|
|
|
+ public AjaxResult siteStatus(@RequestBody JSONObject jsonObject) {
|
|
|
String channelId = jsonObject.containsKey("channelId")?jsonObject.get("channelId").toString():"";
|
|
|
String status = jsonObject.containsKey("status")?jsonObject.get("status").toString():"";
|
|
|
if (null == jsonObject || StringUtils.isBlank(channelId)
|
|
@@ -268,7 +356,7 @@ public class SaleSiteMgrController extends BaseApiController {
|
|
|
@ApiOperation(value = "查询经销商详情信息", notes = "经销商管理编辑子经销商查询经销商详情")
|
|
|
@PostMapping("/detail")
|
|
|
@PreAuthorize("@ss.hasPermi('business:salesite:query')")
|
|
|
- public AjaxResult getChannelDetail(@RequestBody JSONObject jsonObject) {
|
|
|
+ public AjaxResult getSiteDetail(@RequestBody JSONObject jsonObject) {
|
|
|
String channelId = (null != jsonObject && jsonObject.containsKey("channelId"))?jsonObject.getString("channelId"):"";
|
|
|
if (StringUtils.isBlank(channelId)) {
|
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
@@ -283,13 +371,19 @@ public class SaleSiteMgrController extends BaseApiController {
|
|
|
userCntQueryWrapper.eq(ChannelUserRel::getChannelId, channelVO.getChannelId());
|
|
|
int userCnt = channelUserRelService.count(userCntQueryWrapper);
|
|
|
channelVO.setUserCnt(userCnt);
|
|
|
+ channelVO.setParentsName(getParentsName(channelVO.getChannelNo()));
|
|
|
}
|
|
|
// 查询经销商销售额、佣金收入、订单数等
|
|
|
ChannelOperDataVO channelOperDataVO = channelService.getChannelTotalOperData(channelVO.getChannelNo());
|
|
|
- LambdaQueryWrapper<ChannelOrder> queryWrapper = new LambdaQueryWrapper<ChannelOrder>();
|
|
|
- queryWrapper.eq(ChannelOrder::getChannelId, channelId);
|
|
|
- int orderCnt = channelOrderService.count(queryWrapper);
|
|
|
- channelOperDataVO.setOrderCnt(orderCnt);
|
|
|
+ // LambdaQueryWrapper<ChannelOrder> queryWrapper = new LambdaQueryWrapper<ChannelOrder>();
|
|
|
+ // queryWrapper.eq(ChannelOrder::getChannelId, channelId);
|
|
|
+// int orderCnt = channelOrderService.count(queryWrapper);
|
|
|
+// channelOperDataVO.setOrderCnt(orderCnt);
|
|
|
+
|
|
|
+ // 盲票销售张数
|
|
|
+ int ticketSaleCnt = userTicketOrderService.getSaleSiteTotalTicketNumCnt(channelVO.getChannelId());
|
|
|
+ channelOperDataVO.setTicketSaleCnt(ticketSaleCnt);
|
|
|
+
|
|
|
channelVO.setOperData(channelOperDataVO);
|
|
|
return AjaxResult.success(channelVO);
|
|
|
}
|