| @@ -349,20 +349,71 @@ public class WxAgileContractController extends WxContractBaseController { | |||
| */ | |||
| @PostMapping("setRenevue") | |||
| public ResultData setRenevue(@RequestBody WxRentContractAgileRenevue renevue) { | |||
| // unDeposit.updateTenantInfo(getTenantInfo()); | |||
| // if (null == unDeposit.getItems() || unDeposit.getItems().size() <= 0 ) { | |||
| // return new ResultData(Result.ERROR,"无细项"); | |||
| // } | |||
| // try { | |||
| // wxAgileContractService.saveUnDeposit(unDeposit); | |||
| // }catch(Exception e) { | |||
| // return new ResultData(Result.ERROR,"保存信息失败:"+e.getMessage()); | |||
| // } | |||
| // try { | |||
| // wxAgileContractService.createUnDepositBill(unDeposit,this.getUser()); | |||
| // }catch(Exception e) { | |||
| // return new ResultData(Result.ERROR,"保存账单失败:"+e.getMessage()); | |||
| // } | |||
| renevue.updateTenantInfo(getTenantInfo()); | |||
| if (null == renevue.getItems() || renevue.getItems().size() <= 0 ) { | |||
| return new ResultData(Result.ERROR,"无细项"); | |||
| } | |||
| if (null == renevue.getFees() || renevue.getFees().size() <= 0 ) { | |||
| return new ResultData(Result.ERROR,"请选择款项"); | |||
| } | |||
| //一个合同只能有一条记录 | |||
| WxRentContractAgileRenevue _ore = wxAgileContractService.findRenevueByContract(renevue.getRentContractId(),renevue); | |||
| if (null != _ore) { | |||
| renevue.setId(_ore.getId()); | |||
| } | |||
| try { | |||
| wxAgileContractService.saveRenuvue(renevue); | |||
| }catch(Exception e) { | |||
| return new ResultData(Result.ERROR,"保存信息失败:"+e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| /** | |||
| * 设置联营扣点跳点 | |||
| */ | |||
| @PostMapping("setRenevueJump") | |||
| public ResultData setRenevueJump(@RequestBody WxRentContract contract) { | |||
| contract.updateTenantInfo(getTenantInfo()); | |||
| if (null == contract.getRevenueJumps() || contract.getRevenueJumps().size() <= 0 ) { | |||
| return new ResultData(Result.ERROR,"无配置项"); | |||
| } | |||
| try { | |||
| wxAgileContractService.saveRenuvueJumps(contract); | |||
| }catch(Exception e) { | |||
| return new ResultData(Result.ERROR,"保存信息失败:"+e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| /** | |||
| * 设置款项是否参与取高 | |||
| */ | |||
| @PostMapping("setFeesJoinRenevueUp") | |||
| public ResultData setFeesJoinRenevueUp(@RequestBody WxRentContractAgileUnDeposit unDeposit) { | |||
| unDeposit.updateTenantInfo(getTenantInfo()); | |||
| WxRentContractAgileUnDeposit und = wxAgileContractService.getUnDepositById(unDeposit.getId(),unDeposit); | |||
| //计算周期等需要和扣点设置一致 | |||
| WxRentContractAgileRenevue _ore = wxAgileContractService.findRenevueByContract(unDeposit.getRentContractId(),unDeposit); | |||
| if (null == _ore) { | |||
| return new ResultData(Result.ERROR,"请先设置扣点信息"); | |||
| } | |||
| if (und.getTimePeriod().intValue() != _ore.getTimePeriod().intValue() || | |||
| und.getTimeUnit().intValue() != _ore.getTimeUnit().intValue()) { | |||
| return new ResultData(Result.ERROR,"当前款项计费周期和扣点设置不一致。"); | |||
| } | |||
| if (und.getFeesCreateRule().intValue() != _ore.getFeesCreateRule().intValue()) { | |||
| return new ResultData(Result.ERROR,"当前款项费用生成规则和扣点设置不一致。"); | |||
| } | |||
| try { | |||
| wxAgileContractService.setJoinRenevueUp(unDeposit); | |||
| }catch(Exception e) { | |||
| return new ResultData(Result.ERROR,"保存信息失败:"+e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @@ -65,7 +65,8 @@ public class WxRentContractAgileRenevue extends TenantEntity { | |||
| private Date updatetime; | |||
| @TableField(exist = false) | |||
| private List<WxRentContractAgileUnDepositItem> items; | |||
| private List<WxRentContractAgileRenevueItem> items; | |||
| @TableField(exist = false) | |||
| private List<WxRentContractAgileRenevueFees> fees; | |||
| } | |||
| @@ -80,6 +80,9 @@ public class WxRentContractAgileUnDeposit extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="updateTime",name="updateTime") | |||
| private Date updatetime; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否参与联营扣点取高EnumYesOrNo",name="joinRenevueUp") | |||
| private Integer joinRenevueUp; | |||
| @TableField(exist = false) | |||
| private List<WxRentContractAgileUnDepositItem> items; | |||
| @@ -16,5 +16,7 @@ public interface WxRentContractAgileRenevueFeesMapper extends CommonMapper<WxRen | |||
| WxRentContractAgileRenevueFees selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| List<Long> findIdList(WxRentContractAgileRenevueFees wxBillRent); | |||
| void deleteByRenevue(WxRentContractAgileRenevueFees wxBillRent); | |||
| } | |||
| @@ -16,6 +16,6 @@ public interface WxRentContractAgileRenevueItemMapper extends CommonMapper<WxRen | |||
| List<Long> findIdList(WxRentContractAgileRenevueItem wxBillRent); | |||
| void deleteByUnDeposit(WxRentContractAgileRenevueItem wxBillRent); | |||
| void deleteByRenevue(WxRentContractAgileRenevueItem wxBillRent); | |||
| } | |||
| @@ -15,5 +15,7 @@ public interface WxRentContractAgileUnDepositMapper extends CommonMapper<WxRentC | |||
| WxRentContractAgileUnDeposit selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| List<Long> findIdList(WxRentContractAgileUnDeposit wxBillRent); | |||
| void updateJoinRenevueUp(WxRentContractAgileUnDeposit wxBillRent); | |||
| } | |||
| @@ -6,6 +6,7 @@ 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.WxRentContractAgileRenevue; | |||
| import com.iformall.domain.po.WxRentContractAgileUnDeposit; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| @@ -33,10 +34,20 @@ public interface WxAgileContractService { | |||
| WxRentContractAgileUnDeposit findUnDepositDetail(WxRentContractAgileUnDeposit unDeposit); | |||
| WxRentContractAgileUnDeposit getUnDepositById(Long id,TenantEntity tenantEntity); | |||
| List<WxRentContractAgileUnDeposit> findUnDepositList(WxRentContractAgileUnDeposit unDeposit); | |||
| void createUnDepositBill(WxRentContractAgileUnDeposit unDeposit,MallUserInfo user); | |||
| WxRentContractAgileRenevue findRenevueByContract(Long rentContractId,TenantEntity tenantEntity); | |||
| void saveRenuvue(WxRentContractAgileRenevue renevue); | |||
| void saveRenuvueJumps(WxRentContract contract); | |||
| void setJoinRenevueUp(WxRentContractAgileUnDeposit unDeposit); | |||
| List<Long> findBuildingFloorContractIds(TenantEntity tenantEntity,String floorRule,Long building,Long floor,List<Long> shopIds,Integer shopDel); | |||
| List<Long> findShopContractIds(TenantEntity tenantEntity,List<Long> shopIds); | |||
| @@ -17,6 +17,9 @@ import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.domain.po.WxRentContractAgileDeposit; | |||
| import com.iformall.domain.po.WxRentContractAgileDepositShop; | |||
| import com.iformall.domain.po.WxRentContractAgileRenevue; | |||
| import com.iformall.domain.po.WxRentContractAgileRenevueFees; | |||
| import com.iformall.domain.po.WxRentContractAgileRenevueItem; | |||
| import com.iformall.domain.po.WxRentContractAgileUnDeposit; | |||
| import com.iformall.domain.po.WxRentContractAgileUnDepositItem; | |||
| import com.iformall.domain.po.WxRentContractRevenueJump; | |||
| @@ -45,10 +48,14 @@ import com.iformall.mapper.WxContractShopMapper; | |||
| import com.iformall.mapper.WxMerchantMapper; | |||
| import com.iformall.mapper.WxRentContractAgileDepositMapper; | |||
| import com.iformall.mapper.WxRentContractAgileDepositShopMapper; | |||
| import com.iformall.mapper.WxRentContractAgileRenevueFeesMapper; | |||
| import com.iformall.mapper.WxRentContractAgileRenevueItemMapper; | |||
| import com.iformall.mapper.WxRentContractAgileRenevueMapper; | |||
| import com.iformall.mapper.WxRentContractAgileUnDepositItemMapper; | |||
| import com.iformall.mapper.WxRentContractAgileUnDepositMapper; | |||
| import com.iformall.mapper.WxRentContractFreePeriodMapper; | |||
| import com.iformall.mapper.WxRentContractMapper; | |||
| import com.iformall.mapper.WxRentContractRevenueJumpMapper; | |||
| import com.iformall.mapper.WxShopMapper; | |||
| import com.iformall.service.SysConfigService; | |||
| import com.iformall.service.WxAgileContractService; | |||
| @@ -101,6 +108,18 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||
| @Autowired | |||
| WxRentContractAgileUnDepositItemMapper wxRentContractAgileUnDepositItemMapper; | |||
| @Autowired | |||
| WxRentContractAgileRenevueMapper wxRentContractAgileRenevueMapper; | |||
| @Autowired | |||
| WxRentContractRevenueJumpMapper wxRentContractRevenueJumpMapper; | |||
| @Autowired | |||
| WxRentContractAgileRenevueFeesMapper wxRentContractAgileRenevueFeesMapper; | |||
| @Autowired | |||
| WxRentContractAgileRenevueItemMapper wxRentContractAgileRenevueItemMapper; | |||
| @Autowired | |||
| WxRentContractFreePeriodMapper wxRentContractFreePeriodMapper; | |||
| @@ -511,6 +530,12 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||
| return ud; | |||
| } | |||
| @Override | |||
| public WxRentContractAgileUnDeposit getUnDepositById(Long id,TenantEntity tenantEntity) { | |||
| return wxRentContractAgileUnDepositMapper.selectById(id, tenantEntity.getTenantId()); | |||
| } | |||
| @Override | |||
| public List<WxRentContractAgileUnDeposit> findUnDepositList(WxRentContractAgileUnDeposit unDeposit) { | |||
| List<WxRentContractAgileUnDeposit> list = wxRentContractAgileUnDepositMapper.findList(unDeposit); | |||
| @@ -764,6 +789,126 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||
| return wxBillRent; | |||
| } | |||
| @Override | |||
| public WxRentContractAgileRenevue findRenevueByContract(Long rentContractId,TenantEntity tenantEntity) { | |||
| WxRentContractAgileRenevue rq = new WxRentContractAgileRenevue(); | |||
| rq.updateTenantInfo(tenantEntity); | |||
| rq.setRentContractId(rentContractId);; | |||
| List<WxRentContractAgileRenevue> list = wxRentContractAgileRenevueMapper.findList(rq); | |||
| if (null == list || list.size() <= 0 ) { | |||
| return null; | |||
| } | |||
| return list.get(0); | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| @Override | |||
| public void saveRenuvue(WxRentContractAgileRenevue renevue) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| boolean isCreate = false; | |||
| if (null == renevue.getId() ) { | |||
| //保存租赁合同信息 | |||
| renevue.setId(idWorker.nextId()); | |||
| isCreate = true; | |||
| renevue.setCreatetime(new Date()); | |||
| } | |||
| WxRentContract contract = wxRentContractMapper.selectById(renevue.getRentContractId()); | |||
| renevue.setUpdatetime(new Date()); | |||
| if (isCreate) { | |||
| wxRentContractAgileRenevueMapper.insert(renevue); | |||
| }else { | |||
| wxRentContractAgileRenevueMapper.updateById(renevue); | |||
| WxRentContractAgileRenevueItem itemdel = new WxRentContractAgileRenevueItem(); | |||
| itemdel.updateTenantInfo(renevue); | |||
| itemdel.setRenevueId(renevue.getId()); | |||
| wxRentContractAgileRenevueItemMapper.deleteByRenevue(itemdel); | |||
| WxRentContractAgileRenevueFees feesDel = new WxRentContractAgileRenevueFees(); | |||
| feesDel.updateTenantInfo(renevue); | |||
| feesDel.setAgileRenevueId(renevue.getId()); | |||
| wxRentContractAgileRenevueFeesMapper.deleteByRenevue(feesDel); | |||
| } | |||
| validRenevueItem(renevue.getItems(), contract); | |||
| for (int i = 0 ; i < renevue.getItems().size(); i++) { | |||
| WxRentContractAgileRenevueItem item = renevue.getItems().get(i); | |||
| item.setRentContractId(renevue.getRentContractId()); | |||
| item.setRenevueId(renevue.getId()); | |||
| item.setId(idWorker.nextId()); | |||
| item.updateTenantInfo(contract); | |||
| item.setCreatetime(new Date()); | |||
| item.setUpdatetime(new Date()); | |||
| wxRentContractAgileRenevueItemMapper.insert(item); | |||
| } | |||
| for (int i = 0 ; i < renevue.getFees().size(); i++) { | |||
| WxRentContractAgileRenevueFees item = renevue.getFees().get(i); | |||
| item.setRentContractId(renevue.getRentContractId()); | |||
| item.setAgileRenevueId(renevue.getId()); | |||
| item.setId(idWorker.nextId()); | |||
| item.updateTenantInfo(contract); | |||
| item.setCreatetime(new Date()); | |||
| item.setUpdatetime(new Date()); | |||
| wxRentContractAgileRenevueFeesMapper.insert(item); | |||
| } | |||
| } | |||
| private void validRenevueItem(List<WxRentContractAgileRenevueItem> itemList,WxRentContract contract) { | |||
| Date lastEndDate = null; | |||
| for (int i = 0 ; i < itemList.size(); i++) { | |||
| WxRentContractAgileRenevueItem item = itemList.get(i); | |||
| //判断时间是不是连这的 | |||
| if (i == 0) { | |||
| lastEndDate = item.getEndTime(); | |||
| if (!item.getBeginTime().equals(contract.getRentalStartDate())) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"开始时间需要和合同开始时间一致"); | |||
| } | |||
| }else { | |||
| Date _curr = DateUtils.getSecondsTimeAfter(1, lastEndDate); | |||
| if (!_curr.equals(item.getBeginTime())) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"时间区间需要严格连接"); | |||
| } | |||
| } | |||
| if (i == itemList.size()-1) { | |||
| if (!item.getEndTime().equals(contract.getRentalEndDate())) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"结尾时间需要和合同结束时间一致"); | |||
| } | |||
| } | |||
| lastEndDate = item.getEndTime(); | |||
| } | |||
| } | |||
| @Override | |||
| public void saveRenuvueJumps(WxRentContract contract) { | |||
| if (null != contract.getRevenueJumps()) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| List<WxRentContractRevenueJump> jlist = new ArrayList<WxRentContractRevenueJump>(); | |||
| for (int i = 0 ; i < contract.getRevenueJumps().size(); i++) { | |||
| WxRentContractRevenueJump jp = contract.getRevenueJumps().get(i); | |||
| if (StringUtils.isNotBlank(jp.getMinMoney())) { | |||
| jp.updateTenantInfo(contract); | |||
| jp.setId(idWorker.nextId()); | |||
| jp.setRentContractId(contract.getId()); | |||
| jp.setCreateTime(new Date()); | |||
| jp.setUpdateTime(new Date()); | |||
| jlist.add(jp); | |||
| } | |||
| } | |||
| if (jlist.size() > 0 ) { | |||
| wxRentContractRevenueJumpMapper.inertJumps(contract.getTenantId(), jlist); | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| public void setJoinRenevueUp(WxRentContractAgileUnDeposit unDeposit) { | |||
| wxRentContractAgileUnDepositMapper.updateJoinRenevueUp(unDeposit); | |||
| } | |||
| @Override | |||
| public List<Long> findBuildingFloorContractIds(TenantEntity tenantEntity, String floorRule, Long building, | |||
| @@ -56,5 +56,9 @@ | |||
| from wx_rent_contract_agile_renevue_fees where id = #{id} and `tenant_id` = #{tenantId} | |||
| </select> | |||
| <delete id="deleteByRenevue" parameterType="com.iformall.domain.po.WxRentContractAgileRenevueFees"> | |||
| delete from wx_rent_contract_agile_renevue_fees where agile_renevue_id = #{agileRenevueId} | |||
| </delete> | |||
| </mapper> | |||
| @@ -61,8 +61,8 @@ | |||
| from wx_rent_contract_agile_renevue_item where id = #{id} and `tenant_id` = #{tenantId} | |||
| </select> | |||
| <delete id="deleteByUnDeposit" parameterType="com.iformall.domain.po.WxRentContractAgileRenevueItem"> | |||
| delete from wx_rent_contract_agile_renevue_item where `un_deposit_id` = #{unDepositId} | |||
| <delete id="deleteByRenevue" parameterType="com.iformall.domain.po.WxRentContractAgileRenevueItem"> | |||
| delete from wx_rent_contract_agile_renevue_item where `renevue_id` = #{unDepositId} | |||
| </delete> | |||
| </mapper> | |||
| @@ -14,11 +14,12 @@ | |||
| <result column="fees_create_rule" jdbcType="INTEGER" property="feesCreateRule"/> | |||
| <result column="createtime" jdbcType="TIMESTAMP" property="createtime"/> | |||
| <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/> | |||
| <result column="join_renevue_up" jdbcType="INTEGER" property="joinRenevueUp"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`setting_method`,`fees_id`, | |||
| `time_period`,`time_unit`,`calcute_time`,`fees_create_rule`,`createtime`,`updatetime` | |||
| `time_period`,`time_unit`,`calcute_time`,`fees_create_rule`,`createtime`,`updatetime`,`join_renevue_up` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -32,6 +33,7 @@ | |||
| </if> | |||
| <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if> | |||
| <if test=" null != feesId ">and `fees_id` = #{feesId}</if> | |||
| <if test=" null != joinRenevueUp ">and `join_renevue_up` = #{joinRenevueUp}</if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -60,5 +62,9 @@ | |||
| from wx_rent_contract_agile_un_deposit where id = #{id} and `tenant_id` = #{tenantId} | |||
| </select> | |||
| <update id = "updateJoinRenevueUp" parameterType="com.iformall.domain.po.WxRentContractAgileUnDeposit"> | |||
| update wx_rent_contract_agile_un_deposit set join_renevue_up = #{joinRenevueUp} where id = #{id} | |||
| </update> | |||
| </mapper> | |||