|
@@ -33,6 +33,7 @@ public class CrowdTestProject {
|
|
|
private String distributionCity;
|
|
|
private Double quotedPrice;
|
|
|
private Double fixedPrice;
|
|
|
+ private Double restPrice;
|
|
|
private int status;
|
|
|
private Timestamp deadTime;
|
|
|
private Timestamp endTime;
|
|
@@ -255,8 +256,8 @@ public class CrowdTestProject {
|
|
|
public void addTask(CrowdTestTask task){
|
|
|
if (!(this.getStatus() >= CrowdTestProjectStatus.HAS_RECEIVED || this.getStatus()<=CrowdTestTaskStatus.HAS_COMMITED))
|
|
|
throw new BaseException("当前阶段不允许创建新任务");
|
|
|
- if (this.getQuotedPrice() < task.getQuotedPrice()){
|
|
|
- throw new BaseException("任务的报价不能超过项目的剩余价格,项目的剩余价格为:" + this.getQuotedPrice());
|
|
|
+ if (this.getRestPrice() < task.getQuotedPrice()){
|
|
|
+ throw new BaseException("任务的报价不能超过项目的剩余价格,项目的剩余价格为:" + this.getRestPrice());
|
|
|
}
|
|
|
if (this.getDeadTime().getTime() < task.getDeadTime().getTime()){
|
|
|
throw new BaseException("任务截止时间不能超过项目的截止时间,项目的截止时间为:" + this.getDeadTime());
|
|
@@ -264,10 +265,16 @@ public class CrowdTestProject {
|
|
|
if (task.getDeadTime().getTime() < System.currentTimeMillis()){
|
|
|
throw new BaseException("任务截止时间不能小于当前时间");
|
|
|
}
|
|
|
-
|
|
|
+ this.setRestPrice(this.getRestPrice() - task.getQuotedPrice());
|
|
|
this.getCrowdTestTaskList().add(task);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public void removeTask(CrowdTestTask task) {
|
|
|
+ this.setRestPrice(this.getRestPrice() + task.getQuotedPrice());
|
|
|
+ this.getCrowdTestTaskList().remove(task);
|
|
|
+ }
|
|
|
+
|
|
|
public CrowdTestTask getTask(String taskCode){
|
|
|
Optional<CrowdTestTask> testTask = this.getCrowdTestTaskList().stream().filter(crowdTestTask -> crowdTestTask.getCode().equals(taskCode)).findFirst();
|
|
|
if (!testTask.isPresent())
|
|
@@ -704,4 +711,5 @@ public class CrowdTestProject {
|
|
|
}
|
|
|
this.setStatus(CrowdTestProjectStatus.HAS_REJECTED);
|
|
|
}
|
|
|
+
|
|
|
}
|