Преглед изворни кода

更新合同

release_toaliyun_real
xiaohanzi пре 5 година
родитељ
комит
1c39dccf0e
16 измењених фајлова са 182 додато и 937 уклоњено
  1. +0
    -79
      mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractExtensionController.java
  2. +165
    -131
      mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java
  3. +0
    -146
      mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractExtensionController.java
  4. +0
    -7
      mallinkAdmin/src/main/resources/db/migration/V202007311200__FOR_MEMBER_ONLY_001.sql
  5. +0
    -5
      mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java
  6. +0
    -25
      mallinkService/src/main/java/com/iformall/domain/po/WxRentContractShop.java
  7. +0
    -2
      mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java
  8. +0
    -2
      mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java
  9. +0
    -14
      mallinkService/src/main/java/com/iformall/mapper/WxRentContractShopMapper.java
  10. +0
    -4
      mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java
  11. +2
    -12
      mallinkService/src/main/java/com/iformall/service/WxRentContractService.java
  12. +0
    -161
      mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java
  13. +15
    -282
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java
  14. +0
    -21
      mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml
  15. +0
    -12
      mallinkService/src/main/resources/mapper/WxRentContractMapper.xml
  16. +0
    -34
      mallinkService/src/main/resources/mapper/WxRentContractShopMapper.xml

+ 0
- 79
mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractExtensionController.java Прегледај датотеку

@@ -1,79 +0,0 @@
package com.iformall.controller.contract;

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxPropertyContract;
import com.iformall.domain.po.WxRentContract;
import com.iformall.enums.EnumContractType;
import com.iformall.enums.EnumRentStartType;
import com.iformall.service.WxPropertyContractService;
import com.iformall.service.WxRentPropertyContractService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
* @author: furunxin
* @Date: 2020/7/20 18:11
* @Description:
*/

