Commit 15e30bbe by 陶光胜

观云台小程序

parent 25c552de
......@@ -3,12 +3,21 @@ package com.gic.cloud.web.controller;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.web.auth.DataAuthUtils;
import com.gic.cloud.web.constant.StoreChannelEnum;
import com.gic.cloud.web.qo.DateTypeQo;
import com.gic.cloud.web.vo.BaseSalesVo;
import com.gic.cloud.web.vo.LevelVo;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.data.api.dto.BaseSalesDTO;
import com.gic.data.api.dto.BaseSalesParamsDTO;
import com.gic.data.api.service.BaseSalesApiService;
import com.gic.enterprise.dto.WmStoreDTO;
import com.gic.enterprise.service.WmStoreApiService;
import com.gic.mall.share.api.dto.shop.ShopDTO;
import com.gic.mall.share.api.enums.ShopTypeEnum;
import com.gic.mall.share.api.service.ShopApiService;
import com.google.inject.internal.asm.$Handle;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -20,9 +29,15 @@ import java.util.List;
@RestController
public class BaseSalesController {
@Autowired
private DataAuthUtils dataAuthUtils;
@Autowired
private StoreSearchUtils storeSearchUtils;
@Autowired
private BaseSalesApiService baseSalesApiService;
@Autowired
private ShopApiService shopApiService;
@Autowired
private WmStoreApiService wmStoreApiService;
@RequestMapping("base-sales")
public RestResponse baseSales(Integer channel, Integer userId, Integer enterpriseId, String searchJSON,
......@@ -31,6 +46,7 @@ public class BaseSalesController {
List<Integer> list = this.storeSearchUtils.storeSearch(userId, enterpriseId, searchJSON);
List<String> onLine = this.storeSearchUtils.onLineStoreSearch(userId, enterpriseId, searchJSON);
List<Integer> childrenStoreGroupIdList = this.storeSearchUtils.getChildrenStoreGroupIdList(parentId);
List<Long> mbrAreaIdList = this.dataAuthUtils.getMbrAreaId(userId, enterpriseId);
BaseSalesParamsDTO dto = new BaseSalesParamsDTO();
dto.setChannel(channel);
dto.setEnterpriseId(enterpriseId);
......@@ -44,20 +60,82 @@ public class BaseSalesController {
dto.setPageNum(pageNum);
dto.setPageSize(pageSize);
ServiceResponse<Page<BaseSalesDTO>> response = this.baseSalesApiService.pageBaseSales(dto);
if(level == null){
level = this.storeSearchUtils.getLevel(userId, enterpriseId, searchJSON).getLevel();
}
BaseSalesVo vo = new BaseSalesVo();
this.parseData(response.getResult(), StoreChannelEnum.OFFLINE.getChannel(), enterpriseId, level);
vo.setPage(response.getResult());
dto.setCountType(2);//合计
ServiceResponse<Page<BaseSalesDTO>> response1 = this.baseSalesApiService.pageBaseSales(dto);
if(response1.isSuccess() && response1.getResult() != null && CollectionUtils.isNotEmpty(response1.getResult().getResult())){
vo.setTotal(response1.getResult().getResult().get(0));
BaseSalesDTO total = response1.getResult().getResult().get(0);
total.setId("0");
total.setName("合计");
vo.setTotal(total);
}
if(channel == 1 && parentId == null){
dto.setCountType(3); //无归属
ServiceResponse<Page<BaseSalesDTO>> response2 = this.baseSalesApiService.pageBaseSales(dto);
if(response2.isSuccess() && response2.getResult() != null && CollectionUtils.isNotEmpty(response2.getResult().getResult())){
vo.setWgs(response2.getResult().getResult().get(0));
BaseSalesDTO wgs = response2.getResult().getResult().get(0);
if(wgs != null){
wgs.setName("无归属");
wgs.setId("-1");
vo.setWgs(wgs);
}
}
}
return RestResponse.success(vo);
}
public void parseData(Page<BaseSalesDTO> page , Integer channel, Integer enterpriseId, Integer level){
if(page != null && CollectionUtils.isNotEmpty(page.getResult())){
if(channel == null){ //全渠道
page.getResult().stream().forEach(baseSalesDTO -> {
if(StoreChannelEnum.OFFLINE.getChannel() == Integer.valueOf(baseSalesDTO.getId())){
baseSalesDTO.setName(StoreChannelEnum.OFFLINE.getMessage());
}
if(StoreChannelEnum.GICMALL.getChannel() == Integer.valueOf(baseSalesDTO.getId())){
baseSalesDTO.setName(StoreChannelEnum.GICMALL.getMessage());
}
if(StoreChannelEnum.WMMALL.getChannel() == Integer.valueOf(baseSalesDTO.getId())){
baseSalesDTO.setName(StoreChannelEnum.WMMALL.getMessage());
}
if(StoreChannelEnum.TIANMAO.getChannel() == Integer.valueOf(baseSalesDTO.getId())){
baseSalesDTO.setName(StoreChannelEnum.TIANMAO.getMessage());
}
});
}
if(channel == StoreChannelEnum.GICMALL.getChannel()){
List<ShopDTO> result = shopApiService.getAllShopByEnterpriseIdAndName(enterpriseId, null, ShopTypeEnum.MALL_SHOP.getCode()).getResult();
if(CollectionUtils.isNotEmpty(result)){
page.getResult().stream().forEach(baseSalesDTO -> {
for(ShopDTO shopDTO : result){
if(baseSalesDTO.getId().equals(shopDTO.getId())){
baseSalesDTO.setName(shopDTO.getName());
}
}
});
}
}
if(channel == StoreChannelEnum.WMMALL.getChannel()){
List<WmStoreDTO> result1 = wmStoreApiService.listWmStore(enterpriseId, null).getResult();
if(CollectionUtils.isNotEmpty(result1)){
page.getResult().stream().forEach(baseSalesDTO -> {
for(WmStoreDTO dto : result1){
if(baseSalesDTO.getId().equals(dto.getWmMallStoreId()+"")){
baseSalesDTO.setName(dto.getWmMainAccount());
}
}
});
}
}
if(channel == StoreChannelEnum.OFFLINE.getChannel()){
page.getResult().stream().forEach(baseSalesDTO -> {
baseSalesDTO.setLevel(level);
});
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment