|
|
@@ -15,6 +15,7 @@ import com.iformall.mapper.*; |
|
|
import com.iformall.service.*; |
|
|
import com.iformall.service.*; |
|
|
import com.iformall.utils.Constant; |
|
|
import com.iformall.utils.Constant; |
|
|
import com.iformall.utils.DateUtils; |
|
|
import com.iformall.utils.DateUtils; |
|
|
|
|
|
import org.apache.commons.collections.map.HashedMap; |
|
|
import org.apache.commons.io.FileUtils; |
|
|
import org.apache.commons.io.FileUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument; |
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument; |
|
|
@@ -146,13 +147,13 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
result.put("remark",flowRecordList.get(0).getRemark()); |
|
|
result.put("remark",flowRecordList.get(0).getRemark()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//删除预账单 |
|
|
|
|
|
if(wxRentContract.getReceivePeriod() != null && wxRentContract.getLease()!=null && wxRentContract.getRentalStartDate()!=null && wxRentContract.getPrice()!= null){ |
|
|
|
|
|
wxBillRentMapper.deletePreviewBill(wxRentContract); |
|
|
|
|
|
//重新生成 |
|
|
|
|
|
List<WxBillRent> resultList = buildRent(new WxMerchant(),null,wxRentContract,EnumIsPreview.YES.getCode()); |
|
|
|
|
|
wxRentContract.setPreviewBillRentList(resultList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//查询预账单用于展示 |
|
|
|
|
|
WxBillRent wxBillRent = new WxBillRent(); |
|
|
|
|
|
wxBillRent.setRentContractId(id); |
|
|
|
|
|
wxBillRent.setSortColumns(WxBillRent.Field.Period_ASC); |
|
|
|
|
|
wxBillRent.setIsPreview(EnumIsPreview.YES.getCode()); |
|
|
|
|
|
List<WxBillRent> resultList = wxBillRentMapper.findList(wxBillRent); |
|
|
|
|
|
wxRentContract.setPreviewBillRentList(resultList); |
|
|
|
|
|
|
|
|
return new ResultData(Result.SUCCESS, "查询成功", result); |
|
|
return new ResultData(Result.SUCCESS, "查询成功", result); |
|
|
} |
|
|
} |
|
|
@@ -243,36 +244,43 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
@Transactional(rollbackFor = {Exception.class}) |
|
|
@Transactional(rollbackFor = {Exception.class}) |
|
|
@Override |
|
|
@Override |
|
|
public ResultData update(WxRentContract record, Long userId,String userName) { |
|
|
public ResultData update(WxRentContract record, Long userId,String userName) { |
|
|
|
|
|
//删除预账单 |
|
|
|
|
|
List<WxBillRent> resultList = new ArrayList<>(); |
|
|
|
|
|
if(record.getReceivePeriod() != null && record.getLease()!=null && record.getPrice()!= null){ |
|
|
|
|
|
//对比上一次,是否有更改,有,重新生成预账单 |
|
|
|
|
|
WxRentContract dbRent = wxRentContractMapper.selectByPrimaryKey(record.getId()); |
|
|
|
|
|
if(!record.getReceivePeriod().equals(dbRent.getReceivePeriod()) |
|
|
|
|
|
||!record.getLease().equals(dbRent.getLease()) |
|
|
|
|
|
||!record.getType().equals(dbRent.getType()) |
|
|
|
|
|
||!record.getPrice().equals(dbRent.getPrice()) |
|
|
|
|
|
||!record.getAdjustRatio().equals(dbRent.getAdjustRatio()) |
|
|
|
|
|
) { |
|
|
|
|
|
wxBillRentMapper.deletePreviewBill(record); |
|
|
|
|
|
//重新生成 |
|
|
|
|
|
resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
ResultData resultData = getResultDataForUpdate(record, userId); |
|
|
ResultData resultData = getResultDataForUpdate(record, userId); |
|
|
try { |
|
|
|
|
|
//启动审批流 |
|
|
|
|
|
if(record.getFlowParams() != null){ |
|
|
|
|
|
record.getFlowParams().put("businessId",record.getId().toString()); |
|
|
|
|
|
if(record.getMerchantId() != null) { |
|
|
|
|
|
record.getFlowParams().put("supplement", true); //设置补录 |
|
|
|
|
|
} |
|
|
|
|
|
wxFlowService.start(record.getFlowParams(),userId,userName,record.getTenantId()); |
|
|
|
|
|
|
|
|
|
|
|
//合同状态改成待签约 |
|
|
|
|
|
WxRentContract updateRentContract = new WxRentContract(); |
|
|
|
|
|
updateRentContract.setId(record.getId()); |
|
|
|
|
|
updateRentContract.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); |
|
|
|
|
|
wxRentContractMapper.updateStatus(updateRentContract); |
|
|
|
|
|
logger.info("id:{},启动审批流成功 ,是否补录:{}",record.getId().toString(),record.getMerchantId() != null); |
|
|
|
|
|
|
|
|
//启动审批流 |
|
|
|
|
|
if(record.getFlowParams() != null){ |
|
|
|
|
|
record.getFlowParams().put("businessId",record.getId().toString()); |
|
|
|
|
|
if(record.getMerchantId() != null) { |
|
|
|
|
|
record.getFlowParams().put("supplement", true); //设置补录 |
|
|
} |
|
|
} |
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error("启动审批流失败,e:" + e.getMessage()); |
|
|
|
|
|
throw new MallinkException(ErrorCode.FLOW_FAIL.getCode(), "FLOW FAILD " + e.getMessage()); |
|
|
|
|
|
|
|
|
wxFlowService.start(record.getFlowParams(),userId,userName,record.getTenantId()); |
|
|
|
|
|
|
|
|
|
|
|
//合同状态改成待签约 |
|
|
|
|
|
WxRentContract updateRentContract = new WxRentContract(); |
|
|
|
|
|
updateRentContract.setId(record.getId()); |
|
|
|
|
|
updateRentContract.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); |
|
|
|
|
|
wxRentContractMapper.updateStatus(updateRentContract); |
|
|
|
|
|
logger.info("id:{},启动审批流成功 ,是否补录:{}",record.getId().toString(),record.getMerchantId() != null); |
|
|
} |
|
|
} |
|
|
WxRentContract wxRentContract = (WxRentContract)resultData.data; |
|
|
|
|
|
|
|
|
|
|
|
//删除预账单 |
|
|
|
|
|
if(record.getReceivePeriod() != null && record.getLease()!=null && record.getRentalStartDate()!=null && record.getPrice()!= null){ |
|
|
|
|
|
wxBillRentMapper.deletePreviewBill(record); |
|
|
|
|
|
//重新生成 |
|
|
|
|
|
List<WxBillRent> resultList = buildRent(new WxMerchant(),null,record,EnumIsPreview.YES.getCode()); |
|
|
|
|
|
wxRentContract.setPreviewBillRentList(resultList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
WxRentContract wxRentContract = (WxRentContract)resultData.data; |
|
|
|
|
|
wxRentContract.setPreviewBillRentList(resultList); |
|
|
return new ResultData(wxRentContract); |
|
|
return new ResultData(wxRentContract); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -428,9 +436,13 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview); |
|
|
rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview); |
|
|
} else { |
|
|
} else { |
|
|
//按日计租 |
|
|
//按日计租 |
|
|
rentList = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0,isPreview); |
|
|
|
|
|
|
|
|
Map<String,Object> resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0,isPreview); |
|
|
|
|
|
rentList = ( List<WxBillRent>)resultMap.get("billList"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
for (int i = 0; i < rentList.size(); i++) { |
|
|
|
|
|
rentList.get(i).setPeriod(i+1); |
|
|
|
|
|
} |
|
|
return rentList; |
|
|
return rentList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -464,13 +476,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
instance.setTime(rentalStartDate); |
|
|
instance.setTime(rentalStartDate); |
|
|
//开始时间 |
|
|
//开始时间 |
|
|
instance.add(Calendar.MONTH, month * i); |
|
|
instance.add(Calendar.MONTH, month * i); |
|
|
List<WxBillRent> billRentList = buildRent(leaseArr[i], receivePeriod, priceArr[i], instance.getTime(), Calendar.MONTH, wxRentContract, userId, wxMerchant, billcount,isPreview); |
|
|
|
|
|
|
|
|
Map<String,Object> resultMap = buildRent(leaseArr[i], receivePeriod, priceArr[i], instance.getTime(), Calendar.MONTH, wxRentContract, userId, wxMerchant, billcount,isPreview); |
|
|
|
|
|
List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList"); |
|
|
|
|
|
billcount = (Integer)resultMap.get("billcount"); |
|
|
resultList.addAll(billRentList); |
|
|
resultList.addAll(billRentList); |
|
|
} |
|
|
} |
|
|
return resultList; |
|
|
return resultList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<WxBillRent> buildRent(int lease, int receivePeriod, int price, Date startdate, int dayType, WxRentContract wxRentContract, Long userId, WxMerchant wxMerchant, int billcount,Integer isPreview) { |
|
|
|
|
|
|
|
|
public Map<String,Object> buildRent(int lease, int receivePeriod, int price, Date startdate, int dayType, WxRentContract wxRentContract, Long userId, WxMerchant wxMerchant, int billcount,Integer isPreview) { |
|
|
|
|
|
Map<String,Object> resultMap = new HashedMap(); |
|
|
List<WxBillRent> resultList = new ArrayList<>(); |
|
|
List<WxBillRent> resultList = new ArrayList<>(); |
|
|
int extralease = lease % receivePeriod; |
|
|
int extralease = lease % receivePeriod; |
|
|
int extracount = extralease > 0 ? 1 : 0; |
|
|
int extracount = extralease > 0 ? 1 : 0; |
|
|
@@ -561,7 +576,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); |
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return resultList; |
|
|
|
|
|
|
|
|
resultMap.put("billcount",billcount); |
|
|
|
|
|
resultMap.put("billList",resultList); |
|
|
|
|
|
return resultMap; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|