@Slf4j
@RestController
@Api(description = "物业合同续签")
@RequestMapping("wxPropertyContractExtension")
public class WxPropertyContractExtensionController extends WxContractBaseController {

@Autowired
private WxPropertyContractService wxPropertyContractService;

@Autowired
private WxRentPropertyContractService wxRentPropertyContractService;

@GetMapping("getMerchantList")
@SystemControllerLog(description = "获取可续签商户列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "shopType", value = "店铺类型 1:店铺 2:多经点位", dataType = "Integer", paramType = "query", required = true)})
public ResultData getMerchantList(Integer shopType) throws Exception{
WxPropertyContract wxPropertyContract = new WxPropertyContract();
wxPropertyContract.updateTenantInfo(getTenantInfo());
wxPropertyContract.setRentShopType(shopType);
return new ResultData(Result.SUCCESS, "查询成功", wxPropertyContractService.getMerchantList(wxPropertyContract));
}

@PostMapping("add")
@SystemControllerLog(description = "物业合同-新增")
public ResultData add(@RequestBody WxPropertyContract wxPropertyContract) {
log.debug("[" + getIpAddr() + "] WxPropertyContractController::add");
MallUserInfo user = getUser();
wxPropertyContract.updateTenantInfo(user);
wxPropertyContract.setAdjustPeriodHandle();
Integer contractType = wxRentPropertyContractService.getContractType(wxPropertyContract.getRentShopType(), wxPropertyContract.getOperationType(), EnumContractType.PROPERTY.getCode());
wxPropertyContract.setContractType(contractType);
if(wxPropertyContract.getRentStartType()!=null && wxPropertyContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){
wxPropertyContract.setRentalStartDate(wxPropertyContract.getStartDate());
}
return wxPropertyContractService.saveOrUpdate2(wxPropertyContract, user.getId(), user.getName());
}

@PostMapping("update")
@SystemControllerLog(description = "物业合同-修改")
public ResultData update(@RequestBody WxPropertyContract wxPropertyContract) {
log.debug("[" + getIpAddr() + "] WxPropertyContractController::update");
MallUserInfo user = getUser();
wxPropertyContract.updateTenantInfo(user);
wxPropertyContract.setAdjustPeriodHandle();
//第三步提交 SWITCH
return wxPropertyContractService.saveOrUpdate2(wxPropertyContract, user.getId(), user.getName());

}
}

+ 165
- 131
mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java Прегледај датотеку

@@ -12,6 +12,8 @@ import com.iformall.enums.EnumFlowContractType;
import com.iformall.enums.EnumFlowKey;
import com.iformall.enums.EnumFromType;
import com.iformall.enums.EnumIsPreview;
import com.iformall.enums.EnumRentContractAppStatus;
import com.iformall.enums.EnumRentContractStatus;
import com.iformall.enums.EnumRentStartType;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxBillPropertyMapper;
@@ -64,51 +66,6 @@ public class WxRentContractController extends WxContractBaseController {
private WxRentPropertyContractService wxRentPropertyContractService;




@GetMapping("getMerchantList")
@SystemControllerLog(description = "获取商户列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "shopType", value = "店铺类型 1:店铺 2:多经点位", dataType = "Integer", paramType = "query", required = true)})
public ResultData getMerchantList(Integer shopType) throws Exception{
WxMerchant wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(getTenantInfo());
wxMerchant.setRentShopType(shopType);
return new ResultData(Result.SUCCESS, "查询成功", wxMerchantService.getMerchantList(wxMerchant));
}

@GetMapping("autolatePay")
@SystemControllerLog(description = "autolatePay")
public ResultData autolatePay(String startDate, String endDate) throws Exception{
try {
logger.info("账单滞纳金更新开始");
wxBillRentMapper.insertBillAction();
wxBillPropertyMapper.insertBillAction();

wxBillRentMapper.autoAddLatePayPrice();
wxBillPropertyMapper.autoAddLatePayPrice();
logger.info("账单滞纳金更新结束");
}catch (Exception e){
logger.error("LatePayBillActionSchedule error! message:{}",e.getMessage());
logger.error("LatePayBillActionSchedule error!",e);
}
return new ResultData();
}

@GetMapping("getDateDiff")
@ApiImplicitParams({
@ApiImplicitParam(name = "startDate", value = "开始时间", dataType = "string", paramType = "query", required = true),
@ApiImplicitParam(name = "endtDate", value = "结束时间", dataType = "string", paramType = "query", required = true)})
@SystemControllerLog(description = "获取两个时间相差,返回n月零n天")
public ResultData getDateDiff(String startDate, String endDate) throws Exception{
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
Map<String,Integer> map = new HashMap<>();
int[] array = DateUtils.getDiff(sd.parse(startDate),sd.parse(endDate));
map.put("month",array[0]);
map.put("day",array[1]);
return new ResultData(map);
}

@UserDataRuleAnnotation("rent_contract_list")
@GetMapping("/list")
@ApiImplicitParams({
@@ -124,26 +81,12 @@ public class WxRentContractController extends WxContractBaseController {
//Map<String, Object> result = wxRentContractService.listAsPage(wxRentContract, pageNum, pageSize);
return new ResultData(wxRentContractService.getRentContractList(wxRentContract, pageNum, pageSize));
}
/**
* 预览账单展示,编辑账期,后端生成账单金额
* 新增第一步
* @param wxRentContract
* @return
*/
@PostMapping("buildBillPriceList")
@SystemControllerLog(description = "租赁合同-生成账单列表金额")
public ResultData buildBillPriceList(@RequestBody WxRentContract wxRentContract) throws Exception{
logger.debug("[" + getIpAddr() + "] WxRentContractController::buildBillPriceList");
WxRentContract dbRent = wxRentContractMapper.selectById(wxRentContract.getId());
dbRent.setPreviewBillRentList(wxRentContract.getPreviewBillRentList());

if(dbRent.getRentStartType()!=null && dbRent.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){
dbRent.setRentalStartDate(dbRent.getStartDate());
}
List<WxBillRent> result = wxRentContractService.buildRent(getUserId(),dbRent, EnumIsPreview.YES.getCode(), false);
return new ResultData(result);
}

@PostMapping("add")
@SystemControllerLog(description = "租赁合同-添加")
public ResultData add(@RequestBody WxRentContract wxRentContract) {
@@ -175,7 +118,7 @@ public class WxRentContractController extends WxContractBaseController {

/**
* 防止前端3秒重复提交
* 新增第二步 防止前端3秒重复提交
* @param wxRentContract
* @return
*/
@@ -197,6 +140,11 @@ public class WxRentContractController extends WxContractBaseController {
return wxRentContractService.update(wxRentContract, user.getId(),user.getName(),EnumFromType.OTHER.getCode(),oldDate);
}
/**
* 新增第三步
* @param wxRentContract
* @return
*/
@PostMapping("updateFile")
@SystemControllerLog(description = "租赁合同-更新文件")
public ResultData updateFile(@RequestBody WxRentContract wxRentContract) {
@@ -213,9 +161,162 @@ public class WxRentContractController extends WxContractBaseController {
wxRentContract.setRentalStartDate(wxRentContract.getStartDate());
}
return wxRentContractService.updateFile(wxRentContract, user.getId(),user.getName(),oldDate);
}
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "租赁合同-查找")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::findById");
// 同步欠缴状态
WxBillRent wxBillRent = new WxBillRent();
wxBillRent.updateTenantInfo(getTenantInfo());
wxBillRentService.updateBillStatus(wxBillRent);
try {
Map<String, Object> data = wxRentContractService.getById(id);
return new ResultData(data);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}
}
@GetMapping("/hasRentStatus")
@SystemControllerLog(description = "查询店铺租赁状态")
public ResultData hasRentStatus(@ModelAttribute WxRentContract wxRentContract) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::hasRentStatus");
wxRentContract.updateTenantInfo(getTenantInfo());
return wxRentContractService.hasRentStatus(wxRentContract);
}

@GetMapping("/hasContractNumber")
@SystemControllerLog(description = "租赁合同-检查合同编号是否存在")
public ResultData hasContractNumber(@ModelAttribute WxRentContract wxRentContract) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::hasContractNumber");
wxRentContract.updateTenantInfo(getTenantInfo());
return wxRentContractService.hasContractNumber(wxRentContract);
}
@PostMapping("update")
@SystemControllerLog(description = "租赁合同-更新")
public ResultData update(@RequestBody WxRentContract rentContract) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::update");

WxRentContract cure = wxRentContractService.getSimpleDeatil(rentContract.getId());
if (null == cure) {
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"租赁合同未查询到");
}
if (cure.getStatus().intValue() == EnumRentContractStatus.DRAFT.getCode().intValue() ||
(cure.getStatus().intValue() == EnumRentContractStatus.PERFORMANCE.getCode().intValue()
&& cure.getApplyStatus().intValue()== EnumRentContractAppStatus.REJECT.getCode().intValue())) {
if(StringUtils.isBlank(rentContract.getBusDiscountRatio())){
rentContract.setBusDiscountTime(new Integer(0));
}
MallUserInfo user = getUser();
rentContract.updateTenantInfo(user);
rentContract.setAdjustPeriodHandle();
rentContract.setRentPriceHandle();
Date oldDate = rentContract.getRentalStartDate();
if(rentContract.getRentStartType()!=null && rentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){
rentContract.setRentalStartDate(rentContract.getStartDate());
}
ResultData update = null;
try {
update = wxRentContractService.update(rentContract, user.getId(), user.getName(), EnumFromType.OTHER.getCode(), oldDate);
} catch (MallinkException e) {
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
return update;
}else {
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"当前合同状态不允许修改");
}
}
@GetMapping("/endRentContract")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true),
@ApiImplicitParam(name = "status", value = "status", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "租赁合同-终结合同")
public ResultData endRentContract(Long id,Integer status) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::endRentContract");
return wxRentContractService.endRentContract(id,status);
}

