diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/sys/WxBusinessController.java b/mallinkAdmin/src/main/java/com/iformall/controller/sys/WxBusinessController.java index a5a9c770c..f6403e7be 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/sys/WxBusinessController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/sys/WxBusinessController.java @@ -70,7 +70,7 @@ public class WxBusinessController extends BaseController { wxBusiness.setEnddate(sdT.parse(sd.format(eDate)+" 23:59:59")); } - List> mapList = wxBusinessService.businessDataList(wxBusiness); + List> mapList = wxBusinessService.businessDataList(wxBusiness,getUserId()); for (Map map:mapList) { if(map.get("rent") == null){ map.put("rent",0); @@ -107,7 +107,7 @@ public class WxBusinessController extends BaseController { wxBusiness.setStartdate(sdT.parse(sd.format(sDate)+" 00:00:00")); wxBusiness.setEnddate(sdT.parse(sd.format(eDate)+" 23:59:59")); } - List> dataList = wxBusinessService.businessDataList(wxBusiness); + List> dataList = wxBusinessService.businessDataList(wxBusiness,getUserId()); List exeList = new ArrayList<>(); for (Map m:dataList) { WxBusinessDataVo businessDataVo = new WxBusinessDataVo(); diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumBusinessConType.java b/mallinkService/src/main/java/com/iformall/enums/EnumBusinessConType.java new file mode 100644 index 000000000..865a962e4 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumBusinessConType.java @@ -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; + } +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java index b6cbc38a0..910827642 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java @@ -2,6 +2,7 @@ package com.iformall.mapper; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxBillRent; +import com.iformall.domain.po.WxBusiness; import com.iformall.domain.po.WxRentContract; import com.iformall.domain.vo.WxRentPropertyContractVo; @@ -67,4 +68,6 @@ public interface WxRentContractMapper extends CommonMapper int getShopCountMax(); + List> queryContractByBus(WxBusiness wxBusiness); + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxBusinessService.java b/mallinkService/src/main/java/com/iformall/service/WxBusinessService.java index 57496cfdf..f2cfee7d7 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxBusinessService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxBusinessService.java @@ -43,7 +43,7 @@ public interface WxBusinessService { - List> businessDataList(WxBusiness wxBusiness); + List> businessDataList(WxBusiness wxBusiness,Long userid); ResultData devoteList(WxBusiness wxBusiness,Integer pageNum, Integer pageSize); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java index 4791fd635..eb7857f32 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java @@ -3,22 +3,26 @@ package com.iformall.service.impl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; 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.EnumIsPreview; +import com.iformall.enums.EnumRentContractType; import com.iformall.mapper.WxBusinessMapper; +import com.iformall.mapper.WxPropertyContractMapper; +import com.iformall.mapper.WxRentContractMapper; 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.lang3.StringUtils; import org.slf4j.Logger; 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.ArrayList; -import java.util.List; -import java.util.Map; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; @Service public class WxBusinessServiceImpl implements WxBusinessService { @@ -26,6 +30,14 @@ public class WxBusinessServiceImpl implements WxBusinessService { @Autowired WxBusinessMapper wxBusinessMapper; + @Autowired + private WxRentContractMapper wxRentContractMapper; + @Autowired + private WxRentContractService wxRentContractService; + @Autowired + private WxPropertyContractMapper wxPropertyContractMapper; + @Autowired + private WxPropertyContractService wxPropertyContractService; @Override public PageInfo listAsPage(WxBusiness record, Integer pageIndex, Integer pageSize) { @@ -57,8 +69,57 @@ public class WxBusinessServiceImpl implements WxBusinessService { @Override - public List> businessDataList(WxBusiness wxBusiness) { - return wxBusinessMapper.businessDataList(wxBusiness); + public List> businessDataList(WxBusiness wxBusiness,Long userid) { + List> 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 rentContractList = wxRentContractMapper.select(query); + for (WxRentContract dbRent:rentContractList ) { + if(StringUtils.isBlank(dbRent.getRentInfo())){ + System.out.println("rent rentInfo is null:{}"+dbRent.getId()); + continue; + } + List previewBill = new ArrayList<>(); + WxBillRent preview = new WxBillRent(); + preview.setStarttime(dbRent.getRentalStartDate()); + preview.setEndtime(dbRent.getRentalEndDate()); + previewBill.add(preview); + + dbRent.setPreviewBillRentList(previewBill); + List 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 propertyContractList = wxPropertyContractMapper.select(pquery); + for (WxPropertyContract dbRent:propertyContractList) { + if(StringUtils.isBlank(dbRent.getRentInfo())){ + System.out.println("property rentInfo is null:{}"+dbRent.getId()); + continue; + } + List previewBill = new ArrayList<>(); + WxBillProperty preview = new WxBillProperty(); + preview.setStarttime(dbRent.getRentalStartDate()); + preview.setEndtime(dbRent.getRentalEndDate()); + previewBill.add(preview); + + dbRent.setPreviewBillRentList(previewBill); + List 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 diff --git a/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml b/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml index f17c02359..610e59eb9 100644 --- a/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml @@ -850,5 +850,4 @@ and bill.merchant_id=#{merchantId} - diff --git a/mallinkService/src/main/resources/mapper/WxBusinessMapper.xml b/mallinkService/src/main/resources/mapper/WxBusinessMapper.xml index 2131f44e9..e50cf0103 100644 --- a/mallinkService/src/main/resources/mapper/WxBusinessMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBusinessMapper.xml @@ -101,20 +101,11 @@ where m.business_id = b.id and m.tenant_id=#{tenantId} and m.status = 1 and m.is_del = 0 ) /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)) 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} 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( (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt)) diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 2d99a65d9..93b60e391 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -416,5 +416,12 @@ select max(json_length(rent_info)) from wx_rent_contract +