| @@ -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) | |||
| @@ -48,5 +48,7 @@ public interface WxAllBillMapper extends CommonMapper<WxAllBill, Long> { | |||
| void deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| void deleteEnergyReadingBills(@Param("energyReadingCalcuteId")Long energyReadingCalcuteId,@Param("tenantId")String tenantId); | |||
| void updateContractCusName(WxAllBill wxBillRent); | |||
| } | |||
| @@ -11,4 +11,6 @@ public interface WxShopUsersMapper extends CommonMapper<WxShopUsers, String> { | |||
| List<WxShopUsers> findList(WxShopUsers wxShop); | |||
| List<Long> findShopIdList(WxShopUsers wxShop); | |||
| void updateShopOld(WxShopUsers wxShop); | |||
| } | |||
| @@ -129,10 +129,14 @@ public interface WxShopService { | |||
| WxShopUsers getOneShopUsers(WxShopUsers wxShopUsersShop); | |||
| List<WxShopUsers> getShopUsersList(WxShopUsers wxShopUsers); | |||
| void saveOrUpdateShopUsers(WxShopUsers wxShopUsers); | |||
| void changeShopUsers(WxShopUsers wxShopUsers); | |||
| void updateRentShopUsersOld(TenantEntity tenantEntity,Long shopId); | |||
| void deleteShopUsers(WxShopUsers wxShopUsers); | |||
| PageInfo<WxShopUsers> shopUsersListAsPage(WxShopUsers record,Integer pageIndex,Integer pageSize); | |||
| @@ -141,11 +145,16 @@ public interface WxShopService { | |||
| PageInfo<WxShopUsersInfo> shopUsersInfoListAsPage(WxShopUsersInfo record,Integer pageIndex,Integer pageSize); | |||
| void saveOrUpdateShopUsersInfo(WxShopUsersInfo wxShopUsersInfo); | |||
| void saveOrUpdateShopUsersPerson(WxShopUsersPerson wxShopUsers); | |||
| void deleteShopUsersPerson(WxShopUsersPerson wxShopUsers); | |||
| List<WxShopUsersInfo> getUserInfoList(WxShopUsersInfo wxShopUsersInfo); | |||
| List<Long> getUserInfoIds(WxShopUsersInfo wxShopUsersInfo); | |||
| List<Long> getUserShopIds(WxShopUsers wxShopUsers); | |||
| Map<Long,WxShopUsers> getShopUserMap(WxShopUsers wxShopUsers); | |||
| @@ -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); | |||
| @@ -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<Long> shopIdList) { | |||
| WxShopUsersInfo suiq = new WxShopUsersInfo(); | |||
| suiq.updateTenantInfo(customers); | |||
| suiq.setPrincipalType(customers.getPrincipalType()); | |||
| suiq.setName(customers.getName()); | |||
| suiq.setPhone(customers.getPhone()); | |||
| List<WxShopUsersInfo> 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<WxShopUsers> 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(); | |||
| @@ -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<Long> shopIdList) { | |||
| WxShopUsersInfo suiq = new WxShopUsersInfo(); | |||
| suiq.updateTenantInfo(customers); | |||
| suiq.setPrincipalType(customers.getPrincipalType()); | |||
| suiq.setName(customers.getName()); | |||
| suiq.setPhone(customers.getPhone()); | |||
| List<WxShopUsersInfo> 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<WxShopUsers> 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) { | |||
| @@ -999,6 +999,12 @@ public class WxShopServiceImpl implements WxShopService { | |||
| return null; | |||
| } | |||
| @Override | |||
| public List<WxShopUsers> getShopUsersList(WxShopUsers wxShopUsers) { | |||
| List<WxShopUsers> 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<WxShopUsersInfo> 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<WxShopUsersInfo> getUserInfoList(WxShopUsersInfo wxShopUsersInfo) { | |||
| return wxShopUsersInfoMapper.findList(wxShopUsersInfo); | |||
| } | |||
| @Override | |||
| public List<Long> getUserInfoIds(WxShopUsersInfo wxShopUsersInfo) { | |||
| @@ -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 | |||
| </delete> | |||
| <update id="updateContractCusName" parameterType="com.iformall.domain.po.WxAllBill"> | |||
| update wx_all_bill set cus_name = #{cusName} where cus_name is null | |||
| <if test=" null != rentContractId"> | |||
| and rent_contract_id = #{rentContractId} | |||
| </if> | |||
| <if test=" null != propertyContractId"> | |||
| and property_contract_id = #{propertyContractId} | |||
| </if> | |||
| </update> | |||
| </mapper> | |||
| @@ -15,11 +15,12 @@ | |||
| <result column="link_person" jdbcType="VARCHAR" property="linkPerson"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="create_contract_customer_id" jdbcType="BIGINT" property="createContractCustomerId"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `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` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -40,6 +41,10 @@ | |||
| and `create_shop_id` = #{createShopId} | |||
| </if> | |||
| <if test=" null != createContractCustomerId"> | |||
| and `create_contract_customer_id` = #{createContractCustomerId} | |||
| </if> | |||
| <if test=" null != principalType"> | |||
| and `principal_type` = #{principalType} | |||
| </if> | |||
| @@ -82,5 +82,9 @@ | |||
| select distinct shop_id | |||
| from wx_shop_users | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| </select> | |||
| <update id="updateShopOld" parameterType="com.iformall.domain.po.WxShopUsers"> | |||
| update wx_shop_users set status = 1,update_date=#{updateDate} where shop_id = #{shopId} and status = 0 and `type` = #{type} | |||
| </update> | |||
| </mapper> | |||