@GetMapping("getMerchantList")
@SystemControllerLog(description = "获取商户列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "shopType", value = "店铺类型 1:店铺 2:多经点位", dataType = "Integer", paramType = "query", required = true)})
public ResultData getMerchantList(Integer shopType) throws Exception{
WxMerchant wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(getTenantInfo());
wxMerchant.setRentShopType(shopType);
return new ResultData(Result.SUCCESS, "查询成功", wxMerchantService.getMerchantList(wxMerchant));
}

@GetMapping("autolatePay")
@SystemControllerLog(description = "autolatePay")
public ResultData autolatePay(String startDate, String endDate) throws Exception{
try {
logger.info("账单滞纳金更新开始");
wxBillRentMapper.insertBillAction();
wxBillPropertyMapper.insertBillAction();

wxBillRentMapper.autoAddLatePayPrice();
wxBillPropertyMapper.autoAddLatePayPrice();
logger.info("账单滞纳金更新结束");
}catch (Exception e){
logger.error("LatePayBillActionSchedule error! message:{}",e.getMessage());
logger.error("LatePayBillActionSchedule error!",e);
}
return new ResultData();
}

@GetMapping("getDateDiff")
@ApiImplicitParams({
@ApiImplicitParam(name = "startDate", value = "开始时间", dataType = "string", paramType = "query", required = true),
@ApiImplicitParam(name = "endtDate", value = "结束时间", dataType = "string", paramType = "query", required = true)})
@SystemControllerLog(description = "获取两个时间相差,返回n月零n天")
public ResultData getDateDiff(String startDate, String endDate) throws Exception{
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
Map<String,Integer> map = new HashMap<>();
int[] array = DateUtils.getDiff(sd.parse(startDate),sd.parse(endDate));
map.put("month",array[0]);
map.put("day",array[1]);
return new ResultData(map);
}

/**
* 预览账单展示,编辑账期,后端生成账单金额
* @param wxRentContract
* @return
*/
@PostMapping("buildBillPriceList")
@SystemControllerLog(description = "租赁合同-生成账单列表金额")
public ResultData buildBillPriceList(@RequestBody WxRentContract wxRentContract) throws Exception{
logger.debug("[" + getIpAddr() + "] WxRentContractController::buildBillPriceList");
WxRentContract dbRent = wxRentContractMapper.selectById(wxRentContract.getId());
dbRent.setPreviewBillRentList(wxRentContract.getPreviewBillRentList());

if(dbRent.getRentStartType()!=null && dbRent.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){
dbRent.setRentalStartDate(dbRent.getStartDate());
}
List<WxBillRent> result = wxRentContractService.buildRent(getUserId(),dbRent, EnumIsPreview.YES.getCode(), false);
return new ResultData(result);
}

@PostMapping("updateRentStartTime")
@SystemControllerLog(description = "租赁合同-更新租赁开始日期")
public ResultData updateRentStartTime(@RequestBody WxRentContract wxRentContract) {
@@ -233,34 +334,6 @@ public class WxRentContractController extends WxContractBaseController {
return wxRentContractService.update(rentContract, user.getId(),user.getName(), EnumFromType.SWITCH.getCode(),oldDate);
}

@PostMapping("update")
@SystemControllerLog(description = "租赁合同-更新")
public ResultData update(@RequestBody WxRentContract rentContract) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::update");

if(StringUtils.isBlank(rentContract.getBusDiscountRatio())){
rentContract.setBusDiscountTime(new Integer(0));
}
MallUserInfo user = getUser();
rentContract.updateTenantInfo(user);
rentContract.setAdjustPeriodHandle();
rentContract.setRentPriceHandle();
Date oldDate = rentContract.getRentalStartDate();
if(rentContract.getRentStartType()!=null && rentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){
rentContract.setRentalStartDate(rentContract.getStartDate());
}
ResultData update = null;
try {
update = wxRentContractService.update(rentContract, user.getId(), user.getName(), EnumFromType.OTHER.getCode(), oldDate);
} catch (MallinkException e) {
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
return update;
}




@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true)
@@ -270,23 +343,7 @@ public class WxRentContractController extends WxContractBaseController {
return wxRentContractService.deleteById(id);
}

@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "租赁合同-查找")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::findById");
// 同步欠缴状态
WxBillRent wxBillRent = new WxBillRent();
wxBillRent.updateTenantInfo(getTenantInfo());
wxBillRentService.updateBillStatus(wxBillRent);
try {
Map<String, Object> data = wxRentContractService.getById(id);
return new ResultData(data);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}
}


@RequestMapping("/download")
public void download(HttpServletRequest request, HttpServletResponse response){
@@ -302,15 +359,7 @@ public class WxRentContractController extends WxContractBaseController {
// return new ResultData(Result.SUCCESS, "查询成功", wxRentContractService.getRentContractStatusInfo(wxRentContract));
// }

@GetMapping("/endRentContract")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true),
@ApiImplicitParam(name = "status", value = "status", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "租赁合同-终结合同")
public ResultData endRentContract(Long id,Integer status) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::endRentContract");
return wxRentContractService.endRentContract(id,status);
}


@PostMapping("updateMerchant")
@SystemControllerLog(description = "租赁合同-更新商户")
@@ -392,21 +441,6 @@ public class WxRentContractController extends WxContractBaseController {
return new ResultData(Result.SUCCESS, "查询成功", wxRentContractService.getMerchants(wxRentContract));
}

@GetMapping("/hasRentStatus")
@SystemControllerLog(description = "查询店铺租赁状态")
public ResultData hasRentStatus(@ModelAttribute WxRentContract wxRentContract) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::hasRentStatus");
wxRentContract.updateTenantInfo(getTenantInfo());
return wxRentContractService.hasRentStatus(wxRentContract);
}

@GetMapping("/hasContractNumber")
@SystemControllerLog(description = "租赁合同-检查合同编号是否存在")
public ResultData hasContractNumber(@ModelAttribute WxRentContract wxRentContract) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::hasContractNumber");
wxRentContract.updateTenantInfo(getTenantInfo());
return wxRentContractService.hasContractNumber(wxRentContract);
}

@PostMapping("endContract")
@SystemControllerLog(description = "租赁合同-终止合同")


+ 0
- 146
mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractExtensionController.java Прегледај датотеку

@@ -1,146 +0,0 @@
package com.iformall.controller.contract;

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxRentContract;
import com.iformall.domain.po.WxShop;
import com.iformall.enums.EnumContractType;
import com.iformall.enums.EnumFromType;
import com.iformall.enums.EnumRentStartType;
import com.iformall.service.WxRentContractService;
import com.iformall.service.WxRentPropertyContractService;
import com.iformall.service.WxShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author: furunxin
* @Date: 2020/7/14 11:21
* @Description:
*/

