Просмотр исходного кода

[统计][修改][添加业态分析]

release_toaliyun_real
luozukai 7 лет назад
Родитель
Сommit
9bfb6ce66e
5 измененных файлов: 93 добавлений и 27 удалений
  1. +47
    -23
      mallinkAdmin/src/main/java/com/iformall/controller/sys/WxBusinessController.java
  2. +20
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/WxBusinessDataVo.java
  3. +5
    -4
      mallinkService/src/main/java/com/iformall/service/WxBusinessService.java
  4. +3
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java
  5. +18
    -0
      mallinkService/src/main/resources/mapper/WxBusinessMapper.xml

+ 47
- 23
mallinkAdmin/src/main/java/com/iformall/controller/sys/WxBusinessController.java Просмотреть файл

@@ -1,11 +1,13 @@
package com.iformall.controller.sys;

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxBusiness;
import com.iformall.domain.po.WxSubBusiness;
import com.iformall.domain.vo.WxBusinessDataVo;
import com.iformall.domain.vo.WxMerchantSubsidyVo;
import com.iformall.service.ExcelService;
import com.iformall.service.WxBusinessService;
import com.iformall.service.WxSubBusinessService;
import com.iformall.utils.DateUtils;
@@ -13,11 +15,14 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.http.HttpResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

