|
@@ -3,6 +3,8 @@ 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.excel.ChannelExcel;
|
|
|
+import com.qs.mp.admin.domain.excel.UserTicketOrderItemExcel;
|
|
|
import com.qs.mp.admin.domain.vo.TicketCntVO;
|
|
|
import com.qs.mp.admin.service.ITicketService;
|
|
|
import com.qs.mp.channel.domain.Channel;
|
|
@@ -28,6 +30,7 @@ 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.utils.ExcelUtil;
|
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -39,12 +42,14 @@ import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -159,6 +164,84 @@ public class SaleSiteMgrController extends BaseApiController {
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/export")
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:salesite:export')")
|
|
|
+ @ApiOperation("导出经销商信息")
|
|
|
+ @ApiResponses(
|
|
|
+ @ApiResponse(code = 200, message = "经销商列表返回信息",response = ChannelVO.class)
|
|
|
+ )
|
|
|
+ public AjaxResult export(@RequestBody Channel channel) {
|
|
|
+ QueryWrapper<Channel> queryWrapper = new QueryWrapper<>();
|
|
|
+ if(null!=channel && null != channel.getParentId()) {
|
|
|
+ queryWrapper.eq("t1.parent_id", channel.getParentId());
|
|
|
+ }
|
|
|
+ queryWrapper.eq("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.eq(null != channel && null != channel.getProvinceId(), "t1.province_id", channel.getProvinceId());
|
|
|
+ queryWrapper.eq(null != channel && null != channel.getCityId(), "t1.city_id", channel.getCityId());
|
|
|
+ queryWrapper.eq(null != channel && null != channel.getAreaId(), "t1.area_id", channel.getAreaId());
|
|
|
+ List<ChannelVO> list = channelService.selectSaleSiteList(queryWrapper);
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return AjaxResult.error("没有符合条件的经销商信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null != list && list.size() > 0) {
|
|
|
+ for(ChannelVO channelVO : list) {
|
|
|
+ if(null != channelVO && null != channelVO.getChannelId()
|
|
|
+ && StringUtils.isNotBlank(channelVO.getChannelNo())) {
|
|
|
+ channelVO.setParentsName(getParentsNameAndCommRate(channelVO.getChannelNo()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ChannelExcel> excelList = new ArrayList<>();
|
|
|
+ for (ChannelVO channelVO : list) {
|
|
|
+ ChannelExcel channelExcel = new ChannelExcel();
|
|
|
+ channelExcel.setChannelId(channelVO.getChannelId());
|
|
|
+ channelExcel.setCommRate(channelVO.getCommRate());
|
|
|
+ channelExcel.setName(channelVO.getName());
|
|
|
+ channelExcel.setParentsName(channelVO.getParentsName());
|
|
|
+ if (Objects.nonNull(channelVO.getCertifyStatus())) {
|
|
|
+ channelExcel.setCertifyStatus(channelVO.getCertifyStatus().getDesc());
|
|
|
+ }
|
|
|
+ excelList.add(channelExcel);
|
|
|
+ }
|
|
|
+
|
|
|
+ ExcelUtil<ChannelExcel> util = new ExcelUtil<>(ChannelExcel.class);
|
|
|
+ return util.exportExcel(excelList, "经销商导出", false);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getParentsNameAndCommRate(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) {
|
|
|
+ return list.stream().map(channel -> channel.getName() + "(" + channel.getCommRate() + "%)").collect(Collectors.joining(" > "));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 查询所有渠道列表
|
|
|
*
|