@Slf4j
@RestController
@Api(description = "租赁合同续签")
@RequestMapping("wxRentContractExtension")
public class WxRentContractExtensionController extends WxContractBaseController {


@Autowired
private WxRentContractService wxRentContractService;


@Autowired
private WxRentPropertyContractService wxRentPropertyContractService;

@GetMapping("searchMerchant")
@ApiImplicitParams({
@ApiImplicitParam(name = "merchantName", value = "商户名称", dataType = "string", paramType = "query", required = true),
@ApiImplicitParam(name = "shopType", value = "店铺类型 1:店铺 2:多经点位", dataType = "Integer", paramType = "query", required = true)})
@SystemControllerLog(description = "商户搜索")
public ResultData searchMerchant(String merchantName,Integer shopType) throws Exception{
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.updateTenantInfo(getTenantInfo());
wxRentContract.setMerchantName(merchantName);
wxRentContract.setRentShopType(shopType);
List<Map<String,Object>> result = wxRentContractService.searchMerchantByname(wxRentContract);
return new ResultData(result);
}


@GetMapping("getContractInfo")
@ApiImplicitParams({
@ApiImplicitParam(name = "merchantId", value = "商户id", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "根据商户id查询该商户计租中合同信息")
public ResultData getContractInfo(Long merchantId) throws Exception{
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.setMerchantId(merchantId);
wxRentContract = wxRentContractService.getByMerchantId(wxRentContract);
Map<String, Object> data = wxRentContractService.getById(wxRentContract.getId());
return new ResultData(data);
}

@GetMapping("getAllContractInfo")
@ApiImplicitParams({
@ApiImplicitParam(name = "merchantId", value = "商户id", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "根据商户id查询该商户下所有合同")
public ResultData getAllContractInfo(Long merchantId) throws Exception{
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.setMerchantId(merchantId);
List<WxRentContract> rentContracts = wxRentContractService.getAllContractByMerchantId(wxRentContract);
return new ResultData(rentContracts);
}

@PostMapping("extension")
@SystemControllerLog(description = "租赁合同续签")
public ResultData extension(@RequestBody WxRentContract wxRentContract) {
log.debug("[" + getIpAddr() + "] WxRentContractExtensionController::add");
Integer contractType = wxRentPropertyContractService.getContractType(wxRentContract.getRentShopType(), wxRentContract.getOperationType(), EnumContractType.RENT.getCode());
wxRentContract.setContractType(contractType);
if(StringUtils.isBlank(wxRentContract.getBusDiscountRatio())){
wxRentContract.setBusDiscountTime(new Integer(0));
}
MallUserInfo user = getUser();
wxRentContract.updateTenantInfo(user);
//wxRentContract.setTenantId("789");
//wxRentContract.setParentTenantId("788");
//user.setId(Long.parseLong("321127266275430400"));
//user.setUsername("alitest");
wxRentContract.setAdjustPeriodHandle();
Date oldDate = wxRentContract.getRentalStartDate();
if(wxRentContract.getRentStartType()!=null &&wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){
wxRentContract.setRentalStartDate(wxRentContract.getStartDate());
}
return wxRentContractService.extension(wxRentContract, user.getId(),user.getName(),oldDate);
}

@PostMapping("updateMoney")
@SystemControllerLog(description = "租赁合同续签-更新金额")
public ResultData updateMoney(@RequestBody WxRentContract wxRentContract) {
log.debug("[" + getIpAddr() + "] WxRentContractExtensionController::updateMoney");
if(StringUtils.isBlank(wxRentContract.getBusDiscountRatio())){
wxRentContract.setBusDiscountTime(new Integer(0));
}
MallUserInfo user = getUser();
wxRentContract.updateTenantInfo(user);
wxRentContract.setAdjustPeriodHandle();
wxRentContract.setRentPriceHandle();
Date oldDate = wxRentContract.getRentalStartDate();
if(wxRentContract.getRentStartType()!=null &&wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){
wxRentContract.setRentalStartDate(wxRentContract.getStartDate());
}
return wxRentContractService.extensionUpdate(wxRentContract, user.getId(),user.getName(), EnumFromType.OTHER.getCode(),oldDate);
}

@PostMapping("updateFile")
@SystemControllerLog(description = "租赁合同续签-更新文件")
public ResultData updateFile(@RequestBody WxRentContract wxRentContract) {
log.debug("[" + getIpAddr() + "] WxRentContractExtensionController::updateFile");
if(StringUtils.isBlank(wxRentContract.getBusDiscountRatio())){
wxRentContract.setBusDiscountTime(new Integer(0));
}
MallUserInfo user = getUser();
wxRentContract.updateTenantInfo(user);
wxRentContract.setAdjustPeriodHandle();
wxRentContract.setRentPriceHandle();
Date oldDate = wxRentContract.getRentalStartDate();
if(wxRentContract.getRentStartType()!=null && wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){
wxRentContract.setRentalStartDate(wxRentContract.getStartDate());
}
return wxRentContractService.extensionUpdateFile(wxRentContract, user.getId(),user.getName(),oldDate);
}
}

+ 0
- 7
mallinkAdmin/src/main/resources/db/migration/V202007311200__FOR_MEMBER_ONLY_001.sql Прегледај датотеку

@@ -54,13 +54,6 @@ ADD COLUMN `plat` SMALLINT(3) NOT NULL DEFAULT 1 COMMENT '平台 1:微信 2:阿

ALTER TABLE wx_rent_contract DROP COLUMN shop_id;

CREATE TABLE `wx_rent_contract_shop` (
`id` bigint(20) NOT NULL,
`rent_contract_id` bigint(20) NOT NULL COMMENT '租金合同编码',
`shop_id` bigint(20) NOT NULL COMMENT '店铺编码',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='租金合同关联的店铺';


ALTER TABLE `wx_rent_contract` ADD COLUMN `shop_name` VARCHAR(100) COMMENT '店铺名称';


+ 0
- 5
mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java Прегледај датотеку

@@ -195,11 +195,6 @@ public class WxRentContract extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value = "物业合同预账单列表", name = "reviewBillPropertyPList")
private List<WxBillProperty> reviewBillPropertyPList;
@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value = "店铺列表", name = "shopIdList")
private List<Long> shopIdList;
@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value = "审批说明", name = "remark")
private String remark;


+ 0
- 25
mallinkService/src/main/java/com/iformall/domain/po/WxRentContractShop.java Прегледај датотеку

@@ -1,25 +0,0 @@
package com.iformall.domain.po;

import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.BaseEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@TableName(value = "wx_rent_contract_shop")
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class WxRentContractShop extends BaseEntity {

private static final long serialVersionUID = 6159346068143408562L;

protected Long id;

@io.swagger.annotations.ApiModelProperty(value="合同编号",name="rentContractId")
private Long rentContractId;

@io.swagger.annotations.ApiModelProperty(value="店铺编号",name="shopId")
private Long shopId;
}

+ 0
- 2
mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java Прегледај датотеку

@@ -53,6 +53,4 @@ public interface WxPropertyContractMapper extends CommonMapper<WxPropertyContrac
WxPropertyContract findOneByRentId(WxRentContract wxRentContract);

WxPropertyContract getByBill(WxBillProperty billRent);

List<WxRentContract> getMerchantList(WxPropertyContract wxPropertyContract);
}

+ 0
- 2
mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java Прегледај датотеку

@@ -75,8 +75,6 @@ public interface WxRentContractMapper extends CommonMapper<WxRentContract, Long>

List<Map<String,Object>> queryContractByBus(WxBusiness wxBusiness);

List<Map<String,Object>> searchMerchantByname(WxRentContract wxRentContract);

WxRentContract getByMerchantId(WxRentContract wxRentContract);

List<WxRentContract> getAllContractBymerchantId(WxRentContract wxRentContract);


+ 0
- 14
mallinkService/src/main/java/com/iformall/mapper/WxRentContractShopMapper.java Прегледај датотеку

@@ -1,14 +0,0 @@
package com.iformall.mapper;

import com.iformall.common.CommonMapper;
import com.iformall.domain.po.WxRentContractShop;
import java.util.List;

import org.apache.ibatis.annotations.Param;

public interface WxRentContractShopMapper extends CommonMapper<WxRentContractShop, Long> {

List<WxRentContractShop> findList(WxRentContractShop record);
void deleteShops(@Param("contractId") Long contractId);
}

+ 0
- 4
mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java Прегледај датотеку

@@ -43,8 +43,6 @@ public interface WxPropertyContractService {
*/
ResultData saveOrUpdate(WxPropertyContract record, Long userId, String userName);

ResultData saveOrUpdate2(WxPropertyContract record, Long userId, String userName);

/**
* 根据Id删除实体
*
@@ -79,8 +77,6 @@ public interface WxPropertyContractService {

WxPropertyContract getByBill(WxBillProperty billRent);

Object getMerchantList(WxPropertyContract record);
ResultData apply(WxPropertyContract wxPropertyContract,MallUserInfo user);

}

+ 2
- 12
mallinkService/src/main/java/com/iformall/service/WxRentContractService.java Прегледај датотеку

@@ -102,18 +102,6 @@ public interface WxRentContractService {

ResultData getContractByContractNumber(WxRentContract wxRentContract);

List<Map<String,Object>> searchMerchantByname(WxRentContract wxRentContract);

WxRentContract getByMerchantId(WxRentContract wxRentContract);

List<WxRentContract> getAllContractByMerchantId(WxRentContract wxRentContract);

ResultData extension(WxRentContract record,Long userId,String userName,Date oldRentStartDate);

ResultData extensionUpdate(WxRentContract record, Long userId,String userName,int from,Date oldRentStartDate);

ResultData extensionUpdateFile(WxRentContract wxRentContract, Long userId,String userName,Date oldRentStartDate);

ResultData apply(WxRentContract wxRentContract,MallUserInfo user);

boolean hasContract(WxRentContract wxRentContract);
@@ -124,4 +112,6 @@ public interface WxRentContractService {
*/
void outDateContract(WxRentContract wxRentContract);
WxRentContract getSimpleDeatil(Long id);
}

+ 0
- 161
mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java Прегледај датотеку

@@ -415,162 +415,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
return new ResultData(Result.SUCCESS, message, record);
}

