Просмотр исходного кода

[合同][修改][添加调整预览账单逻辑]

release_toaliyun_real
luozukai 6 лет назад
Родитель
Сommit
fc4293b660
3 измененных файлов: 43 добавлений и 12 удалений
  1. +17
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java
  2. +3
    -1
      mallinkService/src/main/java/com/iformall/service/WxRentContractService.java
  3. +23
    -11
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java

+ 17
- 0
mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java Просмотреть файл

@@ -7,6 +7,7 @@ import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController; import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*; import com.iformall.domain.po.*;
import com.iformall.enums.EnumFromType; import com.iformall.enums.EnumFromType;
import com.iformall.enums.EnumIsPreview;
import com.iformall.enums.EnumRentStartType; import com.iformall.enums.EnumRentStartType;
import com.iformall.exception.MallinkException; import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxRentContractMapper; import com.iformall.mapper.WxRentContractMapper;
@@ -28,6 +29,7 @@ import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;


/** /**
@@ -78,6 +80,21 @@ public class WxRentContractController extends BaseController {
return new ResultData(result); return new ResultData(result);
} }


/**
* 预览账单展示,编辑账期,后端生成账单金额
* @param wxRentContract
* @return
*/
@GetMapping("buildBillPriceList")
@SystemControllerLog(description = "租赁合同-生成账单列表金额")
public ResultData buildBillPriceList(@ModelAttribute WxRentContract wxRentContract) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::buildBillPriceList");
WxRentContract dbRent = wxRentContractMapper.selectByPrimaryKey(wxRentContract.getId());
dbRent.setPreviewBillRentList(wxRentContract.getPreviewBillRentList());
List<WxBillRent> result = wxRentContractService.buildRent(new WxMerchant(),getUserId(),dbRent, EnumIsPreview.YES.getCode(), false);
return new ResultData(result);
}

@PostMapping("add") @PostMapping("add")
@SystemControllerLog(description = "租赁合同-添加") @SystemControllerLog(description = "租赁合同-添加")
public ResultData add(@RequestBody WxRentContract wxRentContract) { public ResultData add(@RequestBody WxRentContract wxRentContract) {


+ 3
- 1
mallinkService/src/main/java/com/iformall/service/WxRentContractService.java Просмотреть файл

@@ -74,7 +74,7 @@ public interface WxRentContractService {


void updateApplyStatus(WxRentContract wxRentContract); void updateApplyStatus(WxRentContract wxRentContract);


List<WxBillRent> buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview);
List<WxBillRent> buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview,boolean saveDb);


void buildDeposit(WxMerchant wxMerchant, Long userId,Long rentContractId); void buildDeposit(WxMerchant wxMerchant, Long userId,Long rentContractId);


@@ -93,4 +93,6 @@ public interface WxRentContractService {
void updatePropertyPreviewBill(WxRentContract record); void updatePropertyPreviewBill(WxRentContract record);


Map<String, Object> updateStatus(WxRentContract record); Map<String, Object> updateStatus(WxRentContract record);

List<WxBillRent> buildBillPriceList(WxRentContract rentContract);
} }

+ 23
- 11
mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java Просмотреть файл

@@ -383,7 +383,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0l)) { && !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0l)) {
wxBillRentMapper.deletePreviewBill(record); wxBillRentMapper.deletePreviewBill(record);
//重新生成 //重新生成
List<WxBillRent> resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode());
List<WxBillRent> resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode(),true);
record.setPreviewBillRentList(resultList); record.setPreviewBillRentList(resultList);
} }
return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", record); return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", record);
@@ -410,7 +410,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0)) { && !record.getReceivePeriod().equals(0) && !record.getLease().equals(0)) {
//删除预账单,重新生成 //删除预账单,重新生成
wxBillRentMapper.deletePreviewBill(record); wxBillRentMapper.deletePreviewBill(record);
resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode());
resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode(),true);
} }
} }


