Commit 565f938a by zhiwj

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-data-cloud into developer
parents a9c6b7d0 6c3525f8
......@@ -26,6 +26,7 @@ public class IndexDescDTO implements Serializable {
*/
private String indexName;
private String unit;
/**
* 指标code
*/
......@@ -96,6 +97,9 @@ public class IndexDescDTO implements Serializable {
public void setIndexCode(String indexCode) {
this.indexCode = indexCode;
if("showSalesAmt".equals(this.indexCode)){
this.unit = "元";
}
}
public String getIndexGroupName() {
......@@ -177,4 +181,12 @@ public class IndexDescDTO implements Serializable {
public void setUpdateTipsId(Integer updateTipsId) {
this.updateTipsId = updateTipsId;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
}
......@@ -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,44 +29,118 @@ 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,
DateTypeQo dateTypeQo, String mbrAreaId, Integer level, Integer parentId,
Integer pageNum, Integer pageSize){
String sortField, Integer sortType, Integer pageNum, Integer pageSize){
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);
if(level == null){
level = this.storeSearchUtils.getLevel(userId, enterpriseId, searchJSON).getLevel();
}
BaseSalesParamsDTO dto = new BaseSalesParamsDTO();
dto.setChannel(channel);
dto.setEnterpriseId(enterpriseId);
dto.setStoreInfoIdList(list);
dto.setOnLine(onLine);
dto.setMbrAreaId(StringUtils.isBlank(mbrAreaId) ? null : Long.valueOf(mbrAreaId));
dto.setMbrAreaIdList(mbrAreaIdList);
dto.setType(dateTypeQo.getType());
dto.setDate(dateTypeQo.getDate());
dto.setChildrenStoreGroupIdList(childrenStoreGroupIdList);
dto.setLevel(level);
dto.setSortField(sortField);
dto.setSortType(sortType == null ? 1 : sortType);
dto.setPageNum(pageNum);
dto.setPageSize(pageSize);
ServiceResponse<Page<BaseSalesDTO>> response = this.baseSalesApiService.pageBaseSales(dto);
BaseSalesVo vo = new BaseSalesVo();
vo.setPage(response.getResult());
vo.setPage(this.parseData(response.getResult(), channel, enterpriseId, level));
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);
if(total != null){
total.setId("0");
total.setName("合计");
vo.setTotal(total);
}
}
if(channel == 1 && parentId == null){
if(channel != null && 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 Page<BaseSalesDTO> 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);
});
}
}
return page;
}
}
......@@ -7,8 +7,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.gic.cloud.web.auth.DataAuthUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.data.api.qo.consumestructure.AgeConsumeAreaQO;
import com.gic.data.api.qo.consumestructure.AgeConsumeShareQO;
import com.gic.data.api.qo.consumestructure.GradeConsumeTrendQO;
import com.gic.data.api.service.consumestructure.ConsumeStructureApiService;
import com.gic.enterprise.utils.ResultControllerUtils;
......@@ -19,6 +22,8 @@ public class ConsumeStructureController {
private ConsumeStructureApiService consumeStructureApiService;
@Autowired
private StoreSearchUtils storeSearchUtils;
@Autowired
private DataAuthUtils dataAuthUtils;
/**
* 年龄消费占比(订单人数/订单数/销售额)
......@@ -43,4 +48,25 @@ public class ConsumeStructureController {
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
return ResultControllerUtils.commonResult(consumeStructureApiService.queryAgeConsumeSurvey(params));
}
@RequestMapping("get-age-consume-area")
public RestResponse queryAgeConsumeArea(AgeConsumeAreaQO params) {
log.info("消费构成-消费年龄-区域参数:{}", JSON.toJSONString(params));
params.setOnlineStoreIdList(storeSearchUtils.onLineStoreSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
if (params.getLevel() != null) {
params.setLevel(storeSearchUtils.getLevel(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()).getLevel());
}
params.setGroupIdList(storeSearchUtils.getChildrenStoreGroupIdList(params.getParentId()));
params.setMemberCardIdList(dataAuthUtils.getMbrAreaId(params.getUserId(), params.getEnterpriseId()));
return ResultControllerUtils.commonResult(consumeStructureApiService.pageAgeConsumeArea(params));
}
@RequestMapping("get-grade-consume-trend")
public RestResponse getGradeConsumeTrend(GradeConsumeTrendQO params) {
log.info("消费构成-等级-趋势参数:{}", JSON.toJSONString(params));
params.setOnlineStoreIdList(storeSearchUtils.onLineStoreSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
return ResultControllerUtils.commonResult(consumeStructureApiService.queryGradeConsumeTrend(params));
}
}
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