@Override
@Transactional(rollbackFor = {Exception.class})
public ResultData saveOrUpdate2(WxPropertyContract record, Long userId, String userName) {
// 保存调整金额(预账单调整)
boolean haspreview = false;
if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){
savePreviewBill(record);
haspreview = true;
}

if (record.getRentShopType().equals(EnumRentShopType.POINT.getCode()) && null == record.getShopId()) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "shopId不能为空");
}

WxRentContract wxRentContract = wxRentContractMapper.selectById(record.getRentContractId());
if (wxRentContract != null) {
// if (wxRentContract.getStatus().equals(EnumRentContractStatus.CONTRACT_END.getCode()) ||
// wxRentContract.getStatus().equals(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()) ||
// wxRentContract.getStatus().equals(EnumRentContractStatus.INVALID.getCode())) {
if (wxRentContract.getStatus().equals(EnumRentContractStatus.OUT_DATE.getCode()) ||
wxRentContract.getStatus().equals(EnumRentContractStatus.TERMINATE.getCode()) ||
wxRentContract.getStatus().equals(EnumRentContractStatus.INVALID.getCode())) {
return new ResultData(ErrorCode.RENT_CONTRACT_IS_TERMINATED);
}
} else {
return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND);
}
if (null == record.getMerchantId() && record.getOperationType().equals(EnumContractOperationType.PART.getCode())) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "merchantId不能为空");
}
if (record.getOperationType().equals(EnumContractOperationType.PART.getCode())) {
WxMerchant merchant = wxMerchantMapper.selectById(record.getMerchantId());
if (merchant == null) {
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND);
}
}
if (null == record.getReceivePeriod()) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "付款周期不能为空");
}
if (null == record.getLease()) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "租期不能为空");
}
if (null == record.getPrice()) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "物业费不能为空");
}
if (null == record.getDeposit()) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "押金不能为空");
}
if (record.getPrice().longValue() <= 0) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "物业费要大于0");
}

WxPropertyContract propertyContract = new WxPropertyContract();
propertyContract.updateTenantInfo(wxRentContract);
propertyContract.setRentContractId(record.getRentContractId());
long count = wxPropertyContractMapper.findList(propertyContract)
// .stream().filter(p -> p.getStatus().equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()) ||
// p.getStatus().equals(EnumRentContractStatus.RENT_PAID.getCode()) ||
// p.getStatus().equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())).count();
.stream().filter(p -> p.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) ||
p.getStatus().equals(EnumRentContractStatus.PAING.getCode())).count();
if (count > 1) {
return new ResultData(ErrorCode.RENT_CONTRACT_WITH_SHOP_IS_FOUND);
}
//保存物业合同信息
String message;
boolean hasFlow = true;
if (record.getId() == null) {
if (record.getOperationType().equals(EnumContractOperationType.WHOLE.getCode())) {
WxPropertyContract propertyContractQuery = new WxPropertyContract();
propertyContractQuery.setRentContractId(record.getRentContractId());
int propertyContractCount = wxPropertyContractMapper.selectCount(new QueryWrapper(propertyContractQuery));
if (propertyContractCount > 0) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR);
}
}
hasFlow = false;
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setRentalStartDate(wxRentContract.getRentalStartDate());
record.setRentalEndDate(wxRentContract.getRentalEndDate());
record.setStartDate(wxRentContract.getStartDate());
record.setEndDate(wxRentContract.getEndDate());
Date date = new Date();
record.setCreatetime(date);
record.setUpdatetime(date);
record.setStatus(EnumRentContractStatus.DRAFT.getCode());
record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode());
try {
wxPropertyContractMapper.insert(record);
} catch (Exception e) {
logger.error("保存物业合同信息失败,e:" + e.getMessage());
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage());
}

//生成预览账单
wxBillPropertyMapper.deletePreviewBill(record);
//重新生成
List<WxBillProperty> billList = buildProperty(new WxMerchant(),userId,record,EnumIsPreview.YES.getCode(),true);
record.setPreviewBillRentList(billList);