@@ -800,7 +800,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {


@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
public List<WxBillRent> buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview) {
public List<WxBillRent> buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview,boolean saveDb) {
List<WxBillRent> rentList = new ArrayList<>(); List<WxBillRent> rentList = new ArrayList<>();
//根据商户ID找出合同 //根据商户ID找出合同
WxRentContract wxRentContract; WxRentContract wxRentContract;
@@ -824,7 +824,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
//按月计租 //按月计租
// if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode()) // if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode())
// ||wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { // ||wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) {
rentList = buildRentMonth(userId, wxRentContract, receivePeriod, lease, rentalStartDate, price, isPreview);
rentList = buildRentMonth(userId, wxRentContract, receivePeriod, lease, rentalStartDate, price, isPreview,saveDb);
// } else { // } else {
// //如果按日 // //如果按日
// List<Date> yearList = new ArrayList<>(); // List<Date> yearList = new ArrayList<>();
@@ -889,7 +889,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return priceList; return priceList;
} }


public List<WxBillRent> buildRentMonth(Long userId, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview) {
public List<WxBillRent> buildRentMonth(Long userId, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview,boolean saveDb) {
int size = 0; int size = 0;
long[] priceArrs = null; long[] priceArrs = null;
List<Map<String, Object>> shopInfos = new ArrayList<>(); List<Map<String, Object>> shopInfos = new ArrayList<>();
@@ -977,9 +977,8 @@ public class WxRentContractServiceImpl implements WxRentContractService {
yearList.add(startDate); yearList.add(startDate);
} }



String shopInfoStr = getShopInfoStr(wxRentContract); String shopInfoStr = getShopInfoStr(wxRentContract);
Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr);
Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr,saveDb);
List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList"); List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList");
resultList.addAll(billRentList); resultList.addAll(billRentList);
return resultList; return resultList;
@@ -1001,7 +1000,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return shopInfoStr; return shopInfoStr;
} }


public Map<String, Object> buildRent(int receivePeriod, long[] priceArrs, List<Date> yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr) {
public Map<String, Object> buildRent(int receivePeriod, long[] priceArrs, List<Date> yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) {
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
Map<String,Object> resultMap = new HashedMap(); Map<String,Object> resultMap = new HashedMap();
List<WxBillRent> resultList = new ArrayList<>(); List<WxBillRent> resultList = new ArrayList<>();
@@ -1012,7 +1011,19 @@ public class WxRentContractServiceImpl implements WxRentContractService {
endDate = yearList.get(1); endDate = yearList.get(1);
} }


List<BillTimeVo> billTimeVoList = initBillTimeList(wxRentContract.getRentalStartDate(),wxRentContract.getRentalEndDate(),wxRentContract.getAdjustPeriod(),dayType,receivePeriod);
List<BillTimeVo> billTimeVoList = new ArrayList<>();
if(saveDb){
billTimeVoList = initBillTimeList(wxRentContract.getRentalStartDate(),wxRentContract.getRentalEndDate(),wxRentContract.getAdjustPeriod(),dayType,receivePeriod);
}else{
//预账单编辑账期,生成金额
for (WxBillRent rent:wxRentContract.getPreviewBillRentList()) {
BillTimeVo billTimeVo = new BillTimeVo();
billTimeVo.setStartDate(rent.getStarttime());
billTimeVo.setEndDate(rent.getEndtime());
billTimeVo.setReceiveDate(DateUtils.getDaySet(rent.getStarttime(),Calendar.DATE,-1));
billTimeVoList.add(billTimeVo);
}
}


int index = 0; int index = 0;
for (int i = 0; i < billTimeVoList.size(); i++) { for (int i = 0; i < billTimeVoList.size(); i++) {
@@ -1115,12 +1126,13 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxBillRent.setPeriod(++billcount); wxBillRent.setPeriod(++billcount);
wxBillRent.setShopInfo(shopInfoStr); wxBillRent.setShopInfo(shopInfoStr);
wxBillRent.setLatePayRatio(0); wxBillRent.setLatePayRatio(0);
//wxBillRentMapper.insertSelective(wxBillRent);
resultList.add(wxBillRent); resultList.add(wxBillRent);
} }


//批量插入账单 //批量插入账单
wxBillRentMapper.insertBills(resultList);
if(saveDb) {
wxBillRentMapper.insertBills(resultList);
}
resultMap.put("billcount",billcount); resultMap.put("billcount",billcount);
resultMap.put("billList",resultList); resultMap.put("billList",resultList);
return resultMap; return resultMap;


Загрузка…
Отмена
Сохранить