Skip to content

Commit 31d5db4

Browse files
committed
feat: contract add time field
1 parent 51366a2 commit 31d5db4

File tree

8 files changed

+86
-3
lines changed

8 files changed

+86
-3
lines changed

backend/crm/src/main/java/cn/cordys/common/constants/BusinessModuleField.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ public enum BusinessModuleField {
258258
CONTRACT_PRODUCT_SUM_AMOUNT("contractProductSumAmount", "amount", Set.of("rules.required", "mobile", "readable"), FormKey.CONTRACT.getKey()),
259259
CONTRACT_OWNER("contractOwner", "owner", Set.of("rules.required", "mobile", "readable"), FormKey.CONTRACT.getKey()),
260260
CONTRACT_NO("contractNo", "number", Set.of("rules.required", "mobile", "readable"), FormKey.CONTRACT.getKey()),
261+
CONTRACT_START_TIME("contractStartTime", "startTime", Set.of("rules.required", "mobile", "readable"), FormKey.CONTRACT.getKey()),
262+
CONTRACT_END_TIME("contractEndTime", "endTime", Set.of("rules.required", "mobile", "readable"), FormKey.CONTRACT.getKey()),
261263

262264
/*------ end: CONTRACT ------*/
263265

backend/crm/src/main/java/cn/cordys/crm/contract/domain/Contract.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public class Contract extends BaseModel {
3232
@Schema(description = "合同阶段")
3333
private String stage;
3434

35+
@Schema(description = "合同开始时间")
36+
private Long startTime;
37+
38+
@Schema(description = "合同结束时间")
39+
private Long endTime;
40+
3541
@Schema(description = "作废原因")
3642
private String voidReason;
3743

backend/crm/src/main/java/cn/cordys/crm/contract/dto/request/ContractAddRequest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import cn.cordys.crm.system.dto.response.ModuleFormConfigDTO;
55
import io.swagger.v3.oas.annotations.media.Schema;
66
import jakarta.validation.constraints.NotBlank;
7+
import jakarta.validation.constraints.NotNull;
78
import jakarta.validation.constraints.Size;
89
import lombok.Data;
910

11+
import java.math.BigInteger;
1012
import java.util.List;
1113
import java.util.Map;
1214

@@ -28,6 +30,14 @@ public class ContractAddRequest {
2830
@Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED)
2931
private String owner;
3032

33+
@Schema(description = "合同开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
34+
@NotNull
35+
private Long startTime;
36+
37+
@Schema(description = "合同结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
38+
@NotNull
39+
private Long endTime;
40+
3141
@Schema(description = "自定义字段")
3242
private List<BaseModuleFieldValue> moduleFields;
3343

backend/crm/src/main/java/cn/cordys/crm/contract/mapper/ExtContractMapper.xml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
ct.approval_status,
1616
ct.stage,
1717
ct.`owner`,
18+
ct.start_time,
19+
ct.end_time,
1820
ct.void_reason,
1921
ct.create_user,
2022
ct.create_time,
@@ -134,7 +136,7 @@
134136
<foreach collection="${conditions}" item="condition" index="i">
135137
<if test="condition.name not in
136138
{'name', 'owner', 'createTime', 'updateTime', 'customerId', 'createUser', 'updateUser',
137-
'departmentId', 'number', 'stage', 'amount', 'approvalStatus'}">
139+
'departmentId', 'number', 'stage', 'amount', 'approvalStatus', 'startTime', 'endTime'}">
138140
<if test="condition.multipleValue">
139141
left join contract_field_blob ${tablePrefix}_${i}
140142
on ct.id = ${tablePrefix}_${i}.resource_id and ${tablePrefix}_${i}.field_id = #{condition.name}
@@ -155,7 +157,7 @@
155157
<sql id="fieldSortJoin">
156158
<if test="${sort} != null and ${sort}.valid() and ${sort}.name not in
157159
{'name', 'owner', 'customer_id', 'amount', 'stage', 'update_user', 'create_time',
158-
'approval_status', 'update_time', 'create_user', 'department_id'}">
160+
'approval_status', 'update_time', 'create_user', 'department_id', 'startTime', 'endTime'}">
159161
<bind name="sortName" value="${sort}.name"/>
160162
left join contract_field sort_table
161163
on ct.id = sort_table.resource_id and sort_table.field_id = #{sortName}
@@ -223,6 +225,18 @@
223225
<property name="column" value="ct.approval_status"/>
224226
</include>
225227
</when>
228+
<when test="condition.name == 'startTime'">
229+
<include refid="cn.cordys.common.mapper.CommonMapper.condition">
230+
<property name="condition" value="condition"/>
231+
<property name="column" value="ct.start_time"/>
232+
</include>
233+
</when>
234+
<when test="condition.name == 'endTime'">
235+
<include refid="cn.cordys.common.mapper.CommonMapper.condition">
236+
<property name="condition" value="condition"/>
237+
<property name="column" value="ct.end_time"/>
238+
</include>
239+
</when>
226240
<when test="condition.name == 'departmentId'">
227241
<include refid="cn.cordys.common.mapper.CommonMapper.condition">
228242
<property name="condition" value="condition"/>
@@ -337,8 +351,15 @@
337351
souc_sort.`id` ${sortType}, ct.id ASC
338352
</when>
339353
<when test="${sort}.name == 'approval_status'">
340-
ct.`id` ${sortType}, ct.id ASC
354+
ct.`approval_status` ${sortType}, ct.id ASC
355+
</when>
356+
<when test="${sort}.name == 'start_time'">
357+
ct.`start_time` ${sortType}, ct.id ASC
341358
</when>
359+
<when test="${sort}.name == 'end_time'">
360+
ct.`end_time` ${sortType}, ct.id ASC
361+
</when>
362+
342363

343364
<otherwise>
344365
CASE

backend/crm/src/main/java/cn/cordys/crm/contract/service/ContractService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ public Contract add(ContractAddRequest request, String operatorId, String orgId)
134134
contract.setStage(ContractStage.PENDING_SIGNING.name());
135135
contract.setOrganizationId(orgId);
136136
contract.setApprovalStatus(ContractApprovalStatus.APPROVING.name());
137+
contract.setStartTime(request.getStartTime());
138+
contract.setEndTime(request.getEndTime());
137139
contract.setCreateTime(System.currentTimeMillis());
138140
contract.setCreateUser(operatorId);
139141
contract.setUpdateTime(System.currentTimeMillis());
@@ -266,6 +268,8 @@ public Contract update(ContractUpdateRequest request, String userId, String orgI
266268

267269
List<BaseModuleFieldValue> originFields = contractFieldService.getModuleFieldValuesByResourceId(request.getId());
268270
Contract contract = BeanUtils.copyBean(new Contract(), request);
271+
contract.setStartTime(request.getStartTime());
272+
contract.setEndTime(request.getEndTime());
269273
contract.setUpdateTime(System.currentTimeMillis());
270274
contract.setUpdateUser(userId);
271275
// 保留不可更改的字段

backend/crm/src/main/resources/form/field.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,6 +1778,40 @@
17781778
"key": "required"
17791779
}
17801780
]
1781+
},
1782+
{
1783+
"name": "合同开始时间",
1784+
"internalKey": "contractStartTime",
1785+
"type": "DATE_TIME",
1786+
"dateType": "date",
1787+
"showLabel": true,
1788+
"readable": true,
1789+
"editable": true,
1790+
"fieldWidth": 1,
1791+
"rules": [
1792+
{
1793+
"key": "required"
1794+
}
1795+
],
1796+
"mobile": true,
1797+
"ext_ver": "1.5.0"
1798+
},
1799+
{
1800+
"name": "合同结束时间",
1801+
"internalKey": "contractEndTime",
1802+
"type": "DATE_TIME",
1803+
"dateType": "date",
1804+
"showLabel": true,
1805+
"readable": true,
1806+
"editable": true,
1807+
"fieldWidth": 1,
1808+
"rules": [
1809+
{
1810+
"key": "required"
1811+
}
1812+
],
1813+
"mobile": true,
1814+
"ext_ver": "1.5.0"
17811815
}
17821816
],
17831817
"invoice": [

backend/crm/src/main/resources/migration/1.5.0/dml/V1.5.0_2_2__modify_tel.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ VALUES (UUID_SHORT(), 'business_name', true, '100001'),
2626
(UUID_SHORT(), 'company_size', false, '100001'),
2727
(UUID_SHORT(), 'registration_number', false, '100001');
2828

29+
alter table contract
30+
add start_time bigint not null comment '合同开始时间';
31+
alter table contract
32+
add end_time bigint not null comment '合同结束时间';
2933

3034

3135
SET SESSION innodb_lock_wait_timeout = DEFAULT;

backend/crm/src/test/java/cn/cordys/crm/system/controller/AddNoticeExpireTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ void saveNotice() {
129129
contract.setStage(ContractStage.PENDING_SIGNING.name());
130130
contract.setCreateUser("admin");
131131
contract.setOwner("aaa");
132+
contract.setStartTime(System.currentTimeMillis());
133+
contract.setStartTime(System.currentTimeMillis());
132134
contract.setCreateTime(System.currentTimeMillis());
133135
contract.setUpdateUser("admin");
134136
contract.setUpdateTime(System.currentTimeMillis());

0 commit comments

Comments
 (0)