| @@ -70,7 +70,7 @@ public class WxBusinessController extends BaseController { | |||||
| wxBusiness.setEnddate(sdT.parse(sd.format(eDate)+" 23:59:59")); | wxBusiness.setEnddate(sdT.parse(sd.format(eDate)+" 23:59:59")); | ||||
| } | } | ||||
| List<Map<String,Object>> mapList = wxBusinessService.businessDataList(wxBusiness); | |||||
| List<Map<String,Object>> mapList = wxBusinessService.businessDataList(wxBusiness,getUserId()); | |||||
| for (Map<String,Object> map:mapList) { | for (Map<String,Object> map:mapList) { | ||||
| if(map.get("rent") == null){ | if(map.get("rent") == null){ | ||||
| map.put("rent",0); | map.put("rent",0); | ||||
| @@ -107,7 +107,7 @@ public class WxBusinessController extends BaseController { | |||||
| wxBusiness.setStartdate(sdT.parse(sd.format(sDate)+" 00:00:00")); | wxBusiness.setStartdate(sdT.parse(sd.format(sDate)+" 00:00:00")); | ||||
| wxBusiness.setEnddate(sdT.parse(sd.format(eDate)+" 23:59:59")); | wxBusiness.setEnddate(sdT.parse(sd.format(eDate)+" 23:59:59")); | ||||
| } | } | ||||
| List<Map<String,Object>> dataList = wxBusinessService.businessDataList(wxBusiness); | |||||
| List<Map<String,Object>> dataList = wxBusinessService.businessDataList(wxBusiness,getUserId()); | |||||
| List<WxBusinessDataVo> exeList = new ArrayList<>(); | List<WxBusinessDataVo> exeList = new ArrayList<>(); | ||||
| for (Map<String,Object> m:dataList) { | for (Map<String,Object> m:dataList) { | ||||
| WxBusinessDataVo businessDataVo = new WxBusinessDataVo(); | WxBusinessDataVo businessDataVo = new WxBusinessDataVo(); | ||||
| @@ -0,0 +1,37 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumBusinessConType { | |||||
| RENT(1, "租赁合同"), | |||||
| PRO(2, "物业合同"), | |||||
| ; | |||||
| public static EnumBusinessConType getEnum(Integer code) { | |||||
| for (EnumBusinessConType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumBusinessConType(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -2,6 +2,7 @@ package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxBillRent; | import com.iformall.domain.po.WxBillRent; | ||||
| import com.iformall.domain.po.WxBusiness; | |||||
| import com.iformall.domain.po.WxRentContract; | import com.iformall.domain.po.WxRentContract; | ||||
| import com.iformall.domain.vo.WxRentPropertyContractVo; | import com.iformall.domain.vo.WxRentPropertyContractVo; | ||||
| @@ -67,4 +68,6 @@ public interface WxRentContractMapper extends CommonMapper<WxRentContract, Long> | |||||
| int getShopCountMax(); | int getShopCountMax(); | ||||
| List<Map<String,Object>> queryContractByBus(WxBusiness wxBusiness); | |||||
| } | } | ||||
| @@ -43,7 +43,7 @@ public interface WxBusinessService { | |||||
| List<Map<String,Object>> businessDataList(WxBusiness wxBusiness); | |||||
| List<Map<String,Object>> businessDataList(WxBusiness wxBusiness,Long userid); | |||||
| ResultData devoteList(WxBusiness wxBusiness,Integer pageNum, Integer pageSize); | ResultData devoteList(WxBusiness wxBusiness,Integer pageNum, Integer pageSize); | ||||
| @@ -3,22 +3,26 @@ 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.common.ResultData; | ||||
| import com.iformall.domain.po.WxBusiness; | |||||
| import com.iformall.domain.po.WxCoupon; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.EnumBusinessConType; | |||||
| import com.iformall.enums.EnumBusinessFilter; | import com.iformall.enums.EnumBusinessFilter; | ||||
| import com.iformall.enums.EnumIsPreview; | |||||
| import com.iformall.enums.EnumRentContractType; | |||||
| import com.iformall.mapper.WxBusinessMapper; | import com.iformall.mapper.WxBusinessMapper; | ||||
| import com.iformall.mapper.WxPropertyContractMapper; | |||||
| import com.iformall.mapper.WxRentContractMapper; | |||||
| import com.iformall.service.WxBusinessService; | import com.iformall.service.WxBusinessService; | ||||
| import com.iformall.service.WxPropertyContractService; | |||||
| import com.iformall.service.WxRentContractService; | |||||
| import org.apache.commons.collections.CollectionUtils; | import org.apache.commons.collections.CollectionUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | 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.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import java.math.BigDecimal; | |||||
| import java.math.RoundingMode; | |||||
| import java.util.*; | |||||
| @Service | @Service | ||||
| public class WxBusinessServiceImpl implements WxBusinessService { | public class WxBusinessServiceImpl implements WxBusinessService { | ||||
| @@ -26,6 +30,14 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||||
| @Autowired | @Autowired | ||||
| WxBusinessMapper wxBusinessMapper; | WxBusinessMapper wxBusinessMapper; | ||||
| @Autowired | |||||
| private WxRentContractMapper wxRentContractMapper; | |||||
| @Autowired | |||||
| private WxRentContractService wxRentContractService; | |||||
| @Autowired | |||||
| private WxPropertyContractMapper wxPropertyContractMapper; | |||||
| @Autowired | |||||
| private WxPropertyContractService wxPropertyContractService; | |||||
| @Override | @Override | ||||
| public PageInfo<WxBusiness> listAsPage(WxBusiness record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxBusiness> listAsPage(WxBusiness record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -57,8 +69,57 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||||
| @Override | @Override | ||||
| public List<Map<String,Object>> businessDataList(WxBusiness wxBusiness) { | |||||
| return wxBusinessMapper.businessDataList(wxBusiness); | |||||
| public List<Map<String,Object>> businessDataList(WxBusiness wxBusiness,Long userid) { | |||||
| List<Map<String,Object>> resultList = wxBusinessMapper.businessDataList(wxBusiness); | |||||
| resultList.stream().forEach(e->{ | |||||
| WxBusiness business = new WxBusiness(); | |||||
| business.setId((Integer) e.get("id")); | |||||
| BigDecimal businessSumMoney = new BigDecimal(0); | |||||
| WxRentContract query = new WxRentContract(); | |||||
| query.setBusinessId((Integer) e.get("id")); | |||||
| List<WxRentContract> rentContractList = wxRentContractMapper.select(query); | |||||
| for (WxRentContract dbRent:rentContractList ) { | |||||
| if(StringUtils.isBlank(dbRent.getRentInfo())){ | |||||
| System.out.println("rent rentInfo is null:{}"+dbRent.getId()); | |||||
| continue; | |||||
| } | |||||
| List<WxBillRent> previewBill = new ArrayList<>(); | |||||
| WxBillRent preview = new WxBillRent(); | |||||
| preview.setStarttime(dbRent.getRentalStartDate()); | |||||
| preview.setEndtime(dbRent.getRentalEndDate()); | |||||
| previewBill.add(preview); | |||||
| dbRent.setPreviewBillRentList(previewBill); | |||||
| List<WxBillRent> billRentList = wxRentContractService.buildRent(new WxMerchant(),userid,dbRent, EnumIsPreview.YES.getCode(), false); | |||||
| businessSumMoney = businessSumMoney.add(new BigDecimal(billRentList.get(0).getReceivePay())); | |||||
| } | |||||
| WxPropertyContract pquery = new WxPropertyContract(); | |||||
| pquery.setBusinessId((Integer) e.get("id")); | |||||
| List<WxPropertyContract> propertyContractList = wxPropertyContractMapper.select(pquery); | |||||
| for (WxPropertyContract dbRent:propertyContractList) { | |||||
| if(StringUtils.isBlank(dbRent.getRentInfo())){ | |||||
| System.out.println("property rentInfo is null:{}"+dbRent.getId()); | |||||
| continue; | |||||
| } | |||||
| List<WxBillProperty> previewBill = new ArrayList<>(); | |||||
| WxBillProperty preview = new WxBillProperty(); | |||||
| preview.setStarttime(dbRent.getRentalStartDate()); | |||||
| preview.setEndtime(dbRent.getRentalEndDate()); | |||||
| previewBill.add(preview); | |||||
| dbRent.setPreviewBillRentList(previewBill); | |||||
| List<WxBillProperty> billRentList = wxPropertyContractService.buildProperty(new WxMerchant(),userid,dbRent, EnumIsPreview.YES.getCode(), false); | |||||
| businessSumMoney = businessSumMoney.add(new BigDecimal(billRentList.get(0).getReceivePay())); | |||||
| } | |||||
| BigDecimal area = new BigDecimal(e.get("area").toString()); | |||||
| BigDecimal areaRatio = businessSumMoney.divide(area,2, BigDecimal.ROUND_HALF_UP).divide(new BigDecimal(100),2, BigDecimal.ROUND_HALF_UP); | |||||
| e.put("rent",areaRatio.toBigInteger()); | |||||
| }); | |||||
| return resultList; | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -850,5 +850,4 @@ | |||||
| <if test=" null != merchantId">and bill.merchant_id=#{merchantId}</if> | <if test=" null != merchantId">and bill.merchant_id=#{merchantId}</if> | ||||
| </select> | </select> | ||||
| </mapper> | </mapper> | ||||
| @@ -101,20 +101,11 @@ | |||||
| where m.business_id = b.id and m.tenant_id=#{tenantId} and m.status = 1 and m.is_del = 0 ) | where m.business_id = b.id and m.tenant_id=#{tenantId} and m.status = 1 and m.is_del = 0 ) | ||||
| /100,2) sale, | /100,2) sale, | ||||
| round( | |||||
| (select | |||||
| (select if(sum(br.receive_pay) is null,0,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} and m.status = 1 and m.is_del = 0 ) | |||||
| + | |||||
| (select if(sum(br.receive_pay) is null,0,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} and m.status = 1 and m.is_del = 0 ) | |||||
| from dual) / | |||||
| (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area)) | (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area)) | ||||
| from wx_merchant m | from wx_merchant m | ||||
| left join wx_merchant_shop mtd on mtd.merchant_id = m.id | left join wx_merchant_shop mtd on mtd.merchant_id = m.id | ||||
| left join wx_shop ws on(mtd.shop_id = ws.id) | left join wx_shop ws on(mtd.shop_id = ws.id) | ||||
| where m.business_id = b.id and m.tenant_id=#{tenantId} and m.status = 1 and m.is_del = 0 ) | |||||
| /100,2) rent, | |||||
| where m.business_id = b.id and m.tenant_id=456 and m.status = 1 and m.is_del = 0 )area, | |||||
| round( | round( | ||||
| (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt)) | (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt)) | ||||
| @@ -416,5 +416,12 @@ | |||||
| select max(json_length(rent_info)) from wx_rent_contract | select max(json_length(rent_info)) from wx_rent_contract | ||||
| </select> | </select> | ||||
| <select id="queryContractByBus" resultType="hashmap" parameterType="com.iformall.domain.po.WxBusiness"> | |||||
| select 1 type,c.`rental_start_date`,c.`rental_end_date`,c.id id from wx_merchant m left join wx_rent_contract c on(m.id = c.merchant_id) | |||||
| where m.business_id = #{id} and c.price is not null and c.`rental_start_date` is not null and c.`rental_end_date` is not null | |||||
| union all | |||||
| select 2 type,c.`rental_start_date`,c.`rental_end_date`,c.id id from wx_merchant m left join wx_property_contract c on(m.id = c.merchant_id) | |||||
| where m.business_id = #{id} and c.price is not null and c.`rental_start_date` is not null and c.`rental_end_date` is not null | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||