|
@@ -6,6 +6,7 @@ import cn.com.ty.lift.business.contract.dao.entity.model.ContractRequest;
|
|
|
import cn.com.ty.lift.business.contract.dao.entity.model.ContractsHistoryRequest;
|
|
|
import cn.com.ty.lift.business.contract.dao.mapper.ContractsHistoryMapper;
|
|
|
import cn.com.ty.lift.business.contract.dao.mapper.ContractsMapper;
|
|
|
+import cn.com.ty.lift.business.framework.BusinessBasicException;
|
|
|
import cn.com.ty.lift.business.framework.util.MessageUtils;
|
|
|
import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
@@ -13,6 +14,7 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.Date;
|
|
@@ -32,6 +34,9 @@ public class ContractService {
|
|
|
@Resource
|
|
|
private ContractsHistoryMapper contractsHistoryMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private PaymentService paymentService;
|
|
|
+
|
|
|
/**
|
|
|
* @param request 合同列表查询条件
|
|
|
* @return RestResponse 合同分页列表结果
|
|
@@ -70,6 +75,7 @@ public class ContractService {
|
|
|
* @description 新增合同
|
|
|
* @date 2019/12/7 3:31 PM
|
|
|
*/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public RestResponse add(Contracts contracts) {
|
|
|
if (contracts.getNextId() == null) {
|
|
|
//按当前日期时间戳自动生成合同编号
|
|
@@ -78,7 +84,13 @@ public class ContractService {
|
|
|
}
|
|
|
int result = contractsMapper.insert(contracts);
|
|
|
if (result > 0) {
|
|
|
- return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.add.success"));
|
|
|
+ //批量插入收款信息
|
|
|
+ boolean ret = paymentService.insertBatch(contracts);
|
|
|
+ if (ret) {
|
|
|
+ return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.add.success"));
|
|
|
+ } else {
|
|
|
+ throw new BusinessBasicException("批量插入收款信息失败");
|
|
|
+ }
|
|
|
}
|
|
|
return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
|
|
|
}
|