| @@ -8,6 +8,7 @@ import com.iformall.domain.po.WxBusiness; | |||||
| import com.iformall.domain.po.WxSubBusiness; | import com.iformall.domain.po.WxSubBusiness; | ||||
| import com.iformall.service.WxBusinessService; | import com.iformall.service.WxBusinessService; | ||||
| import com.iformall.service.WxSubBusinessService; | import com.iformall.service.WxSubBusinessService; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -16,10 +17,9 @@ import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import java.util.ArrayList; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.*; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("wxBusiness") | @RequestMapping("wxBusiness") | ||||
| @@ -54,40 +54,18 @@ public class WxBusinessController extends BaseController { | |||||
| @ApiOperation("业态分析接口") | @ApiOperation("业态分析接口") | ||||
| @GetMapping("businessDataList") | @GetMapping("businessDataList") | ||||
| @SystemControllerLog(description = "业态分析接口") | @SystemControllerLog(description = "业态分析接口") | ||||
| public ResultData businessDataList(@ModelAttribute WxBusiness wxBusiness) { | |||||
| public ResultData businessDataList(@ModelAttribute WxBusiness wxBusiness) throws Exception{ | |||||
| logger.debug("[" + getIpAddr() + "] WxBusinessController::businessDataList"); | logger.debug("[" + getIpAddr() + "] WxBusinessController::businessDataList"); | ||||
| List<Map<String,String>> result = new ArrayList<>(); | |||||
| Map<String,String> map = new HashMap<>(); | |||||
| map.put("title","餐饮");//业态 | |||||
| map.put("id","1");//业态id | |||||
| map.put("volume","2323.23");//营业额 | |||||
| map.put("sale","32323.23");//销售坪效 | |||||
| map.put("rent","32323.23");//租赁坪效 | |||||
| map.put("rentSaleRate","0.23");//租售比 | |||||
| map.put("comPrice","香奈儿");//客单价 | |||||
| map.put("maxCom","32323.23");//贡献率最高商户 | |||||
| result.add(map); | |||||
| map = new HashMap<>(); | |||||
| map.put("title","娱乐");//业态 | |||||
| map.put("id","2");//业态id | |||||
| map.put("volume","2323.23");//营业额 | |||||
| map.put("sale","32323.23");//销售坪效 | |||||
| map.put("rent","32323.23");//租赁坪效 | |||||
| map.put("rentSaleRate","0.23");//租售比 | |||||
| map.put("comPrice","香奈儿");//客单价 | |||||
| map.put("maxCom","32323.23");//贡献率最高商户 | |||||
| result.add(map); | |||||
| map = new HashMap<>(); | |||||
| map.put("title","影视");//业态 | |||||
| map.put("id","3");//业态id | |||||
| map.put("volume","2323.23");//营业额 | |||||
| map.put("sale","32323.23");//销售坪效 | |||||
| map.put("rent","32323.23");//租赁坪效 | |||||
| map.put("rentSaleRate","0.23");//租售比 | |||||
| map.put("comPrice","香奈儿");//客单价 | |||||
| map.put("maxCom","32323.23");//贡献率最高商户 | |||||
| result.add(map); | |||||
| return new ResultData(result); | |||||
| wxBusiness.setTenantId(getTenantId()); | |||||
| if(wxBusiness.getStartdate() == null || wxBusiness.getEnddate() == null){ | |||||
| Date sDate = DateUtils.getFirstDayForCurrMonth(DateUtils.getLastMonthToDay()); | |||||
| Date d = 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")); | |||||
| } | |||||
| return wxBusinessService.businessDataList(wxBusiness); | |||||
| } | } | ||||
| @ApiOperation("贡献率排行") | @ApiOperation("贡献率排行") | ||||
| @@ -38,6 +38,8 @@ public class WxBusiness implements Serializable { | |||||
| @Transient | @Transient | ||||
| @io.swagger.annotations.ApiModelProperty(value="查询-结束时间",name="enddate") | @io.swagger.annotations.ApiModelProperty(value="查询-结束时间",name="enddate") | ||||
| private Date enddate; | private Date enddate; | ||||
| @Transient | |||||
| private String tenantId; | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| @@ -2,6 +2,7 @@ package com.iformall.mapper; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxBusiness; | import com.iformall.domain.po.WxBusiness; | ||||
| import io.lettuce.core.dynamic.annotation.Param; | import io.lettuce.core.dynamic.annotation.Param; | ||||
| @@ -12,4 +13,9 @@ public interface WxBusinessMapper extends CommonMapper<WxBusiness, String> { | |||||
| List<WxBusiness> findListAll(); | List<WxBusiness> findListAll(); | ||||
| List<WxBusiness> findListForMerchant(@Param("tenantId") String tenantId); | List<WxBusiness> findListForMerchant(@Param("tenantId") String tenantId); | ||||
| List<WxBusiness> findListForCoupon(@Param("tenantId") String tenantId); | List<WxBusiness> findListForCoupon(@Param("tenantId") String tenantId); | ||||
| List<Map<String,Object>> businessDataList(WxBusiness wxBusiness); | |||||
| List<Map<String,Object>> devoteList(WxBusiness wxBusiness); | |||||
| } | } | ||||
| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxBusiness; | import com.iformall.domain.po.WxBusiness; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -40,9 +41,11 @@ public interface WxBusinessService { | |||||
| */ | */ | ||||
| WxBusiness getById(Integer id); | WxBusiness getById(Integer id); | ||||
| ResultData businessDataList(WxBusiness wxBusiness); | |||||
| ResultData devoteList(WxBusiness wxBusiness,Integer pageNum, Integer pageSize); | |||||
| @@ -40,5 +40,5 @@ public interface WxSubBusinessService { | |||||
| */ | */ | ||||
| WxSubBusiness getById(Integer id); | WxSubBusiness getById(Integer id); | ||||
| } | } | ||||
| @@ -2,8 +2,8 @@ package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxBusiness; | import com.iformall.domain.po.WxBusiness; | ||||
| import com.iformall.enums.EnumBusiness; | |||||
| import com.iformall.enums.EnumBusinessFilter; | import com.iformall.enums.EnumBusinessFilter; | ||||
| import com.iformall.mapper.WxBusinessMapper; | import com.iformall.mapper.WxBusinessMapper; | ||||
| import com.iformall.service.WxBusinessService; | import com.iformall.service.WxBusinessService; | ||||
| @@ -50,4 +50,13 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||||
| } | } | ||||
| @Override | |||||
| public ResultData businessDataList(WxBusiness wxBusiness) { | |||||
| return new ResultData(wxBusinessMapper.businessDataList(wxBusiness)); | |||||
| } | |||||
| @Override | |||||
| public ResultData devoteList(WxBusiness wxBusiness, Integer pageNum, Integer pageSize) { | |||||
| return new ResultData(PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxBusinessMapper.devoteList(wxBusiness))); | |||||
| } | |||||
| } | } | ||||
| @@ -2,6 +2,7 @@ package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxBusiness; | import com.iformall.domain.po.WxBusiness; | ||||
| import com.iformall.domain.po.WxSubBusiness; | import com.iformall.domain.po.WxSubBusiness; | ||||
| import com.iformall.mapper.WxBusinessMapper; | import com.iformall.mapper.WxBusinessMapper; | ||||
| @@ -43,5 +44,4 @@ public class WxSubBusinessServiceImpl implements WxSubBusinessService { | |||||
| return wxSubBusinessMapper.selectByPrimaryKey(id); | return wxSubBusinessMapper.selectByPrimaryKey(id); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1166,5 +1166,15 @@ public class DateUtils { | |||||
| } | } | ||||
| /** | |||||
| * 获取上个月的今天 | |||||
| */ | |||||
| public static Date getLastMonthToDay() { | |||||
| Date date = new Date(); | |||||
| Calendar calendar = Calendar.getInstance(); | |||||
| calendar.setTime(date); // 设置为当前时间 | |||||
| calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); // 设置为上一个月 | |||||
| return calendar.getTime(); | |||||
| } | |||||
| } | } | ||||
| @@ -80,7 +80,84 @@ | |||||
| order by create_date asc | order by create_date asc | ||||
| </select> | </select> | ||||
| <select id="businessDataList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap"> | |||||
| select b.id,b.title, | |||||
| round( | |||||
| (select sum(mtd.trade_amt) | |||||
| from wx_merchant m | |||||
| left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and mtd.create_date between #{startdate} and #{enddate}) | |||||
| /100,2) volume, | |||||
| round( | |||||
| (select sum(mtd.trade_amt) | |||||
| from wx_merchant m | |||||
| left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and mtd.create_date between #{startdate} and #{enddate}) | |||||
| / | |||||
| (select sum(ws.operation_area) | |||||
| from wx_merchant m | |||||
| left join wx_merchant_shop mtd on mtd.merchant_id = m.id | |||||
| left join wx_shop ws on(mtd.shop_id = ws.id) | |||||
| where m.business_id = b.id and m.tenant_id=#{tenantId}) | |||||
| /100,2) sale, | |||||
| round( | |||||
| (select | |||||
| (select sum(br.receive_pay) receive_pay from wx_merchant m | |||||
| left join wx_bill_rent br on(br.merchant_id=m.id) where m.business_id = b.id and m.tenant_id=#{tenantId} and br.receive_date between #{startdate} and #{enddate}) | |||||
| + | |||||
| (select sum(br.receive_pay) receive_pay from wx_merchant m | |||||
| left join wx_bill_property br on(br.merchant_id=m.id) where m.business_id = b.id and m.tenant_id=#{tenantId} and br.receive_date between #{startdate} and #{enddate}) | |||||
| from dual) / | |||||
| (select sum(ws.operation_area) | |||||
| from wx_merchant m | |||||
| left join wx_merchant_shop mtd on mtd.merchant_id = m.id | |||||
| left join wx_shop ws on(mtd.shop_id = ws.id) | |||||
| where m.business_id = b.id and m.tenant_id=#{tenantId} ) | |||||
| /100,2) rent, | |||||
| round( | |||||
| (select sum(mtd.trade_amt) | |||||
| from wx_merchant m | |||||
| left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and mtd.create_date between #{startdate} and #{enddate}) | |||||
| / | |||||
| (select sum(ws.operation_area) | |||||
| from wx_merchant m | |||||
| left join wx_merchant_shop mtd on mtd.merchant_id = m.id | |||||
| left join wx_shop ws on(mtd.shop_id = ws.id) | |||||
| where m.business_id = b.id and m.tenant_id=#{tenantId}) | |||||
| /100,2) | |||||
| / | |||||
| round( | |||||
| (select | |||||
| (select sum(br.receive_pay) receive_pay from wx_merchant m | |||||
| left join wx_bill_rent br on(br.merchant_id=m.id) where m.business_id = b.id and m.tenant_id=#{tenantId} and br.receive_date between #{startdate} and #{enddate}) | |||||
| + | |||||
| (select sum(br.receive_pay) receive_pay from wx_merchant m | |||||
| left join wx_bill_property br on(br.merchant_id=m.id) where m.business_id = b.id and m.tenant_id=#{tenantId} and br.receive_date between #{startdate} and #{enddate}) | |||||
| from dual) / | |||||
| (select sum(ws.operation_area) | |||||
| from wx_merchant m | |||||
| left join wx_merchant_shop mtd on mtd.merchant_id = m.id | |||||
| left join wx_shop ws on(mtd.shop_id = ws.id) | |||||
| where m.business_id = b.id) | |||||
| /100,2) rentSaleRate, | |||||
| round( | |||||
| (select sum(mtd.trade_amt) | |||||
| from wx_merchant m | |||||
| left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and mtd.create_date between #{startdate} and #{enddate}) / | |||||
| (select count(mtd.id) | |||||
| from wx_merchant m | |||||
| left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and mtd.create_date between #{startdate} and #{enddate}) | |||||
| /100,2) comPrice | |||||
| from wx_business b | |||||
| limit 20 | |||||
| </select> | |||||
| <select id="devoteList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap"> | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||