# Conflicts: # mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.javarelease_toaliyun_real
| @@ -6,9 +6,7 @@ import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxBillProperty; | |||
| import com.iformall.domain.po.WxBillRent; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.enums.EnumRentStartType; | |||
| import com.iformall.mapper.WxPropertyContractMapper; | |||
| import com.iformall.service.WxBillPropertyService; | |||
| @@ -22,7 +20,7 @@ import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Date; | |||
| import java.util.Map; | |||
| /** | |||
| @@ -44,6 +42,7 @@ public class WxPropertyContractController extends BaseController { | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "物业合同-列表") | |||
| public ResultData list(@ModelAttribute WxPropertyContract wxPropertyContract, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::list"); | |||
| if (null == wxPropertyContract) { | |||
| @@ -55,12 +54,17 @@ public class WxPropertyContractController extends BaseController { | |||
| } | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "物业合同-新增") | |||
| public ResultData add(@RequestBody WxPropertyContract wxPropertyContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::add"); | |||
| MallUserInfo user = getUser(); | |||
| wxPropertyContract.setTenantId(user.getTenantId()); | |||
| wxPropertyContract.setAdjustPeriodHandle(); | |||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract, user.getId(), user.getName()); | |||
| if(wxPropertyContract.getRentStartType()!=null && wxPropertyContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | |||
| wxPropertyContract.setRentalStartDate(wxPropertyContract.getStartDate()); | |||
| } | |||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract, user.getId(), user.getName(),0); | |||
| } | |||
| @PostMapping("updateRentStartTime") | |||
| @@ -77,21 +81,23 @@ public class WxPropertyContractController extends BaseController { | |||
| MallUserInfo user = getUser(); | |||
| propertyContract.setTenantId(user.getTenantId()); | |||
| propertyContract.setAdjustPeriodHandle(); | |||
| return wxPropertyContractService.saveOrUpdate(propertyContract, user.getId(), user.getName()); | |||
| return wxPropertyContractService.saveOrUpdate(propertyContract, user.getId(), user.getName(),1); | |||
| } | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "物业合同-修改") | |||
| public ResultData update(@RequestBody WxPropertyContract wxPropertyContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::update"); | |||
| MallUserInfo user = getUser(); | |||
| wxPropertyContract.setTenantId(user.getTenantId()); | |||
| wxPropertyContract.setAdjustPeriodHandle(); | |||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract, user.getId(), user.getName()); | |||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract, user.getId(), user.getName(),0); | |||
| } | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "物业合同-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::delete"); | |||
| wxPropertyContractService.deleteById(id); | |||
| @@ -100,6 +106,7 @@ public class WxPropertyContractController extends BaseController { | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "物业合同-根据ID查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::findById"); | |||
| WxBillProperty wxBillProperty = new WxBillProperty(); | |||
| @@ -109,12 +116,14 @@ public class WxPropertyContractController extends BaseController { | |||
| } | |||
| @RequestMapping("/download") | |||
| @SystemControllerLog(description = "物业合同-下载") | |||
| public void download(HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::download"); | |||
| wxPropertyContractService.download(request, response, getTenantId()); | |||
| } | |||
| @GetMapping("/getPropertyContractStatusInfo") | |||
| @SystemControllerLog(description = "物业合同-状态信息") | |||
| public ResultData getPropertyContractStatusInfo(@ModelAttribute WxPropertyContract wxPropertyContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::getPropertyContractStatusInfo"); | |||
| wxPropertyContract.setTenantId(getTenantId()); | |||
| @@ -123,12 +132,14 @@ public class WxPropertyContractController extends BaseController { | |||
| @GetMapping("/endPropertyContract") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "物业合同-终止") | |||
| public ResultData endRentContract(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::endRentContract"); | |||
| return wxPropertyContractService.endRentContract(id); | |||
| } | |||
| @GetMapping("/getRentContractList") | |||
| @SystemControllerLog(description = "物业合同-查询列表") | |||
| public ResultData getRentContractList(@ModelAttribute WxPropertyContract wxPropertyContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::getRentContractList"); | |||
| wxPropertyContract.setTenantId(getTenantId()); | |||
| @@ -137,6 +148,7 @@ public class WxPropertyContractController extends BaseController { | |||
| @GetMapping("/endPropertyContractByRentContractId") | |||
| @ApiImplicitParam(name = "rentContractId", value = "rentContractId", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "物业合同-根据租赁合同终止") | |||
| public ResultData endPropertyContractByRentContractId(Long rentContractId) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::endPropertyContractByRentContractId"); | |||
| return wxPropertyContractService.endPropertyContractByRentContractId(rentContractId); | |||
| @@ -144,6 +156,7 @@ public class WxPropertyContractController extends BaseController { | |||
| @GetMapping("/hasRentContract") | |||
| @ApiImplicitParam(name = "rentContractId", value = "rentContractId", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "物业合同-是否存在相关的租赁合同") | |||
| public ResultData hasRentContract(Long rentContractId) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::hasRentContract"); | |||
| return wxPropertyContractService.hasRentContract(rentContractId); | |||
| @@ -151,6 +164,7 @@ public class WxPropertyContractController extends BaseController { | |||
| @GetMapping("updatePropertyContractStatus") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "物业合同-更新合同状态") | |||
| public ResultData updatePropertyContractStatus(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::updateRentContractStatus"); | |||
| return wxPropertyContractService.updatePropertyContractStatus(id); | |||
| @@ -89,10 +89,11 @@ public class WxRentContractController extends BaseController { | |||
| MallUserInfo user = getUser(); | |||
| wxRentContract.setTenantId(user.getTenantId()); | |||
| wxRentContract.setAdjustPeriodHandle(); | |||
| Date oldDate = wxRentContract.getRentalStartDate(); | |||
| if(wxRentContract.getRentStartType()!=null &&wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | |||
| wxRentContract.setRentalStartDate(wxRentContract.getStartDate()); | |||
| } | |||
| return wxRentContractService.save(wxRentContract, user.getId(),user.getName()); | |||
| return wxRentContractService.save(wxRentContract, user.getId(),user.getName(),oldDate); | |||
| } | |||
| @PostMapping("updateRentStartTime") | |||
| @@ -101,7 +102,7 @@ public class WxRentContractController extends BaseController { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::updateRentStartTime"); | |||
| WxRentContract rentContract = wxRentContractMapper.selectByPrimaryKey(wxRentContract.getId()); | |||
| rentContract.setRentalStartDate(wxRentContract.getRentalStartDate()); | |||
| Date oldDate = wxRentContract.getRentalStartDate(); | |||
| if(wxRentContract.getRentStartType()!=null && wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | |||
| rentContract.setRentalStartDate(rentContract.getStartDate()); | |||
| } | |||
| @@ -109,7 +110,7 @@ public class WxRentContractController extends BaseController { | |||
| rentContract.setTenantId(user.getTenantId()); | |||
| rentContract.setAdjustPeriodHandle(); | |||
| rentContract.setRentPriceHandle(); | |||
| return wxRentContractService.update(rentContract, user.getId(),user.getName()); | |||
| return wxRentContractService.update(rentContract, user.getId(),user.getName(),1,oldDate); | |||
| } | |||
| @PostMapping("update") | |||
| @@ -120,10 +121,11 @@ public class WxRentContractController extends BaseController { | |||
| wxRentContract.setTenantId(user.getTenantId()); | |||
| wxRentContract.setAdjustPeriodHandle(); | |||
| wxRentContract.setRentPriceHandle(); | |||
| Date oldDate = wxRentContract.getRentalStartDate(); | |||
| if(wxRentContract.getRentStartType()!=null && wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | |||
| wxRentContract.setRentalStartDate(wxRentContract.getStartDate()); | |||
| } | |||
| return wxRentContractService.update(wxRentContract, user.getId(),user.getName()); | |||
| return wxRentContractService.update(wxRentContract, user.getId(),user.getName(),0,oldDate); | |||
| } | |||
| /** | |||
| @@ -139,11 +141,11 @@ public class WxRentContractController extends BaseController { | |||
| wxRentContract.setTenantId(user.getTenantId()); | |||
| wxRentContract.setAdjustPeriodHandle(); | |||
| wxRentContract.setRentPriceHandle(); | |||
| Date oldDate = wxRentContract.getRentalStartDate(); | |||
| if(wxRentContract.getRentStartType()!=null &&wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | |||
| wxRentContract.setRentalStartDate(wxRentContract.getStartDate()); | |||
| } | |||
| return wxRentContractService.update(wxRentContract, user.getId(),user.getName()); | |||
| return wxRentContractService.update(wxRentContract, user.getId(),user.getName(),0,oldDate); | |||
| } | |||
| @PostMapping("updateFile") | |||
| @@ -154,10 +156,11 @@ public class WxRentContractController extends BaseController { | |||
| wxRentContract.setTenantId(user.getTenantId()); | |||
| wxRentContract.setAdjustPeriodHandle(); | |||
| wxRentContract.setRentPriceHandle(); | |||
| Date oldDate = wxRentContract.getRentalStartDate(); | |||
| if(wxRentContract.getRentStartType()!=null && wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | |||
| wxRentContract.setRentalStartDate(wxRentContract.getStartDate()); | |||
| } | |||
| return wxRentContractService.updateFile(wxRentContract, user.getId(),user.getName()); | |||
| return wxRentContractService.updateFile(wxRentContract, user.getId(),user.getName(),oldDate); | |||
| } | |||
| @GetMapping("/del") | |||
| @@ -40,7 +40,7 @@ public interface WxPropertyContractService { | |||
| * @param userId | |||
| * @return | |||
| */ | |||
| ResultData saveOrUpdate(WxPropertyContract record, Long userId,String userName); | |||
| ResultData saveOrUpdate(WxPropertyContract record, Long userId,String userName,int from); | |||
| /** | |||
| * 根据Id删除实体 | |||
| @@ -8,6 +8,7 @@ import io.swagger.models.auth.In; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -41,9 +42,9 @@ public interface WxRentContractService { | |||
| * @param userName | |||
| * @return | |||
| */ | |||
| ResultData save(WxRentContract record,Long userId,String userName); | |||
| ResultData save(WxRentContract record,Long userId,String userName,Date oldRentStartDate); | |||
| ResultData update(WxRentContract record, Long userId,String userName); | |||
| ResultData update(WxRentContract record, Long userId,String userName,int from,Date oldRentStartDate); | |||
| /** | |||
| * 根据Id删除实体 | |||
| @@ -65,7 +66,7 @@ public interface WxRentContractService { | |||
| void exportContract(HttpServletRequest request, HttpServletResponse response, String tenantId, Long id); | |||
| ResultData updateFile(WxRentContract wxRentContract, Long userId,String userName); | |||
| ResultData updateFile(WxRentContract wxRentContract, Long userId,String userName,Date oldRentStartDate); | |||
| ResultData updateRentContractStatus(Long id); | |||
| @@ -200,7 +200,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| @Override | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public ResultData saveOrUpdate(WxPropertyContract record, Long userId,String userName) { | |||
| public ResultData saveOrUpdate(WxPropertyContract record, Long userId,String userName,int from) { | |||
| // 保存调整金额(预账单调整) | |||
| boolean haspreview = false; | |||
| if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){ | |||
| @@ -289,7 +289,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| if (wxPropertyContract == null) { | |||
| return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); | |||
| } | |||
| record.setRentalStartDate(wxRentContract.getRentalStartDate()); | |||
| if(from != 1){ | |||
| record.setRentalStartDate(wxRentContract.getRentalStartDate()); | |||
| } | |||
| record.setRentalEndDate(wxRentContract.getRentalEndDate()); | |||
| record.setStartDate(wxRentContract.getStartDate()); | |||
| record.setEndDate(wxRentContract.getEndDate()); | |||
| @@ -246,7 +246,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| @Override | |||
| public ResultData save(WxRentContract record,Long userId,String userName) { | |||
| public ResultData save(WxRentContract record,Long userId,String userName,Date oldRentStartDate) { | |||
| //保存租赁合同信息 | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| @@ -343,7 +343,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| try { | |||
| record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode()); | |||
| Date tempDate = record.getRentalStartDate(); | |||
| record.setRentalStartDate(oldRentStartDate); | |||
| wxRentContractMapper.insertSelective(record); | |||
| record.setRentalStartDate(tempDate); | |||
| } catch (Exception e) { | |||
| logger.error("保存租赁合同信息失败,e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| @@ -378,7 +382,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| @Override | |||
| public ResultData update(WxRentContract record, Long userId,String userName) { | |||
| public ResultData update(WxRentContract record, Long userId,String userName,int from,Date oldRentStartDate) { | |||
| //查询预账单用于展示 | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| wxBillRent.setRentContractId(record.getId()); | |||
| @@ -387,7 +391,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| List<WxBillRent> resultList = wxBillRentMapper.findList(wxBillRent); | |||
| //更新 | |||
| ResultData resultData = getResultDataForUpdate(record, userId); | |||
| ResultData resultData = getResultDataForUpdate(record, userId,from,oldRentStartDate); | |||
| if (resultData.code != Result.SUCCESS) { | |||
| return resultData; | |||
| } | |||
| @@ -428,7 +432,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return new ResultData(wxRentContract); | |||
| } | |||
| public ResultData getResultDataForUpdate(WxRentContract record, Long userId) { | |||
| public ResultData getResultDataForUpdate(WxRentContract record, Long userId,int from,Date oldRentStartDate) { | |||
| //更新租赁合同信息 | |||
| WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(record.getId()); | |||
| if (wxRentContract == null) { | |||
| @@ -441,20 +445,23 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| instance.add(dayType, record.getLease()); | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | |||
| BigDecimal hundred = new BigDecimal(100); | |||
| BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); | |||
| BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); | |||
| BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); | |||
| record.setPrice(price.multiply(hundred).longValue()); | |||
| } else { | |||
| if (StringUtils.isNotEmpty(record.getPriceStr())) { | |||
| record.setPrice(new BigDecimal(record.getPriceStr()).multiply(new BigDecimal(100)).longValue()); | |||
| if(from != 1){ | |||
| if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | |||
| BigDecimal hundred = new BigDecimal(100); | |||
| BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); | |||
| BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); | |||
| BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); | |||
| record.setPrice(price.multiply(hundred).longValue()); | |||
| } else { | |||
| record.setPrice(0L); | |||
| if (StringUtils.isNotEmpty(record.getPriceStr())) { | |||
| record.setPrice(new BigDecimal(record.getPriceStr()).multiply(new BigDecimal(100)).longValue()); | |||
| } else { | |||
| record.setPrice(0L); | |||
| } | |||
| } | |||
| } | |||
| if (StringUtils.isNotEmpty(record.getDepositStr())) { | |||
| record.setDeposit(new BigDecimal(record.getDepositStr()).multiply(new BigDecimal(100)).longValue()); | |||
| } else { | |||
| @@ -519,7 +526,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| try { | |||
| Date tempDate = record.getRentalStartDate(); | |||
| record.setRentalStartDate(oldRentStartDate); | |||
| wxRentContractMapper.updateByPrimaryKeySelective(record); | |||
| record.setRentalStartDate(tempDate); | |||
| } catch (Exception e) { | |||
| logger.error("更新租赁合同信息失败,e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| @@ -1247,14 +1257,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Override | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public ResultData updateFile(WxRentContract record, Long userId,String userName) { | |||
| public ResultData updateFile(WxRentContract record, Long userId,String userName,Date oldRentStartDate) { | |||
| // 保存调整金额(预账单调整) | |||
| if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){ | |||
| for (WxBillRent wxBillRent:record.getPreviewBillRentList()) { | |||
| wxBillRentMapper.update(wxBillRent); | |||
| } | |||
| } | |||
| ResultData resultData = getResultDataForUpdate(record, userId); | |||
| ResultData resultData = getResultDataForUpdate(record, userId,0,oldRentStartDate); | |||
| if (resultData.code != Result.SUCCESS) { | |||
| return resultData; | |||
| } | |||