message = "保存物业合同信息成功";
} else {//更新物业合同信息
//查询预账单用于展示
WxBillProperty wxBillRent = new WxBillProperty();
wxBillRent.setPropertyContractId(record.getId());
wxBillRent.setSortColumns(BaseEntity.SortField.Period_ASC);
wxBillRent.setIsPreview(EnumIsPreview.YES.getCode());
List<WxBillProperty> billList = wxBillPropertyMapper.findList(wxBillRent);
record.setPreviewBillRentList(billList);

if(!haspreview){
if (record.getReceivePeriod() != null && record.getLease() != null && record.getPrice() != null
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0l)) {
//删除预账单,重新生成
wxBillPropertyMapper.deletePreviewBill(record);
//重新生成
billList = buildProperty(new WxMerchant(),userId,record,EnumIsPreview.YES.getCode(),true);
record.setPreviewBillRentList(billList);
}
}

WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectById(record.getId());
if (wxPropertyContract == null) {
return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND);
}

record.setRentalStartDate(wxRentContract.getRentalStartDate());
record.setRentalEndDate(wxRentContract.getRentalEndDate());
record.setStartDate(wxRentContract.getStartDate());
record.setEndDate(wxRentContract.getEndDate());
record.setPrice(record.getPrice() != null ? record.getPrice() : 0);
record.setDeposit(record.getDeposit() != null ? record.getDeposit() : 0);
record.setUpdatetime(new Date());

//如果是合并合同 物业合同的状态为 意向
if (record.getOperationType().equals(EnumContractOperationType.WHOLE.getCode())) {
record.setStatus(EnumRentContractStatus.DRAFT.getCode());
}

if (CollectionUtils.isEmpty(record.getFlowParams())) {
hasFlow = false;
record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode());
}
try {
wxPropertyContractMapper.updateById(record);
} catch (Exception e) {
logger.error("更新物业合同信息失败,e:" + e.getMessage());
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage());
}

message = "更新物业合同信息成功";
}
return new ResultData(Result.SUCCESS, message, record);
}

