From 71dd8c2b666494637bf2610ad5538810f04a4e0d Mon Sep 17 00:00:00 2001 From: winter <664946893@qq.com> Date: Sat, 9 Nov 2024 19:13:08 +0800 Subject: [PATCH] fix --- .../controller/basic/WxMapController.java | 36 - .../contract/WxContractBaseController.java | 21 +- .../contract/WxRentContractController.java | 248 +----- .../controller/rent/WxAllBillController.java | 66 +- .../db/migration/V202411000000001.sql | 270 ++++++ .../iformall/controller/BaseController.java | 10 + .../iformall/controller/WxBillController.java | 107 ++- .../iformall/controller/WxInfoController.java | 36 +- .../controller/WxMallAdminController.java | 6 +- .../interceptor/AuthorizationInterceptor.java | 25 +- .../domain/dto/WxRentLoginUserDTO.java | 16 + .../com/iformall/domain/po/WxAllBill.java | 22 +- .../domain/po/WxContractCustomers.java | 90 ++ .../iformall/domain/po/WxContractShop.java | 46 + .../po/WxEnergyReadingCalcuteResult.java | 3 +- .../com/iformall/domain/po/WxMerchant.java | 30 +- .../iformall/domain/po/WxRentContract.java | 180 +--- .../domain/po/WxRentContractAgileDeposit.java | 3 - .../po/WxRentContractAgileUnDeposit.java | 3 - .../java/com/iformall/domain/po/WxShop.java | 30 + .../com/iformall/domain/po/WxShopUsers.java | 3 + .../com/iformall/domain/vo/WxBillNotify.java | 8 +- .../domain/vo/WxRentPropertyContractVo.java | 9 - ...xMerchantBillVo.java => WxShopBillVo.java} | 7 +- .../enums/EnumContractCustomersStatus.java | 35 + .../com/iformall/mapper/WxAllBillMapper.java | 4 +- .../mapper/WxContractCustomersMapper.java | 16 + .../iformall/mapper/WxContractShopMapper.java | 18 + .../iformall/mapper/WxRentContractMapper.java | 23 - .../iformall/mapper/WxShopUsersMapper.java | 1 + .../print/data/impl/PrintBillDataHandler.java | 10 - .../impl/PrintMerchantSettleDataHandler.java | 4 +- .../service/WxAgileContractService.java | 8 + .../iformall/service/WxAllBillService.java | 2 +- .../service/WxRentContractService.java | 14 - .../com/iformall/service/WxShopService.java | 8 +- .../service/helper/WxBillAllHelper.java | 131 +-- .../impl/WxAgileContractServiceImpl.java | 165 ++-- .../service/impl/WxAllBillServiceImpl.java | 4 +- .../service/impl/WxEnergyServiceImpl.java | 14 +- .../impl/WxFinancePrintServiceImpl.java | 4 +- .../service/impl/WxMerchantServiceImpl.java | 10 +- .../impl/WxRentContractServiceImpl.java | 818 ++++++++++-------- .../service/impl/WxShopServiceImpl.java | 70 +- .../java/com/iformall/utils/Constant.java | 2 + .../main/resources/mapper/WxAllBillMapper.xml | 36 +- .../mapper/WxContractCustomersMapper.xml | 84 ++ .../resources/mapper/WxContractShopMapper.xml | 73 ++ .../WxRentContractAgileDepositMapper.xml | 4 +- ...WxRentContractAgileUnDepositItemMapper.xml | 4 +- .../WxRentContractAgileUnDepositMapper.xml | 4 +- .../resources/mapper/WxRentContractMapper.xml | 240 +---- .../resources/mapper/WxShopUsersMapper.xml | 12 + 53 files changed, 1709 insertions(+), 1384 deletions(-) create mode 100644 mallinkAdmin/src/main/resources/db/migration/V202411000000001.sql create mode 100644 mallinkService/src/main/java/com/iformall/domain/dto/WxRentLoginUserDTO.java create mode 100644 mallinkService/src/main/java/com/iformall/domain/po/WxContractCustomers.java create mode 100644 mallinkService/src/main/java/com/iformall/domain/po/WxContractShop.java rename mallinkService/src/main/java/com/iformall/domain/vo/{WxMerchantBillVo.java => WxShopBillVo.java} (93%) create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumContractCustomersStatus.java create mode 100644 mallinkService/src/main/java/com/iformall/mapper/WxContractCustomersMapper.java create mode 100644 mallinkService/src/main/java/com/iformall/mapper/WxContractShopMapper.java create mode 100644 mallinkService/src/main/resources/mapper/WxContractCustomersMapper.xml create mode 100644 mallinkService/src/main/resources/mapper/WxContractShopMapper.xml diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMapController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMapController.java index 6d6eac5a4..7ed379efe 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMapController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMapController.java @@ -55,33 +55,6 @@ public class WxMapController extends BaseController { @Autowired private WxCreditHistoryService wxCreditHistoryService; - @ApiOperation("根据id查询接口") - @GetMapping("/findShopBySid") - @ApiImplicitParam(name = "sid", value = "id", dataType = "Long", paramType = "query", required = true) - @SystemControllerLog(description = "店铺管理-id查询") - public ResultData findShopBySid(String sid) { - logger.debug("[" + getIpAddr() + "] WxMapController::findShopBySid"); - Map resultObject = new HashMap<>(); - Map wxShopObject = wxShopService.detailBySid(getTenantInfo(), sid); - Map wxMerchantObject = new HashMap<>(); - Map wxRentContractObject = new HashMap<>(); - if(wxShopObject != null && !wxShopObject.isEmpty() - && EnumShopStatus.RENT.getCode().toString().equals(wxShopObject.get("status").toString())){ - //已出租 - long shopId = Long.parseLong(wxShopObject.get("id").toString()); - String shopNumber = wxShopObject.get("shopNumber").toString(); - wxMerchantObject = wxMerchantService.detailByShopId(getTenantInfo(), shopId); - if(wxMerchantObject != null && !wxMerchantObject.isEmpty()){ - long merchantId = Long.parseLong(wxMerchantObject.get("id").toString()); - wxRentContractObject = wxRentContractService.currentValidByMerchantId(getTenantInfo(),merchantId,shopNumber); - } - } - resultObject.put("wxShop",wxShopObject); - resultObject.put("wxMerchant",wxMerchantObject); - resultObject.put("wxRentContract",wxRentContractObject); - return new ResultData(Result.SUCCESS, "查询成功", resultObject); - } - @ApiOperation("根据id查询接口") @GetMapping("/findStatisticsBySid") @ApiImplicitParam(name = "sid", value = "sid", dataType = "Long", paramType = "query", required = true) @@ -151,15 +124,6 @@ public class WxMapController extends BaseController { return new ResultData(Result.SUCCESS, "查询成功", wxMerchantService.findMerchantByShop(shopId)); } - @ApiOperation("根据id查询接口") - @GetMapping("/findRentByShop") - @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) - @SystemControllerLog(description = "店铺管理-id查询") - public ResultData findRentByShop(Long shopId) { - logger.debug("[" + getIpAddr() + "] WxMapController::findRentByShop"); - return new ResultData(Result.SUCCESS, "查询成功", wxRentContractService.findRentByShop(shopId)); - } - @ApiOperation("根据id查询接口") @GetMapping("/findStatisticsByShop") @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java index b4683f01c..118db78e7 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java @@ -1,6 +1,7 @@ package com.iformall.controller.contract; import com.iformall.controller.base.BaseController; +import com.iformall.domain.po.WxContractCustomers; import com.iformall.domain.po.WxFlowModel; import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxPropertyContract; @@ -11,6 +12,7 @@ import com.iformall.enums.EnumFlowContractType; import com.iformall.enums.EnumFlowKey; import com.iformall.enums.EnumRentAgileType; import com.iformall.enums.EnumRentShopType; +import com.iformall.service.WxAgileContractService; import com.iformall.service.WxFlowService; import com.iformall.service.WxShopService; @@ -18,7 +20,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RestController; import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -31,8 +36,11 @@ public class WxContractBaseController extends BaseController{ @Autowired private WxShopService wxShopService; + + @Autowired + private WxAgileContractService wxAgileContractService; - protected Map generateFlowParams(WxMerchant merchant,EnumFlowKey flowType,EnumFlowContractType contractType,EnumRentAgileType agileType,String remark,Long contractId,Long wholeProperyId) { + protected Map generateFlowParams(WxContractCustomers contractCustomers,EnumFlowKey flowType,EnumFlowContractType contractType,EnumRentAgileType agileType,String remark,Long contractId,Long wholeProperyId) { Map map = new HashMap(); map.put("businessType", flowType.getCode()); map.put("remark", remark); @@ -68,7 +76,7 @@ public class WxContractBaseController extends BaseController{ Map rentNameMap = new HashMap(); rentNameMap.put("key","rentName"); - rentNameMap.put("value",wxShopService.getRentName(merchant)); + rentNameMap.put("value",contractCustomers.getName()); variablesList.add(rentNameMap); map.put("variables", variablesList); @@ -119,4 +127,13 @@ public class WxContractBaseController extends BaseController{ return false; } + public static boolean dateHasIntersection(Date startDate1, Date endDate1, Date startDate2, Date endDate2) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (startDate1.compareTo(endDate2) <= 0 && startDate2.compareTo(endDate1) <= 0) { + return true; + } else { + return false; + } + } + } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java index 1f99754d4..a213163c7 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -50,6 +50,8 @@ public class WxRentContractController extends WxContractBaseController { @Autowired private WxRentContractMapper wxRentContractMapper; @Autowired + private WxAgileContractService wxAgileContractService; + @Autowired private WxRentPropertyContractService wxRentPropertyContractService; @Autowired private WxShopService wxShopService; @@ -78,20 +80,6 @@ public class WxRentContractController extends WxContractBaseController { wxRentContract.setBusinessForRule(dataRule.getBussinessIds()); wxRentContract.setShopTypeForRule(dataRule.getShopTypes()); } - if (null == wxRentContract.getIsPrivateMerchant()) { - wxRentContract.setIsPrivateMerchant(EnumYesOrNo.NO.getCode()); - } - //如果是已售,则查询虚拟商户,并且店铺类型是商业的 - if (wxRentContract.getIsPrivateMerchant()==2) { - wxRentContract.setIsPrivateMerchant(EnumYesOrNo.YES.getCode()); - List rentShopTypeList = new ArrayList(); - rentShopTypeList.add(EnumRentShopType.SHOP.getCode()); - rentShopTypeList.add(EnumRentShopType.POINT.getCode()); - wxRentContract.setPrivateRentShopTypeList(rentShopTypeList); - }else if (wxRentContract.getIsPrivateMerchant()==1) { - wxRentContract.setIsPrivateMerchant(EnumYesOrNo.YES.getCode()); - wxRentContract.setPrivateRentShopType(EnumRentShopType.XIZILOU.getCode()); - } wxRentContract.setAgileType(EnumRentAgileType.STANDARDS_YEAR.getCode()); PageInfo page = wxRentContractService.getRentContractList(wxRentContract, pageNum, pageSize); Integer hasFlow = null; @@ -132,6 +120,11 @@ public class WxRentContractController extends WxContractBaseController { if(wxRentContract.getRentStartType()!=null &&wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ wxRentContract.setRentalStartDate(wxRentContract.getStartDate()); } + try { + validShop(wxRentContract); + } catch (Exception e) { + return new ResultData(Result.ERROR,e.getMessage()); + } return wxRentContractService.save(wxRentContract, user,user.getName(),oldDate); } @@ -259,6 +252,13 @@ public class WxRentContractController extends WxContractBaseController { if(rentContract.getRentStartType()!=null && rentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ rentContract.setRentalStartDate(rentContract.getStartDate()); } + + try { + validShop(rentContract); + } catch (Exception e) { + return new ResultData(Result.ERROR,e.getMessage()); + } + ResultData update = null; try { update = wxRentContractService.updateOneStep(rentContract, user, user.getName(), EnumFromType.OTHER.getCode(), oldDate,false); @@ -271,142 +271,6 @@ public class WxRentContractController extends WxContractBaseController { } } - /** - * 查询商户可用商铺 - * @param merchantId - * @param contractId - * @return - */ - @GetMapping("/merchantShops") - @ApiImplicitParams({ - @ApiImplicitParam(name = "merchantId", value = "merchantId", dataType = "Long", paramType = "query", required = true), - @ApiImplicitParam(name = "contractId", value = "contractId", dataType = "Long", paramType = "query", required = true)}) - public ResultData merchantShops(Long merchantId,Long contractId) { - //如果商户是虚拟商户,则直接返回绑定的铺位 - List shopList = null; - WxMerchant merchant = wxMerchantService.selectById(merchantId); - if (merchant.getIsPrivate() == EnumYesOrNo.YES.getCode() && merchant.getCreateFrom() == EnumMerchantCreateFrom.SYS_SHOP_CREATE.getCode()) { - shopList = new ArrayList(); - //不从这取,因为这是存的第一次创建时店铺的编号,这个店铺有可能被删除重新创建 - //shopList.add(Long.parseLong(merchant.getCreateFromId())); - String shopNumber = merchant.getCreateShopNumber(); - WxShop shop = wxShopService.getShopByShopNumber(merchant, shopNumber); - if (null != shop) { - shopList.add(shop.getId()); - } - }else { - shopList = wxMerchantService.getMerchantShopIds(merchantId); - } - if (null == shopList || shopList.size() <= 0 ) { - return new ResultData(Result.ERROR,"商户未绑定店铺!"); - } - WxRentContract rentq = new WxRentContract(); - rentq.setStatuss(EnumRentContractStatus.getValidStatus()); - rentq.setMerchantId(merchantId); - rentq.updateTenantInfo(getUser()); - List rentContractList = wxRentContractService.findList(rentq); - List rentValidShopIdList = new ArrayList(); - if (null != rentContractList) { - for (WxRentContract rent : rentContractList) { - List shopidlist = rent.shopIdsByRentInfo(); - if (null != shopidlist) { - for (Long sid: shopidlist) { - if (!rentValidShopIdList.contains(sid)) { - rentValidShopIdList.add(sid); - } - } - } - } - } - //如果是新建,或者修改,此时能查询出来未在有效合同里面的店铺 - - //如果是续签,则还能查询出来合同本身的店铺 - List currentContractShopIds = null; - if (null != contractId) { - WxRentContract rentContract = wxRentContractService.getSimpleDeatil(contractId); - if (null == rentContract) { - return new ResultData(Result.ERROR,"租金合同不存在!"); - } - if (rentContract.getStatus().intValue() != EnumRentContractStatus.PAING.getCode() - && rentContract.getStatus().intValue() != EnumRentContractStatus.OUT_DATE.getCode()) { - return new ResultData(Result.ERROR,"租金合同状态为计租中或者正常到期才能续签。"); - } - List _currentContractShopIds = rentContract.shopIdsByRentInfo(); - if (null != _currentContractShopIds) { - currentContractShopIds = new ArrayList(); - for (int i = 0 ; i < _currentContractShopIds.size() ; i ++) { - Long cs = _currentContractShopIds.get(i); - if (shopList.contains(cs)) { - currentContractShopIds.add(cs); - } - } - } - } - //去掉正常状态的合同里的店铺 - shopList.stream().filter(s -> !rentValidShopIdList.contains(s)); - if ( null != currentContractShopIds) { - //去重 - shopList.removeAll(currentContractShopIds); - } - List shops = wxShopService.getByIds(rentq,shopList); - //再加上合同里面店铺 - if(null != currentContractShopIds && currentContractShopIds.size() > 0 ) { - List contractShops = wxShopService.getByIds(rentq,currentContractShopIds); - if (null != contractShops) { - for (int i = 0 ; i < contractShops.size() ; i ++) { - WxShop s = contractShops.get(i); - if (!shopList.contains(s.getId())) { - shops.add(s); - } - } - } - } - - return new ResultData(shops); - } - - /** - * 查询商户计租中或者正常到期的合同 - * @param wxRentContract - * @return - */ - @GetMapping("getXuQianRentContract") - @ApiImplicitParams({}) - public ResultData getXuQianRentContract(@ModelAttribute WxRentContract wxRentContract) { - wxRentContract.updateTenantInfo(getTenantInfo()); - List statss = new ArrayList(); - statss.add(EnumRentContractStatus.PAING.getCode()); - statss.add(EnumRentContractStatus.OUT_DATE.getCode()); - wxRentContract.setStatuss(statss); - wxRentContract.setSortColumn(BaseEntity.SortField.Createtime_DESC.getValue()); - if (null == wxRentContract.getIsPrivateMerchant()) { - wxRentContract.setIsPrivateMerchant(EnumYesOrNo.NO.getCode()); - } - PageInfo page = wxRentContractService.getRentContractList(wxRentContract, 1, 100000); - if (null != page && null != page.getList()) { - List> retList = new ArrayList>(); - for (WxRentContract wr:page.getList()) { - retList.add(wxRentContractService.getById(wr.getId())); - } - return new ResultData(retList); - -// List painglist = new ArrayList(); -// painglist.addAll(page.getList()); -// painglist.stream().filter( p -> p.getStatus().intValue()==EnumRentContractStatus.PAING.getCode().intValue()); -// if (painglist.size()>0) { -// return new ResultData(wxRentContractService.getById(painglist.get(0).getId())); -// }else { -// List outdatelist = new ArrayList(); -// outdatelist.addAll(page.getList()); -// outdatelist.stream().filter( p -> p.getStatus().intValue()==EnumRentContractStatus.OUT_DATE.getCode().intValue()); -// if (outdatelist.size() > 0 ) { -// return new ResultData(wxRentContractService.getById(outdatelist.get(0).getId())); -// } -// } - } - return new ResultData(); - } - /** * 作废 * @param wxRentContract @@ -593,28 +457,37 @@ public class WxRentContractController extends WxContractBaseController { } private void validShop(WxRentContract rentContract) throws Exception { - //判断该合同的店铺是不是在商户的店铺的绑定关系里面 - List shopIds = null; - WxMerchant merchant = wxMerchantService.selectById(rentContract.getMerchantId()); - if (merchant.getIsPrivate() == EnumYesOrNo.YES.getCode()) { - WxShop shq = new WxShop(); - shq.updateTenantInfo(merchant); - shq.setQueryShopNumber(merchant.getCreateShopNumber()); - shq.setIsDel(EnumYesOrNo.NO.getCode()); - shopIds = wxShopService.getShopIds(shq); - }else { - shopIds = wxMerchantService.getMerchantShopIds(rentContract.getMerchantId()); - } - if (null == shopIds) { - throw new MallinkException(Result.ERROR, "该商户未绑定任何商铺。"); - } - List cids = rentContract.shopIdsByRentInfo(); - if (null == cids) { - throw new MallinkException(Result.ERROR, "该合同未绑定任何商铺。"); - } - - if (!shopIds.containsAll(cids)) { - throw new MallinkException(Result.ERROR, "该合同绑定的部分商铺未在商户绑定的店铺范围内。"); + //TODO 判断该合同的店铺是不是存在有效的合同,或者审批中的合同,要判断时间区间是否有重复 + List shopIdList = rentContract.shopIdsByRentInfo(); + List contractIds = wxAgileContractService.findShopContractIds(rentContract, shopIdList); + //查询是否有跟当前合同时间有冲突的合同 + if (null != contractIds) { + if (null != rentContract.getId()) { + contractIds.remove(rentContract.getId()); + } + if (contractIds.size() > 0) { + WxRentContract rc = new WxRentContract(); + rc.updateTenantInfo(rentContract); + rc.setIds(contractIds); + List statusList = new ArrayList(); + statusList.add(EnumRentContractStatus.DRAFT.getCode()); + statusList.add(EnumRentContractStatus.PAING.getCode()); + statusList.add(EnumRentContractStatus.READY_FOR_PAING.getCode()); + statusList.add(EnumRentContractStatus.PERFORMANCE.getCode()); + statusList.add(EnumRentContractStatus.UNWRITE.getCode()); + rc.setStatuss(statusList); + List contractList = wxRentContractService.findList(rc); + if (null != contractList && contractList.size() > 0 ) { + for (int i = 0 ; i < contractList.size(); i ++ ) { + WxRentContract wrc = contractList.get(i); + if (dateHasIntersection(rentContract.getRentalStartDate(),rentContract.getRentalEndDate(), + wrc.getRentalStartDate(),wrc.getRentalEndDate())) { + throw new MallinkException(Result.ERROR, "房间资源存在时间冲突的合同。"); + } + } + } + } + } } @@ -658,13 +531,13 @@ public class WxRentContractController extends WxContractBaseController { } } - WxMerchant merchant = wxMerchantService.selectById(rentContract.getMerchantId()); + WxContractCustomers customers = wxAgileContractService.findCustomers(rentContract, rentContract.getId()); if(rentContract.getOperationType().intValue() == EnumContractOperationType.PART.getCode().intValue() || rentContract.getOperationType().intValue() == EnumContractOperationType.JINMAO.getCode().intValue()) { - rentContract.setFlowParams(generateFlowParams(merchant,EnumFlowKey.NEW_RENT_CONTRACT, EnumFlowContractType.RENT,EnumRentAgileType.getEnum(rentContract.getAgileType()), wxRentContract.getRemark(), wxRentContract.getId(),null)); + rentContract.setFlowParams(generateFlowParams(customers,EnumFlowKey.NEW_RENT_CONTRACT, EnumFlowContractType.RENT,EnumRentAgileType.getEnum(rentContract.getAgileType()), wxRentContract.getRemark(), wxRentContract.getId(),null)); }else if(rentContract.getOperationType().intValue() == EnumContractOperationType.WHOLE.getCode().intValue()){ - rentContract.setFlowParams(generateFlowParams(merchant,EnumFlowKey.NNEW_RENT_CONTRACT, EnumFlowContractType.WHOLE_SHOP, EnumRentAgileType.getEnum(rentContract.getAgileType()),wxRentContract.getRemark(), wxRentContract.getId(),wxRentContract.getPropertyId())); + rentContract.setFlowParams(generateFlowParams(customers,EnumFlowKey.NNEW_RENT_CONTRACT, EnumFlowContractType.WHOLE_SHOP, EnumRentAgileType.getEnum(rentContract.getAgileType()),wxRentContract.getRemark(), wxRentContract.getId(),wxRentContract.getPropertyId())); }else { return new ResultData(Result.ERROR,"合同操作类型非法。"); } @@ -699,22 +572,6 @@ public class WxRentContractController extends WxContractBaseController { statuss.add(EnumRentContractStatus.OUT_DATE.getCode()); wxRentContract.setStatuss(statuss); } - if (null == wxRentContract.getIsPrivateMerchant()) { - wxRentContract.setIsPrivateMerchant(EnumYesOrNo.NO.getCode()); - } - - //如果是已售,则查询虚拟商户,并且店铺类型是商业的 - if (wxRentContract.getIsPrivateMerchant()==2) { - wxRentContract.setIsPrivateMerchant(EnumYesOrNo.YES.getCode()); - List rentShopTypeList = new ArrayList(); - rentShopTypeList.add(EnumRentShopType.SHOP.getCode()); - rentShopTypeList.add(EnumRentShopType.POINT.getCode()); - wxRentContract.setPrivateRentShopTypeList(rentShopTypeList); - }else if (wxRentContract.getIsPrivateMerchant()==1) { - wxRentContract.setIsPrivateMerchant(EnumYesOrNo.YES.getCode()); - wxRentContract.setPrivateRentShopType(EnumRentShopType.XIZILOU.getCode()); - } - } wxRentContract.setSortColumns(SortField.Createtime_DESC); @@ -824,14 +681,6 @@ public class WxRentContractController extends WxContractBaseController { return new ResultData(); } - @GetMapping("/getMerchants") - public ResultData getMerchants(@ModelAttribute WxRentContract wxRentContract) { - logger.debug("[" + getIpAddr() + "] WxRentContractController::getMerchants"); - wxRentContract.updateTenantInfo(getTenantInfo()); - return new ResultData(Result.SUCCESS, "查询成功", wxRentContractService.getMerchants(wxRentContract)); - } - - @GetMapping("/getContractByContractNumber") public ResultData getContractByContractNumber(@ModelAttribute WxRentContract wxRentContract) { logger.debug("[" + getIpAddr() + "] WxRentContractController::getContractByContractNumber"); @@ -944,7 +793,6 @@ public class WxRentContractController extends WxContractBaseController { } WxPropertyContract bq = new WxPropertyContract(); bq.updateTenantInfo(rentContract); - bq.setMerchantId(contract.getMerchantId()); bq.setRentContractId(rentContract.getId()); bq.setOperationType(EnumContractOperationType.WHOLE.getCode()); //包括提前终止的,租金+物业合同是一对一的 diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxAllBillController.java b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxAllBillController.java index 8c0fbf89e..d2b7c8ac3 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxAllBillController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxAllBillController.java @@ -28,7 +28,7 @@ import com.iformall.domain.vo.WxBillExcelTemplate; import com.iformall.domain.vo.WxBillHotNotify; import com.iformall.domain.vo.WxBillJianMian; import com.iformall.domain.vo.WxBillSum; -import com.iformall.domain.vo.WxMerchantBillVo; +import com.iformall.domain.vo.WxShopBillVo; import com.iformall.enums.EnumBillAllType; import com.iformall.enums.EnumBillOweOrNearType; import com.iformall.enums.EnumBillStatus; @@ -109,7 +109,7 @@ public class WxAllBillController extends BillBaseController { private WxFinancePrintService wxFinancePrintService; /** - * 商户账单汇总计费列表 + * 铺位账单汇总计费列表 * @param wxMerchant * @param pageNum * @param pageSize @@ -119,40 +119,40 @@ public class WxAllBillController extends BillBaseController { @ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) - public ResultData merchantBillList(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) { - wxMerchant.updateTenantInfo(getTenantInfo()); + public ResultData merchantBillList(@ModelAttribute WxShop wxShop, Integer pageNum, Integer pageSize) { + wxShop.updateTenantInfo(getTenantInfo()); WxUserDataRule dataRule = this.getCurrentDataFloors(); if (null != dataRule) { - wxMerchant.setFloorForRule(dataRule.getFloorIds()); - wxMerchant.setBusinessForRule(dataRule.getBussinessIds()); - wxMerchant.setShopTypeForRule(dataRule.getShopTypes()); + wxShop.setFloorForRule(dataRule.getFloorIds()); + wxShop.setBusinessForRule(dataRule.getBussinessIds()); + wxShop.setShopTypeForRule(dataRule.getShopTypes()); } - return new ResultData(getVoPage(wxMerchant, pageNum, pageSize)); - } - - private PageInfo getVoPage(WxMerchant wxMerchant,Integer pageNum, Integer pageSize) { - Date starttime = wxMerchant.getStarttime(); - Date enttime = wxMerchant.getEndtime(); - wxMerchant.setStarttime(null); - wxMerchant.setEndtime(null); - if (null != wxMerchant.getOnlyOwe() && EnumYesOrNo.YES.getCode().intValue() == wxMerchant.getOnlyOwe().intValue()) { - wxMerchant.setOweBillBeforeDays(getOweBillBeforeDays()); - List mids = billAllHelper.getOwdMerchantIds(wxMerchant, starttime, enttime); - if (null != mids && mids.size() > 0 ) { - wxMerchant.setIds(mids);; + return new ResultData(getVoPage(wxShop, pageNum, pageSize)); + } + + private PageInfo getVoPage(WxShop wxShop,Integer pageNum, Integer pageSize) { + Date starttime = wxShop.getStarttime(); + Date enttime = wxShop.getEndtime(); + wxShop.setStarttime(null); + wxShop.setEndtime(null); + if (null != wxShop.getOnlyOwe() && EnumYesOrNo.YES.getCode().intValue() == wxShop.getOnlyOwe().intValue()) { + wxShop.setOweBillBeforeDays(getOweBillBeforeDays()); + List sids = billAllHelper.getOwdShopIds(wxShop, starttime, enttime); + if (null != sids && sids.size() > 0 ) { + wxShop.setIds(sids);; }else { - wxMerchant.setId(-1L); + wxShop.setId(-1L); } } - wxMerchant.setIsPreview(EnumYesOrNo.NO.getCode()); - PageInfo merchantPage = wxMerchantService.listAsPage(wxMerchant, pageNum, pageSize); - PageInfo page = new PageInfo(); + wxShop.setIsPreview(EnumYesOrNo.NO.getCode()); + PageInfo shopPage = wxShopSerivce.listAsPage(wxShop, pageNum, pageSize); + PageInfo page = new PageInfo(); page.setPageNum(pageNum); page.setPageSize(pageSize); - if (null != merchantPage && null != merchantPage.getList() && merchantPage.getList().size() > 0 ) { - List retList = new ArrayList(); + if (null != shopPage && null != shopPage.getList() && shopPage.getList().size() > 0 ) { + List retList = new ArrayList(); for (int i = 0 ; i < merchantPage.getList().size(); i ++) { - WxMerchantBillVo vo = new WxMerchantBillVo(); + WxShopBillVo vo = new WxShopBillVo(); WxMerchant m = merchantPage.getList().get(i); vo.setMerchantId(m.getId()); vo.setMerchantName(m.getName()); @@ -195,8 +195,8 @@ public class WxAllBillController extends BillBaseController { wxMerchant.setBusinessForRule(dataRule.getBussinessIds()); wxMerchant.setShopTypeForRule(dataRule.getShopTypes()); } - PageInfo page = getVoPage(wxMerchant, 1, 10000); - excelService.exportExcel(page.getList(), null, "商户账单总览数据", WxMerchantBillVo.class, "商户账单总览数据.xlsx", response, false); + PageInfo page = getVoPage(wxMerchant, 1, 10000); + excelService.exportExcel(page.getList(), null, "商户账单总览数据", WxShopBillVo.class, "商户账单总览数据.xlsx", response, false); } /** @@ -209,7 +209,7 @@ public class WxAllBillController extends BillBaseController { if (null == wxMerchant.getId()) { return new ResultData(Result.ERROR,"请选择商户"); } - WxMerchantBillVo vo = getMerchantBillVo(wxMerchant); + WxShopBillVo vo = getMerchantBillVo(wxMerchant); if (null == vo) { return new ResultData(); } @@ -217,7 +217,7 @@ public class WxAllBillController extends BillBaseController { return new ResultData(vo); } - private WxMerchantBillVo getMerchantBillVo( WxMerchant wxMerchant) { + private WxShopBillVo getMerchantBillVo( WxMerchant wxMerchant) { wxMerchant.updateTenantInfo(getTenantInfo()); Date starttime = wxMerchant.getStarttime(); Date enttime = wxMerchant.getEndtime(); @@ -227,7 +227,7 @@ public class WxAllBillController extends BillBaseController { if (null == m) { return null; } - WxMerchantBillVo vo = new WxMerchantBillVo(); + WxShopBillVo vo = new WxShopBillVo(); vo.setMerchantId(m.getId()); vo.setMerchantName(m.getName()); vo.setShopNumber(billAllHelper.getMerchantShopNumber(m)); @@ -279,7 +279,7 @@ public class WxAllBillController extends BillBaseController { } merchant.updateTenantInfo(getTenantInfo()); WxPayAccountBill ab = wxPayAccountBillService.getByTenantInfo(merchant); - WxMerchantBillVo vo = getMerchantBillVo(merchant); + WxShopBillVo vo = getMerchantBillVo(merchant); if (null != ab) { vo.setMallBankAccount(ab.getBankCardId()); vo.setMallBankAccountName(ab.getBankName()); diff --git a/mallinkAdmin/src/main/resources/db/migration/V202411000000001.sql b/mallinkAdmin/src/main/resources/db/migration/V202411000000001.sql new file mode 100644 index 000000000..749b57bb6 --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V202411000000001.sql @@ -0,0 +1,270 @@ +alter table wx_rent_contract drop column merchant_id; +alter table wx_rent_contract drop column merchant_name; +alter table wx_rent_contract drop column brand; +alter table wx_rent_contract drop column business_id; +alter table wx_rent_contract drop column shop_type; +alter table wx_rent_contract drop column shop_type_str; +alter table wx_rent_contract drop column property_name; +alter table wx_rent_contract drop column property_fee; +alter table wx_rent_contract drop column fee_cycle; +alter table wx_rent_contract drop column water_fee; +alter table wx_rent_contract drop column electricity_fees; +alter table wx_rent_contract drop column first_party_bank_info; +alter table wx_rent_contract drop column second_party_bank_info; +alter table wx_rent_contract drop column second_party_tax_info; +alter table wx_rent_contract drop column shop_type_sub; +alter table wx_rent_contract drop column lease_purpose; +alter table wx_rent_contract drop column contractual_rules; +alter table wx_rent_contract drop column delivery_date; +alter table wx_rent_contract drop column delivery_grace_period; +alter table wx_rent_contract drop column opening_date; +alter table wx_rent_contract drop column business_hours; +alter table wx_rent_contract drop column scope_metre; +alter table wx_rent_contract drop column pay_date; + +alter table wx_rent_contract_agile_deposit drop column merchant_id; +alter table wx_rent_contract_agile_un_deposit drop column merchant_id; +alter table wx_rent_contract_agile_un_deposit_item drop column merchant_id; + +#此处要把万星的虚拟商户给删掉 soho的 +alter table wx_rent_contract drop column is_private_merchant; +alter table wx_rent_contract drop column private_rent_shop_type; + +#此处要把万星的合同,根据商户的刷成customers_id (商业和soho的) +alter table wx_rent_contract add column customers_id bigint(20) not null comment '客户ID'; + + +CREATE TABLE `wx_contract_customers` ( + `id` bigint(20) NOT NULL COMMENT '主键ID', + `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', + `parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', + `principal_type` int(20) NOT NULL COMMENT '主体类型', + `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '名称', + `phone` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '电话', + `legal_person` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '法人', + `id_number` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '身份证号', + `sex` int(1) DEFAULT NULL COMMENT '性别', + `link_person` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '联系人', + `create_date` datetime NOT NULL COMMENT '创建时间', + `update_date` datetime NOT NULL COMMENT '更新时间', + `status` int(1) NOT NULL DEFAULT '0' COMMENT '状态', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='合同意向客户'; + +CREATE TABLE `wx_contract_shop` ( + `id` bigint(20) NOT NULL COMMENT '主键ID', + `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', + `parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', + `contract_id` bigint(20) NOT NULL COMMENT '合同编号', + `shop_id` bigint(20) NOT NULL COMMENT '店铺编号', + `create_date` datetime NOT NULL COMMENT '创建时间', + `update_date` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `UNIQUE_R_S` (`tenant_id`,`contract_id`,`shop_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='合同铺位关联'; + + + +alter table wx_all_bill_0 drop column merchant_id; +alter table wx_all_bill_1 drop column merchant_id; +alter table wx_all_bill_2 drop column merchant_id; +alter table wx_all_bill_3 drop column merchant_id; +alter table wx_all_bill_4 drop column merchant_id; +alter table wx_all_bill_5 drop column merchant_id; +alter table wx_all_bill_6 drop column merchant_id; +alter table wx_all_bill_7 drop column merchant_id; +alter table wx_all_bill_8 drop column merchant_id; +alter table wx_all_bill_9 drop column merchant_id; +alter table wx_all_bill_10 drop column merchant_id; +alter table wx_all_bill_11 drop column merchant_id; +alter table wx_all_bill_12 drop column merchant_id; +alter table wx_all_bill_13 drop column merchant_id; +alter table wx_all_bill_14 drop column merchant_id; +alter table wx_all_bill_15 drop column merchant_id; +alter table wx_all_bill_16 drop column merchant_id; +alter table wx_all_bill_17 drop column merchant_id; +alter table wx_all_bill_18 drop column merchant_id; +alter table wx_all_bill_19 drop column merchant_id; +alter table wx_all_bill_20 drop column merchant_id; +alter table wx_all_bill_21 drop column merchant_id; +alter table wx_all_bill_22 drop column merchant_id; +alter table wx_all_bill_23 drop column merchant_id; +alter table wx_all_bill_24 drop column merchant_id; +alter table wx_all_bill_25 drop column merchant_id; +alter table wx_all_bill_26 drop column merchant_id; +alter table wx_all_bill_27 drop column merchant_id; +alter table wx_all_bill_28 drop column merchant_id; +alter table wx_all_bill_29 drop column merchant_id; +alter table wx_all_bill_30 drop column merchant_id; +alter table wx_all_bill_31 drop column merchant_id; +alter table wx_all_bill_32 drop column merchant_id; +alter table wx_all_bill_33 drop column merchant_id; +alter table wx_all_bill_34 drop column merchant_id; +alter table wx_all_bill_35 drop column merchant_id; +alter table wx_all_bill_36 drop column merchant_id; +alter table wx_all_bill_37 drop column merchant_id; +alter table wx_all_bill_38 drop column merchant_id; +alter table wx_all_bill_39 drop column merchant_id; +alter table wx_all_bill_40 drop column merchant_id; +alter table wx_all_bill_41 drop column merchant_id; +alter table wx_all_bill_42 drop column merchant_id; +alter table wx_all_bill_43 drop column merchant_id; +alter table wx_all_bill_44 drop column merchant_id; +alter table wx_all_bill_45 drop column merchant_id; +alter table wx_all_bill_46 drop column merchant_id; +alter table wx_all_bill_47 drop column merchant_id; +alter table wx_all_bill_48 drop column merchant_id; +alter table wx_all_bill_49 drop column merchant_id; +alter table wx_all_bill_50 drop column merchant_id; +alter table wx_all_bill_51 drop column merchant_id; +alter table wx_all_bill_52 drop column merchant_id; +alter table wx_all_bill_53 drop column merchant_id; +alter table wx_all_bill_54 drop column merchant_id; +alter table wx_all_bill_55 drop column merchant_id; +alter table wx_all_bill_56 drop column merchant_id; +alter table wx_all_bill_57 drop column merchant_id; +alter table wx_all_bill_58 drop column merchant_id; +alter table wx_all_bill_59 drop column merchant_id; +alter table wx_all_bill_60 drop column merchant_id; +alter table wx_all_bill_61 drop column merchant_id; +alter table wx_all_bill_62 drop column merchant_id; +alter table wx_all_bill_63 drop column merchant_id; +alter table wx_all_bill_64 drop column merchant_id; +alter table wx_all_bill_65 drop column merchant_id; +alter table wx_all_bill_66 drop column merchant_id; +alter table wx_all_bill_67 drop column merchant_id; +alter table wx_all_bill_68 drop column merchant_id; +alter table wx_all_bill_69 drop column merchant_id; +alter table wx_all_bill_70 drop column merchant_id; +alter table wx_all_bill_71 drop column merchant_id; +alter table wx_all_bill_72 drop column merchant_id; +alter table wx_all_bill_73 drop column merchant_id; +alter table wx_all_bill_74 drop column merchant_id; +alter table wx_all_bill_75 drop column merchant_id; +alter table wx_all_bill_76 drop column merchant_id; +alter table wx_all_bill_77 drop column merchant_id; +alter table wx_all_bill_78 drop column merchant_id; +alter table wx_all_bill_79 drop column merchant_id; +alter table wx_all_bill_80 drop column merchant_id; +alter table wx_all_bill_81 drop column merchant_id; +alter table wx_all_bill_82 drop column merchant_id; +alter table wx_all_bill_83 drop column merchant_id; +alter table wx_all_bill_84 drop column merchant_id; +alter table wx_all_bill_85 drop column merchant_id; +alter table wx_all_bill_86 drop column merchant_id; +alter table wx_all_bill_87 drop column merchant_id; +alter table wx_all_bill_88 drop column merchant_id; +alter table wx_all_bill_89 drop column merchant_id; +alter table wx_all_bill_90 drop column merchant_id; +alter table wx_all_bill_91 drop column merchant_id; +alter table wx_all_bill_92 drop column merchant_id; +alter table wx_all_bill_93 drop column merchant_id; +alter table wx_all_bill_94 drop column merchant_id; +alter table wx_all_bill_95 drop column merchant_id; +alter table wx_all_bill_96 drop column merchant_id; +alter table wx_all_bill_97 drop column merchant_id; +alter table wx_all_bill_98 drop column merchant_id; +alter table wx_all_bill_99 drop column merchant_id; + +alter table wx_all_bill_0 modify column shop_id bigint(20) not null; +alter table wx_all_bill_1 modify column shop_id bigint(20) not null; +alter table wx_all_bill_2 modify column shop_id bigint(20) not null; +alter table wx_all_bill_3 modify column shop_id bigint(20) not null; +alter table wx_all_bill_4 modify column shop_id bigint(20) not null; +alter table wx_all_bill_5 modify column shop_id bigint(20) not null; +alter table wx_all_bill_6 modify column shop_id bigint(20) not null; +alter table wx_all_bill_7 modify column shop_id bigint(20) not null; +alter table wx_all_bill_8 modify column shop_id bigint(20) not null; +alter table wx_all_bill_9 modify column shop_id bigint(20) not null; +alter table wx_all_bill_10 modify column shop_id bigint(20) not null; +alter table wx_all_bill_11 modify column shop_id bigint(20) not null; +alter table wx_all_bill_12 modify column shop_id bigint(20) not null; +alter table wx_all_bill_13 modify column shop_id bigint(20) not null; +alter table wx_all_bill_14 modify column shop_id bigint(20) not null; +alter table wx_all_bill_15 modify column shop_id bigint(20) not null; +alter table wx_all_bill_16 modify column shop_id bigint(20) not null; +alter table wx_all_bill_17 modify column shop_id bigint(20) not null; +alter table wx_all_bill_18 modify column shop_id bigint(20) not null; +alter table wx_all_bill_19 modify column shop_id bigint(20) not null; +alter table wx_all_bill_20 modify column shop_id bigint(20) not null; +alter table wx_all_bill_21 modify column shop_id bigint(20) not null; +alter table wx_all_bill_22 modify column shop_id bigint(20) not null; +alter table wx_all_bill_23 modify column shop_id bigint(20) not null; +alter table wx_all_bill_24 modify column shop_id bigint(20) not null; +alter table wx_all_bill_25 modify column shop_id bigint(20) not null; +alter table wx_all_bill_26 modify column shop_id bigint(20) not null; +alter table wx_all_bill_27 modify column shop_id bigint(20) not null; +alter table wx_all_bill_28 modify column shop_id bigint(20) not null; +alter table wx_all_bill_29 modify column shop_id bigint(20) not null; +alter table wx_all_bill_30 modify column shop_id bigint(20) not null; +alter table wx_all_bill_31 modify column shop_id bigint(20) not null; +alter table wx_all_bill_32 modify column shop_id bigint(20) not null; +alter table wx_all_bill_33 modify column shop_id bigint(20) not null; +alter table wx_all_bill_34 modify column shop_id bigint(20) not null; +alter table wx_all_bill_35 modify column shop_id bigint(20) not null; +alter table wx_all_bill_36 modify column shop_id bigint(20) not null; +alter table wx_all_bill_37 modify column shop_id bigint(20) not null; +alter table wx_all_bill_38 modify column shop_id bigint(20) not null; +alter table wx_all_bill_39 modify column shop_id bigint(20) not null; +alter table wx_all_bill_40 modify column shop_id bigint(20) not null; +alter table wx_all_bill_41 modify column shop_id bigint(20) not null; +alter table wx_all_bill_42 modify column shop_id bigint(20) not null; +alter table wx_all_bill_43 modify column shop_id bigint(20) not null; +alter table wx_all_bill_44 modify column shop_id bigint(20) not null; +alter table wx_all_bill_45 modify column shop_id bigint(20) not null; +alter table wx_all_bill_46 modify column shop_id bigint(20) not null; +alter table wx_all_bill_47 modify column shop_id bigint(20) not null; +alter table wx_all_bill_48 modify column shop_id bigint(20) not null; +alter table wx_all_bill_49 modify column shop_id bigint(20) not null; +alter table wx_all_bill_50 modify column shop_id bigint(20) not null; +alter table wx_all_bill_51 modify column shop_id bigint(20) not null; +alter table wx_all_bill_52 modify column shop_id bigint(20) not null; +alter table wx_all_bill_53 modify column shop_id bigint(20) not null; +alter table wx_all_bill_54 modify column shop_id bigint(20) not null; +alter table wx_all_bill_55 modify column shop_id bigint(20) not null; +alter table wx_all_bill_56 modify column shop_id bigint(20) not null; +alter table wx_all_bill_57 modify column shop_id bigint(20) not null; +alter table wx_all_bill_58 modify column shop_id bigint(20) not null; +alter table wx_all_bill_59 modify column shop_id bigint(20) not null; +alter table wx_all_bill_60 modify column shop_id bigint(20) not null; +alter table wx_all_bill_61 modify column shop_id bigint(20) not null; +alter table wx_all_bill_62 modify column shop_id bigint(20) not null; +alter table wx_all_bill_63 modify column shop_id bigint(20) not null; +alter table wx_all_bill_64 modify column shop_id bigint(20) not null; +alter table wx_all_bill_65 modify column shop_id bigint(20) not null; +alter table wx_all_bill_66 modify column shop_id bigint(20) not null; +alter table wx_all_bill_67 modify column shop_id bigint(20) not null; +alter table wx_all_bill_68 modify column shop_id bigint(20) not null; +alter table wx_all_bill_69 modify column shop_id bigint(20) not null; +alter table wx_all_bill_70 modify column shop_id bigint(20) not null; +alter table wx_all_bill_71 modify column shop_id bigint(20) not null; +alter table wx_all_bill_72 modify column shop_id bigint(20) not null; +alter table wx_all_bill_73 modify column shop_id bigint(20) not null; +alter table wx_all_bill_74 modify column shop_id bigint(20) not null; +alter table wx_all_bill_75 modify column shop_id bigint(20) not null; +alter table wx_all_bill_76 modify column shop_id bigint(20) not null; +alter table wx_all_bill_77 modify column shop_id bigint(20) not null; +alter table wx_all_bill_78 modify column shop_id bigint(20) not null; +alter table wx_all_bill_79 modify column shop_id bigint(20) not null; +alter table wx_all_bill_80 modify column shop_id bigint(20) not null; +alter table wx_all_bill_81 modify column shop_id bigint(20) not null; +alter table wx_all_bill_82 modify column shop_id bigint(20) not null; +alter table wx_all_bill_83 modify column shop_id bigint(20) not null; +alter table wx_all_bill_84 modify column shop_id bigint(20) not null; +alter table wx_all_bill_85 modify column shop_id bigint(20) not null; +alter table wx_all_bill_86 modify column shop_id bigint(20) not null; +alter table wx_all_bill_87 modify column shop_id bigint(20) not null; +alter table wx_all_bill_88 modify column shop_id bigint(20) not null; +alter table wx_all_bill_89 modify column shop_id bigint(20) not null; +alter table wx_all_bill_90 modify column shop_id bigint(20) not null; +alter table wx_all_bill_91 modify column shop_id bigint(20) not null; +alter table wx_all_bill_92 modify column shop_id bigint(20) not null; +alter table wx_all_bill_93 modify column shop_id bigint(20) not null; +alter table wx_all_bill_94 modify column shop_id bigint(20) not null; +alter table wx_all_bill_95 modify column shop_id bigint(20) not null; +alter table wx_all_bill_96 modify column shop_id bigint(20) not null; +alter table wx_all_bill_97 modify column shop_id bigint(20) not null; +alter table wx_all_bill_98 modify column shop_id bigint(20) not null; +alter table wx_all_bill_99 modify column shop_id bigint(20) not null; + + diff --git a/mallinkBApi/src/main/java/com/iformall/controller/BaseController.java b/mallinkBApi/src/main/java/com/iformall/controller/BaseController.java index 7a8bdeed7..3779c6594 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/BaseController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/BaseController.java @@ -3,6 +3,7 @@ package com.iformall.controller; import com.iformall.common.ErrorCode; import com.iformall.common.SysConfigConstant; +import com.iformall.domain.dto.WxRentLoginUserDTO; import com.iformall.domain.po.*; import com.iformall.domain.po.base.BaseCUserEntity; import com.iformall.domain.po.base.TenantEntity; @@ -230,4 +231,13 @@ public class BaseController { // user.setIsAdmin(1); // return user; } + + public WxRentLoginUserDTO getRentLoginUser() { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + WxRentLoginUserDTO dto = (WxRentLoginUserDTO)request.getAttribute(Constant.REQUEST_SHOP_USER_KEY); + if (null == dto) { + throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(),"业主/租户登录用户不存在"); + } + return dto; + } } diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxBillController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxBillController.java index d544cee04..3d361e1d5 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxBillController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxBillController.java @@ -7,6 +7,7 @@ import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.common.SysConfigConstant; import com.iformall.domain.dto.WxBillPayDTO; +import com.iformall.domain.dto.WxRentLoginUserDTO; import com.iformall.domain.po.SysConfig; import com.iformall.domain.po.WxBillAction; import com.iformall.domain.po.WxAllBill; @@ -14,7 +15,10 @@ import com.iformall.domain.po.WxFlowModel; import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxMerchantBUser; import com.iformall.domain.po.WxPayAccountBill; +import com.iformall.domain.po.WxShop; +import com.iformall.domain.po.WxShopUsers; import com.iformall.domain.po.WxUserDataRule; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxBillHotNotify; import com.iformall.enums.EnumBillAllType; import com.iformall.enums.EnumBillOweOrNearType; @@ -23,6 +27,7 @@ import com.iformall.enums.EnumBillUpdateType; import com.iformall.enums.EnumFilterSettle; import com.iformall.enums.EnumFlowKey; import com.iformall.enums.EnumMerchantStatus; +import com.iformall.enums.EnumShopUsersStatus; import com.iformall.enums.EnumYesOrNo; import com.iformall.service.SysConfigService; import com.iformall.service.WxAllBillService; @@ -31,6 +36,7 @@ import com.iformall.service.WxBillSettleService; import com.iformall.service.WxFlowService; import com.iformall.service.WxMerchantService; import com.iformall.service.WxPayAccountBillService; +import com.iformall.service.WxShopService; import com.iformall.service.helper.WxBillAllHelper; import com.iformall.service.payBill.PayBillServiceFactory; import com.iformall.utils.Constant; @@ -60,12 +66,8 @@ public class WxBillController extends BaseController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); - //@Autowired - //WxBillAllService wxBillAllService; @Autowired - WxMerchantService wxMerchantService; - //@Autowired - //WxBillSettleService wxBillSettleService; + WxShopService wxShopService; @Autowired private WxFlowService wxFlowService; @Autowired @@ -111,6 +113,22 @@ public class WxBillController extends BaseController { return new ResultData(tmap); } + private WxShop getCurrentShopList() { + WxRentLoginUserDTO user = this.getRentLoginUser(); + WxShopUsers su = new WxShopUsers(); + su.updateTenantInfo(user); + su.setPhone(user.getPhone()); + su.setStatus(EnumShopUsersStatus.LIVE.getCode()); + List shopIds = wxShopService.getUserShopIds(su); + if (null == shopIds || shopIds.size() <= 0 ) { + return null; + }else { + WxShop shop = new WxShop(); + shop.updateTenantInfo(user); + shop.setIds(shopIds); + return shop; + } + } /** * 商户催缴账单列表 @@ -120,11 +138,12 @@ public class WxBillController extends BaseController { * @return */ @GetMapping("notifyList") - public ResultData notifyList(@ModelAttribute WxMerchant wxMerchant) { - WxMerchantBUser buser = this.getLoginBUser(); - wxMerchant.setId(buser.getMerchantId()); - wxMerchant.updateTenantInfo(buser); - return new ResultData(billAllHelper.getBillNotifyList(wxMerchant,EnumYesOrNo.YES.getCode())); + public ResultData notifyList() { + WxShop shop = getCurrentShopList(); + if (null == shop) { + return new ResultData(); + } + return new ResultData(billAllHelper.getBillNotifyList(shop,EnumYesOrNo.YES.getCode())); } /** @@ -135,12 +154,13 @@ public class WxBillController extends BaseController { * @return */ @GetMapping("oweBillList") - public ResultData oweBillList(@ModelAttribute WxMerchant wxMerchant) { - WxMerchantBUser buser = this.getLoginBUser(); - wxMerchant.setId(buser.getMerchantId()); - wxMerchant.setOweBillBeforeDays(getOweBillBeforeDays()); - wxMerchant.updateTenantInfo(buser); - return new ResultData(billAllHelper.getBillNotifyList(wxMerchant,null)); + public ResultData oweBillList() { + WxShop shop = getCurrentShopList(); + if (null == shop) { + return new ResultData(); + } + shop.setOweBillBeforeDays(getOweBillBeforeDays()); + return new ResultData(billAllHelper.getBillNotifyList(shop,null)); } private Integer getOweBillBeforeDays() { @@ -160,13 +180,14 @@ public class WxBillController extends BaseController { * @return */ @GetMapping("nearBillList") - public ResultData nearBillList(@ModelAttribute WxMerchant wxMerchant) { - WxMerchantBUser buser = this.getLoginBUser(); - wxMerchant.updateTenantInfo(buser); - wxMerchant.setId(buser.getMerchantId()); - wxMerchant.setOweBillBeforeDays(getOweBillBeforeDays()); - wxMerchant.setNearBillBeforeDays(getNearBillBeforeDays()); - return new ResultData(billAllHelper.getBillNotifyList(wxMerchant,null)); + public ResultData nearBillList() { + WxShop shop = getCurrentShopList(); + if (null == shop) { + return new ResultData(); + } + shop.setOweBillBeforeDays(getOweBillBeforeDays()); + shop.setNearBillBeforeDays(getNearBillBeforeDays()); + return new ResultData(billAllHelper.getBillNotifyList(shop,null)); } private Integer getNearBillBeforeDays() { @@ -180,28 +201,30 @@ public class WxBillController extends BaseController { @ApiOperation("查询账单") @RequestMapping("list") - public ResultData listBill(@ModelAttribute WxMerchant wxMerchant,Integer pageNum, Integer pageSize) { - if (null != wxMerchant.getOnlyOweOrNear()) { - if (EnumBillOweOrNearType.OWE.getCode().intValue() == wxMerchant.getOnlyOweOrNear().intValue()) { - wxMerchant.setOweBillBeforeDays(getOweBillBeforeDays()); - }else if (EnumBillOweOrNearType.NEAR.getCode().intValue() == wxMerchant.getOnlyOweOrNear().intValue()) { - wxMerchant.setOweBillBeforeDays(getOweBillBeforeDays()); - wxMerchant.setNearBillBeforeDays(getNearBillBeforeDays()); + public ResultData listBill(@ModelAttribute WxShop wxShop,Integer pageNum, Integer pageSize) { + WxShop shop0 = getCurrentShopList(); + if (null == shop0) { + return new ResultData(); + } + if (null != wxShop.getOnlyOweOrNear()) { + if (EnumBillOweOrNearType.OWE.getCode().intValue() == wxShop.getOnlyOweOrNear().intValue()) { + shop0.setOweBillBeforeDays(getOweBillBeforeDays()); + }else if (EnumBillOweOrNearType.NEAR.getCode().intValue() == wxShop.getOnlyOweOrNear().intValue()) { + shop0.setOweBillBeforeDays(getOweBillBeforeDays()); + shop0.setNearBillBeforeDays(getNearBillBeforeDays()); } } - wxMerchant.setId(this.getLoginBUser().getMerchantId()); - wxMerchant.updateTenantInfo(getTenantInfo()); - return new ResultData(billAllHelper.getBillList(wxMerchant,pageNum,pageSize)); + return new ResultData(billAllHelper.getBillList(shop0,pageNum,pageSize)); } @ApiOperation("账单详情") @GetMapping("detail") - public ResultData detail(@ModelAttribute WxMerchant wxMerchant,Integer billTypeValue,Long billId) { - if (null == wxMerchant) { - wxMerchant = new WxMerchant(); + public ResultData detail(Integer billTypeValue,Long billId) { + WxShop shop = getCurrentShopList(); + if (null == shop) { + return new ResultData(); } - wxMerchant.updateTenantInfo(getTenantInfo()); - return new ResultData(wxAllBillService.getById(wxMerchant,billId)); + return new ResultData(wxAllBillService.getById(shop,billId)); } @ApiOperation("账单操作记录列表") @@ -254,10 +277,8 @@ public class WxBillController extends BaseController { return new ResultData(Result.ERROR,"分类非法"); } } - WxMerchant wxMerchant = new WxMerchant(); - wxMerchant.setId(this.getLoginBUser().getMerchantId()); - wxMerchant.updateTenantInfo(getTenantInfo()); - WxAllBill billdetail = billAllHelper.getBillDetail(btype, wxMerchant,billId); + TenantEntity tenantEntity = getTenantInfo(); + WxAllBill billdetail = billAllHelper.getBillDetail(tenantEntity,billId); if (null == billdetail) { return new ResultData(Result.ERROR,"账单支付未查询到"); } @@ -265,7 +286,7 @@ public class WxBillController extends BaseController { // if (owe.compareTo(new BigDecimal(payMoney)) < 0) { // return new ResultData(Result.ERROR,"支付金额大于欠费金额,请刷新账单后再支付"); // } - WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxMerchant); + WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(tenantEntity); if (null == wxPayAccountBill || null == wxPayAccountBill.getPayChannel()) { return new ResultData(Result.ERROR,"账单支付配置错误,请联系管理员"); } diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxInfoController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxInfoController.java index 20e139b55..5a6c36070 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxInfoController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxInfoController.java @@ -51,6 +51,9 @@ public class WxInfoController extends BaseController { @Autowired MallUserInfoService mallUserInfoService; + + @Autowired + WxShopService wxShopService; @Autowired MallUserRoleService mallUserRoleService; @@ -249,6 +252,7 @@ public class WxInfoController extends BaseController { String iv = map.get("iv"); String openId = map.get("openId"); String session_key = map.get("session_key"); + String shopUser = map.get("shopUser"); //登录凭证不能为空 if (StringUtils.isBlank(encryptedData)) { @@ -284,21 +288,27 @@ public class WxInfoController extends BaseController { if (null != phone) { resultMap.put("phone", phone); - MallUserInfo user = mallUserInfoService.getByPhone(phone, tenantEntity); - if(user == null) { - return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(),"手机号["+phone+"]非绑定后台管理员账号", resultMap); - } - if (mallUserRoleService.checkIsMobileAdmin(user)) { - resultMap.put("phone", user.getPhone()); - resultMap.put("admin", "1"); - - user.setBopenId(buser.getOpenId()); - mallUserInfoService.saveOrUpdate(user); - resultMap.put("token", user.getId().toString()+Constant.TOKEN_ADMIN_END); + if (StringUtils.isBlank(shopUser) || (!"1".equals(shopUser))) { + MallUserInfo user = mallUserInfoService.getByPhone(phone, tenantEntity); + if(user == null) { + return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(),"手机号["+phone+"]非绑定后台管理员账号", resultMap); + } + if (mallUserRoleService.checkIsMobileAdmin(user)) { + resultMap.put("phone", user.getPhone()); + resultMap.put("admin", "1"); + + user.setBopenId(buser.getOpenId()); + mallUserInfoService.saveOrUpdate(user); + resultMap.put("token", user.getId().toString()+Constant.TOKEN_ADMIN_END); + return new ResultData(resultMap); + } else { + return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(),user.getName()+"不是超管或者没有"+EnumMenuType.MOBILE_ADMIN.getMessage()+"的权限", resultMap); + } + }else { + resultMap.put("token", phone+"_"+buser.getTenantId()+"_"+StringUtils.trimToEmpty(buser.getParentTenantId())+Constant.TOKEN_SHOP_USER_END); return new ResultData(resultMap); - } else { - return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(),user.getName()+"不是超管或者没有"+EnumMenuType.MOBILE_ADMIN.getMessage()+"的权限", resultMap); } + } else { return new ResultData(ErrorCode.PHONE_DECODE_ERR, resultMap); } diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxMallAdminController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxMallAdminController.java index a7c57b807..db4fa6792 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxMallAdminController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxMallAdminController.java @@ -176,9 +176,9 @@ public class WxMallAdminController extends BaseController { * @return */ @GetMapping("notifyList") - public ResultData notifyList(@ModelAttribute WxMerchant wxMerchant) { - setQueryDataRule(wxMerchant); - return new ResultData(billAllHelper.getBillNotifyList(wxMerchant,EnumYesOrNo.YES.getCode())); + public ResultData notifyList(@ModelAttribute WxShop wxShop) { + setQueryDataRule(wxShop); + return new ResultData(billAllHelper.getBillNotifyList(wxShop,EnumYesOrNo.YES.getCode())); } private Integer getOweBillBeforeDays() { diff --git a/mallinkBApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java b/mallinkBApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java index 433767380..a7c37690b 100644 --- a/mallinkBApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java +++ b/mallinkBApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java @@ -6,6 +6,7 @@ import com.iformall.annotation.AuthIgnore; import com.iformall.annotation.TenantIgnore; import com.iformall.common.ErrorCode; import com.iformall.common.TenantThreadLocal; +import com.iformall.domain.dto.WxRentLoginUserDTO; import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxMall; import com.iformall.domain.po.WxMerchantBUser; @@ -93,6 +94,7 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { String tenantId = null; String parenTenantId = null; MallUserInfo adminUser = null; + WxRentLoginUserDTO rentLoginUser = null; if (StringUtils.isNotBlank(token)) { //商管操作台 if(token.endsWith(Constant.TOKEN_ADMIN_END)){ @@ -102,6 +104,15 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " adminUserId失效,请重新登录"); } request.setAttribute(Constant.REQUEST_MALL_USER_KEY, adminUser); + //租赁缴费 + }else if (token.endsWith(Constant.TOKEN_SHOP_USER_END)) { + String[] tokens = token.split(":"); + String[] contents = tokens[0].split("_"); + rentLoginUser = new WxRentLoginUserDTO(); + rentLoginUser.setPhone(contents[0]); + rentLoginUser.setTenantId(contents[1]); + rentLoginUser.setParentTenantId(StringUtils.trimToNull(contents[2])); + request.setAttribute(Constant.REQUEST_SHOP_USER_KEY, rentLoginUser); }else { BaseCUserEntity user = cUserTokenService.getBByToken(token); if (user == null || user.getExpireTime().getTime() < System.currentTimeMillis()) { @@ -117,7 +128,7 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { buser = wxMerchantBUserService.getById(Long.parseLong(bid)); } - if (buser == null && adminUser == null) { + if (buser == null && adminUser == null && null == rentLoginUser) { throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " 登录失效,请重新登录"); } @@ -138,6 +149,11 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { if (StringUtils.isNotBlank(adminUser.getParentTenantId())) { parenTenantId = adminUser.getParentTenantId(); } + }else if (null != rentLoginUser) { + tenantId = rentLoginUser.getTenantId(); + if (StringUtils.isNotBlank(rentLoginUser.getParentTenantId())) { + parenTenantId = rentLoginUser.getParentTenantId(); + } } } @@ -153,11 +169,18 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { && !tenantId.equals(adminUser.getParentTenantId())){ throw new MallinkException(ErrorCode.SYS_AUTH_ERROR); } + }else if (null != rentLoginUser) { + if(!tenantId.equals(rentLoginUser.getTenantId()) + && !rentLoginUser.getTenantId().equals(parenTenantId) + && !tenantId.equals(rentLoginUser.getParentTenantId())){ + throw new MallinkException(ErrorCode.SYS_AUTH_ERROR); + } } if (null != buser) { request.setAttribute(Constant.LOGIN_B_USER_KEY, buser.getId()); } + request.setAttribute(Constant.TENANT_ID, tenantId); request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); diff --git a/mallinkService/src/main/java/com/iformall/domain/dto/WxRentLoginUserDTO.java b/mallinkService/src/main/java/com/iformall/domain/dto/WxRentLoginUserDTO.java new file mode 100644 index 000000000..f2526b04a --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/dto/WxRentLoginUserDTO.java @@ -0,0 +1,16 @@ +package com.iformall.domain.dto; + +import com.iformall.domain.po.base.TenantEntity; + +import lombok.Data; + +/** + * 获取积分DTO + * + * @author xmzhao71 + * @date 2023-08-31 + */ +@Data +public class WxRentLoginUserDTO extends TenantEntity{ + private String phone; +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java b/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java index aa56c06fc..56094114e 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java @@ -35,13 +35,12 @@ public class WxAllBill extends TenantEntity { protected Long id; - @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") - public Long merchantId; + @io.swagger.annotations.ApiModelProperty(value="归属商铺ID",name="shopId") + public Long shopId; + + @Excel(name = "商铺号", width = 20, orderNum = "1") + public String shopNumber; - @Excel(name = "商户名称", width = 20, orderNum = "2") - @TableField(exist = false) - public String merchantName; - @Excel(name = "制单时间", format = "yyyy-MM-dd HH:mm:ss", width = 20, orderNum = "13") @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createtime") public Date createtime; @@ -263,12 +262,6 @@ public class WxAllBill extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="租金里面的营业管理费",name="operatingManageFeeNeedPay") public String operatingManageFeeNeedPay; - @io.swagger.annotations.ApiModelProperty(value="归属商铺ID,非必须",name="shopId") - public Long shopId; - - @Excel(name = "商铺号", width = 20, orderNum = "1") - public String shopNumber; - @io.swagger.annotations.ApiModelProperty(value = "商铺信息", name = "shopInfo") public String shopInfo; @@ -346,9 +339,6 @@ public class WxAllBill extends TenantEntity { .setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); } - @TableField(exist = false) - public List merchantIdList; - @TableField(exist = false) public String month; @@ -392,8 +382,6 @@ public class WxAllBill extends TenantEntity { @TableField(exist = false) List unFixedbillFeesStandardsList; - @TableField(exist = false) - private Integer hasMerchant; @TableField(exist = false) private Integer hasParentBillId; @TableField(exist = false) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxContractCustomers.java b/mallinkService/src/main/java/com/iformall/domain/po/WxContractCustomers.java new file mode 100644 index 000000000..9f31f123d --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxContractCustomers.java @@ -0,0 +1,90 @@ +package com.iformall.domain.po; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.common.SortColumn; +import com.iformall.domain.po.base.TenantEntity; +import com.iformall.enums.EnumCUserBaseInfoSex; +import com.iformall.enums.EnumContractCustomersStatus; +import com.iformall.enums.EnumRentShopType; +import com.iformall.enums.EnumShopUsersPrincipalType; +import com.iformall.enums.EnumShopUsersStatus; +import com.iformall.enums.EnumShopUsersType; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@TableName(value = "wx_contract_customers") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class WxContractCustomers extends TenantEntity { + + private Long id; + + @io.swagger.annotations.ApiModelProperty(value = "主体类型EnumShopUsersPrincipalType", name = "type") + private Integer principalType; + @TableField(exist = false) + private String principalTypeName; + public String getPrincipalTypeName() { + if (null != principalType) { + return EnumShopUsersPrincipalType.getEnum(principalType).getMessage(); + } + return null; + } + + @io.swagger.annotations.ApiModelProperty(value="名称",name="name") + private String name; + + @io.swagger.annotations.ApiModelProperty(value="手机号",name="phone") + private String phone; + + @io.swagger.annotations.ApiModelProperty(value="法人",name="legalPerson") + private String legalPerson; + + @io.swagger.annotations.ApiModelProperty(value="身份证号码",name="idNumber") + private String idNumber; + + @io.swagger.annotations.ApiModelProperty(value="性别EnumCUserBaseInfoSex",name="sex") + private Integer sex; + @TableField(exist = false) + private String sexName; + public String getSexName() { + if (null != sex) { + return EnumCUserBaseInfoSex.getEnum(sex).getMessage(); + } + return null; + } + + @io.swagger.annotations.ApiModelProperty(value="联系人",name="linkPerson") + private String linkPerson; + + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") + private Date updateDate; + + @Excel(name="状态",width = 20,orderNum = "7",replace = {"意向客户_0","正式客户_1"}) + @io.swagger.annotations.ApiModelProperty(value="状态EnumContractCustomersStatus",name="status") + private Integer status; + @TableField(exist = false) + private String statusName; + public String getStatusName() { + if (null != status) { + return EnumContractCustomersStatus.getEnum(status).getMessage(); + } + return null; + } + + @TableField(exist = false) + private String nameEqal; + @TableField(exist = false) + private String phoneEqal; +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxContractShop.java b/mallinkService/src/main/java/com/iformall/domain/po/WxContractShop.java new file mode 100644 index 000000000..31849bfb6 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxContractShop.java @@ -0,0 +1,46 @@ +package com.iformall.domain.po; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.common.SortColumn; +import com.iformall.domain.po.base.TenantEntity; +import com.iformall.enums.EnumCUserBaseInfoSex; +import com.iformall.enums.EnumContractCustomersStatus; +import com.iformall.enums.EnumRentShopType; +import com.iformall.enums.EnumShopUsersPrincipalType; +import com.iformall.enums.EnumShopUsersStatus; +import com.iformall.enums.EnumShopUsersType; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@TableName(value = "wx_contract_shop") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class WxContractShop extends TenantEntity { + + private Long id; + + @io.swagger.annotations.ApiModelProperty(value="合体编号",name="contractId") + private Long contractId; + + @io.swagger.annotations.ApiModelProperty(value="店铺编号",name="shopId") + private Long shopId; + + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") + private Date updateDate; + + @TableField(exist = false) + private List shopIds; + +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxEnergyReadingCalcuteResult.java b/mallinkService/src/main/java/com/iformall/domain/po/WxEnergyReadingCalcuteResult.java index 64fc33ea8..0e4ceff7f 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxEnergyReadingCalcuteResult.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxEnergyReadingCalcuteResult.java @@ -93,12 +93,11 @@ public class WxEnergyReadingCalcuteResult extends TenantEntity { @TableField(exist = false) private String feesIdsStr; - public WxAllBill generateBill(WxEnergyReadingCalcute calcute,WxMerchant merchant,WxShop shop,MallUserInfo user,Date starttime,Date endtime,String needPay,String detail,String remark) { + public WxAllBill generateBill(WxEnergyReadingCalcute calcute,WxShop shop,MallUserInfo user,Date starttime,Date endtime,String needPay,String detail,String remark) { WxAllBill daily = new WxAllBill(); final IdWorker idWorker = IdWorker.get(); daily.setId(idWorker.nextId()); daily.updateTenantInfo(this); - daily.setMerchantId(merchant.getId()); daily.setCreatetime(new Date()); daily.setCreateBy(user.getId()); daily.setCreateByName(user.getName()); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java index 1a99c3da9..b7a4f407d 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java @@ -449,17 +449,6 @@ public class WxMerchant extends TenantEntity { private String initLog; - @TableField(exist = false) - private Integer onlyOwe; - - //账单逾期计算提前天数 - @TableField(exist = false) - private Integer oweBillBeforeDays; - - //临期计算提前天数 - @TableField(exist = false) - private Integer nearBillBeforeDays; - //账单完结备注 @TableField(exist = false) private String billCompleteRemark; @@ -469,25 +458,12 @@ public class WxMerchant extends TenantEntity { @TableField(exist = false) private Long shopId; - @TableField(exist = false) - private Integer needPayPreDays; - @TableField(exist = false) - private Integer needPayNoDays; - - @TableField(exist = false) - public Integer onlyOweOrNear; - @TableField(exist = false) public Integer billType; @TableField(exist = false) public Long energyFeesId; - @TableField(exist = false) - public List energyFeesIdList; + - @TableField(exist = false) - public Integer toPayMerchant; - @TableField(exist = false) - public Integer isPreview; @TableField(exist = false) public List feesIdList; @TableField(exist = false) @@ -497,10 +473,6 @@ public class WxMerchant extends TenantEntity { @TableField(exist = false) public String feesIdListStr; @TableField(exist = false) - public Integer advanceHasMoney; - @TableField(exist = false) - public Date receiveDate; - @TableField(exist = false) public Integer isAll; @TableField(exist = false) private List privateRentShopTypeList; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java index 8f255ea86..c5a3ef8c6 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java @@ -25,6 +25,7 @@ import java.math.RoundingMode; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -39,6 +40,18 @@ public class WxRentContract extends TenantEntity { protected Long id; + private Long customersId; + @TableField(exist = false) + private Integer customerType; + @TableField(exist = false) + private String customerName; + @TableField(exist = false) + private String customerLinkPerson; + @TableField(exist = false) + private String customerPhone; + @TableField(exist = false) + private String customerLegalPerson; + @io.swagger.annotations.ApiModelProperty(value = "来源ID,针对续签,从哪个合同续签", name = "fromId") private Long fromId; @@ -62,26 +75,6 @@ public class WxRentContract extends TenantEntity { @TableField(exist = false) private String buildArea; -// @TableField(exist = false) -// private String priceStr; - -// public String getPriceStr() { -// if(price!=null) { -// priceStr = new BigDecimal(price).divide(new BigDecimal(100)).toString(); -// } -// return priceStr; -// } - -// @TableField(exist = false) -// private String depositStr; -// -// public String getDepositStr() { -// if(deposit!=null) { -// depositStr = new BigDecimal(deposit).divide(new BigDecimal(100)).toString(); -// } -// return depositStr; -// } - @TableField(exist = false) @SortColumn(column = "allPeriod") private Integer allPeriod; @@ -114,85 +107,11 @@ public class WxRentContract extends TenantEntity { private Integer endProperty; -// 商品类别 - private String shopTypeSub; -// 租赁用途 - private String leasePurpose; - -// 联系地址 -// 本合同正本一式 份,甲方执 份,乙方执 份 - //{total:,partyA:,partyB:} - private String contractualRules; -// 商铺交付日期 - private Date deliveryDate; -// 交付宽限期(天) - private Integer deliveryGracePeriod; -// 开业日期 - private Date openingDate; -// 营业时间 每日 点至 点 - //{start:,end:} - private String businessHours; -// 合同期内 米不得新设相同品牌之分店或加盟店 - private Integer scopeMetre; - -// 物业公司名称 请输入物业公司名称 -// 物业费金额 请输入金额 -// 物业费支付周期 -// -// 水费 元/吨 -// -// 电费 元/度 - - - -// 甲方开户银行 -// 甲方开户名称 -// 甲方银行账号 -// -// 乙方开户银行 -// 乙方开户名称 -// 乙方银行账号 -// -// 乙方纳税人识别号 -// 乙方税务登记地址 -// 乙方开户银行 -// 乙方开户名称 -// 乙方银行账号 -// 乙方联系电话 - - - @io.swagger.annotations.ApiModelProperty(value = "合同编号", name = "contractNumber") private String contractNumber; - //甲方信息(公司,地址,电话取wx_mall) - // 甲方统一社会信用代码 -// private String socialCreditCodeA; -// // 甲方开户银行 -// private String bankNameA; -// // 甲方开户名称 -// private String accountNameA; -// // 甲方银行账号 -// private String accountNumA; - - private String firstPartyBankInfo; - - //物业信息 - //物业公司名称 - private String propertyName; - //物业费金额(分/月) - private String propertyFee; - //物业费支付周期(月/季/年) - private Integer feeCycle; - //水费(分/吨) - private String waterFee; - //电费(分/度) - private String electricityFees; - - //乙方信息 - //联系方式 //地址 private String linkAddress; @@ -208,31 +127,8 @@ public class WxRentContract extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "开户行", name = "bankName") private String bankName; - // 乙方统一社会信用代码 -// private String socialCreditCode; -// // 乙方开户银行 -// // 乙方开户名称 -// private String accountName; - // 乙方银行账号 - - private String secondPartyBankInfo; - - private String secondPartyTaxInfo; - - - // 乙方纳税人识别号 -// private String taxpayerNumber; -// // 乙方税务登记地址 -// private String taxpayerAdress; - @io.swagger.annotations.ApiModelProperty(value = "金额小数点位数", name = "decimalSize") private Integer decimalSize = Constant.default_short_decimal_size ; - @io.swagger.annotations.ApiModelProperty(value = "商户", name = "merchantId") - private Long merchantId; - @io.swagger.annotations.ApiModelProperty(value = "是不是私密商户(虚拟)", name = "isPrivateMerchant") - private Integer isPrivateMerchant; - @io.swagger.annotations.ApiModelProperty(value = "虚拟商户店铺类型EnumRentShopType", name = "privateRentShopType") - private Integer privateRentShopType; @io.swagger.annotations.ApiModelProperty(value = "月租金/分成(元)", name = "price") private String price; @TableField(exist = false) @@ -272,20 +168,8 @@ public class WxRentContract extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "押金详细", name = "cashtypeLsit") private String cashtypeLsit; - @io.swagger.annotations.ApiModelProperty(value = "交租日 计租开始时间减去交租日的天数为基数 提前多少日交租", name = "payDate") - @SortColumn(column = "payDate") - private Integer payDate; @io.swagger.annotations.ApiModelProperty(value = "是否删除1是0否", name = "isDel") private Integer isDel; - @io.swagger.annotations.ApiModelProperty(value = "商户名称", name = "merchantName") - private String merchantName; - @io.swagger.annotations.ApiModelProperty(value = "经营品牌", name = "brand") - private Long brand; - @io.swagger.annotations.ApiModelProperty(value = "经常业态ID", name = "businessId") - private Integer businessId; - @io.swagger.annotations.ApiModelProperty(value = "店铺类型", name = "shopType") - private Integer shopType; - private String shopTypeStr; @io.swagger.annotations.ApiModelProperty(value = "店铺名称", name = "shopName") private String shopName; @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updatetime") @@ -599,6 +483,39 @@ public class WxRentContract extends TenantEntity { return sb.toString(); } + public Map getRentShopAreaRate() { + String rentInfo = this.getRentInfo(); + if (!StringUtils.isBlank(rentInfo)) { + Map shopAreaMap = new HashMap(); + JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); + int size = rentInfoArray.size(); + BigDecimal total = new BigDecimal(0); + for (int i = 0; i < size; i++) { + JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); + Long shopId = rentInfoObject.getLong("id"); + String rentArea = rentInfoObject.getString("rentArea"); + if (StringUtils.isBlank(rentArea)) { + shopAreaMap.put(shopId, new BigDecimal("0")); + }else { + shopAreaMap.put(shopId, new BigDecimal("rentArea")); + total = total.add(new BigDecimal("rentArea")); + } + } + if (total.compareTo(new BigDecimal(0)) <= 0 ) { + total = new BigDecimal(1); + } + Map shopAreaRateMap = new HashMap(); + for (Iterator it = shopAreaMap.keySet().iterator();it.hasNext();) { + Long sid = it.next(); + BigDecimal sa = shopAreaMap.get(sid); + shopAreaRateMap.put(sid, sa.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); + } + return shopAreaRateMap; + } + return null; + } + + public Map getDepositEnergyFees(Map feesMap) { String dsdstr = this.getCashtypeContentLsit(); if (!StringUtils.isBlank(dsdstr)) { @@ -623,9 +540,6 @@ public class WxRentContract extends TenantEntity { return null; } - @TableField(exist = false) - private List merchantIds; - @TableField(exist = false) private String onlyPropertyContractId; @@ -667,8 +581,6 @@ public class WxRentContract extends TenantEntity { @TableField(exist = false) private String queryShopNumber; @TableField(exist = false) - private List privateRentShopTypeList; - @TableField(exist = false) List contractDepositList; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileDeposit.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileDeposit.java index 436c079ae..7e945c5ed 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileDeposit.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileDeposit.java @@ -25,9 +25,6 @@ public class WxRentContractAgileDeposit extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="合同编号",name="rentContractId") private Long rentContractId; - @io.swagger.annotations.ApiModelProperty(value="商户编号",name="merchantId") - private Long merchantId; - @io.swagger.annotations.ApiModelProperty(value="科目编号",name="feesId") private Long feesId; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileUnDeposit.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileUnDeposit.java index 50751852d..08688bbb0 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileUnDeposit.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileUnDeposit.java @@ -30,9 +30,6 @@ public class WxRentContractAgileUnDeposit extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="合同编号",name="rentContractId") private Long rentContractId; - @io.swagger.annotations.ApiModelProperty(value="商户编号",name="merchantId") - private Long merchantId; - @io.swagger.annotations.ApiModelProperty(value="费用设置方式EnumRentContractAgilSettingMethod",name="settingMethod") private Integer settingMethod; @TableField(exist = false) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java b/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java index d15963621..e653d2615 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java @@ -197,4 +197,34 @@ public class WxShop extends TenantEntity { private List typeList; @TableField(exist = false) private String queryShopNumber; + + @TableField(exist = false) + private Date starttime; + @TableField(exist = false) + private Date endtime; + //账单逾期计算提前天数 + @TableField(exist = false) + private Integer oweBillBeforeDays; + //临期计算提前天数 + @TableField(exist = false) + private Integer nearBillBeforeDays; + @TableField(exist = false) + private Integer needPayPreDays; + @TableField(exist = false) + public Integer toPayMerchant; + @TableField(exist = false) + public Integer isPreview; + @TableField(exist = false) + private Integer needPayNoDays; + @TableField(exist = false) + public List energyFeesIdList; + @TableField(exist = false) + public Integer advanceHasMoney; + @TableField(exist = false) + public Date receiveDate; + @TableField(exist = false) + public Integer onlyOweOrNear; + @TableField(exist = false) + private Integer onlyOwe; + } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxShopUsers.java b/mallinkService/src/main/java/com/iformall/domain/po/WxShopUsers.java index 09d891b0e..99cace2f6 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxShopUsers.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxShopUsers.java @@ -101,4 +101,7 @@ public class WxShopUsers extends TenantEntity { } return null; } + + @TableField(exist = false) + private List shopIds; } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxBillNotify.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxBillNotify.java index 0e846f0a6..a85eb061c 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxBillNotify.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxBillNotify.java @@ -23,10 +23,10 @@ public class WxBillNotify implements Serializable { private String receivePay; private String pay; private String owe; - private Long merchantId; - private String merchantName; - private String merchantPhone; - private String merchantLinkPerson; + private Long shopId; + private String shopUserName; + private String shopUserPerson; + private String shopUserPhone; public String getOwe() { return new BigDecimal(receivePay).subtract(new BigDecimal(pay)).toPlainString(); diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxRentPropertyContractVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxRentPropertyContractVo.java index c51442601..7fe24aac0 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxRentPropertyContractVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxRentPropertyContractVo.java @@ -34,9 +34,6 @@ public class WxRentPropertyContractVo extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "商铺信息", name = "rentInfo") private String rentInfo; - @io.swagger.annotations.ApiModelProperty(value = "商户名称", name = "merchantName") - private String merchantName; - @io.swagger.annotations.ApiModelProperty(value = "计租开始时间", name = "rentalStartDate") private Date rentalStartDate; @@ -64,9 +61,6 @@ public class WxRentPropertyContractVo extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "租赁商铺类型1店铺2多经点位", name = "rentShopType") private Integer rentShopType; - @io.swagger.annotations.ApiModelProperty(value = "商户ID", name = "merchantId") - private Long merchantId; - @io.swagger.annotations.ApiModelProperty(value = "物业合同状态", name = "propertyStatus") private Integer propertyStatus; @@ -108,10 +102,7 @@ public class WxRentPropertyContractVo extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "首期账单结束时间", name = "firstBillDateEnd") private Date firstBillDateEnd; - private List merchantIds; - private String queryShopNumber; - private Integer isPrivateMerchant; } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantBillVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxShopBillVo.java similarity index 93% rename from mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantBillVo.java rename to mallinkService/src/main/java/com/iformall/domain/vo/WxShopBillVo.java index cbf487f62..8cd10f4f1 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantBillVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxShopBillVo.java @@ -15,14 +15,11 @@ import java.util.Date; import java.util.List; @Data -public class WxMerchantBillVo implements Serializable { +public class WxShopBillVo implements Serializable { private static final long serialVersionUID = 1L; - private Long merchantId; - @Excel(name = "商户名称", width = 20, orderNum = "2") - @TableField(exist = false) - private String merchantName;//商户名称 + private Long shopId; @Excel(name = "商铺号", width = 20, orderNum = "3") @TableField(exist = false) private String shopNumber; diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumContractCustomersStatus.java b/mallinkService/src/main/java/com/iformall/enums/EnumContractCustomersStatus.java new file mode 100644 index 000000000..4c184b207 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumContractCustomersStatus.java @@ -0,0 +1,35 @@ +package com.iformall.enums; + +/** + */ +public enum EnumContractCustomersStatus { + + TEMP(0, "意向客户"), + FORMUL(1, "正式客户"), + ; + + public static EnumContractCustomersStatus getEnum(Integer code) { + for (EnumContractCustomersStatus value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumContractCustomersStatus(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/WxAllBillMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java index 35a40b960..d9362c3f5 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java @@ -17,6 +17,8 @@ public interface WxAllBillMapper extends CommonMapper { List findList(WxAllBill wxBillRent); List queryBillRentContractIdList(WxAllBill record); + List getShopIdList(WxAllBill record); + List getMerchantAdvanceGroupSumList(WxAllBill wxBillRent); List getBillNotifyList(WxAllBill record); @@ -37,8 +39,6 @@ public interface WxAllBillMapper extends CommonMapper { List getFeesBillSum(WxAllBill wxBillRent); - List getMerchantIdList(WxAllBill wxBillRent); - List getBillHotNotify(WxAllBill wxBillRent); WxAllBill selectById(@Param("id")Long id,@Param("tenantId")String tenantId); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxContractCustomersMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxContractCustomersMapper.java new file mode 100644 index 000000000..a75ea3f9a --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxContractCustomersMapper.java @@ -0,0 +1,16 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.WxContractCustomers; +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +/** + */ +public interface WxContractCustomersMapper extends CommonMapper { + + List findList(WxContractCustomers wxShop); + + WxContractCustomers selectById(@Param("id")Long id,@Param("tenantId")String tenantId); +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxContractShopMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxContractShopMapper.java new file mode 100644 index 000000000..24a42444b --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxContractShopMapper.java @@ -0,0 +1,18 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.WxContractCustomers; +import com.iformall.domain.po.WxContractShop; + +import java.util.List; + +/** + */ +public interface WxContractShopMapper extends CommonMapper { + + List findList(WxContractShop wxShop); + + List findContractIdList(WxContractShop wxShop); + + void deleteByCondition(WxContractShop wxShop); +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java index 95b323e32..c22d3b30f 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java @@ -17,22 +17,14 @@ public interface WxRentContractMapper extends CommonMapper List findList(WxRentContract wxRentContract); - void updateStatusForUnsign(WxRentContract wxRentContract); - void updateApplyStatus(WxRentContract wxRentContract); void updateStatus(WxRentContract wxRentContract); long queryOweCount(WxRentContract wxRentContract); - List getMerchants(WxRentContract wxRentContract); - int selectRentContractCountByShopId(@Param("tenantId") String tenantId,@Param("parentTenantId") String parentTenantId,@Param("shopId") Long shopId,@Param("id") Long id); - List selectRentContractByMerchantId(WxRentContract wxRentContract); - - //List selectRentContractByShopId(@Param("tenantId") String tenantId,@Param("parentTenantId") String parentTenantId,@Param("shopId") Long shopId,@Param("status") Integer status); - int hasContractNumber(WxRentContract wxRentContract); List listContractVo(WxRentPropertyContractVo record); @@ -41,23 +33,8 @@ public interface WxRentContractMapper extends CommonMapper int getShopCountMax(); - List> queryContractByBus(WxBusiness wxBusiness); - - WxRentContract getByMerchantId(WxRentContract wxRentContract); - - List getAllContractBymerchantId(WxRentContract wxRentContract); - - //List getContractByMerchant(WxRentContract wxRentContract); - Integer getCanApplyCount(@Param("id") Long id); - List getMerchantIdsByStatuss(WxRentContract wxRentContract); - - @Deprecated - List> findRentByShop(@Param("shopId")Long shopId); - - List> currentValidByMerchantId(WxRentContract rentContract); - List getUsedRentShopIds(WxRentContract wxRentContract); long findCount(WxRentContract wxRentContract); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxShopUsersMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxShopUsersMapper.java index b6f466b1b..0c663a027 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxShopUsersMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxShopUsersMapper.java @@ -9,4 +9,5 @@ import java.util.List; public interface WxShopUsersMapper extends CommonMapper { List findList(WxShopUsers wxShop); + List findShopIdList(WxShopUsers wxShop); } diff --git a/mallinkService/src/main/java/com/iformall/print/data/impl/PrintBillDataHandler.java b/mallinkService/src/main/java/com/iformall/print/data/impl/PrintBillDataHandler.java index 375a4223d..5187522c0 100644 --- a/mallinkService/src/main/java/com/iformall/print/data/impl/PrintBillDataHandler.java +++ b/mallinkService/src/main/java/com/iformall/print/data/impl/PrintBillDataHandler.java @@ -51,12 +51,6 @@ public class PrintBillDataHandler implements PrintDataParser{ }else if (name.equals("owe")) { return receive.getOwe(); }else if (name.equals("merchantName")) { - if (null != merchantMap && null != receive.getMerchantId()) { - WxMerchant m = merchantMap.get(receive.getMerchantId()); - if (null != m) { - return m.getName(); - } - } return ""; }else if (name.equals("feesName")) { if (StringUtils.isNotBlank(receive.getEnergyFeesName())) { @@ -75,10 +69,6 @@ public class PrintBillDataHandler implements PrintDataParser{ if (StringUtils.isNotBlank(receive.getShopNumber())) { return receive.getShopNumber(); } - if (null != shopNumber && null != receive.getMerchantId()) { - String m = shopNumber.get(receive.getMerchantId()); - return m; - } return ""; } return null; diff --git a/mallinkService/src/main/java/com/iformall/print/data/impl/PrintMerchantSettleDataHandler.java b/mallinkService/src/main/java/com/iformall/print/data/impl/PrintMerchantSettleDataHandler.java index 6b06f1e3e..df3ef5dc6 100644 --- a/mallinkService/src/main/java/com/iformall/print/data/impl/PrintMerchantSettleDataHandler.java +++ b/mallinkService/src/main/java/com/iformall/print/data/impl/PrintMerchantSettleDataHandler.java @@ -9,7 +9,7 @@ import com.iformall.domain.po.WxAllBill; import com.iformall.domain.po.WxEnergyFees; import com.iformall.domain.po.WxFinanceReceive; import com.iformall.domain.po.WxMerchant; -import com.iformall.domain.vo.WxMerchantBillVo; +import com.iformall.domain.vo.WxShopBillVo; import com.iformall.print.data.PrintDataParser; import com.iformall.utils.DateUtils; @@ -21,7 +21,7 @@ public class PrintMerchantSettleDataHandler implements PrintDataParser{ Map merchantMap = (Map) params[0]; Map feesMap = (Map) params[1]; Map shopNumber = (Map) params[2]; - WxMerchantBillVo receive = (WxMerchantBillVo) o; + WxShopBillVo receive = (WxShopBillVo) o; //根据科目来查询对应的信息 if (name.equals("maxDate")) { return DateUtils.date2String(receive.getMaxDate(),DateUtils.DATE_PATTERN); diff --git a/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java b/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java index 9a15b7559..a0a67b408 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java @@ -3,9 +3,11 @@ package com.iformall.service; import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; import com.iformall.domain.po.MallUserInfo; +import com.iformall.domain.po.WxContractCustomers; import com.iformall.domain.po.WxRentContract; import com.iformall.domain.po.WxRentContractAgileDeposit; import com.iformall.domain.po.WxRentContractAgileUnDeposit; +import com.iformall.domain.po.base.TenantEntity; import java.util.List; @@ -32,4 +34,10 @@ public interface WxAgileContractService { List findUnDepositList(WxRentContractAgileUnDeposit unDeposit); void createUnDepositBill(WxRentContractAgileUnDeposit unDeposit,MallUserInfo user); + + List findBuildingFloorContractIds(TenantEntity tenantEntity,String floorRule,Long building,Long floor,List shopIds,Integer shopDel); + + List findShopContractIds(TenantEntity tenantEntity,List shopIds); + + WxContractCustomers findCustomers(TenantEntity tenantEntity,Long customerId); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxAllBillService.java b/mallinkService/src/main/java/com/iformall/service/WxAllBillService.java index 5f27bf3da..80eb56241 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxAllBillService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxAllBillService.java @@ -33,7 +33,7 @@ public interface WxAllBillService { PageInfo listAsPage(WxAllBill record, Integer pageIndex, Integer pageSize); - List getMerchantIds(WxAllBill wxBillRent); + List getShopIds(WxAllBill wxBillRent); List getBillHotNotify(WxAllBill wxBillRent); diff --git a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java index 591c706cc..df084bd27 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java @@ -91,8 +91,6 @@ public interface WxRentContractService { void buildDeposit( TenantEntity tenantEntity,MallUserInfo user,Long rentContractId); - Object getMerchants(WxRentContract wxRentContract); - //void updateInvalidContract(Long rentContractId); ResultData hasRentStatus(WxRentContract wxRentContract); @@ -134,18 +132,6 @@ public interface WxRentContractService { WxRentContract getSimpleDeatil(Long id); - /** - * 查询合同的店铺是否已经在其他有效合同里面了 - * @param wxRentContract - * @return - */ - boolean hasOtherValidContractShop(WxRentContract wxRentContract); - - @Deprecated - Map findRentByShop(Long shopId); - - Map currentValidByMerchantId(TenantEntity tenantInfo, Long merchantId,String shopNumber); - long findCount(WxRentContract wxRentContract); void setEndContractTime(WxRentContract wxRentContract); diff --git a/mallinkService/src/main/java/com/iformall/service/WxShopService.java b/mallinkService/src/main/java/com/iformall/service/WxShopService.java index acb48ee0c..dc934c088 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxShopService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxShopService.java @@ -15,6 +15,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Collection; import java.util.List; import java.util.Map; @@ -141,6 +142,9 @@ public interface WxShopService { void deleteShopUsersPerson(WxShopUsersPerson wxShopUsers); - String getRentName(WxMerchant merchant); - + List getUserShopIds(WxShopUsers wxShopUsers); + Map getShopUserMap(WxShopUsers wxShopUsers); + + WxShopUsers getCurrentShopUser(TenantEntity tenantEntity,Long shopId); + } diff --git a/mallinkService/src/main/java/com/iformall/service/helper/WxBillAllHelper.java b/mallinkService/src/main/java/com/iformall/service/helper/WxBillAllHelper.java index 38edb8d9a..23b11ddb7 100644 --- a/mallinkService/src/main/java/com/iformall/service/helper/WxBillAllHelper.java +++ b/mallinkService/src/main/java/com/iformall/service/helper/WxBillAllHelper.java @@ -30,6 +30,8 @@ import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxMerchantBUser; import com.iformall.domain.po.WxPropertyContract; import com.iformall.domain.po.WxRentContract; +import com.iformall.domain.po.WxShop; +import com.iformall.domain.po.WxShopUsers; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxBillHotNotify; import com.iformall.domain.vo.WxBillNotify; @@ -42,6 +44,7 @@ import com.iformall.enums.EnumBillOweOrNearType; import com.iformall.enums.EnumBillStatus; import com.iformall.enums.EnumBillType; import com.iformall.enums.EnumRentContractManageFeeType; +import com.iformall.enums.EnumShopUsersStatus; import com.iformall.enums.EnumSystemUserType; import com.iformall.enums.EnumYesOrNo; import com.iformall.service.WxAllBillService; @@ -78,38 +81,36 @@ public class WxBillAllHelper { return DateUtils.getSecondsTimeAfter(afterDays*3600*24, nowBegin); } - private void updateQueryParm(WxMerchant wxMerchant,WxAllBill bill,Date starttime,Date enttime) { - bill.updateTenantInfo(wxMerchant); - bill.setFloorForRule(wxMerchant.getFloorForRule()); - bill.setBusinessForRule(wxMerchant.getBusinessForRule()); - bill.setShopTypeForRule(wxMerchant.getShopTypeForRule()); - bill.setBuilding(wxMerchant.getBuilding()); - bill.setFloor(wxMerchant.getFloor()); - bill.setMerchantName(wxMerchant.getName()); - bill.setMerchantId(wxMerchant.getId()); + private void updateQueryParm(WxShop wxShop,WxAllBill bill,Date starttime,Date enttime) { + bill.updateTenantInfo(wxShop); + bill.setFloorForRule(wxShop.getFloorForRule()); + bill.setBusinessForRule(wxShop.getBusinessForRule()); + bill.setShopTypeForRule(wxShop.getShopTypeForRule()); + bill.setBuilding(wxShop.getBuilding()); + bill.setFloor(wxShop.getFloor()); bill.setStarttime(starttime); bill.setEndtime(enttime); //bill.setRentShopType(wxMerchant.getType()); - if (null != wxMerchant.getOweBillBeforeDays()) { - bill.setOweBillLastTime(getDateBefore(wxMerchant.getOweBillBeforeDays())); + if (null != wxShop.getOweBillBeforeDays()) { + bill.setOweBillLastTime(getDateBefore(wxShop.getOweBillBeforeDays())); } - if (null != wxMerchant.getNearBillBeforeDays()) { - bill.setNearBillLastTime(getDateBefore(wxMerchant.getNearBillBeforeDays())); + if (null != wxShop.getNearBillBeforeDays()) { + bill.setNearBillLastTime(getDateBefore(wxShop.getNearBillBeforeDays())); } - if (null != wxMerchant.getNeedPayPreDays()) { - bill.setNeedPayStartDay(getDateBefore(wxMerchant.getNeedPayPreDays())); + if (null != wxShop.getNeedPayPreDays()) { + bill.setNeedPayStartDay(getDateBefore(wxShop.getNeedPayPreDays())); } - bill.setToPayMerchant(wxMerchant.getToPayMerchant()); - bill.setIsPreview(wxMerchant.getIsPreview()); - bill.setNeedPayNoDays(wxMerchant.getNeedPayNoDays()); - bill.setEnergyFeesIds(wxMerchant.getEnergyFeesIdList()); - bill.setAdvanceHasMoney(wxMerchant.getAdvanceHasMoney()); - bill.setReceiveDate(wxMerchant.getReceiveDate()); + bill.setToPayMerchant(wxShop.getToPayMerchant()); + bill.setIsPreview(wxShop.getIsPreview()); + bill.setNeedPayNoDays(wxShop.getNeedPayNoDays()); + bill.setEnergyFeesIds(wxShop.getEnergyFeesIdList()); + bill.setAdvanceHasMoney(wxShop.getAdvanceHasMoney()); + bill.setReceiveDate(wxShop.getReceiveDate()); } - public WxBillSum getBillSum(WxMerchant wxMerchant,Date starttime, Date enttime) { + public WxBillSum getBillSum(WxShop wxShop,Date starttime, Date enttime) { WxAllBill br = new WxAllBill(); - updateQueryParm(wxMerchant, br,starttime,enttime); + updateQueryParm(wxShop, br,starttime,enttime); WxBillSum rentSum = wxAllBillService.getBillMonthSum(br); if (null == rentSum) { rentSum = new WxBillSum(); @@ -117,15 +118,15 @@ public class WxBillAllHelper { return rentSum; } - public List getFeesBillSum(WxMerchant wxMerchant,Date starttime, Date enttime) { + public List getFeesBillSum(WxShop wxShop,Date starttime, Date enttime) { WxAllBill br = new WxAllBill(); - updateQueryParm(wxMerchant, br,starttime,enttime); + updateQueryParm(wxShop, br,starttime,enttime); return wxAllBillService.getFeesBillSum(br); } - public List getBillHotNotify(WxMerchant wxMerchant,Date starttime, Date enttime) { + public List getBillHotNotify(WxShop wxShop,Date starttime, Date enttime) { WxAllBill br = new WxAllBill(); - updateQueryParm(wxMerchant, br,starttime,enttime); + updateQueryParm(wxShop, br,starttime,enttime); return wxAllBillService.getBillHotNotify(br); } @@ -213,10 +214,10 @@ public class WxBillAllHelper { return "0"; } - public List getOwdMerchantIds(WxMerchant wxMerchant,Date starttime, Date enttime) { + public List getOwdShopIds(WxShop wxShop,Date starttime, Date enttime) { WxAllBill br = new WxAllBill(); - updateQueryParm(wxMerchant, br,starttime,enttime); - return wxAllBillService.getMerchantIds(br); + updateQueryParm(wxShop, br,starttime,enttime); + return wxAllBillService.getShopIds(br); } private List getUnionIds(List...lists ) { @@ -234,9 +235,9 @@ public class WxBillAllHelper { return null; } - public PageInfo getBillList(WxMerchant wxMerchant,Integer pageNum, Integer pageSize) { + public PageInfo getBillList(WxShop wxShop,Integer pageNum, Integer pageSize) { WxAllBill wxAllBill = new WxAllBill(); - updateQueryParm(wxMerchant, wxAllBill,wxMerchant.getStarttime(),wxMerchant.getEndtime()); + updateQueryParm(wxShop, wxAllBill,wxShop.getStarttime(),wxShop.getEndtime()); wxAllBill.setIsPreview(EnumYesOrNo.NO.getCode()); wxAllBill.setSortColumns("starttime asc"); return wxAllBillService.listAsPage(wxAllBill, pageNum, pageSize); @@ -253,27 +254,42 @@ public class WxBillAllHelper { return wxAllBillService.getById(tenantEntity, id); } - public List getBillNotifyList(WxMerchant wxMerchant,Integer notifyed) { + public List getBillNotifyList(WxShop wxShop,Integer notifyed) { WxAllBill wxBillRent = new WxAllBill(); - updateQueryParm(wxMerchant, wxBillRent,wxMerchant.getStarttime(),wxMerchant.getEndtime()); + updateQueryParm(wxShop, wxBillRent,wxShop.getStarttime(),wxShop.getEndtime()); wxBillRent.setNotifyed(notifyed); wxBillRent.setSortColumns("starttime asc"); List retList = wxAllBillService.notifyList(wxBillRent); if (null != retList && retList.size() > 0 ) { - //单个商户的就不查了 - if (null == wxMerchant.getId()) { - Map merchantMap = wxMerchantService.findMerchantMap(wxMerchant); - for (int i = 0 ; i < retList.size() ; i++) { - WxBillNotify bn = retList.get(i); - if (null != bn.getMerchantId() && null != merchantMap) { - WxMerchant m = merchantMap.get(bn.getMerchantId()); - if (null != m) { - bn.setMerchantName(m.getName()); - bn.setMerchantPhone(m.getLinkPhone()); - bn.setMerchantLinkPerson(m.getLinkPerson()); - } + List shopIdList = new ArrayList(); + for (int i = 0 ; i < retList.size(); i ++) { + WxBillNotify wbn = retList.get(i); + if (null != wbn.getShopId()) { + if (!shopIdList.contains(wbn.getShopId())) { + shopIdList.add(wbn.getShopId()); } + } + } + + if (shopIdList.size() > 0) { + WxShopUsers suq = new WxShopUsers(); + suq.updateTenantInfo(wxShop); + suq.setStatus(EnumShopUsersStatus.LIVE.getCode()); + suq.setShopIds(shopIdList); + Map shopUserMap = wxShopService.getShopUserMap(suq); + if (null != shopUserMap) { + for (int i = 0 ; i < retList.size() ; i++) { + WxBillNotify bn = retList.get(i); + if (null != bn.getShopId()) { + WxShopUsers s = shopUserMap.get(bn.getShopId()); + if (null != s) { + bn.setShopUserName(s.getName()); + bn.setShopUserPerson(s.getLinkPerson()); + bn.setShopUserPhone(s.getPhone()); + } + } + } } } } @@ -292,13 +308,18 @@ public class WxBillAllHelper { Map result = new HashMap<>(); result.put("starttime", DateUtils.date2String(bill.getStarttime(),DateUtils.DATE_PATTERN)); result.put("endtime", DateUtils.date2String(bill.getEndtime(),DateUtils.DATE_PATTERN)); - WxMerchant m = wxMerchantService.selectById(bill.getMerchantId()); - if (null != m) { - result.put("shopNumber", getMerchantShopNumber(m)); - result.put("merchantName", m.getName()); - result.put("linkPerson", m.getLinkPerson()); - result.put("linkPhone", m.getLinkPhone()); - exportFileName = exportFileName+"_"+m.getName(); + if (null != bill.getShopId()) { + WxShop shop = wxShopService.getById(bill.getShopId()); + if (null != shop) { + result.put("shopNumber", shop.getShopNumber()); + } + WxShopUsers su = wxShopService.getCurrentShopUser(bill, bill.getShopId()); + if (null != su) { + result.put("merchantName", su.getName()); + result.put("linkPerson", su.getLinkPerson()); + result.put("linkPhone", su.getPhone()); + exportFileName = exportFileName+"_"+su.getName(); + } } result.put("billTypeName", bill.getBillTypeName()); exportFileName = exportFileName +"_"+ bill.getBillTypeName(); @@ -355,8 +376,8 @@ public class WxBillAllHelper { wxAllBillService.updatePayByMerchant(dto, user,isOnline); } - public WxAllBill getBillDetail(EnumBillAllType billType,WxMerchant wxMerchant,Long billId) { - return wxAllBillService.getById(wxMerchant,billId); + public WxAllBill getBillDetail(TenantEntity tenantEntity,Long billId) { + return wxAllBillService.getById(tenantEntity,billId); } public void updatePayToMerchant(WxBillPayDTO dto,MallUserInfo user) { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java index 3d4746c30..0d746e6cf 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java @@ -10,6 +10,8 @@ import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxAllBill; +import com.iformall.domain.po.WxContractCustomers; +import com.iformall.domain.po.WxContractShop; import com.iformall.domain.po.WxEnergyFees; import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxRentContract; @@ -18,6 +20,7 @@ import com.iformall.domain.po.WxRentContractAgileDepositShop; import com.iformall.domain.po.WxRentContractAgileUnDeposit; import com.iformall.domain.po.WxRentContractAgileUnDepositItem; import com.iformall.domain.po.WxShop; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.BillTimeVo; import com.iformall.enums.EnumBillAllType; import com.iformall.enums.EnumBillExtraCreateFrom; @@ -34,6 +37,8 @@ import com.iformall.enums.EnumYesOrNo; import com.iformall.exception.MallinkException; import com.iformall.mapper.WxAllBillMapper; import com.iformall.mapper.WxBusinessMapper; +import com.iformall.mapper.WxContractCustomersMapper; +import com.iformall.mapper.WxContractShopMapper; import com.iformall.mapper.WxMerchantMapper; import com.iformall.mapper.WxRentContractAgileDepositMapper; import com.iformall.mapper.WxRentContractAgileDepositShopMapper; @@ -60,6 +65,8 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -92,6 +99,15 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { @Autowired WxRentContractFreePeriodMapper wxRentContractFreePeriodMapper; + @Autowired + WxContractShopMapper wxContractShopMapper; + + @Autowired + WxContractCustomersMapper wxContractCustomersMapper; + + @Autowired + WxShopMapper wxShopMapper; + @Lazy @Autowired WxMerchantService wxMerchantService; @@ -106,11 +122,12 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { @Override public PageInfo getRentContractList(WxRentContract rentContract, Integer pageIndex, Integer pageSize) { if (StringUtils.isNoneBlank(rentContract.getFloorForRule())) { - List mids = wxMerchantService.getFloorBuildMerchantIds(rentContract, rentContract.getFloorForRule() , null, null,rentContract.getShopTypeForRule(), 0, 0,null); - if (null == mids || mids.size() <= 0 ) { + List contractIds = this.findBuildingFloorContractIds(rentContract, rentContract.getFloorForRule(), null, null, null, 0); + //List mids = wxMerchantService.getFloorBuildMerchantIds(rentContract, rentContract.getFloorForRule() , null, null,rentContract.getShopTypeForRule(), 0, 0,null); + if (null == contractIds || contractIds.size() <= 0 ) { rentContract.setId(-1L); } else { - rentContract.setMerchantIds(mids); + rentContract.setIds(contractIds); } } PageInfo pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxRentContractMapper.findList(rentContract)); @@ -135,10 +152,6 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { record.setCreateBy(user.getId()); record.setCreateByName(user.getName()); } - WxMerchant merchant = wxMerchantService.selectById(record.getMerchantId()); - record.setIsPrivateMerchant(merchant.getIsPrivate()); - record.setPrivateRentShopType(merchant.getCreateShopType()); - record.setMerchantName(merchant.getName()); record.setUpdatetime(new Date()); record.setUpdateBy(user.getId()); record.setUpdateByName(user.getName()); @@ -183,7 +196,6 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { if (null != deposit.getShopList() && deposit.getShopList().size() > 0 ) { WxRentContractAgileDeposit rca = new WxRentContractAgileDeposit(); rca.setRentContractId(wxRentContract.getId()); - rca.setMerchantId(contract.getMerchantId()); rca.updateTenantInfo(wxRentContract); rca.setId(idWorker.nextId()); rca.setFeesId(deposit.getFeesId()); @@ -253,7 +265,6 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { unDeposit.setCreatetime(new Date()); } unDeposit.setUpdatetime(new Date()); - unDeposit.setMerchantId(contract.getMerchantId()); if (isCreate) { wxRentContractAgileUnDepositMapper.insert(unDeposit); }else { @@ -289,7 +300,6 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { WxRentContractAgileUnDepositItem item = unDeposit.getItems().get(i); item.setRentContractId(unDeposit.getRentContractId()); item.setUnDepositId(unDeposit.getId()); - item.setMerchantId(unDeposit.getMerchantId()); item.setFeesId(unDeposit.getFeesId()); item.setId(idWorker.nextId()); item.updateTenantInfo(contract); @@ -380,51 +390,50 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { fq.updateTenantInfo(wxRentContract); Map typeMap = wxEnergyService.getFeesMap(fq); + //根据关联的店铺面积来分金额 + Map shopAreaRateMap = wxRentContract.getRentShopAreaRate(); + if (null == shopAreaRateMap) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"无店铺信息"); + } + + List shopIdList = wxRentContract.shopIdsByRentInfo(); + List insertList = new ArrayList(); final IdWorker idWorker = IdWorker.get(); for (int i = 0 ; i < depositList.size(); i++) { - WxRentContractAgileDeposit deposit = depositList.get(i); + WxRentContractAgileDeposit deposit = depositList.get(i); WxEnergyFees fees = typeMap.get(deposit.getFeesId()); - WxAllBill wxBillDeposit = new WxAllBill(); - wxBillDeposit.setId(idWorker.nextId()); - wxBillDeposit.updateTenantInfo(wxRentContract); - wxBillDeposit.setRentContractId(wxRentContract.getId()); - wxBillDeposit.setBillType(fees.getBillType()); - wxBillDeposit.setIsPreview(EnumYesOrNo.YES.getCode()); - wxBillDeposit.setCanEdit(EnumYesOrNo.NO.getCode()); - wxBillDeposit.setPriceDetail(fees.getName()); - wxBillDeposit.setPay("0"); - wxBillDeposit.setReceivePay(deposit.getPrice()); - wxBillDeposit.setNeedPay(deposit.getPrice()); - wxBillDeposit.setStarttime(wxRentContract.getRentalStartDate()); - wxBillDeposit.setEndtime(wxRentContract.getRentalEndDate()); - wxBillDeposit.setReceiveDate(wxRentContract.getRentalStartDate()); - wxBillDeposit.setPeriod(WxRentContractHelper.getPeriod(wxRentContract.getRentalStartDate())); - wxBillDeposit.updateTenantInfo(wxRentContract); - wxBillDeposit.setMerchantId(wxRentContract.getMerchantId()); - - WxRentContractAgileDepositShop shopq = new WxRentContractAgileDepositShop(); - shopq.updateTenantInfo(wxRentContract); - shopq.setRentContractId(wxRentContract.getId()); - List shopList = deposit.getShopList(); - StringBuffer snstr = new StringBuffer(); - for (int j = 0 ; j < shopList.size() ; j ++) { - WxShop ds = shopList.get(j); - snstr.append(ds.getShopNumber()).append(","); - } - wxBillDeposit.setShopNumber(snstr.toString()); - //wxBillDeposit.setShopId(); - - wxBillDeposit.setRentArea(wxRentContract.getRentArea()); - wxBillDeposit.setCreatetime(new Date()); - wxBillDeposit.setCreateBy(user.getId()); - wxBillDeposit.setCreateByName(user.getName()); - wxBillDeposit.setUpdatetime(new Date()); - wxBillDeposit.setUpdateBy(user.getId()); - wxBillDeposit.setUpdateByName(user.getName()); - wxBillDeposit.setEnergyFeesId(deposit.getFeesId()); - wxBillDeposit.setRentContractAgileFeesType(EnumRentContractAgileFeesType.DEPOSIT.getCode()); - insertList.add(wxBillDeposit); + for (int j = 0 ; j < shopIdList.size(); j++ ) { + Long sid = shopIdList.get(j); + BigDecimal shoprate = shopAreaRateMap.get(sid); + WxAllBill wxBillDeposit = new WxAllBill(); + wxBillDeposit.setId(idWorker.nextId()); + wxBillDeposit.updateTenantInfo(wxRentContract); + wxBillDeposit.setRentContractId(wxRentContract.getId()); + wxBillDeposit.setBillType(fees.getBillType()); + wxBillDeposit.setIsPreview(EnumYesOrNo.YES.getCode()); + wxBillDeposit.setCanEdit(EnumYesOrNo.NO.getCode()); + wxBillDeposit.setPriceDetail(fees.getName()); + wxBillDeposit.setPay("0"); + wxBillDeposit.setReceivePay(new BigDecimal(deposit.getPrice()).multiply(shoprate).toPlainString()); + wxBillDeposit.setNeedPay(wxBillDeposit.getReceivePay()); + wxBillDeposit.setStarttime(wxRentContract.getRentalStartDate()); + wxBillDeposit.setEndtime(wxRentContract.getRentalEndDate()); + wxBillDeposit.setReceiveDate(wxRentContract.getRentalStartDate()); + wxBillDeposit.setPeriod(WxRentContractHelper.getPeriod(wxRentContract.getRentalStartDate())); + wxBillDeposit.updateTenantInfo(wxRentContract); + wxBillDeposit.setShopId(sid); + wxBillDeposit.setRentArea(wxRentContract.getRentArea()); + wxBillDeposit.setCreatetime(new Date()); + wxBillDeposit.setCreateBy(user.getId()); + wxBillDeposit.setCreateByName(user.getName()); + wxBillDeposit.setUpdatetime(new Date()); + wxBillDeposit.setUpdateBy(user.getId()); + wxBillDeposit.setUpdateByName(user.getName()); + wxBillDeposit.setEnergyFeesId(deposit.getFeesId()); + wxBillDeposit.setRentContractAgileFeesType(EnumRentContractAgileFeesType.DEPOSIT.getCode()); + insertList.add(wxBillDeposit); + } } try { if (insertList.size() > 0 ) { @@ -520,7 +529,10 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { //截止收租日在当前时间之前 Date date = new Date(); wxBillRent.updateTenantInfo(unDeposit); - wxBillRent.setMerchantId(unDeposit.getMerchantId()); + //wxBillRent.setMerchantId(unDeposit.getMerchantId()); + + + wxBillRent.setShopId(item.getShopId()); wxBillRent.setShopNumber(shopNumber); wxBillRent.setRentArea(item.getRentArea()); @@ -532,5 +544,54 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { wxBillRent.setUpdateByName(user.getName()); return wxBillRent; } + + + @Override + public List findBuildingFloorContractIds(TenantEntity tenantEntity, String floorRule, Long building, + Long floor,List shopIds,Integer shopDel) { + + WxShop shopQ = new WxShop(); + if (null != shopDel) { + shopQ.setIsDel(shopDel); + } + shopQ.updateTenantInfo(tenantEntity); + if (null != floorRule) { + shopQ.setFloorForRule(floorRule); + } + if (null != building) { + shopQ.setBuilding(building); + } + if (null != floor) { + shopQ.setFloor(floor); + } + + shopQ.setIds(shopIds);; + + List sIds = wxShopMapper.findIdList(shopQ); + if (null == sIds || sIds.size() <= 0 ) { + return null; + } + WxContractShop cs = new WxContractShop(); + cs.updateTenantInfo(tenantEntity); + cs.setShopIds(sIds); + return wxContractShopMapper.findContractIdList(cs); + } + + + @Override + public List findShopContractIds(TenantEntity tenantEntity, List shopIds) { + WxContractShop cs = new WxContractShop(); + cs.updateTenantInfo(tenantEntity); + cs.setShopIds(shopIds); + return wxContractShopMapper.findContractIdList(cs); + } + + + @Override + public WxContractCustomers findCustomers(TenantEntity tenantEntity, Long customerId) { + return wxContractCustomersMapper.selectById(customerId, tenantEntity.getTenantId()); + } + + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxAllBillServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxAllBillServiceImpl.java index ca4640aba..0ab0e4708 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxAllBillServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxAllBillServiceImpl.java @@ -213,9 +213,9 @@ public class WxAllBillServiceImpl extends WxBillBaseService implements WxAllBill } @Override - public List getMerchantIds(WxAllBill wxBillRent) { + public List getShopIds(WxAllBill wxBillRent) { updateQueryParam(wxBillRent); - return wxAllBillMapper.getMerchantIdList(wxBillRent); + return wxAllBillMapper.getShopIdList(wxBillRent); } @Override diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxEnergyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxEnergyServiceImpl.java index e7c9d22de..ed8646e58 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxEnergyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxEnergyServiceImpl.java @@ -13,7 +13,7 @@ import com.iformall.common.ResultData; import com.iformall.domain.dto.FloorBuildingIdDTO; import com.iformall.domain.po.*; import com.iformall.domain.po.base.TenantEntity; -import com.iformall.domain.vo.WxMerchantBillVo; +import com.iformall.domain.vo.WxShopBillVo; import com.iformall.enums.EnumBillAllType; import com.iformall.enums.EnumEnergyMeterPhysicsType; import com.iformall.enums.EnumEnergyMeterShopFloorType; @@ -1570,13 +1570,11 @@ public class WxEnergyServiceImpl implements WxEnergyService { crq.setCalcuteId(calcute.getId()); List shopIdList = wxEnergyReadingCalcuteResultMapper.findShopIdList(crq); Map shopMap = null; - Map merchantMap = null; if (shopIdList.size() > 0 ) { WxShop sq = new WxShop(); sq.updateTenantInfo(record); sq.setIds(shopIdList); shopMap = wxShopService.findShopMap(sq); - merchantMap = wxMerchantService.getShopMerchantMap(sq); } WxEnergyFees fees = this.getFeesById(calcute.getFeesId(), record.getTenantId()); @@ -1594,14 +1592,6 @@ public class WxEnergyServiceImpl implements WxEnergyService { if (null == shop) { throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺ID["+result.getShopId()+"]未查询到店铺"); } - WxMerchant merchant = null; - if (null != merchantMap) { - merchant = merchantMap.get(result.getShopId()); - } - if (null == merchant) { - throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺"+shop.getShopNumber()+"未绑定商户,请先绑定商户"); - } - WxEnergyFeesShop feesShop = wxEnergyFeesShopMapper.selectById(result.getFeesShopId(), result.getTenantId()); if (null == feesShop) { throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺"+shop.getShopNumber()+"该科目费用标准未查询到"); @@ -1614,7 +1604,7 @@ public class WxEnergyServiceImpl implements WxEnergyService { feesShopList.add(feesShop); } - WxAllBill bill = result.generateBill(calcute, merchant, shop, user,result.getBeginTime(),result.getEndTime(), result.getMoney(), result.getMoneyDeail(), "能源计算自动生成"); + WxAllBill bill = result.generateBill(calcute, shop, user,result.getBeginTime(),result.getEndTime(), result.getMoney(), result.getMoneyDeail(), "能源计算自动生成"); billList.add(bill); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxFinancePrintServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxFinancePrintServiceImpl.java index 5edaebcb4..25380c795 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFinancePrintServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFinancePrintServiceImpl.java @@ -22,7 +22,7 @@ import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.base.BaseEntity; import com.iformall.domain.vo.PrintVo; import com.iformall.domain.vo.WxBillSum; -import com.iformall.domain.vo.WxMerchantBillVo; +import com.iformall.domain.vo.WxShopBillVo; import com.iformall.enums.EnumFinancePrintDataType; import com.iformall.enums.EnumYesOrNo; import com.iformall.exception.MallinkException; @@ -313,7 +313,7 @@ public class WxFinancePrintServiceImpl implements WxFinancePrintService { } return voList; }else if (printDatatype.getCode().intValue() == EnumFinancePrintDataType.RENT_OWE.getCode()) { - WxMerchantBillVo bq = (WxMerchantBillVo) entity; + WxShopBillVo bq = (WxShopBillVo) entity; if (null != shopNumber && null != bq.getMerchantId()) { bq.setShopNumber(shopNumber.get(bq.getMerchantId())); }else { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index 2288bab98..ed134cc33 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -375,11 +375,11 @@ public class WxMerchantServiceImpl implements WxMerchantService { WxRentContract wxRentContract = new WxRentContract(); wxRentContract.setMerchantId(wxMerchant.getId()); - List lrc = wxRentContractMapper.selectRentContractByMerchantId(wxRentContract); - if (!lrc.isEmpty()) { - wxMerchant.setRentalStartDate(lrc.get(0).getRentalStartDate()); - wxMerchant.setRentalEndDate(lrc.get(0).getRentalEndDate()); - } + //List lrc = wxRentContractMapper.selectRentContractByMerchantId(wxRentContract); + //if (!lrc.isEmpty()) { + // wxMerchant.setRentalStartDate(lrc.get(0).getRentalStartDate()); + // wxMerchant.setRentalEndDate(lrc.get(0).getRentalEndDate()); + //} List wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShop); for (WxMerchantShop merchantShop : wxMerchantShopList) { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 8db5a9515..8af58f5c0 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -13,6 +13,8 @@ import com.iformall.common.SysConfigConstant; import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.SysConfig; import com.iformall.domain.po.WxAllBill; +import com.iformall.domain.po.WxContractCustomers; +import com.iformall.domain.po.WxContractShop; import com.iformall.domain.po.WxEnergyFees; import com.iformall.domain.po.WxFlowModel; import com.iformall.domain.po.WxFlowRecord; @@ -37,6 +39,7 @@ import com.iformall.domain.vo.WxRentContractYearsVo; import com.iformall.enums.EnumBillAllType; import com.iformall.enums.EnumBillExtraCreateFrom; import com.iformall.enums.EnumBillStatus; +import com.iformall.enums.EnumContractCustomersStatus; import com.iformall.enums.EnumContractOperationType; import com.iformall.enums.EnumContractReceivePeriodUnit; import com.iformall.enums.EnumEndProperty; @@ -63,6 +66,8 @@ import com.iformall.enums.EnumYesOrNo; import com.iformall.exception.MallinkException; import com.iformall.mapper.WxAllBillMapper; import com.iformall.mapper.WxBusinessMapper; +import com.iformall.mapper.WxContractCustomersMapper; +import com.iformall.mapper.WxContractShopMapper; import com.iformall.mapper.WxFlowRecordMapper; import com.iformall.mapper.WxMerchantMapper; import com.iformall.mapper.WxMerchantShopMapper; @@ -74,6 +79,7 @@ import com.iformall.mapper.WxRentContractRevenueJumpMapper; import com.iformall.mapper.WxRentContractRevenueSalesMapper; import com.iformall.mapper.WxShopMapper; import com.iformall.service.SysConfigService; +import com.iformall.service.WxAgileContractService; import com.iformall.service.WxEnergyService; import com.iformall.service.WxFlowRecordService; import com.iformall.service.WxFlowService; @@ -89,6 +95,8 @@ import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; import com.iformall.utils.DownFileUtil; import com.iformall.utils.PriceUtil; + +import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.map.HashedMap; import org.apache.commons.compress.utils.Lists; import org.apache.commons.lang3.StringUtils; @@ -108,6 +116,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.math.BigDecimal; import java.math.RoundingMode; import java.text.SimpleDateFormat; @@ -142,6 +151,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { @Autowired WxRentContractRevenueSalesMapper wxRentContractRevenueSalesMapper; + + @Autowired + WxContractCustomersMapper wxContractCustomersMapper; + + @Autowired + WxContractShopMapper wxContractShopMapper; @Autowired WxShopMapper wxShopMapper; @@ -191,6 +206,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { @Lazy @Autowired WxPropertyContractService wxPropertyContractService; + + @Lazy + @Autowired + WxAgileContractService wxAgileContractService; @Lazy @Autowired @@ -228,6 +247,13 @@ public class WxRentContractServiceImpl implements WxRentContractService { throw new MallinkException(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); } + WxContractCustomers customers = wxContractCustomersMapper.selectById(id,wxRentContract.getTenantId()); + wxRentContract.setCustomerType(customers.getPrincipalType()); + wxRentContract.setCustomerLinkPerson(customers.getLinkPerson()); + wxRentContract.setCustomerName(customers.getName()); + wxRentContract.setCustomerPhone(customers.getPhone()); + wxRentContract.setCustomerLegalPerson(customers.getLegalPerson()); + //init dateDiff if(wxRentContract.getRentalStartDate() != null && wxRentContract.getRentalEndDate() != null){ //加1天 @@ -237,11 +263,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { result.put("totalPeriodDay",array[1]); } - //init rentPrice - //if(StringUtils.isNotBlank(wxRentContract.getRentPrice())){ - //wxRentContract.setRentPrice(Double.parseDouble(wxRentContract.getRentPrice())/100 + ""); - //} - //init 租赁单价 String rentInfo = wxRentContract.getRentInfo(); if(StringUtils.isNotBlank(rentInfo)){ @@ -309,13 +330,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { jq.setRentContractId(wxRentContract.getId()); wxRentContract.setRevenueJumps(wxRentContractRevenueJumpMapper.findList(jq)); result.put("wxRentContract", wxRentContract); - //关联的商户 - if (wxRentContract.getMerchantId() != null) { - WxMerchant wxMerchant = wxMerchantService.getById(wxRentContract.getMerchantId()); - result.put("wxMerchant", wxMerchant); - } else { - result.put("wxMerchant", null); - } //关联的店铺 if (wxRentContract.shopIdsByRentInfo().size()> 0) { WxShop record = new WxShop(); @@ -331,23 +345,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { //设置审批流程状态 result.put("applyStatus", wxRentContract.getApplyStatus()); - //租赁费用欠缴 -// result.put("rentOweCount",wxRentContractMapper.queryOweCount(wxRentContract)); - //物业费用欠缴 -// WxPropertyContract propertyContract = new WxPropertyContract(); -// propertyContract.setRentContractId(id); -// result.put("propertyOweCount",wxPropertyContractMapper.queryOweCount(propertyContract)); -// result.put("protertyContract", wxPropertyContractMapper.findOneByRentId(wxRentContract)); -// //押金欠缴 -// result.put("depositOweCount",wxBillDepositMapper.queryOweCount(wxRentContract)); -// //押金状态 -// WxBillDeposit wxBillDeposit = new WxBillDeposit(); -// wxBillDeposit.setRentContractId(id); -// wxBillDeposit.updateTenantInfo(wxRentContract); -// List select = wxBillDepositMapper.findList(wxBillDeposit); -// if (!select.isEmpty()) { -// result.put("depositStatus", select.get(0).getStatus()); -// } //发起人备注 WxFlowRecord wxFlowRecord = new WxFlowRecord(); wxFlowRecord.setBusinessId(String.valueOf(id)); @@ -432,10 +429,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { shopName = shopName +","+ shopNumber; } } - // - WxMerchant merchant = wxMerchantMapper.selectById(record.getMerchantId()); - record.setIsPrivateMerchant(merchant.getIsPrivate()); - record.setPrivateRentShopType(merchant.getCreateShopType()); + setShops(record,shopList); + //关联客户 + setCustomers(record); try { record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode()); record.setStatus(EnumRentContractStatus.UNWRITE.getCode()); @@ -452,6 +448,58 @@ public class WxRentContractServiceImpl implements WxRentContractService { return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", record); } + + public void setCustomers(WxRentContract record) { + WxContractCustomers cq = new WxContractCustomers(); + cq.updateTenantInfo(record); + cq.setPrincipalType(record.getCustomerType()); + cq.setNameEqal(record.getCustomerName()); + cq.setPhoneEqal(record.getCustomerPhone()); + List list = wxContractCustomersMapper.findList(cq); + WxContractCustomers cus = null; + if (null != list && list.size() > 0 ){ + cus = list.get(0); + } + if (null == cus) { + final IdWorker idWorker = IdWorker.get(); + cus = new WxContractCustomers(); + cus.updateTenantInfo(record); + cus.setId(idWorker.nextId()); + cus.setPrincipalType(record.getCustomerType()); + cus.setName(record.getCustomerName()); + cus.setPhone(record.getCustomerPhone()); + cus.setLegalPerson(record.getCustomerLegalPerson()); + cus.setLinkPerson(record.getCustomerLinkPerson()); + cus.setCreateDate(new Date()); + cus.setUpdateDate(new Date()); + cus.setStatus(EnumContractCustomersStatus.TEMP.getCode()); + wxContractCustomersMapper.insert(cus); + } + record.setCustomersId(cus.getId()); + } + + public void setShops(WxRentContract record,List shopIdList) { + WxContractShop sdel = new WxContractShop(); + sdel.updateTenantInfo(record); + sdel.setContractId(record.getId()); + wxContractShopMapper.deleteByCondition(sdel); + + if (null != shopIdList && shopIdList.size() > 0 ) { + final IdWorker idWorker = IdWorker.get(); + for ( int i = 0 ; i < shopIdList.size(); i ++) { + WxContractShop s = new WxContractShop(); + s.updateTenantInfo(record); + s.setContractId(record.getId()); + s.setShopId(shopIdList.get(i)); + s.setCreateDate(new Date()); + s.setUpdateDate(new Date()); + s.setId(idWorker.nextId()); + wxContractShopMapper.insert(s); + } + } + + } + @Override public List getShopIds(WxRentContract record) { @@ -515,6 +563,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { List resultList = wxAllBillMapper.findList(wxBillRent); //更新 + setCustomers(record); ResultData resultData = getResultDataForUpdate(record, user,from,oldRentStartDate,writeComplate,false); if (resultData.code != Result.SUCCESS) { return resultData; @@ -541,10 +590,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { record.setDecimalSize(Constant.default_short_decimal_size); } wxAllBillMapper.deleteBillByContract(record); - WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(record); final IdWorker idWorker = IdWorker.get(); - int count = 1; List shopIds = record.shopIdsByRentInfo(); + //根据关联的店铺面积来分金额 + Map shopAreaRateMap = record.getRentShopAreaRate(); + if (null == shopAreaRateMap) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"无店铺信息"); + } + List billList = new ArrayList(); for (WxAllBill bill:record.getPreviewBillRentList()) { bill.setId(idWorker.nextId()); Date date = new Date(); @@ -567,7 +620,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { //bill.setLatePayRatio(0); bill.setPay("0"); //bill.setIsDel(EnumDelStatus.NOT_DEL.getCode()); - bill.setMerchantId(record.getMerchantId()); if (null != shopIds && shopIds.size() == 1) { bill.setShopId(shopIds.get(0)); } @@ -581,9 +633,34 @@ public class WxRentContractServiceImpl implements WxRentContractService { //bill.setServiceChargePay(servicePay.toPlainString()); //bill.setOwe(bill.getReceivePay() + bill.getServiceChargePay()); //bill.setOwe(bill.getReceivePay()); - count++; + + //根据铺位来实际创建账单 + for (int i = 0 ; i < shopIds.size(); i ++) { + WxAllBill b = new WxAllBill(); + Long sid = shopIds.get(i); + BigDecimal shoprate = shopAreaRateMap.get(sid); + try { + BeanUtils.copyProperties(b, bill); + b.setId(idWorker.nextId()); + b.setShopId(sid); + b.setNeedPay(new BigDecimal(bill.getNeedPay()).multiply(shoprate).toPlainString()); + b.setReceivePay(b.getNeedPay()); + billList.add(b); + } catch (IllegalAccessException e) { + logger.error("savePreviewBill error.",e); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); + } catch (InvocationTargetException e) { + logger.error("savePreviewBill error.",e); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); + } + + + } + + } + if (billList.size() > 0 ){ + wxAllBillMapper.insertBills(record.getTenantId(),billList); } - wxAllBillMapper.insertBills(record.getTenantId(),record.getPreviewBillRentList()); } /** @@ -606,6 +683,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { final IdWorker idWorker = IdWorker.get(); int count = 1; List shopIds = record.shopIdsByRentInfo(); + //根据关联的店铺面积来分金额 + Map shopAreaRateMap = record.getRentShopAreaRate(); + if (null == shopAreaRateMap) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"无店铺信息"); + } List billList = new ArrayList(); for (WxAllBill _bi:record.getPreviewBillRentList()) { BigDecimal needPay = new BigDecimal("0"); @@ -624,51 +706,52 @@ public class WxRentContractServiceImpl implements WxRentContractService { if (needPay.compareTo(new BigDecimal(0)) <= 0) { continue; } - WxAllBill bill = new WxAllBill(); - bill.setId(idWorker.nextId()); - Date date = new Date(); - bill.setBillType(billType); - bill.setRentContractId(record.getId()); - bill.setCreatetime(date); - bill.setCreateBy(user.getId()); - bill.setCreateByName(user.getName());; - bill.updateTenantInfo(record); - bill.setStarttime(_bi.getStarttime()); - bill.setEndtime(_bi.getEndtime()); - bill.setIsPreview(_bi.getIsPreview()); - //bill.setManageFeeType(feeType.getCode()); - bill.setNeedPay(needPay.toPlainString()); - bill.setReceivePay(needPay.toPlainString()); - bill.setUpdatetime(date); - bill.setUpdateBy(user.getId()); - bill.setUpdateByName(user.getName()); - //bill.setPeriod(count); - bill.setShopInfo(getShopInfoStr(record)); - //bill.setLatePayRatio(0); - bill.setPay("0"); - //bill.setIsDel(EnumDelStatus.NOT_DEL.getCode()); - bill.setMerchantId(record.getMerchantId()); - if (null != shopIds && shopIds.size() == 1) { - bill.setShopId(shopIds.get(0)); - } - //setManageExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod()); - if (bill.getReceivePay().equals("0")) { - bill.setPayDate(date); - } - - if (feeType.getCode() == EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE.getCode()) { - bill.setEnergyFeesId(EnumBillAllType.RENT_BUSSINESS_MANAGE.getEnergyFeesId()); - }else if (feeType.getCode() == EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE.getCode()) { - bill.setEnergyFeesId(EnumBillAllType.RENT_OPERATION_MANAGE.getEnergyFeesId()); - } - - //计算手续费 - //BigDecimal servicePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), record.getDecimalSize(), BigDecimal.ROUND_HALF_UP); - //bill.setServiceChargePay(servicePay.toPlainString()); - //bill.setOwe(bill.getReceivePay() + bill.getServiceChargePay()); - //bill.setOwe(bill.getReceivePay()); - count++; - billList.add(bill); + for (int i = 0 ; i < shopIds.size(); i ++) { + Long sid = shopIds.get(i); + BigDecimal shoprate = shopAreaRateMap.get(sid); + WxAllBill bill = new WxAllBill(); + bill.setId(idWorker.nextId()); + Date date = new Date(); + bill.setBillType(billType); + bill.setRentContractId(record.getId()); + bill.setCreatetime(date); + bill.setCreateBy(user.getId()); + bill.setCreateByName(user.getName());; + bill.updateTenantInfo(record); + bill.setStarttime(_bi.getStarttime()); + bill.setEndtime(_bi.getEndtime()); + bill.setIsPreview(_bi.getIsPreview()); + //bill.setManageFeeType(feeType.getCode()); + bill.setNeedPay(needPay.multiply(shoprate).toPlainString()); + bill.setReceivePay(bill.getNeedPay()); + bill.setUpdatetime(date); + bill.setUpdateBy(user.getId()); + bill.setUpdateByName(user.getName()); + //bill.setPeriod(count); + bill.setShopInfo(getShopInfoStr(record)); + //bill.setLatePayRatio(0); + bill.setPay("0"); + //bill.setIsDel(EnumDelStatus.NOT_DEL.getCode()); + bill.setShopId(sid); + //setManageExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod()); + if (bill.getReceivePay().equals("0")) { + bill.setPayDate(date); + } + + if (feeType.getCode() == EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE.getCode()) { + bill.setEnergyFeesId(EnumBillAllType.RENT_BUSSINESS_MANAGE.getEnergyFeesId()); + }else if (feeType.getCode() == EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE.getCode()) { + bill.setEnergyFeesId(EnumBillAllType.RENT_OPERATION_MANAGE.getEnergyFeesId()); + } + + //计算手续费 + //BigDecimal servicePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), record.getDecimalSize(), BigDecimal.ROUND_HALF_UP); + //bill.setServiceChargePay(servicePay.toPlainString()); + //bill.setOwe(bill.getReceivePay() + bill.getServiceChargePay()); + //bill.setOwe(bill.getReceivePay()); + count++; + billList.add(bill); + } } if (billList.size() > 0 ) { wxAllBillMapper.insertBills(record.getTenantId(),billList); @@ -746,7 +829,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { shopName = shopName +","+shopNumber; } } - + setShops(record,shopList); try { Date tempDate = record.getRentalStartDate(); record.setRentalStartDate(oldRentStartDate); @@ -809,6 +892,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { if (wxRentContract != null && StringUtils.isNotBlank(wxRentContract.getDeposit()) && new BigDecimal(wxRentContract.getDeposit()).compareTo(new BigDecimal(0)) > 0 ) { + List shopIdList = wxRentContract.shopIdsByRentInfo(); WxEnergyFees fq = new WxEnergyFees(); fq.updateTenantInfo(tenantEntity); @@ -817,7 +901,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { //根据不同的科目生成不同的押金账单 Map feesMap = wxRentContract.getDepositEnergyFees(typeMap); - + Map shopAreaRateMap = wxRentContract.getRentShopAreaRate(); + if (null == shopAreaRateMap) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"无店铺信息"); + } List insertList = new ArrayList(); for (Iterator it = feesMap.keySet().iterator();it.hasNext();){ @@ -825,71 +912,72 @@ public class WxRentContractServiceImpl implements WxRentContractService { WxEnergyFees depositFee = feesMap.get(energyFeesId); WxEnergyFees fees = typeMap.get(energyFeesId); final IdWorker idWorker = IdWorker.get(); - WxAllBill wxBillDeposit = new WxAllBill(); - wxBillDeposit.setId(idWorker.nextId()); - wxBillDeposit.setRentContractId(wxRentContract.getId()); - wxBillDeposit.setBillType(EnumBillAllType.RENT_DEPOSIT.getCode()); - wxBillDeposit.setIsPreview(EnumYesOrNo.NO.getCode()); - wxBillDeposit.setCanEdit(EnumYesOrNo.NO.getCode()); - if (null != fees) { - wxBillDeposit.setPriceDetail("合同押金项["+fees.getName()+"]"+depositFee.getPrice()+"元"+"/"+fees.getCalcuteUnitName()); - } - wxBillDeposit.setPay("0"); - String needpay = depositFee.getPrice(); - -// String count = "1"; -// if (null != depositFee.getCalcuteUnit() && depositFee.getCalcuteUnit().intValue() == EnumFeesStandardsCalcuteUnit.MM.getCode().intValue()) { -// count = wxRentContract.getRentArea(); -// } -// String needpay = depositFee.calcuteTotalMoney(wxRentContract.getDecimalSize(), null, null, count, true, null, null); - wxBillDeposit.setReceivePay(needpay); - wxBillDeposit.setNeedPay(needpay); - //wxBillDeposit.setOwe(needpay); - //找到计租方式 - int dayType = wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode()) ? Calendar.DAY_OF_MONTH : Calendar.MONTH; - - Date date = new Date(); - wxBillDeposit.setStarttime(wxRentContract.getFirstBillDateStart()); - wxBillDeposit.setEndtime(wxRentContract.getFirstBillDateEnd()); - wxBillDeposit.setReceiveDate(wxRentContract.getFirstBillReceiveDate()); - wxBillDeposit.setPeriod(WxRentContractHelper.getPeriod(wxRentContract.getFirstBillReceiveDate())); - //wxBillDeposit.setExpiredDay(0L); - wxBillDeposit.updateTenantInfo(wxRentContract); - //wxBillDeposit.setIsDel(0); - wxBillDeposit.setMerchantId(wxRentContract.getMerchantId()); - wxBillDeposit.setShopNumber(wxRentContract.getRentInfoShopNumber()); - if (null != user) { - //wxBillDeposit.setUserId(user.getId()); - } - if (wxRentContract.shopIdsByRentInfo().size()==1) { - wxBillDeposit.setShopId(wxRentContract.shopIdsByRentInfo().get(0)); - } - wxBillDeposit.setRentArea(wxRentContract.getRentArea()); - wxBillDeposit.setCreatetime(date); - if (null != user) { - wxBillDeposit.setCreateBy(user.getId()); - wxBillDeposit.setCreateByName(user.getName()); - } - wxBillDeposit.setUpdatetime(date); - if (null != user) { - wxBillDeposit.setUpdateBy(user.getId()); - wxBillDeposit.setUpdateByName(user.getName()); - } - //wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); - String rentInfo = wxRentContract.getRentInfo(); - if (rentInfo != null) { - JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); - Map shopInfo = new HashMap<>(); - for (int i = 0, size = rentInfoArray.size(); i < size; i++) { - JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); - shopInfo.put(rentInfoObject.getString("shopNumber"), rentInfoObject.get("deposit")); - } - wxBillDeposit.setShopInfo(JSONObject.toJSONString(shopInfo)); - } - wxBillDeposit.setEnergyFeesId(energyFeesId); - - insertList.add(wxBillDeposit); - + + for (int i = 0 ; i < shopIdList.size(); i++ ) { + Long sid = shopIdList.get(i); + BigDecimal shoprate = shopAreaRateMap.get(sid); + WxAllBill wxBillDeposit = new WxAllBill(); + wxBillDeposit.setId(idWorker.nextId()); + wxBillDeposit.setRentContractId(wxRentContract.getId()); + wxBillDeposit.setBillType(EnumBillAllType.RENT_DEPOSIT.getCode()); + wxBillDeposit.setIsPreview(EnumYesOrNo.NO.getCode()); + wxBillDeposit.setCanEdit(EnumYesOrNo.NO.getCode()); + //if (null != fees) { + // wxBillDeposit.setPriceDetail("合同押金项["+fees.getName()+"]"+depositFee.getPrice()+"元"+"/"+fees.getCalcuteUnitName()); + //} + wxBillDeposit.setPay("0"); + String needpay = depositFee.getPrice(); + + // String count = "1"; + // if (null != depositFee.getCalcuteUnit() && depositFee.getCalcuteUnit().intValue() == EnumFeesStandardsCalcuteUnit.MM.getCode().intValue()) { + // count = wxRentContract.getRentArea(); + // } + // String needpay = depositFee.calcuteTotalMoney(wxRentContract.getDecimalSize(), null, null, count, true, null, null); + wxBillDeposit.setReceivePay(new BigDecimal(needpay).multiply(shoprate).toPlainString()); + wxBillDeposit.setNeedPay(wxBillDeposit.getReceivePay()); + //wxBillDeposit.setOwe(needpay); + //找到计租方式 + int dayType = wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode()) ? Calendar.DAY_OF_MONTH : Calendar.MONTH; + + Date date = new Date(); + wxBillDeposit.setStarttime(wxRentContract.getFirstBillDateStart()); + wxBillDeposit.setEndtime(wxRentContract.getFirstBillDateEnd()); + wxBillDeposit.setReceiveDate(wxRentContract.getFirstBillReceiveDate()); + wxBillDeposit.setPeriod(WxRentContractHelper.getPeriod(wxRentContract.getFirstBillReceiveDate())); + //wxBillDeposit.setExpiredDay(0L); + wxBillDeposit.updateTenantInfo(wxRentContract); + //wxBillDeposit.setIsDel(0); + wxBillDeposit.setShopNumber(wxRentContract.getRentInfoShopNumber()); + if (null != user) { + //wxBillDeposit.setUserId(user.getId()); + } + wxBillDeposit.setShopId(sid); + wxBillDeposit.setRentArea(wxRentContract.getRentArea()); + wxBillDeposit.setCreatetime(date); + if (null != user) { + wxBillDeposit.setCreateBy(user.getId()); + wxBillDeposit.setCreateByName(user.getName()); + } + wxBillDeposit.setUpdatetime(date); + if (null != user) { + wxBillDeposit.setUpdateBy(user.getId()); + wxBillDeposit.setUpdateByName(user.getName()); + } + //wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); + String rentInfo = wxRentContract.getRentInfo(); + if (rentInfo != null) { + JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); + Map shopInfo = new HashMap<>(); + for (int j = 0, size = rentInfoArray.size(); j < size; j++) { + JSONObject rentInfoObject = rentInfoArray.getJSONObject(j); + shopInfo.put(rentInfoObject.getString("shopNumber"), rentInfoObject.get("deposit")); + } + wxBillDeposit.setShopInfo(JSONObject.toJSONString(shopInfo)); + } + wxBillDeposit.setEnergyFeesId(energyFeesId); + + insertList.add(wxBillDeposit); + } } try { @@ -903,12 +991,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { } } - @Override - public Object getMerchants(WxRentContract wxRentContract) { - List rentContractList = wxRentContractMapper.getMerchants(wxRentContract); - return rentContractList; - } - @Override public ResultData hasRentStatus(WxRentContract record) { String rentInfo = record.getRentInfo(); @@ -1152,6 +1234,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { cupdate.setDecimalSize(null);//去掉默认的,避免更新 wxRentContractMapper.updateById(cupdate); } + + List shopIdList = wxRentContract.shopIdsByRentInfo(); + Map shopAreaRateMap = wxRentContract.getRentShopAreaRate(); + if (null == shopAreaRateMap) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"无店铺信息"); + } //免租期 List freePeriods = getFreeDays(wxRentContract); @@ -1283,6 +1371,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { } } + WxAllBill wxBillRent = new WxAllBill(); wxBillRent.setIsPreview(isPreview); wxBillRent.setId(idWorker.nextId()); @@ -1309,7 +1398,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { //setExpiredDay(wxBillRent,dayType,receivePeriod); //wxBillRent.setRevenue("0"); wxBillRent.updateTenantInfo(wxRentContract); - wxBillRent.setMerchantId(wxRentContract.getMerchantId()); //wxBillRent.setUserId(user.getId()); if (null != wxRentContract.shopIdsByRentInfo() && wxRentContract.shopIdsByRentInfo().size() == 1) { wxBillRent.setShopId(wxRentContract.shopIdsByRentInfo().get(0)); @@ -1350,9 +1438,56 @@ public class WxRentContractServiceImpl implements WxRentContractService { //批量插入账单 if(saveDb) { - wxAllBillMapper.insertBills(wxRentContract.getTenantId(),resultList); + List rblist = new ArrayList(); + for (int k = 0 ; k < resultList.size(); k++) { + WxAllBill rb = resultList.get(k); + for (int g = 0 ; g < shopIdList.size(); g ++ ){ + WxAllBill rs = new WxAllBill(); + Long sid = shopIdList.get(g); + BigDecimal shoprate = shopAreaRateMap.get(sid); + try { + BeanUtils.copyProperties(rs, rb); + rs.setId(idWorker.nextId()); + rs.setShopId(sid); + rs.setNeedPay(new BigDecimal(rb.getNeedPay()).multiply(shoprate).toPlainString()); + rs.setReceivePay(rs.getNeedPay()); + rblist.add(rs); + } catch (IllegalAccessException e) { + logger.error("savePreviewBill error.",e); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); + } catch (InvocationTargetException e) { + logger.error("savePreviewBill error.",e); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); + } + } + } + wxAllBillMapper.insertBills(wxRentContract.getTenantId(),rblist); if (manageList.size() > 0 ) { - wxAllBillMapper.insertBills(wxRentContract.getTenantId(),manageList); + List mblist = new ArrayList(); + for (int k = 0 ; k < manageList.size(); k++) { + WxAllBill rb = manageList.get(k); + for (int g = 0 ; g < shopIdList.size(); g ++ ){ + WxAllBill rs = new WxAllBill(); + Long sid = shopIdList.get(g); + BigDecimal shoprate = shopAreaRateMap.get(sid); + try { + BeanUtils.copyProperties(rs, rb); + rs.setId(idWorker.nextId()); + rs.setShopId(sid); + rs.setNeedPay(new BigDecimal(rb.getNeedPay()).multiply(shoprate).toPlainString()); + rs.setReceivePay(rs.getNeedPay()); + mblist.add(rs); + } catch (IllegalAccessException e) { + logger.error("savePreviewBill error.",e); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); + } catch (InvocationTargetException e) { + logger.error("savePreviewBill error.",e); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); + } + } + } + + wxAllBillMapper.insertBills(wxRentContract.getTenantId(),mblist); } } resultMap.put("billcount",billcount); @@ -1370,7 +1505,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { manage.setPeriod(wxBillRent.getPeriod()); manage.updateTenantInfo(wxBillRent); manage.setIsPreview(wxBillRent.getIsPreview()); - manage.setMerchantId(wxBillRent.getMerchantId()); manage.setCreatetime(wxBillRent.getCreatetime()); manage.setCreateBy(wxBillRent.getCreateBy()); manage.setCreateByName(wxBillRent.getCreateByName()); @@ -1514,11 +1648,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { @Override public PageInfo getRentContractList(WxRentContract rentContract, Integer pageIndex, Integer pageSize) { if (StringUtils.isNoneBlank(rentContract.getFloorForRule())) { - List mids = wxMerchantService.getFloorBuildMerchantIds(rentContract, rentContract.getFloorForRule() , null, null,rentContract.getShopTypeForRule(), 0, 0,null); - if (null == mids || mids.size() <= 0 ) { + List contractIds = wxAgileContractService.findBuildingFloorContractIds(rentContract, rentContract.getFloorForRule(), null, null, null, 0); + //List mids = wxMerchantService.getFloorBuildMerchantIds(rentContract, rentContract.getFloorForRule() , null, null,rentContract.getShopTypeForRule(), 0, 0,null); + if (null == contractIds || contractIds.size() <= 0 ) { rentContract.setId(-1L); } else { - rentContract.setMerchantIds(mids); + rentContract.setIds(contractIds); } } //PageInfo pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxRentContractMapper.getRentContractList(rentContract)); @@ -1594,14 +1729,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { if (EnumRentContractType.RENT_BY_CUSTOMIZE.getCode() == record.getType()) { record.setPrice("0.01"); } - if (record != null && - record.getMerchantId() != null && - record.getReceivePeriod() != null ) { + if (record != null && record.getReceivePeriod() != null ) { //预览账单改为正式,并写入商户id WxAllBill billRent = new WxAllBill(); billRent.setRentContractId(id); billRent.setIsPreview(EnumIsPreview.NO.getCode()); - billRent.setMerchantId(record.getMerchantId()); billRent.updateTenantInfo(record); wxAllBillMapper.updatePreviewStatus(billRent); // WxMerchant wxMerchant = new WxMerchant(); @@ -1641,8 +1773,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { WxPropertyContract propertyContract = wxPropertyContractMapper.selectOne(new QueryWrapper(wxPropertyContract)); logger.info("物业合同状态及账单状态修改:{}",propertyContract); if (propertyContract != null) { - propertyContract.setMerchantId(record.getMerchantId()); - wxPropertyContractMapper.updateById(propertyContract); wxPropertyContractService.updatePropertyContractStatus(propertyContract.getId()); } } @@ -1762,21 +1892,27 @@ public class WxRentContractServiceImpl implements WxRentContractService { //如果存在审批中的合同,不允许提交审批 WxRentContract wrq = new WxRentContract(); wrq.updateTenantInfo(user); - wrq.setMerchantId(rentContract.getMerchantId()); + List shopIds = rentContract.shopIdsByRentInfo(); + List contractIds = wxAgileContractService.findBuildingFloorContractIds(wrq, null, null, null, shopIds, 0); + if (null != contractIds && contractIds.size() > 0 ) { + wrq.setIds(contractIds); + } wrq.setStatus(EnumRentContractStatus.PERFORMANCE.getCode()); List clist = wxRentContractMapper.findList(wrq); if (null != clist && clist.size() > 0 ) { - return new ResultData(Result.ERROR, "当前商户存在其他审批中的租金合同。请先作完成。"); + return new ResultData(Result.ERROR, "房间资源存在其他审批中的租金合同。请先作完成。"); } //如果该合同是租金+物业合同,则还要判断物业合同 if(rentContract.getOperationType().intValue() == EnumContractOperationType.WHOLE.getCode().intValue()) { WxPropertyContract wpc = new WxPropertyContract(); wpc.updateTenantInfo(user); - wpc.setMerchantId(rentContract.getMerchantId()); + if (null != contractIds && contractIds.size() > 0 ) { + wpc.setIds(contractIds); + } wpc.setStatus(EnumRentContractStatus.PERFORMANCE.getCode()); List plist = wxPropertyContractMapper.findList(wpc); if (null != plist && plist.size() > 0 ) { - return new ResultData(Result.ERROR, "当前商户存在其他审批中的物业合同。请先作完成。"); + return new ResultData(Result.ERROR, "房间资源存在其他审批中的物业合同。请先作完成。"); } } // Integer count = wxRentContractMapper.getCanApplyCount(rentContract.getId()); @@ -1788,10 +1924,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { return new ResultData(Result.ERROR, "编号["+rentContract.getId()+"]租金合同没有审批流程."); } - if (rentContract.getMerchantId() == null) { - return new ResultData(Result.ERROR, "编号["+rentContract.getId()+"]租金合同没有绑定商户."); - } - if ((EnumRentContractStatus.DRAFT.getCode().intValue() == rentContract.getStatus().intValue()) || (EnumRentContractStatus.PERFORMANCE.getCode().intValue() == rentContract.getStatus().intValue() && (EnumRentContractAppStatus.REJECT.getCode().intValue() == rentContract.getApplyStatus().intValue() || @@ -1814,61 +1946,21 @@ public class WxRentContractServiceImpl implements WxRentContractService { } @Override - @Transactional(rollbackFor = {Exception.class}) public void outDateContract(WxMall wxMall) { - //查询有计租合同的商户 - WxRentContract wr = new WxRentContract(); - wr.setStatuss(EnumRentContractStatus.getValidStatus()); - wr.updateTenantInfo(wxMall); - List merchantIds = wxRentContractMapper.getMerchantIdsByStatuss(wr); - for (Long mid: merchantIds) { - if (null == mid) { - continue; - } - try { - //查询商户下计租到期的合同,更新合同状态 - WxRentContract wrc = new WxRentContract(); - wrc.setMerchantId(mid); - wrc.setStatus(EnumRentContractStatus.PAING.getCode()); - List contractList = wxRentContractMapper.findList(wrc); - List shopIdList = new ArrayList(); - for (WxRentContract contract:contractList) { - if (contract.getRentalEndDate().before(new Date())) { - contract.setStatus(EnumRentContractStatus.OUT_DATE.getCode()); - wxRentContractMapper.updateById(contract); - List shopIds = contract.shopIdsByRentInfo(); - for (Long sid: shopIds) { - if (!shopIdList.contains(sid)) { - shopIdList.add(sid); - } - } - } + try { + //查询商户下计租到期的合同,更新合同状态 + WxRentContract wrc = new WxRentContract(); + wrc.updateTenantInfo(wxMall); + wrc.setStatus(EnumRentContractStatus.PAING.getCode()); + List contractList = wxRentContractMapper.findList(wrc); + for (WxRentContract contract:contractList) { + if (contract.getRentalEndDate().before(new Date())) { + contract.setStatus(EnumRentContractStatus.OUT_DATE.getCode()); + wxRentContractMapper.updateById(contract); } - - //到期合同中的店铺,如果存在有效合同,则不释放 - if (shopIdList.size() > 0 ) { - WxRentContract wrcq = new WxRentContract(); - wrcq.setMerchantId(mid); - wrcq.setStatuss(EnumRentContractStatus.getValidStatus()); - List contractList0 = wxRentContractMapper.findList(wrcq); - for (WxRentContract w : contractList0) { - List shopids0 = w.shopIdsByRentInfo(); - if (null != shopids0) { - shopIdList.removeAll(shopids0); - } - } - } - - //释放店铺 -// if (null != shopIdList && shopIdList.size() > 0) { -// wxMerchantShopMapper.delShops(mid, shopIdList); -// //更新商铺的状态为未出租 -// wxShopMapper.updateUnRentByIds(shopIdList); -// } - }catch(Exception e) { - logger.error("merchantId["+mid+"] outDateContract error.",e); } - + }catch(Exception e) { + logger.error("outDateContract error.",e); } } @@ -1893,52 +1985,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { return wxRentContractMapper.selectById(id); } - @Override - public boolean hasOtherValidContractShop(WxRentContract wxRentContract) { - WxRentContract wrc = new WxRentContract(); - wrc.setMerchantId(wxRentContract.getMerchantId()); - wrc.setStatuss(EnumRentContractStatus.getValidStatus()); - List contractList = wxRentContractMapper.findList(wrc); - boolean exists =false; - for (WxRentContract wc : contractList) { - if (null != wxRentContract.shopIdsByRentInfo()) { - for (Long sid : wxRentContract.shopIdsByRentInfo()) { - if(wc.getRentInfo().indexOf(String.valueOf(sid)) != -1 ) { - exists = true; - break; - } - } - } - } - return exists; - } - - @Override - public Map findRentByShop(Long shopId) { - List> rentByShop = wxRentContractMapper.findRentByShop(shopId); - if(rentByShop != null && rentByShop.size() > 0){ - return rentByShop.get(0); - } - return null; - } - - @Override - public Map currentValidByMerchantId(TenantEntity tenantInfo, Long merchantId,String shopNumber) { - WxRentContract rentContract = new WxRentContract(); - rentContract.updateTenantInfo(tenantInfo); - rentContract.setMerchantId(merchantId); - rentContract.setShopNumber(shopNumber); - List statuss = new ArrayList<>(); - statuss.add(EnumRentContractStatus.READY_FOR_PAING.getCode()); - statuss.add(EnumRentContractStatus.PAING.getCode()); - rentContract.setStatuss(statuss); - List> rentContracts = wxRentContractMapper.currentValidByMerchantId(rentContract); - if(rentContracts != null && rentContracts.size() > 0){ - return rentContracts.get(0); - } - return null; - } - @Override public long findCount(WxRentContract wxRentContract) { TenantEntity tenantEntity = new TenantEntity(); @@ -2705,7 +2751,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { return vo; } - private WxAllBill generateManageBill(WxRentContract rentcontract,WxAllBill rentBill,String total,String rate,EnumBillAllType type,EnumBillExtraCreateFrom createFrom) { + @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) + public WxAllBill generateManageBill(WxRentContract rentcontract,WxAllBill rentBill,String total,String rate,EnumBillAllType type,EnumBillExtraCreateFrom createFrom) { //商业管理费,营运管理费应收改为0,因为金额已经合并了 WxAllBill bussinessmanageBill = new WxAllBill(); bussinessmanageBill.updateTenantInfo(rentcontract); @@ -2717,43 +2764,75 @@ public class WxRentContractServiceImpl implements WxRentContractService { bussinessmanageBill.setEndtimeEqual(rentBill.getEndtime()); List bmbillList = wxAllBillMapper.findList(bussinessmanageBill); WxAllBill bmbill = null; + Map shopAreaRateMap = rentcontract.getRentShopAreaRate(); + List shopIdList = rentcontract.shopIdsByRentInfo(); String bussinessmoney = new BigDecimal(total).multiply(new BigDecimal(rate)).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString(); if (null != bmbillList && bmbillList.size() > 0 ) { - bmbill = bmbillList.get(0); + //查询每一个铺位的 + for (int i = 0 ; i < bmbillList.size() ; i ++) { + WxAllBill b = bmbillList.get(i); + Long sid = b.getShopId(); + BigDecimal shoprate = shopAreaRateMap.get(sid); + String oldmoney = b.getNeedPay(); + String newmoney = new BigDecimal(bussinessmoney).multiply(shoprate).setScale(rentcontract.getDecimalSize()).toPlainString(); + b.setMoneyChangeDetail("原合同商业管理费金额:"+bmbill.getNeedPay()+"元,总计分摊比率为:"+rate+",计算调整为:"+bussinessmoney+"元。本铺分摊:"+newmoney+"元"); + b.setReceivePay(newmoney); + b.setNeedPay(newmoney); + b.setBillRemark(createFrom.getMessage()+",自动计算。"+"原合同商业管理费金额:"+oldmoney+"元,总计分摊比率为:"+rate+",计算调整为:"+bussinessmoney+"元。本铺分摊:"+newmoney+"元"); + b.setUpdatetime(new Date()); + wxAllBillMapper.updateById(b); + } + + bmbill = new WxAllBill(); + try { + BeanUtils.copyProperties(bmbill, bmbillList.get(0)); + } catch (IllegalAccessException | InvocationTargetException e) { + logger.error("generateManageBill error.",e); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单错误"); + } bmbill.setMoneyChangeDetail("原合同商业管理费金额:"+bmbill.getNeedPay()+"元,总计分摊比率为:"+rate+",计算调整为:"+bussinessmoney+"元。"); bmbill.setReceivePay(bussinessmoney); bmbill.setBillRemark(createFrom.getMessage()+",自动计算。"+"原合同商业管理费金额:"+bmbill.getNeedPay()+"元,总计分摊比率为:"+rate+",计算调整为:"+bussinessmoney+"元。"); - if (new BigDecimal(bmbill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) { - //bmbill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); - }else { - //bmbill.setStatus(EnumBillStatus.PAID.getCode()); - } - bmbill.setUpdatetime(new Date()); - wxAllBillMapper.updateById(bmbill); }else { if (new BigDecimal(bussinessmoney).compareTo(new BigDecimal(0)) > 0 ) { - bmbill = new WxAllBill(); - final IdWorker idWorker = IdWorker.get(); - bmbill.setId(idWorker.nextId()); - bmbill.updateTenantInfo(rentcontract); - bmbill.setBillType(type.getCode()); - bmbill.setEnergyFeesId(type.getEnergyFeesId()); - bmbill.setRentContractId(rentcontract.getId()); - bmbill.setIsPreview(EnumYesOrNo.NO.getCode()); - bmbill.setCanEdit(EnumYesOrNo.NO.getCode()); - bmbill.setMerchantId(rentcontract.getMerchantId()); - bmbill.setCreatetime(new Date()); - bmbill.setUpdatetime(new Date()); - bmbill.setPriceDetail(""); - bmbill.setNeedPay(bussinessmoney); - bmbill.setReceivePay(bussinessmoney); - bmbill.setPay("0"); - bmbill.setStarttime(rentBill.getStarttime()); - bmbill.setEndtime(rentBill.getEndtime()); - bmbill.setBillRemark(createFrom.getMessage()+",自动计算创建,总计分摊比率为:"+rate); - bmbill.setExtraCreateFrom(createFrom.getCode()); - bmbill.setMoneyChangeDetail("自动计算创建,总计分摊比率为:"+rate+",应收金额为:"+bussinessmoney+"元,"); - wxAllBillMapper.insert(bmbill); + for (int i = 0 ; i < shopIdList.size(); i++) { + Long sid = shopIdList.get(i); + BigDecimal shoprate = shopAreaRateMap.get(sid); + String newmoney = new BigDecimal(bussinessmoney).multiply(shoprate).setScale(rentcontract.getDecimalSize()).toPlainString(); + WxAllBill b = new WxAllBill(); + final IdWorker idWorker = IdWorker.get(); + b.setId(idWorker.nextId()); + b.updateTenantInfo(rentcontract); + b.setBillType(type.getCode()); + b.setEnergyFeesId(type.getEnergyFeesId()); + b.setRentContractId(rentcontract.getId()); + b.setIsPreview(EnumYesOrNo.NO.getCode()); + b.setCanEdit(EnumYesOrNo.NO.getCode()); + b.setShopId(sid); + b.setCreatetime(new Date()); + b.setUpdatetime(new Date()); + b.setPriceDetail(""); + b.setNeedPay(newmoney); + b.setReceivePay(newmoney); + b.setPay("0"); + b.setStarttime(rentBill.getStarttime()); + b.setEndtime(rentBill.getEndtime()); + b.setBillRemark(createFrom.getMessage()+",自动计算创建,总计分摊比率为:"+rate+",本铺分摊:"+newmoney+"元"); + b.setExtraCreateFrom(createFrom.getCode()); + b.setMoneyChangeDetail("自动计算创建,总计分摊比率为:"+rate+",应收金额为:"+bussinessmoney+"元,"); + wxAllBillMapper.insert(bmbill); + if (null == bmbill) { + bmbill = new WxAllBill(); + try { + BeanUtils.copyProperties(bmbill, b); + } catch (IllegalAccessException | InvocationTargetException e) { + logger.error("generateManageBill error.",e); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单错误"); + } + bmbill.setBillRemark(createFrom.getMessage()+",自动计算创建,总计分摊比率为:"+rate); + bmbill.setReceivePay(bussinessmoney); + } + } }else { return null; } @@ -2762,74 +2841,75 @@ public class WxRentContractServiceImpl implements WxRentContractService { } private WxAllBill generatePropertyBill(WxRentContract rentcontract,Long propertyContractId,WxAllBill rentBill,WxAllBill propertyBill,String total,String rate,EnumBillExtraCreateFrom createFrom) { - String bussinessmoney = new BigDecimal(total).multiply(new BigDecimal(rate)).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString(); - if (null != propertyBill ) { - propertyBill.setMoneyChangeDetail("原合同商业管理费金额:"+propertyBill.getNeedPay()+"元,总计分摊比率为:"+rate+",计算调整为:"+bussinessmoney+"元。"); - propertyBill.setReceivePay(bussinessmoney); - propertyBill.setBillRemark(createFrom.getMessage()+",自动计算"+"原合同商业管理费金额:"+propertyBill.getNeedPay()+"元,总计分摊比率为:"+rate+",计算调整为:"+bussinessmoney+"元。"); - if (new BigDecimal(propertyBill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) { - //propertyBill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); - }else { - //bmbill.setStatus(EnumBillStatus.PAID.getCode()); - } - propertyBill.setUpdatetime(new Date()); - wxAllBillMapper.updateById(propertyBill); - return propertyBill; - }else { - if (new BigDecimal(bussinessmoney).compareTo(new BigDecimal(0)) > 0 ) { - WxAllBill bmbill = new WxAllBill(); - final IdWorker idWorker = IdWorker.get(); - bmbill.setId(idWorker.nextId()); - bmbill.updateTenantInfo(rentcontract); - bmbill.setBillType(EnumBillAllType.PROPERTY.getCode()); - bmbill.setEnergyFeesId(EnumBillAllType.PROPERTY.getEnergyFeesId()); - bmbill.setRentContractId(rentcontract.getId()); - bmbill.setPropertyContractId(propertyContractId); - bmbill.setIsPreview(EnumYesOrNo.NO.getCode()); - bmbill.setCanEdit(EnumYesOrNo.NO.getCode()); - bmbill.setMerchantId(rentcontract.getMerchantId()); - bmbill.setCreatetime(new Date()); - bmbill.setUpdatetime(new Date()); - bmbill.setPriceDetail(""); - bmbill.setNeedPay(bussinessmoney); - bmbill.setReceivePay(bussinessmoney); - bmbill.setPay("0"); - bmbill.setStarttime(rentBill.getStarttime()); - bmbill.setEndtime(rentBill.getEndtime()); - bmbill.setBillRemark(createFrom.getMessage()+",自动计算创建,总计分摊比率为:"+rate); - bmbill.setExtraCreateFrom(createFrom.getCode()); - bmbill.setMoneyChangeDetail("自动计算创建,总计分摊比率为:"+rate+",应收金额为:"+bussinessmoney+"元,"); - wxAllBillMapper.insert(bmbill); - return bmbill; - } - return null; - } +// String bussinessmoney = new BigDecimal(total).multiply(new BigDecimal(rate)).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString(); +// if (null != propertyBill ) { +// propertyBill.setMoneyChangeDetail("原合同商业管理费金额:"+propertyBill.getNeedPay()+"元,总计分摊比率为:"+rate+",计算调整为:"+bussinessmoney+"元。"); +// propertyBill.setReceivePay(bussinessmoney); +// propertyBill.setBillRemark(createFrom.getMessage()+",自动计算"+"原合同商业管理费金额:"+propertyBill.getNeedPay()+"元,总计分摊比率为:"+rate+",计算调整为:"+bussinessmoney+"元。"); +// if (new BigDecimal(propertyBill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) { +// //propertyBill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); +// }else { +// //bmbill.setStatus(EnumBillStatus.PAID.getCode()); +// } +// propertyBill.setUpdatetime(new Date()); +// wxAllBillMapper.updateById(propertyBill); +// return propertyBill; +// }else { +// if (new BigDecimal(bussinessmoney).compareTo(new BigDecimal(0)) > 0 ) { +// WxAllBill bmbill = new WxAllBill(); +// final IdWorker idWorker = IdWorker.get(); +// bmbill.setId(idWorker.nextId()); +// bmbill.updateTenantInfo(rentcontract); +// bmbill.setBillType(EnumBillAllType.PROPERTY.getCode()); +// bmbill.setEnergyFeesId(EnumBillAllType.PROPERTY.getEnergyFeesId()); +// bmbill.setRentContractId(rentcontract.getId()); +// bmbill.setPropertyContractId(propertyContractId); +// bmbill.setIsPreview(EnumYesOrNo.NO.getCode()); +// bmbill.setCanEdit(EnumYesOrNo.NO.getCode()); +// bmbill.setMerchantId(rentcontract.getMerchantId()); +// bmbill.setCreatetime(new Date()); +// bmbill.setUpdatetime(new Date()); +// bmbill.setPriceDetail(""); +// bmbill.setNeedPay(bussinessmoney); +// bmbill.setReceivePay(bussinessmoney); +// bmbill.setPay("0"); +// bmbill.setStarttime(rentBill.getStarttime()); +// bmbill.setEndtime(rentBill.getEndtime()); +// bmbill.setBillRemark(createFrom.getMessage()+",自动计算创建,总计分摊比率为:"+rate); +// bmbill.setExtraCreateFrom(createFrom.getCode()); +// bmbill.setMoneyChangeDetail("自动计算创建,总计分摊比率为:"+rate+",应收金额为:"+bussinessmoney+"元,"); +// wxAllBillMapper.insert(bmbill); +// return bmbill; +// } +// return null; +// } + return null; } private WxAllBill generateRentBill(WxRentContract rentcontract,String money,String rate,Date starttime,Date endtime,EnumBillExtraCreateFrom createFrom) { WxAllBill bmbill = new WxAllBill(); - final IdWorker idWorker = IdWorker.get(); - bmbill.setId(idWorker.nextId()); - bmbill.updateTenantInfo(rentcontract); - bmbill.setBillType(EnumBillAllType.RENT.getCode()); - bmbill.setEnergyFeesId(EnumBillAllType.RENT.getEnergyFeesId()); - bmbill.setRentContractId(rentcontract.getId()); - bmbill.setIsPreview(EnumYesOrNo.NO.getCode()); - bmbill.setCanEdit(EnumYesOrNo.NO.getCode()); - bmbill.setMerchantId(rentcontract.getMerchantId()); - bmbill.setCreatetime(new Date()); - bmbill.setUpdatetime(new Date()); - bmbill.setPriceDetail(""); - bmbill.setNeedPay(money); - bmbill.setReceivePay(money); - bmbill.setPay("0"); - bmbill.setStarttime(starttime); - bmbill.setEndtime(endtime); - bmbill.setBillRemark(createFrom.getMessage()+",自动计算创建,分摊比例为"+rate); - bmbill.setExtraCreateFrom(createFrom.getCode()); - bmbill.setMoneyChangeDetail("自动计算创建,分摊比例为"+rate+",计算应收金额为:"+money+"元,"); - wxAllBillMapper.insert(bmbill); +// final IdWorker idWorker = IdWorker.get(); +// bmbill.setId(idWorker.nextId()); +// bmbill.updateTenantInfo(rentcontract); +// bmbill.setBillType(EnumBillAllType.RENT.getCode()); +// bmbill.setEnergyFeesId(EnumBillAllType.RENT.getEnergyFeesId()); +// bmbill.setRentContractId(rentcontract.getId()); +// bmbill.setIsPreview(EnumYesOrNo.NO.getCode()); +// bmbill.setCanEdit(EnumYesOrNo.NO.getCode()); +// bmbill.setMerchantId(rentcontract.getMerchantId()); +// bmbill.setCreatetime(new Date()); +// bmbill.setUpdatetime(new Date()); +// bmbill.setPriceDetail(""); +// bmbill.setNeedPay(money); +// bmbill.setReceivePay(money); +// bmbill.setPay("0"); +// bmbill.setStarttime(starttime); +// bmbill.setEndtime(endtime); +// bmbill.setBillRemark(createFrom.getMessage()+",自动计算创建,分摊比例为"+rate); +// bmbill.setExtraCreateFrom(createFrom.getCode()); +// bmbill.setMoneyChangeDetail("自动计算创建,分摊比例为"+rate+",计算应收金额为:"+money+"元,"); +// wxAllBillMapper.insert(bmbill); return bmbill; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java index 8a47f2109..d6818c7a2 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java @@ -50,6 +50,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.Serializable; import java.lang.reflect.InvocationTargetException; +import java.math.BigDecimal; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -629,21 +630,6 @@ public class WxShopServiceImpl implements WxShopService { map.put("merchantName", merchant.getName()); map.put("linkPerson", merchant.getLinkPerson()); map.put("linkPhone", merchant.getLinkPhone()); - - WxRentContract rentContractQ = new WxRentContract(); - rentContractQ.updateTenantInfo(tenantEntity); - rentContractQ.setMerchantId(merchant.getId()); - List rentList = wxRentContractMapper.findList(rentContractQ); - if (null != rentList && rentList.size() > 0 ) { - WxRentContract rc = rentList.get(0); - map.put("price", rc.getPrice()); - map.put("receivePeriod", rc.getReceivePeriod()); - EnumContractReceivePeriodUnit pu = EnumContractReceivePeriodUnit.getEnum(rc.getReceivePeriodUnit()); - if (null != pu) { - map.put("receivePeriodUnit", pu.getMessage()); - } - - } } } } @@ -1126,30 +1112,40 @@ public class WxShopServiceImpl implements WxShopService { } @Override - public String getRentName(WxMerchant merchant) { - if (merchant.getIsPrivate() == EnumYesOrNo.NO.getCode()) { - return merchant.getName(); - }else { - if (StringUtils.isBlank(merchant.getCreateShopNumber())) { - return merchant.getName(); - } - WxShop shop = this.getShopByShopNumber(merchant, merchant.getCreateShopNumber()) ; - if (null != shop ) { - //查询租户和业主 - WxShopUsers suq = new WxShopUsers(); - suq.updateTenantInfo(merchant); - suq.setShopId(shop.getId()); - suq.setStatus(EnumShopUsersStatus.LIVE.getCode()); - suq.setSortColumns("type desc"); - WxShopUsers wsu = this.getOneShopUsers(suq); - if (null != wsu) { - return wsu.getName(); - }else { - return merchant.getName(); + public List getUserShopIds(WxShopUsers wxShopUsers) { + return wxShopUsersMapper.findShopIdList(wxShopUsers); + } + + @Override + public Map getShopUserMap(WxShopUsers wxShopUsers) { + wxShopUsers.setSortColumn(" status asc, type desc"); + List list = wxShopUsersMapper.findList(wxShopUsers); + if (null == list || list.size() <= 0 ) { + return null; + } + Map retMap = new HashMap(); + for (int i = 0 ; i < list.size(); i++) { + WxShopUsers su = list.get(i); + if (null != su.getShopId()) { + if (!retMap.containsKey(su.getShopId())) { + retMap.put(su.getShopId(), su); } - }else { - return merchant.getName(); } } + return retMap; + } + + @Override + public WxShopUsers getCurrentShopUser(TenantEntity tenantEntity, Long shopId) { + WxShopUsers suq = new WxShopUsers(); + suq.updateTenantInfo(tenantEntity); + suq.setShopId(shopId); + suq.setStatus(EnumShopUsersStatus.LIVE.getCode()); + suq.setSortColumn("type desc"); + List list = wxShopUsersMapper.findList(suq); + if (null == list || list.size() <= 0 ) { + return null; + }; + return list.get(0); } } diff --git a/mallinkService/src/main/java/com/iformall/utils/Constant.java b/mallinkService/src/main/java/com/iformall/utils/Constant.java index 2a07ed0fd..de0c892c0 100644 --- a/mallinkService/src/main/java/com/iformall/utils/Constant.java +++ b/mallinkService/src/main/java/com/iformall/utils/Constant.java @@ -49,6 +49,7 @@ public class Constant { public static final String TOKEN_WXC_END = ":wx-cuser"; public static final String TOKEN_TTC_END = ":tt-cuser"; public static final String TOKEN_ADMIN_END = ":admin-user"; + public static final String TOKEN_SHOP_USER_END = ":shop-user"; public static final String cuserQr = "weapp:cuser-qr:"; @@ -63,6 +64,7 @@ public class Constant { public static final String PARENT_TENANT_ID = "PARENT_TENANT_ID"; public static final String REQUEST_C_USER_KEY = "REQUEST_C_USER"; public static final String REQUEST_MALL_USER_KEY = "REQUEST_MALL_USER"; + public static final String REQUEST_SHOP_USER_KEY = "REQUEST_SHOP_USER"; public static final String APP_Id = "APP_Id"; public static final String APP_NAME = "APP_NAME"; diff --git a/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml b/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml index fb4195341..770158147 100644 --- a/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml @@ -5,7 +5,8 @@ - + + @@ -34,8 +35,6 @@ - - @@ -51,7 +50,7 @@ - `id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,`createtime`,`create_by`,`create_by_name`,`updatetime`,`update_by`,`update_by_name`, + `id`,`tenant_id`,`parent_tenant_id`,`createtime`,`create_by`,`create_by_name`,`updatetime`,`update_by`,`update_by_name`, `price_detail`,`need_pay`,`receive_pay`,`pay`,`bill_type`,`pay_way`,`pay_date`,`set_off`,`use_money`,`starttime`,`endtime`,`status`,`energy_fees_id`,`return_pay`, `bill_remark`,`last_owe_call_time`,`last_owe_call_user`,`bussiness_manage_fee_need_pay`,`operating_manage_fee_need_pay`,`shop_id`,`shop_number`,`receive_date`,`period`, `is_preview`,`shop_info`,`rent_contract_id`,`rent_contract_agile_fees_type`,`property_contract_id`,`parent_bill_id`,`energy_reading_calcuteId`,`energy_reading_id`,`extra_create_from`,`rent_area`, @@ -62,7 +61,6 @@ where `tenant_id` = #{tenantId} and `id` = #{id} and `parent_tenant_id` = #{parentTenantId} - and `merchant_id` = #{merchantId} and `create_by` = #{createBy} and `create_by_name` like concat('%',#{createByName},'%') and `bill_type` = #{billType} @@ -130,7 +128,6 @@ (`last_owe_call_time` is not null and `receive_pay` - `pay`- IFNULL(`set_off`,'0') > 0 and bill_type in (13,21,5,7)) ) - and `merchant_id` is not null and `parent_bill_id` is not null and `parent_bill_id` is null and `energy_reading_calcuteId` = #{energyReadingCalcuteId} @@ -153,12 +150,6 @@ #{pidItem} - - and `merchant_id` in - - #{midItem} - - and `status` in @@ -190,6 +181,12 @@ + + - - @@ -275,10 +267,10 @@ - + @@ -315,10 +307,6 @@ and property_contract_id = #{propertyContractId} - - and merchant_id = #{merchantId} - - @@ -362,7 +350,7 @@ VALUES ( - #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.merchantId},#{item.createtime}, + #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.createtime}, #{item.createBy},#{item.createByName},#{item.updatetime},#{item.updateBy},#{item.updateByName},#{item.priceDetail}, #{item.needPay},#{item.receivePay},#{item.pay},#{item.billType},#{item.payWay},#{item.payDate},#{item.setOff},#{item.useMoney}, #{item.starttime},#{item.endtime},#{item.status},#{item.energyFeesId},#{item.returnPay},#{item.billRemark}, diff --git a/mallinkService/src/main/resources/mapper/WxContractCustomersMapper.xml b/mallinkService/src/main/resources/mapper/WxContractCustomersMapper.xml new file mode 100644 index 000000000..585204cc9 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxContractCustomersMapper.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`parent_tenant_id`,`principal_type`,`name`,`phone`,`legal_person`,`id_number`,`sex`, + `link_person`,`create_date`,`update_date`,`status` + + + + where 1=1 + + + and `id` = #{id} + + + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + + + and `principal_type` = #{principalType} + + + + and `name` like concat('%', #{name},'%') + + + + and `name` = #{nameEqal} + + + + and `phone` like concat('%', #{phone},'%') + + + + and `phone` = #{phoneEqal} + + + + and `status` = #{status} + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxContractShopMapper.xml b/mallinkService/src/main/resources/mapper/WxContractShopMapper.xml new file mode 100644 index 000000000..962bfe571 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxContractShopMapper.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + `id`,`tenant_id`,`parent_tenant_id`,`contract_id`,`shop_id`,`create_date`,`update_date` + + + + where 1=1 + + + and `id` = #{id} + + + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + + + and `contract_id` = #{contractId} + + + + and `shop_id` = #{shopId} + + + + and shop_id in + + #{sidItem} + + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + delete from wx_contract_shop + + + diff --git a/mallinkService/src/main/resources/mapper/WxRentContractAgileDepositMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractAgileDepositMapper.xml index c0a323fe2..b9cdf6b2e 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractAgileDepositMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractAgileDepositMapper.xml @@ -8,13 +8,12 @@ - - `id`,`tenant_id`,`parent_tenant_id`,`createtime`,`updatetime`,`rent_contract_id`,`merchant_id`,`fees_id`,`price` + `id`,`tenant_id`,`parent_tenant_id`,`createtime`,`updatetime`,`rent_contract_id`,`fees_id`,`price` @@ -27,7 +26,6 @@ and `parent_tenant_id` = #{parentTenantId} and `rent_contract_id` = #{rentContractId} - and `merchant_id` = #{merchantId} and `fees_id` = #{feesId} and id in diff --git a/mallinkService/src/main/resources/mapper/WxRentContractAgileUnDepositItemMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractAgileUnDepositItemMapper.xml index 3a5cab1b5..265d5bc1f 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractAgileUnDepositItemMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractAgileUnDepositItemMapper.xml @@ -7,7 +7,6 @@ - @@ -23,7 +22,7 @@ - `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`un_deposit_id`,`merchant_id`,`shop_id`,`shop_number`, + `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`un_deposit_id`,`shop_id`,`shop_number`, `fees_id`,`begin_time`,`end_time`,`price`,`price_unit`,`createtime`,`updatetime`,`is_free`,`rent_area`,`is_father` @@ -37,7 +36,6 @@ and `parent_tenant_id` = #{parentTenantId} and `rent_contract_id` = #{rentContractId} - and `merchant_id` = #{merchantId} and `fees_id` = #{feesId} and `un_deposit_id` = #{unDepositId} and `is_father` = #{isFather} diff --git a/mallinkService/src/main/resources/mapper/WxRentContractAgileUnDepositMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractAgileUnDepositMapper.xml index e97345ce9..d3a8ea0af 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractAgileUnDepositMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractAgileUnDepositMapper.xml @@ -6,7 +6,6 @@ - @@ -18,7 +17,7 @@ - `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`merchant_id`,`setting_method`,`fees_id`,`price`,`price_unit`, + `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`setting_method`,`fees_id`,`price`,`price_unit`, `time_period`,`time_unit`,`calcute_time`,`fees_create_rule`,`createtime`,`updatetime` @@ -32,7 +31,6 @@ and `parent_tenant_id` = #{parentTenantId} and `rent_contract_id` = #{rentContractId} - and `merchant_id` = #{merchantId} and `fees_id` = #{feesId} and id in diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 5701a68ae..353606c22 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -3,17 +3,10 @@ - - - - - - - - - - - + + + + @@ -22,47 +15,23 @@ - - - + + - - - - - - - - - - - - - - - - - - - - - - - @@ -84,40 +53,23 @@ - - - - - - - - - - - - - - - - - @@ -128,23 +80,18 @@ - - - - `id`,`merchant_id`,`is_private_merchant`,`private_rent_shop_type`,`agile_type`, - `shop_type_sub`,`lease_purpose`,`contractual_rules`,`delivery_date`,`delivery_grace_period`,`opening_date`,`business_hours`,`scope_metre`, + `id`,`agile_type`,`customers_id`,`tenant_id`,`parent_tenant_id`, `decimal_size`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`,`receive_period_unit`, - `tenant_id`,`parent_tenant_id`,`filepath`,`status`,`contract_number`,`price_detail`,`create_by`,`update_by`, - `first_party_bank_info`,`second_party_bank_info`,`second_party_tax_info`,`day_price_calcute`,`first_bill_date_start`,`first_bill_date_end`, - `property_name`,`property_fee`,`fee_cycle`,`water_fee`,`electricity_fees`,`month_average_days`,`free_period_remark`, - `deposit`,cashtype_content_lsit,cashtype_lsit,`pay_date`,`is_del`,`merchant_name`,`revenue_jumps_remark`, - `brand`,`business_id`,`shop_type`,`shop_type_str`,`updatetime`,`createtime`,`link_person`,`link_phone`,`link_address`, + `filepath`,`status`,`contract_number`,`price_detail`,`create_by`,`update_by`, + `day_price_calcute`,`first_bill_date_start`,`first_bill_date_end`,`month_average_days`,`free_period_remark`, + `deposit`,cashtype_content_lsit,cashtype_lsit,`is_del`,`revenue_jumps_remark`, + `updatetime`,`createtime`,`link_person`,`link_phone`,`link_address`, `pay_account`,`filename`,`lease`,`type`,`revenue`,`revenue_ratio`,`revenue_ratio_way`,`revenue_ratio_set`,`adjust_ratio`,`adjust_period`,`pay_ratio`, `start_date`,`end_date`,`shop_name`,`from_id`,`end_contract_time`,`revenue_fixed_rent_price`,`revenue_rent_price`, `apply_status`,`bank_name`,`fix_start_date`,`fix_end_date`,`pay_period_rate`,`create_by_name`,`update_by_name`, @@ -159,10 +106,8 @@ where 1 = 1 and `id` = #{id} and `from_id` = #{fromId} - and `merchant_id` = #{merchantId} - and `is_private_merchant` = #{isPrivateMerchant} - and `private_rent_shop_type` = #{privateRentShopType} and `agile_type` = #{agileType} + and `customers_id` = #{customersId} and `price` = #{price} and `rental_start_date` = #{rentalStartDate} and `rental_end_date` = #{rentalEndDate} @@ -182,12 +127,7 @@ and `apply_status` = #{applyStatus} and `contract_number` = #{contractNumber} and `deposit` = #{deposit} - and `pay_date` = #{payDate} and `is_del` = #{isDel} - and `merchant_name` like concat('%', #{merchantName},'%') - and `brand` = #{brand} - and `business_id` = #{businessId} - and `shop_type` = #{shopType} and `updatetime` = #{updatetime} and `createtime` = #{createtime} and `link_person` = #{linkPerson} @@ -210,24 +150,6 @@ and concat(',',shop_name,',') like concat('%,',#{queryShopNumber},',%') - - and business_id in (${businessForRule}) - - - - and private_rent_shop_type in - - #{pmItem} - - - - - and merchant_id in - - #{mItem} - - - and status in @@ -280,27 +202,11 @@ update wx_rent_contract set status=#{status} where id=#{id} - - - - - - - - - select rc.id,rc.tenant_id,rc.parent_tenant_id,rc.id as rent_id, pc.id as property_id, rc.merchant_name,rc.rental_start_date,rc.rental_end_date,rc.`status`, + select rc.id,rc.tenant_id,rc.parent_tenant_id,rc.id as rent_id, pc.id as property_id, rc.rental_start_date,rc.rental_end_date,rc.`status`, rc.price as rent_price,rc.contract_number,rc.shop_name,rc.type,rc.apply_status,rc.price_detail,rc.revenue_fixed_rent_price,rc.revenue_rent_price, - rc.rent_info,pc.price as property_price,rc.merchant_id,pc.`status` as property_status, + rc.rent_info,pc.price as property_price,pc.`status` as property_status, rc.price_unit as rent_price_unit,pc.price_unit as property_price_unit,rc.day_price_calcute,rc.free_period_remark, rc.business_type businessType,rc.month_average_days,rc.revenue_jumps_remark,rc.first_bill_date_start,rc.first_bill_date_end from wx_rent_contract rc left join wx_property_contract pc on rc.id=pc.rent_contract_id @@ -413,20 +297,15 @@ and rc.`contract_number` = #{contractNumber} - and rc.`is_private_merchant` = #{isPrivateMerchant} and rc.`id` = #{rentId} and pc.`id` = #{propertyId} - and rc.`merchant_name` like - concat('%',#{merchantName},'%') - and (json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%') or rc.shop_name like concat('%',#{shopNumber},'%') ) - and rc.`merchant_id` = #{merchantId} and concat(',',rc.shop_name,',') like concat('%,',#{queryShopNumber},',%') @@ -445,12 +324,6 @@ and rc.business_id in (${businessForRule}) - - and rc.merchant_id in - - #{mItem} - - order by ${sortColumns} order by rc.createtime desc,rc.id desc @@ -467,95 +340,10 @@ select max(json_length(rent_info)) from wx_rent_contract - - - - - - - - - +