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

[铜锣湾][添加][预账单]

release_toaliyun_real
luozukai 7 лет назад
committed by Stormeye Wu
Родитель
Сommit
1120c9915b
7 измененных файлов: 90 добавлений и 54 удалений
  1. +2
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/WxPropertyContractController.java
  2. +1
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxBillProperty.java
  3. +1
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxBillRent.java
  4. +25
    -12
      mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java
  5. +53
    -36
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java
  6. +4
    -2
      mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml
  7. +4
    -2
      mallinkService/src/main/resources/mapper/WxBillRentMapper.xml

+ 2
- 2
mallinkAdmin/src/main/java/com/iformall/controller/WxPropertyContractController.java Просмотреть файл

@@ -81,9 +81,9 @@ public class WxPropertyContractController extends BaseController {
}

/**
* 生成账单
* 生成预览账单
*/
@ApiOperation("生成账单")
@ApiOperation("生成预览账单")
@GetMapping(value = "/buildBill")
public ResultData buildBill(@ModelAttribute WxRentContract wxRentContract) {
logger.debug("[" + getIpAddr() + "] WxPropertyContractController::buildBill");


+ 1
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxBillProperty.java Просмотреть файл

@@ -318,6 +318,7 @@ public class WxBillProperty implements Serializable {
,UserId_ASC("`userId` ASC"),UserId_DESC("`userId` DESC")
,ShopId_ASC("`shopId` ASC"),ShopId_DESC("`shopId` DESC")
,Updatetime_ASC("`updatetime` ASC"),Updatetime_DESC("`updatetime` DESC")
,Period_ASC("`period` ASC")
;
private String value;
Field(String value){


+ 1
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxBillRent.java Просмотреть файл

@@ -318,6 +318,7 @@ public class WxBillRent implements Serializable {
,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC")
,UserId_ASC("`userId` ASC"),UserId_DESC("`userId` DESC")
,ShopId_ASC("`shopId` ASC"),ShopId_DESC("`shopId` DESC")
,Period_ASC("`period` ASC")
;
private String value;
Field(String value){


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

@@ -121,13 +121,20 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
result.put("remark",flowRecordList.get(0).getRemark());
}

//生成预览账单
if(wxPropertyContract.getReceivePeriod() != null && wxPropertyContract.getLease()!=null) {
wxBillPropertyMapper.deletePreviewBill(wxPropertyContract);
//重新生成
List<WxBillProperty> billList = buildProperty(new WxMerchant(),wxPropertyContract,EnumIsPreview.YES.getCode());
wxPropertyContract.setPreviewBillRentList(billList);
}
// //生成预览账单
// if(wxPropertyContract.getReceivePeriod() != null && wxPropertyContract.getLease()!=null) {
// wxBillPropertyMapper.deletePreviewBill(wxPropertyContract);
// //重新生成
// List<WxBillProperty> billList = buildProperty(new WxMerchant(),wxPropertyContract,EnumIsPreview.YES.getCode());
// wxPropertyContract.setPreviewBillRentList(billList);
// }
//查询预账单用于展示
WxBillProperty wxBillRent = new WxBillProperty();
wxBillRent.setPropertyContractId(id);
wxBillRent.setSortColumns(WxBillProperty.Field.Period_ASC);
wxBillRent.setIsPreview(EnumIsPreview.YES.getCode());
List<WxBillProperty> resultList = wxBillPropertyMapper.findList(wxBillRent);
wxPropertyContract.setPreviewBillRentList(resultList);

return new ResultData(Result.SUCCESS, "查询成功", result);
}
@@ -482,6 +489,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
}
}
}
for (int i = 0; i < result.size(); i++) {
result.get(i).setPeriod(i+1);
}
return result;
}

@@ -729,11 +739,14 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
//生成预览账单
//根据租赁合同找到对应的物业合同,生成物业账单
WxPropertyContract propertyContract = wxPropertyContractMapper.findOneByRentId(wxRentContract);
if(propertyContract!=null && propertyContract.getReceivePeriod() != null && propertyContract.getLease()!=null) {
wxBillPropertyMapper.deletePreviewBill(propertyContract);
//重新生成
List<WxBillProperty> billList = buildProperty(new WxMerchant(),propertyContract,EnumIsPreview.YES.getCode());
return billList;
if(propertyContract != null) {
if(!wxRentContract.getLease().equals(propertyContract.getLease())
||!wxRentContract.getPrice().equals(propertyContract.getPrice())){
wxBillPropertyMapper.deletePreviewBill(propertyContract);
//重新生成
List<WxBillProperty> billList = buildProperty(new WxMerchant(),propertyContract,EnumIsPreview.YES.getCode());
return billList;
}
}
return new ArrayList<>();
}


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

@@ -15,6 +15,7 @@ import com.iformall.mapper.*;
import com.iformall.service.*;
import com.iformall.utils.Constant;
import com.iformall.utils.DateUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
@@ -146,13 +147,13 @@ public class WxRentContractServiceImpl implements WxRentContractService {
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);
}
@@ -243,36 +244,43 @@ public class WxRentContractServiceImpl implements WxRentContractService {
@Transactional(rollbackFor = {Exception.class})
@Override
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);
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);
}

@@ -428,9 +436,13 @@ public class WxRentContractServiceImpl implements WxRentContractService {
rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview);
} 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;
}

@@ -464,13 +476,16 @@ public class WxRentContractServiceImpl implements WxRentContractService {
instance.setTime(rentalStartDate);
//开始时间
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);
}
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<>();
int extralease = lease % receivePeriod;
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());
}
}
return resultList;
resultMap.put("billcount",billcount);
resultMap.put("billList",resultList);
return resultMap;
}




+ 4
- 2
mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml Просмотреть файл

@@ -38,7 +38,7 @@
</sql>

<sql id="dynamicWhereConditions">
where is_preview = 0
where 1=1
<if test=" null != id "> and `id` = #{id} </if>
<if test=" null != propertyContractId "> and `property_contract_id` = #{propertyContractId} </if>
<if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
@@ -57,7 +57,9 @@
<if test=" null != shopId "> and `shop_id` = #{shopId} </if>
<if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
<if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
<if test=" null == isPreview ">and is_preview = 0</if>
<if test=" null != isPreview ">and is_preview = #{isPreview}</if>

<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">


+ 4
- 2
mallinkService/src/main/resources/mapper/WxBillRentMapper.xml Просмотреть файл

@@ -37,7 +37,7 @@
</sql>
<sql id="dynamicWhereConditions">
where is_preview = 0
where 1=1
<if test=" null != id ">and `id` = #{id}</if>
<if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
<if test=" null != receivePay ">and `receive_pay` = #{receivePay}</if>
@@ -56,7 +56,9 @@
<if test=" null != shopId ">and `shop_id` = #{shopId}</if>
<if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
<if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
<if test=" null == isPreview ">and is_preview = 0</if>
<if test=" null != isPreview ">and is_preview = #{isPreview}</if>

<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">


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