@Override
public ResultData updatePropertyContractStatus(Long id) {
if (id == null) {
@@ -1277,11 +1121,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
return wxPropertyContractMapper.getByBill(billRent);
}

@Override
public Object getMerchantList(WxPropertyContract record) {
return wxPropertyContractMapper.getMerchantList(record);
}

@Override
public ResultData apply(WxPropertyContract record, MallUserInfo user) {


+ 15
- 282
mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java Прегледај датотеку

@@ -114,9 +114,6 @@ public class WxRentContractServiceImpl implements WxRentContractService {
@Autowired
WxPayAccountBillService wxPayAccountBillService;
@Autowired
WxRentContractShopMapper wxRentContractShopMapper;

// @Override
// public Map<String, Object> listAsPage(WxRentContract record, Integer pageIndex, Integer pageSize) {
// //Object rentContractStatusInfo = getRentContractStatusInfo(record);
@@ -490,15 +487,6 @@ public class WxRentContractServiceImpl implements WxRentContractService {
record.setRentalStartDate(oldRentStartDate);
record.setShopName(shopName);
wxRentContractMapper.insert(record);
wxRentContractShopMapper.deleteShops(record.getId());
record.setShopIdList(shopList);
for (Long shopId: shopList) {
WxRentContractShop rentShop = new WxRentContractShop();
rentShop.setShopId(shopId);
rentShop.setRentContractId(record.getId());
wxRentContractShopMapper.insert(rentShop);
}
record.setRentalStartDate(tempDate);
} catch (Exception e) {
logger.error("保存租赁合同信息失败,e:" + e.getMessage());
@@ -666,7 +654,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
} else {
record.setDeposit(0L);
}
List<Long> shopList = Lists.newArrayList();
record.setUpdatetime(new Date());
// if (record.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
String rentInfo = record.getRentInfo();
@@ -676,6 +664,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return new ResultData(ErrorCode.SHOP_NOT_SELECTED);
}
//查询rent_info 包括 shopId
String shopName = "";
for (int i = 0; i < size; i++) {
JSONObject rentInfoObject = rentInfoArray.getJSONObject(i);
WxRentContract wxRentContractQuery = new WxRentContract();
@@ -709,6 +698,10 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return new ResultData(ErrorCode.SHOP_IS_RENT.getCode(), "店铺 " + wxShop.getShopNumber() + " 已出租");
}
}
if (!shopList.contains(shopId)) {
shopList.add(shopId);
shopName = shopName +","+shopNumber;
}
}
// } else {
// WxRentContract wxRentContractQuery = new WxRentContract();
@@ -729,6 +722,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
try {
Date tempDate = record.getRentalStartDate();
record.setRentalStartDate(oldRentStartDate);
record.setShopName(shopName);
wxRentContractMapper.updateById(record);
record.setRentalStartDate(tempDate);
} catch (Exception e) {
@@ -1271,8 +1265,8 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxBillRent.setIsDel(0);
wxBillRent.setMerchantId(wxRentContract.getMerchantId());
wxBillRent.setUserId(userId);
if (null != wxRentContract.getShopIdList() && wxRentContract.getShopIdList().size() == 1) {
wxBillRent.setShopId(wxRentContract.getShopIdList().get(0));
if (null != wxRentContract.shopIdsByRentInfo() && wxRentContract.shopIdsByRentInfo().size() == 1) {
wxBillRent.setShopId(wxRentContract.shopIdsByRentInfo().get(0));
}
wxBillRent.setCreatetime(date);
wxBillRent.setUpdatetime(date);
@@ -1485,8 +1479,8 @@ public class WxRentContractServiceImpl implements WxRentContractService {
try {
wxRentContract.setUpdatetime(new Date());
wxRentContractMapper.updateById(wxRentContract);
//停用商户
wxMerchantService.disable(wxRentContract.getMerchantId());
//停用商户
//wxMerchantService.disable(wxRentContract.getMerchantId());
//物业合同终止
if (status == 1) {
WxPropertyContract wxPropertyContract = new WxPropertyContract();
@@ -2456,271 +2450,6 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return new ResultData(wxRentContract);
}

@Override
public List<Map<String, Object>> searchMerchantByname(WxRentContract wxRentContract) {
return wxRentContractMapper.searchMerchantByname(wxRentContract);
}

@Override
public WxRentContract getByMerchantId(WxRentContract wxRentContract) {
return wxRentContractMapper.getByMerchantId(wxRentContract);
}

@Override
public List<WxRentContract> getAllContractByMerchantId(WxRentContract wxRentContract) {
return wxRentContractMapper.getAllContractBymerchantId(wxRentContract);
}

@Transactional(rollbackFor = {Exception.class})
@Override
public ResultData extension(WxRentContract record, Long userId, String userName, Date oldRentStartDate) {
//保存租赁合同信息
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
int dayType = record.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode()) ? Calendar.DAY_OF_MONTH : Calendar.MONTH;
//计租开始时间
Calendar instance = Calendar.getInstance();
instance.setTime(record.getRentalStartDate());
instance.add(dayType, record.getLease());
instance.add(Calendar.DAY_OF_MONTH, -1);
//起租结束时间
if (!record.getStartDate().equals(record.getRentalStartDate())) {
instance.clear();
instance.setTime(record.getRentalStartDate());
instance.add(Calendar.DAY_OF_MONTH, -1);
record.setEndDate(instance.getTime());
} else {
record.setEndDate(record.getStartDate());
}

if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) {
if(record.getRevenue() == null || record.getRevenue().longValue() <= 0){
record.setPrice(0l);
}else{
if(record.getPayRatio()!=null && record.getPayRatio().intValue() > 0){
record.setPrice(countPrice(record.getPayRatio(),record.getRevenue(),EnumMissTimeType.OTHER.getCode(),record.getAdjustPeriod(),EnumGetRatioFrom.RENT.getCode()));
}else{
int dayCount = record.getReceivePeriod() * 30;
RatioVo ratioVo = getPayRatio(EnumGetRatioFrom.RENT.getCode(),record.getRevenue(),record.getBusDiscountRatio(),record.getBusDiscountTime(),dayCount,record.getReceivePeriod());
//record.setPayRatio(ratioVo.getRatio());
record.setPrice(ratioVo.getPrice());
}
}
} else {
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 {
record.setDeposit(0L);
}

Date date = new Date();
record.setCreatetime(date);
record.setUpdatetime(date);

List<Long> shopList = Lists.newArrayList();
String shopName = "";
//if (record.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
String rentInfo = record.getRentInfo();
JSONArray rentInfoArray = JSONArray.parseArray(rentInfo);
int size = rentInfoArray.size();
if (size == 0) {
return new ResultData(ErrorCode.SHOP_NOT_SELECTED);
}
//查询rent_info 包括 shopId
for (int i = 0; i < size; i++) {
JSONObject rentInfoObject = rentInfoArray.getJSONObject(i);
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.updateTenantInfo(record);
Long shopId = rentInfoObject.getLong("shopId");
String shopNumber = rentInfoObject.getString("shopNumber");
WxShop wxShop = wxShopMapper.selectById(shopId);
if (wxShop == null) {
return new ResultData(ErrorCode.SHOP_IS_NOT_FOUND.getCode(), "店铺 " + shopNumber + " 已删除");
}
if (!shopList.contains(shopId)) {
shopList.add(shopId);
shopName = shopName+","+shopNumber;
}
}
//} else {
// shopList.add(record.getShopId());
//}

try {
record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode());
record.setStatus(EnumRentContractStatus.DRAFT.getCode());
Date tempDate = record.getRentalStartDate();
record.setRentalStartDate(oldRentStartDate);
record.setShopName(shopName);
wxRentContractMapper.insert(record);
record.setRentalStartDate(tempDate);
} catch (Exception e) {
logger.error("保存租赁合同信息失败,e:" + e.getMessage());
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage());
}

//生成预览账单(补录第二步,第三步走编辑)
// if (record.getReceivePeriod() != null && record.getLease() != null && record.getPrice() != null
// && !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0l)) {
// wxBillRentMapper.deletePreviewBill(record);
// //重新生成
// List<WxBillRent> resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode(),true);
// record.setPreviewBillRentList(resultList);
// }
List<WxBillRent> resultList = buildRent(null, record, EnumIsPreview.YES.getCode(),true);
record.setPreviewBillRentList(resultList);
EventUtil.publistRentEvent(this, record);
return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", record);
}

@Transactional(rollbackFor = {Exception.class})
@Override
public ResultData extensionUpdate(WxRentContract record, Long userId, String userName, int from, Date oldRentStartDate) {
//查询预账单用于展示
WxBillRent wxBillRent = new WxBillRent();
wxBillRent.setRentContractId(record.getId());
wxBillRent.setSortColumns(BaseEntity.SortField.Period_ASC);
wxBillRent.setIsPreview(EnumIsPreview.YES.getCode());
List<WxBillRent> resultList = wxBillRentMapper.findList(wxBillRent);

//更新
ResultData resultData = getResultDataForExtensionUpdate(record, userId,from,oldRentStartDate);
if (resultData.code != Result.SUCCESS) {
return resultData;
}

if(CollectionUtils.isEmpty(record.getPreviewBillRentList())) {
if (record.getReceivePeriod() != null && record.getLease() != null
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0)) {
//删除预账单,重新生成
wxBillRentMapper.deletePreviewBill(record);
resultList = buildRent( null, record, EnumIsPreview.YES.getCode(),true);
}
}

//保存调整金额(预账单调整)
savePreviewBill(record);

WxRentContract wxRentContract = (WxRentContract)resultData.data;
wxRentContract.setPreviewBillRentList(resultList);
return new ResultData(wxRentContract);
}

public ResultData getResultDataForExtensionUpdate(WxRentContract record, Long userId,int from,Date oldRentStartDate) {
//更新租赁合同信息
WxRentContract wxRentContract = wxRentContractMapper.selectById(record.getId());
if (wxRentContract == null) {
return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND);
}
wxRentContract.setBusDiscountTime(record.getBusDiscountTime());
wxRentContract.setBusDiscountRatio(record.getBusDiscountRatio());
wxRentContract.setPayRatio(record.getPayRatio());

int dayType = wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode()) ? Calendar.DAY_OF_MONTH : Calendar.MONTH;

Calendar instance = Calendar.getInstance();
instance.setTime(record.getRentalStartDate());
instance.add(dayType, record.getLease());
instance.add(Calendar.DAY_OF_MONTH, -1);