@@ -29,9 +34,11 @@ public class WxBusinessController extends BaseController {

@Autowired
private WxBusinessService wxBusinessService;

@Autowired
private WxSubBusinessService wxSubBusinessService;
@Autowired
private ExcelService excelService;


@ApiOperation("业态全列表接口")
@GetMapping("listAll")
@@ -59,15 +66,49 @@ public class WxBusinessController extends BaseController {
wxBusiness.setTenantId(getTenantId());
if(wxBusiness.getStartdate() == null || wxBusiness.getEnddate() == null){
Date sDate = DateUtils.getFirstDayForCurrMonth(DateUtils.getLastMonthToDay());
Date d = DateUtils.getLastDayForMonth(DateUtils.getLastMonthToDay());
Date eDate = DateUtils.getLastDayForMonth(DateUtils.getLastMonthToDay());
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
wxBusiness.setStartdate(sdT.parse(sd.format(sDate)+" 00:00:00"));
wxBusiness.setEnddate(sdT.parse(sd.format(d)+" 23:59:59"));
wxBusiness.setEnddate(sdT.parse(sd.format(eDate)+" 23:59:59"));
}
return wxBusinessService.businessDataList(wxBusiness);
}

@ApiOperation("导出业态数据列表")
@GetMapping("exportBusinessDataList")
@SystemControllerLog(description = "导出业态数据列表")
public void exportBusinessDataList(@ModelAttribute WxBusiness wxBusiness, HttpServletResponse response) throws Exception{
logger.debug("[" + getIpAddr() + "] WxBusinessController::exportBusinessDataList");
wxBusiness.setTenantId(getTenantId());
if(wxBusiness.getStartdate() == null || wxBusiness.getEnddate() == null){
Date sDate = DateUtils.getFirstDayForCurrMonth(DateUtils.getLastMonthToDay());
Date eDate = DateUtils.getLastDayForMonth(DateUtils.getLastMonthToDay());
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
wxBusiness.setStartdate(sdT.parse(sd.format(sDate)+" 00:00:00"));
wxBusiness.setEnddate(sdT.parse(sd.format(eDate)+" 23:59:59"));
}
List<Map<String,Object>> dataList = (List<Map<String,Object>>)wxBusinessService.businessDataList(wxBusiness).data;
List<WxBusinessDataVo> exeList = new ArrayList<>();
for (Map<String,Object> m:dataList) {
WxBusinessDataVo businessDataVo = new WxBusinessDataVo();
businessDataVo.setName((String)m.get("title"));
if(m.get("comPrice") != null)
businessDataVo.setComPrice(m.get("comPrice").toString());
if(m.get("rent") != null)
businessDataVo.setRentRate(m.get("rent").toString());
if(m.get("rentSaleRate") != null)
businessDataVo.setRentSaleRate(m.get("rentSaleRate").toString());
if(m.get("volume") != null)
businessDataVo.setSale(m.get("volume").toString());
if(m.get("sale") != null)
businessDataVo.setSaleRate(m.get("sale").toString());
exeList.add(businessDataVo);
}
excelService.exportExcel(exeList, null, "业态统计", WxBusinessDataVo.class, "业态统计列表.xlsx", response, false);
}

@ApiOperation("贡献率排行")
@GetMapping("devoteList")
@SystemControllerLog(description = "贡献率排行")
@@ -76,25 +117,8 @@ public class WxBusinessController extends BaseController {
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData devoteList(@ModelAttribute WxBusiness wxBusiness,Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxBusinessController::devoteList");
List<Map<String,String>> result = new ArrayList<>();
Map<String,String> map = new HashMap<>();
map.put("merchantName","西贝筱面");
map.put("sale","2323.23");//营业额
map.put("saleRate","32323.23");//商户销售坪效
map.put("devoteRate","1.23");//贡献率
result.add(map);
map = new HashMap<>();
map.put("merchantName","肯德基");
map.put("sale","2323.23");//营业额
map.put("saleRate","32323.23");//商户销售坪效
map.put("devoteRate","1.23");//贡献率
result.add(map);
PageInfo<Map<String,String>> page = new PageInfo<>();
page.setList(result);
page.setTotal(2);
page.setPageNum(1);
page.setPageSize(20);
return new ResultData(page);
wxBusiness.setTenantId(getTenantId());
return new ResultData(wxBusinessService.devoteList(wxBusiness,pageNum,pageSize));
}




+ 20
- 0
mallinkService/src/main/java/com/iformall/domain/vo/WxBusinessDataVo.java Просмотреть файл

@@ -0,0 +1,20 @@
package com.iformall.domain.vo;

import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;

@Data
public class WxBusinessDataVo {
@Excel(name="业态",width = 20,orderNum = "1")
private String name;
@Excel(name="营业额(万)",width = 20,orderNum = "2")
private String sale = "0";
@Excel(name="销售坪效(元/m2)",width = 20,orderNum = "3")
private String saleRate = "0" ;
@Excel(name="租赁坪效(元/m2)",width = 20,orderNum = "5")
private String rentRate = "0";
@Excel(name="租售比",width = 20,orderNum = "6")
private String rentSaleRate = "0";
@Excel(name="客单价(元)",width = 20,orderNum = "7")
private String comPrice = "0";
}

+ 5
- 4
mallinkService/src/main/java/com/iformall/service/WxBusinessService.java Просмотреть файл

@@ -3,7 +3,10 @@ package com.iformall.service;
import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxBusiness;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

public interface WxBusinessService {
@@ -47,8 +50,6 @@ public interface WxBusinessService {

ResultData devoteList(WxBusiness wxBusiness,Integer pageNum, Integer pageSize);



}

+ 3
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java Просмотреть файл

@@ -12,6 +12,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Service
@@ -59,4 +61,5 @@ public class WxBusinessServiceImpl implements WxBusinessService {
public ResultData devoteList(WxBusiness wxBusiness, Integer pageNum, Integer pageSize) {
return new ResultData(PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxBusinessMapper.devoteList(wxBusiness)));
}

}

+ 18
- 0
mallinkService/src/main/resources/mapper/WxBusinessMapper.xml Просмотреть файл

@@ -157,7 +157,25 @@
</select>

<select id="devoteList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap">
select m.name merchantName,round(sum(mtd.trade_amt)/sum(ws.operation_area) /100,2) saleRate,

round(
round(sum(mtd.trade_amt)/sum(ws.operation_area) /100,2)/
(select round(sum(mtd.trade_amt)/sum(ws.operation_area) /100,2)
from wx_merchant m
left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
left join wx_merchant_shop wmt on wmt.merchant_id = m.id
left join wx_shop ws on(wmt.shop_id = ws.id)
where m.business_id=#{id} and m.tenant_id=#{tenantId})
,2) devoteRate

from wx_merchant m
left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
left join wx_merchant_shop wmt on wmt.merchant_id = m.id
left join wx_shop ws on(wmt.shop_id = ws.id)
where m.business_id=#{id} and m.tenant_id=#{tenantId}
group by m.id
order by devoteRate desc
</select>

</mapper>

Загрузка…
Отмена
Сохранить