|
@@ -103,15 +103,26 @@ public class ContractService extends ServiceImpl<ContractsMapper, Contracts> {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public RestResponse add(ContractsExtend extend) {
|
|
|
- Project project = new Project();
|
|
|
- project.setId(IdWorker.getId());
|
|
|
Contracts contracts = extend.getContracts();
|
|
|
+ if (ObjectUtil.isEmpty(extend.getContractId())) {
|
|
|
+ Project project = new Project();
|
|
|
+ project.setId(IdWorker.getId());
|
|
|
+ contracts.setProjectId(project.getId());
|
|
|
+ //插入项目信息
|
|
|
+ Project info = saveProject(contracts, extend, project);
|
|
|
+ if (ObjectUtil.isEmpty(info)) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return RestResponse.fail(MessageUtils.get("msg.add.fail"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //续签合同
|
|
|
+ contracts.setPreviousId(extend.getContractId());
|
|
|
+ }
|
|
|
if (ObjectUtil.isEmpty(contracts.getCode())) {
|
|
|
//按当前日期时间戳自动生成合同编号
|
|
|
String contractId = DateUtils.generateCode();
|
|
|
contracts.setCode(contractId);
|
|
|
}
|
|
|
- contracts.setProjectId(project.getId());
|
|
|
//插入合同信息
|
|
|
int result = contractsMapper.insert(contracts);
|
|
|
if (result < 0) {
|
|
@@ -119,12 +130,6 @@ public class ContractService extends ServiceImpl<ContractsMapper, Contracts> {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return RestResponse.fail(MessageUtils.get("msg.add.fail"));
|
|
|
}
|
|
|
- //插入项目信息
|
|
|
- Project info = saveProject(contracts, extend, project);
|
|
|
- if (ObjectUtil.isEmpty(info)) {
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
- return RestResponse.fail(MessageUtils.get("msg.add.fail"));
|
|
|
- }
|
|
|
//批量插入收款信息
|
|
|
boolean ret = paymentService.insertBatch(extend.getPaymentList(), contracts.getId());
|
|
|
if (!ret) {
|
|
@@ -134,6 +139,17 @@ public class ContractService extends ServiceImpl<ContractsMapper, Contracts> {
|
|
|
return RestResponse.success(null, MessageUtils.get("msg.add.success"));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param contracts 合同复核
|
|
|
+ * @return 1.成功, 0.失败, 消息描述
|
|
|
+ * @description 合同复核
|
|
|
+ * @date 2020/2/11 12:55 下午
|
|
|
+ */
|
|
|
+ public boolean check(Contracts contracts) {
|
|
|
+ contracts.setIsCheck(1);
|
|
|
+ return updateById(contracts);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param extend 修改合同、项目、付款信息数据项
|
|
|
* @return 1.成功, 0.失败, 消息描述
|
|
@@ -144,6 +160,7 @@ public class ContractService extends ServiceImpl<ContractsMapper, Contracts> {
|
|
|
public RestResponse modify(ContractsExtend extend) {
|
|
|
Contracts contracts = extend.getContracts();
|
|
|
//修改合同信息
|
|
|
+ contracts.setIsCheck(0);
|
|
|
boolean contractResult = updateById(contracts);
|
|
|
if (!contractResult) {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|