if(!EnumFromType.SWITCH.getCode().equals(from)){
if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) {
if(record.getPayRatio()!=null && record.getPayRatio().intValue() > 0){
record.setPrice(countPrice(record.getPayRatio(),record.getRevenue(),EnumMissTimeType.OTHER.getCode(),record.getAdjustPeriod(),from));
}else{
int dayCount = record.getReceivePeriod() * 30;
RatioVo ratioVo = getPayRatio(EnumGetRatioFrom.RENT.getCode(),record.getRevenue(),record.getBusDiscountRatio(),record.getBusDiscountTime(),dayCount,record.getReceivePeriod());
//record.setPayRatio(ratioVo.getRatio());
record.setPrice(ratioVo.getPrice());
}
} else {
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 {
record.setDeposit(0L);
}

record.setUpdatetime(new Date());

// if (record.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
String rentInfo = record.getRentInfo();
JSONArray rentInfoArray = JSONArray.parseArray(rentInfo);
int size = rentInfoArray.size();
if (size == 0) {
return new ResultData(ErrorCode.SHOP_NOT_SELECTED);
}
//查询rent_info 包括 shopId
for (int i = 0; i < size; i++) {
JSONObject rentInfoObject = rentInfoArray.getJSONObject(i);
WxRentContract wxRentContractQuery = new WxRentContract();
wxRentContractQuery.updateTenantInfo(record);
Long shopId = rentInfoObject.getLong("shopId");
String shopNumber = rentInfoObject.getString("shopNumber");
if (shopId == null) {
return new ResultData(ErrorCode.SHOP_IS_NOT_FOUND.getCode(), "店铺 " + shopNumber + " 已删除");
}
WxShop wxShop = wxShopMapper.selectById(shopId);
if (wxShop == null) {
return new ResultData(ErrorCode.SHOP_IS_NOT_FOUND.getCode(), "店铺 " + shopNumber + " 已删除");
}
}
// } else {
// WxRentContract wxRentContractQuery = new WxRentContract();
// wxRentContractQuery.updateTenantInfo(record);
// wxRentContractQuery.setShopId(record.getShopId());
//// long count = wxRentContractMapper.queryRentContractData(wxRentContract).stream().
//// filter(rc -> rc.get("status").equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode())
//// || rc.get("status").equals(EnumRentContractStatus.RENT_PAID.getCode())
//// || rc.get("status").equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())).count();
// long count = wxRentContractMapper.queryRentContractData(wxRentContract).stream().
// filter(rc -> rc.get("status").equals(EnumRentContractStatus.READY_FOR_PAING.getCode())
// || rc.get("status").equals(EnumRentContractStatus.PAING.getCode())).count();
// if (count > 0) {
// return new ResultData(ErrorCode.RENT_CONTRACT_WITH_SHOP_IS_FOUND);
// }
// }

try {
Date tempDate = record.getRentalStartDate();
record.setRentalStartDate(oldRentStartDate);
wxRentContractMapper.updateById(record);
record.setRentalStartDate(tempDate);
} catch (Exception e) {
logger.error("更新租赁合同信息失败,e:" + e.getMessage());
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage());
}
return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", wxRentContract);
}

@Transactional(rollbackFor = {Exception.class})
@Override
public ResultData extensionUpdateFile(WxRentContract record, Long userId,String userName,Date oldRentStartDate) {
// 保存调整金额(预账单调整)
if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){
savePreviewBill(record);
}
ResultData resultData = getResultDataForExtensionUpdate(record, userId,0,oldRentStartDate);
if (resultData.code != Result.SUCCESS) {
return resultData;
}

return resultData;
}

@Override
public ResultData apply(WxRentContract wxRentContract,MallUserInfo user) {
WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId());
@@ -2796,4 +2525,8 @@ public class WxRentContractServiceImpl implements WxRentContractService {
// }
// }
}
@Override
public WxRentContract getSimpleDeatil(Long id) {
return wxRentContractMapper.selectById(id);
}
}

+ 0
- 21
mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml Прегледај датотеку

@@ -386,25 +386,4 @@
select property_contract_id from wx_bill_property id = #{id}
)
</select>

<select id="getMerchantList" parameterType="com.iformall.domain.po.WxPropertyContract" resultType="com.iformall.domain.po.WxRentContract">
select rc.* from wx_rent_contract rc
where rc.status in(3,9)
<if test=" null != tenantId and '' != tenantId">
and rc.`tenant_id` = #{tenantId}
</if>
<if test=" null != parentTenantId and '' != parentTenantId">
and rc.`parent_tenant_id` = #{parentTenantId}
</if>
and rc.id not in (select pc.rent_contract_id from (
select rent_contract_id from wx_property_contract where 1=1 and `status`!=6
<if test=" null != tenantId and '' != tenantId">
and `tenant_id` = #{tenantId}
</if>
<if test=" null != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
</if>
) pc)
and rent_shop_type = #{rentShopType}
</select>
</mapper>

+ 0
- 12
mallinkService/src/main/resources/mapper/WxRentContractMapper.xml Прегледај датотеку

@@ -660,18 +660,6 @@
)
</select> -->

<select id="searchMerchantByname" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract">
select merchant_id,merchant_name from wx_rent_contract where tenant_id = #{tenantId} and merchant_name like concat('%',#{merchantName},'%') and rent_shop_type = #{rentShopType} and status in (3,5) and merchant_id not in (select merchant_id from wx_rent_contract where status=9) ORDER BY merchant_name
</select>

<select id="getByMerchantId" resultType="com.iformall.domain.po.WxRentContract" parameterType="com.iformall.domain.po.WxRentContract">
select * from wx_rent_contract where merchant_id = #{merchantId} and status in (3,5) ORDER BY rental_end_date DESC limit 1
</select>

<select id="getAllContractBymerchantId" resultType="com.iformall.domain.po.WxRentContract" parameterType="com.iformall.domain.po.WxRentContract">
select * from wx_rent_contract where merchant_id = #{merchantId} ORDER BY rental_end_date
</select>

<select id="getContractByMerchant" resultType="com.iformall.domain.po.WxRentContract" parameterType="com.iformall.domain.po.WxRentContract">
select * from wx_rent_contract where merchant_id = #{merchantId} and status=3
</select>


+ 0
- 34
mallinkService/src/main/resources/mapper/WxRentContractShopMapper.xml Прегледај датотеку

@@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.iformall.mapper.WxRentContractShopMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxRentContractShop">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId"/>
<result column="shop_id" jdbcType="BIGINT" property="shopId"/>
</resultMap>

<sql id="allColumns">
`id`,`rent_contract_id`,`shop_id`
</sql>


<sql id="dynamicWhereConditions">
where 1 = 1
<if test=" null != id ">and `id` = #{id}</if>
<if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
<if test=" null != shopId ">and `shop_id` = #{shopId}</if>
<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>

<select id="findList" parameterType="com.iformall.domain.po.WxRentContractShop" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_rent_contract_shop
<include refid="dynamicWhereConditions"/>
</select>
<delete id="deleteShops" parameterType="Long">
delete from wx_rent_contract_shop where rent_contract_id = #{contractId}
</delete>
</mapper>


Loading…
Откажи
Сачувај