From da9c0783b82e7a8c715478a441a5bf97a00637b2 Mon Sep 17 00:00:00 2001 From: winter <664946893@qq.com> Date: Thu, 21 Nov 2024 15:11:10 +0800 Subject: [PATCH] fix --- .../iformall/domain/po/WxShopUsersInfo.java | 3 + .../com/iformall/mapper/WxAllBillMapper.java | 2 + .../iformall/mapper/WxShopUsersMapper.java | 2 + .../com/iformall/service/WxShopService.java | 9 ++ .../impl/WxAgileContractServiceImpl.java | 30 ++++--- .../impl/WxPropertyContractServiceImpl.java | 87 ++++++++++++++++++- .../impl/WxRentContractServiceImpl.java | 82 ++++++++++++++++- .../service/impl/WxShopServiceImpl.java | 35 ++++++++ .../main/resources/mapper/WxAllBillMapper.xml | 10 +++ .../mapper/WxShopUsersInfoMapper.xml | 7 +- .../resources/mapper/WxShopUsersMapper.xml | 6 +- 11 files changed, 251 insertions(+), 22 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxShopUsersInfo.java b/mallinkService/src/main/java/com/iformall/domain/po/WxShopUsersInfo.java index 30ed085c3..a9d297061 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxShopUsersInfo.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxShopUsersInfo.java @@ -73,6 +73,9 @@ public class WxShopUsersInfo extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") private Date updateDate; + @io.swagger.annotations.ApiModelProperty(value = "创建的合同客户编号", name = "createContractCustomerId") + private Long createContractCustomerId; + @TableField(exist = false) private String phoneEqual; @TableField(exist = false) diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java index ea171f8cf..49a19228f 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java @@ -48,5 +48,7 @@ public interface WxAllBillMapper extends CommonMapper { void deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); void deleteEnergyReadingBills(@Param("energyReadingCalcuteId")Long energyReadingCalcuteId,@Param("tenantId")String tenantId); + + void updateContractCusName(WxAllBill wxBillRent); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxShopUsersMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxShopUsersMapper.java index a8901ed92..8a2ab0d71 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxShopUsersMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxShopUsersMapper.java @@ -11,4 +11,6 @@ public interface WxShopUsersMapper extends CommonMapper { List findList(WxShopUsers wxShop); List findShopIdList(WxShopUsers wxShop); + + void updateShopOld(WxShopUsers wxShop); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxShopService.java b/mallinkService/src/main/java/com/iformall/service/WxShopService.java index df0f35ff2..727fe5fb3 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxShopService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxShopService.java @@ -129,10 +129,14 @@ public interface WxShopService { WxShopUsers getOneShopUsers(WxShopUsers wxShopUsersShop); + List getShopUsersList(WxShopUsers wxShopUsers); + void saveOrUpdateShopUsers(WxShopUsers wxShopUsers); void changeShopUsers(WxShopUsers wxShopUsers); + void updateRentShopUsersOld(TenantEntity tenantEntity,Long shopId); + void deleteShopUsers(WxShopUsers wxShopUsers); PageInfo shopUsersListAsPage(WxShopUsers record,Integer pageIndex,Integer pageSize); @@ -141,11 +145,16 @@ public interface WxShopService { PageInfo shopUsersInfoListAsPage(WxShopUsersInfo record,Integer pageIndex,Integer pageSize); + void saveOrUpdateShopUsersInfo(WxShopUsersInfo wxShopUsersInfo); + void saveOrUpdateShopUsersPerson(WxShopUsersPerson wxShopUsers); void deleteShopUsersPerson(WxShopUsersPerson wxShopUsers); + List getUserInfoList(WxShopUsersInfo wxShopUsersInfo); + List getUserInfoIds(WxShopUsersInfo wxShopUsersInfo); + List getUserShopIds(WxShopUsers wxShopUsers); Map getShopUserMap(WxShopUsers wxShopUsers); 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 3e5760688..140007d6a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java @@ -481,10 +481,12 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { Long sid = shopIdList.get(j); BigDecimal shoprentArea = shopAreaRateMap.get(sid); BigDecimal shoprate = shoprentArea.divide(new BigDecimal(wxRentContract.getRentArea()),wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); - WxShopUsers su = shopUserMap.get(sid); - String cusName = ""; - if (null != su) { - cusName = su.getName(); + String cusName = null; + if (null != shopUserMap) { + WxShopUsers su = shopUserMap.get(sid); + if (null != su) { + cusName = su.getName(); + } } WxAllBill wxBillDeposit = new WxAllBill(); @@ -607,10 +609,12 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { Long sid= shopIdList.get(i); BigDecimal shoprentArea = shopAreaMap.get(sid); BigDecimal shoprate = shoprentArea.divide(new BigDecimal(contract.getRentArea()),contract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); - WxShopUsers su = shopUserMap.get(sid); - String cusName = ""; - if (null != su) { - cusName = su.getName(); + String cusName = null; + if (null != shopUserMap) { + WxShopUsers su = shopUserMap.get(sid); + if (null != su) { + cusName = su.getName(); + } } String money = new BigDecimal(needpay).multiply(shoprate).toPlainString(); WxAllBill bill = buildUnDepositBill(unDeposit,idWorker,contract.getId(),fees,sid,cusName,start,end,receiveDate,money,shoprentArea.toPlainString(),user); @@ -618,10 +622,12 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { } }else { Long sid= item.getShopId(); - WxShopUsers su = shopUserMap.get(sid); - String cusName = ""; - if (null != su) { - cusName = su.getName(); + String cusName = null; + if (null != shopUserMap) { + WxShopUsers su = shopUserMap.get(sid); + if (null != su) { + cusName = su.getName(); + } } WxAllBill bill = buildUnDepositBill(unDeposit,idWorker,contract.getId(),fees,sid,cusName,start,end,receiveDate,needpay,item.getRentArea(),user); billList.add(bill); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java index a0668821f..11e7a885b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -542,6 +542,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService } @Override + @Transactional(rollbackFor = {Exception.class}) public ResultData updatePropertyContractStatus(Long id) { if (id == null) { return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); @@ -556,6 +557,19 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService wxPropertyContract.setStatus(EnumRentContractStatus.READY_FOR_PAING.getCode()); } wxPropertyContractMapper.updateById(wxPropertyContract); + + //合同客户状态变更 + WxContractCustomers customers = wxContractCustomersMapper.selectById(record.getCustomersId(), record.getTenantId()); + customers.setStatus(EnumContractCustomersStatus.FORMUL.getCode()); + customers.setUpdateDate(new Date()); + wxContractCustomersMapper.updateById(customers); + + //把customers写入到wxShopUser + String cusName = castCustomersToShopUsers(customers,record.shopIdsByShop()); + + //如果合同的账单cusName为空的话,则设置为customers name + handleContractBillCusName(record,cusName); + //建立账单 if (record.getReceivePeriod() != null && new BigDecimal(record.getPrice()).compareTo(new BigDecimal(0)) > 0) { //预览账单改为正式,并写入商户id @@ -563,6 +577,69 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService } return new ResultData(Result.SUCCESS, "操作成功"); } + + public String castCustomersToShopUsers(WxContractCustomers customers,List shopIdList) { + WxShopUsersInfo suiq = new WxShopUsersInfo(); + suiq.updateTenantInfo(customers); + suiq.setPrincipalType(customers.getPrincipalType()); + suiq.setName(customers.getName()); + suiq.setPhone(customers.getPhone()); + List ids = wxShopService.getUserInfoList(suiq); + Long infoId = null; + String cusName = null; + if (null == ids || ids.size() <= 0 ) { + WxShopUsersInfo sui = new WxShopUsersInfo(); + sui.updateTenantInfo(customers); + sui.setPrincipalType(customers.getPrincipalType()); + sui.setName(customers.getName()); + sui.setPhone(customers.getPhone()); + sui.setLegalPerson(customers.getLegalPerson()); + sui.setIdNumber(customers.getIdNumber()); + sui.setSex(customers.getSex()); + sui.setLinkPerson(customers.getLinkPerson()); + sui.setCreateContractCustomerId(customers.getId()); + wxShopService.saveOrUpdateShopUsersInfo(sui); + infoId = sui.getId(); + cusName = customers.getName(); + }else { + infoId = ids.get(0).getId(); + cusName = ids.get(0).getName(); + } + + for (int i = 0 ; i < shopIdList.size(); i++) { + Long shopId = shopIdList.get(i); + //查询这个infoId是不是当前的租户 + WxShopUsers suq = new WxShopUsers(); + suq.updateTenantInfo(customers); + suq.setShopId(shopId); + suq.setInfoId(infoId); + suq.setStatus(EnumShopUsersStatus.LIVE.getCode()); + List ulist = wxShopService.getShopUsersList(suq); + if (null != ulist && ulist.size() > 0 ) { + //WxShopUsers su = ulist.get(0); + }else { + //先把当前的租户变更掉 + wxShopService.updateRentShopUsersOld(customers,shopId); + //新增租户 + WxShopUsers su = new WxShopUsers(); + su.updateTenantInfo(customers); + su.setShopId(shopId); + su.setInfoId(infoId); + su.setType(EnumShopUsersType.RENTER.getCode()); + su.setStatus(EnumShopUsersStatus.LIVE.getCode()); + wxShopService.saveOrUpdateShopUsers(su); + } + } + return cusName; + } + + public void handleContractBillCusName(WxPropertyContract record,String cusName) { + WxAllBill bill = new WxAllBill(); + bill.updateTenantInfo(record); + bill.setCusName(cusName); + bill.setPropertyContractId(record.getId()); + wxAllBillMapper.updateContractCusName(bill); + } @Override public void updatePropertyPreviewBill(WxPropertyContract record) { @@ -601,10 +678,12 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService Long shopId = shopIds.get(i); BigDecimal shoprentArea = shopAreaRateMap.get(shopId); BigDecimal shoprate = shoprentArea.divide(new BigDecimal(wxPropertyContract.getRentArea()),wxPropertyContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); - WxShopUsers su = shopUserMap.get(shopId); - String cusName = ""; - if (null != su) { - cusName = su.getName(); + String cusName = null; + if (null != shopUserMap) { + WxShopUsers su = shopUserMap.get(shopId); + if (null != su) { + cusName = su.getName(); + } } WxAllBill wxBillDeposit = new WxAllBill(); 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 53da053e7..a482b5751 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -29,6 +29,7 @@ import com.iformall.domain.po.WxRentContractRevenueJump; import com.iformall.domain.po.WxRentContractRevenueSales; import com.iformall.domain.po.WxShop; import com.iformall.domain.po.WxShopUsers; +import com.iformall.domain.po.WxShopUsersInfo; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.BillTimeVo; import com.iformall.domain.vo.RatioVo; @@ -63,6 +64,7 @@ import com.iformall.enums.EnumRentDayPriceCalcute; import com.iformall.enums.EnumRentShopType; import com.iformall.enums.EnumRentStartType; import com.iformall.enums.EnumShopUsersStatus; +import com.iformall.enums.EnumShopUsersType; import com.iformall.enums.EnumTradeDailyDateType; import com.iformall.enums.EnumYesOrNo; import com.iformall.exception.MallinkException; @@ -931,10 +933,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { Long sid = shopIdList.get(i); BigDecimal shoprentArea = shopAreaRateMap.get(sid); BigDecimal shoprate = shoprentArea.divide(new BigDecimal(wxRentContract.getRentArea()),wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); - WxShopUsers su = shopUserMap.get(sid); - String cusName = ""; - if (null != su) { - cusName = su.getName(); + String cusName = null; + if (null != shopUserMap) { + WxShopUsers su = shopUserMap.get(sid); + if (null != su) { + cusName = su.getName(); + } } WxAllBill wxBillDeposit = new WxAllBill(); @@ -1796,6 +1800,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { } @Override + @Transactional(rollbackFor = {Exception.class}) public ResultData updateRentContractStatus(Long id,boolean buildProperyBill) { if (id == null) { return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); @@ -1827,6 +1832,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { customers.setUpdateDate(new Date()); wxContractCustomersMapper.updateById(customers); + //把customers写入到wxShopUser + String cusName = castCustomersToShopUsers(customers,record.shopIdsByRentInfo()); + + //如果合同的账单cusName为空的话,则设置为customers name + handleContractBillCusName(record,cusName); + //EventUtil.publistRentEvent(this, wxRentContract); //建立账单 //自定义账单无单价,为能生成账单,设置该值 @@ -1866,6 +1877,69 @@ public class WxRentContractServiceImpl implements WxRentContractService { return new ResultData(Result.SUCCESS, "操作成功"); } + + public String castCustomersToShopUsers(WxContractCustomers customers,List shopIdList) { + WxShopUsersInfo suiq = new WxShopUsersInfo(); + suiq.updateTenantInfo(customers); + suiq.setPrincipalType(customers.getPrincipalType()); + suiq.setName(customers.getName()); + suiq.setPhone(customers.getPhone()); + List ids = wxShopService.getUserInfoList(suiq); + Long infoId = null; + String cusName = null; + if (null == ids || ids.size() <= 0 ) { + WxShopUsersInfo sui = new WxShopUsersInfo(); + sui.updateTenantInfo(customers); + sui.setPrincipalType(customers.getPrincipalType()); + sui.setName(customers.getName()); + sui.setPhone(customers.getPhone()); + sui.setLegalPerson(customers.getLegalPerson()); + sui.setIdNumber(customers.getIdNumber()); + sui.setSex(customers.getSex()); + sui.setLinkPerson(customers.getLinkPerson()); + sui.setCreateContractCustomerId(customers.getId()); + wxShopService.saveOrUpdateShopUsersInfo(sui); + infoId = sui.getId(); + cusName = customers.getName(); + }else { + infoId = ids.get(0).getId(); + cusName = ids.get(0).getName(); + } + + for (int i = 0 ; i < shopIdList.size(); i++) { + Long shopId = shopIdList.get(i); + //查询这个infoId是不是当前的租户 + WxShopUsers suq = new WxShopUsers(); + suq.updateTenantInfo(customers); + suq.setShopId(shopId); + suq.setInfoId(infoId); + suq.setStatus(EnumShopUsersStatus.LIVE.getCode()); + List ulist = wxShopService.getShopUsersList(suq); + if (null != ulist && ulist.size() > 0 ) { + //WxShopUsers su = ulist.get(0); + }else { + //先把当前的租户变更掉 + wxShopService.updateRentShopUsersOld(customers,shopId); + //新增租户 + WxShopUsers su = new WxShopUsers(); + su.updateTenantInfo(customers); + su.setShopId(shopId); + su.setInfoId(infoId); + su.setType(EnumShopUsersType.RENTER.getCode()); + su.setStatus(EnumShopUsersStatus.LIVE.getCode()); + wxShopService.saveOrUpdateShopUsers(su); + } + } + return cusName; + } + + public void handleContractBillCusName(WxRentContract record,String cusName) { + WxAllBill bill = new WxAllBill(); + bill.updateTenantInfo(record); + bill.setCusName(cusName); + bill.setRentContractId(record.getId()); + wxAllBillMapper.updateContractCusName(bill); + } @Override public void updatePropertyPreviewBill(WxRentContract record) { 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 fb097b037..c3501392a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java @@ -999,6 +999,12 @@ public class WxShopServiceImpl implements WxShopService { return null; } + @Override + public List getShopUsersList(WxShopUsers wxShopUsers) { + List shopUserList = wxShopUsersMapper.findList(wxShopUsers); + return shopUserList; + } + private void setShopUserProperty(WxShopUsers sus) { WxShopUsersInfo su = wxShopUsersInfoMapper.selectById(sus.getInfoId()); if (null != su) { @@ -1067,6 +1073,15 @@ public class WxShopServiceImpl implements WxShopService { wxShopUsersMapper.updateById(wxShopUsers); } + @Override + public void updateRentShopUsersOld(TenantEntity tenantEntity,Long shopId) { + WxShopUsers wxShopUsers = new WxShopUsers(); + wxShopUsers.setShopId(shopId); + wxShopUsers.setUpdateDate(new Date()); + wxShopUsers.setType(EnumShopUsersType.RENTER.getCode()); + wxShopUsersMapper.updateShopOld(wxShopUsers); + } + @Override public void deleteShopUsers(WxShopUsers wxShopUsers) { wxShopUsersMapper.deleteById(wxShopUsers.getId()); @@ -1095,6 +1110,21 @@ public class WxShopServiceImpl implements WxShopService { PageInfo page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxShopUsersInfoMapper.findList(record)); return page; } + + @Override + public void saveOrUpdateShopUsersInfo(WxShopUsersInfo record) { + if (record.getId() == null) { + final IdWorker idWorker = IdWorker.get(); + record.setId(idWorker.nextId()); + Date date = new Date(); + record.setUpdateDate(date); + record.setCreateDate(date); + wxShopUsersInfoMapper.insert(record); + }else { + record.setUpdateDate(new Date()); + wxShopUsersInfoMapper.updateById(record); + } + } @Override public void saveOrUpdateShopUsersPerson(WxShopUsersPerson record) { @@ -1118,6 +1148,11 @@ public class WxShopServiceImpl implements WxShopService { public void deleteShopUsersPerson(WxShopUsersPerson record) { wxShopUsersPersonMapper.deleteById(record.getId()); } + + @Override + public List getUserInfoList(WxShopUsersInfo wxShopUsersInfo) { + return wxShopUsersInfoMapper.findList(wxShopUsersInfo); + } @Override public List getUserInfoIds(WxShopUsersInfo wxShopUsersInfo) { diff --git a/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml b/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml index dd95db80b..5de759c3a 100644 --- a/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml @@ -402,5 +402,15 @@ and pay <= 0 and IFNULL(`set_off`,'0') <= 0 and IFNULL(`return_pay`,'0') <= 0 and IFNULL(`use_money`,'0') <= 0 + + update wx_all_bill set cus_name = #{cusName} where cus_name is null + + and rent_contract_id = #{rentContractId} + + + and property_contract_id = #{propertyContractId} + + + diff --git a/mallinkService/src/main/resources/mapper/WxShopUsersInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxShopUsersInfoMapper.xml index 7499cfdaf..0aad7edc5 100644 --- a/mallinkService/src/main/resources/mapper/WxShopUsersInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxShopUsersInfoMapper.xml @@ -15,11 +15,12 @@ + `id`,`tenant_id`,`parent_tenant_id`,`create_shop_id`,`principal_type`,`name`,`phone`,`legal_person`,`id_number`,`sex`, - `link_person`,`create_date`,`update_date` + `link_person`,`create_date`,`update_date`,`create_contract_customer_id` @@ -40,6 +41,10 @@ and `create_shop_id` = #{createShopId} + + and `create_contract_customer_id` = #{createContractCustomerId} + + and `principal_type` = #{principalType} diff --git a/mallinkService/src/main/resources/mapper/WxShopUsersMapper.xml b/mallinkService/src/main/resources/mapper/WxShopUsersMapper.xml index ed2464b4f..e0b1396d8 100644 --- a/mallinkService/src/main/resources/mapper/WxShopUsersMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxShopUsersMapper.xml @@ -82,5 +82,9 @@ select distinct shop_id from wx_shop_users - + + + + update wx_shop_users set status = 1,update_date=#{updateDate} where shop_id = #{shopId} and status = 0 and `type` = #{type} +