ソースを参照

科技需求--我要接单

Antiloveg 8 年 前
コミット
9c8e2ad91c

+ 112 - 1
src/main/java/com/goafanti/demand/bo/InputDemandOrder.java

@@ -1,5 +1,116 @@
 package com.goafanti.demand.bo;
 
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.Size;
+
+import com.goafanti.common.constant.ErrorConstants;
+
 public class InputDemandOrder {
-	private String demandId;
+	@Size(min = 0, max = 36, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	demandId;
+	
+	@Size(min = 0, max = 255, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	enclosureUrl;
+	
+	@Max(value = 6, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	status;
+	
+	@Max(value = 99999999, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	intentionMoney;
+	
+	@Max(value = 99999999, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	contractMoney;
+	
+	@Max(value = 99999999, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	commission;
+	
+	@Max(value = 99999999, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	serviceMoney;
+	
+	@Max(value = 1, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	refund;
+	
+	@Size(min = 0, max = 128, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String comment;
+
+	public String getDemandId() {
+		return demandId;
+	}
+
+	public void setDemandId(String demandId) {
+		this.demandId = demandId;
+	}
+
+	public String getEnclosureUrl() {
+		return enclosureUrl;
+	}
+
+	public void setEnclosureUrl(String enclosureUrl) {
+		this.enclosureUrl = enclosureUrl;
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public Integer getIntentionMoney() {
+		return intentionMoney;
+	}
+
+	public void setIntentionMoney(Integer intentionMoney) {
+		this.intentionMoney = intentionMoney;
+	}
+
+	public Integer getContractMoney() {
+		return contractMoney;
+	}
+
+	public void setContractMoney(Integer contractMoney) {
+		this.contractMoney = contractMoney;
+	}
+
+	public Integer getCommission() {
+		return commission;
+	}
+
+	public void setCommission(Integer commission) {
+		this.commission = commission;
+	}
+
+	public Integer getServiceMoney() {
+		return serviceMoney;
+	}
+
+	public void setServiceMoney(Integer serviceMoney) {
+		this.serviceMoney = serviceMoney;
+	}
+
+	public Integer getRefund() {
+		return refund;
+	}
+
+	public void setRefund(Integer refund) {
+		this.refund = refund;
+	}
+
+	public String getComment() {
+		return comment;
+	}
+
+	public void setComment(String comment) {
+		this.comment = comment;
+	}
+	
+	
 }

+ 2 - 1
src/main/java/com/goafanti/demand/service/DemandOrderService.java

@@ -1,11 +1,12 @@
 package com.goafanti.demand.service;
 
 import com.goafanti.common.model.DemandOrder;
+import com.goafanti.common.model.DemandOrderLog;
 
 public interface DemandOrderService {
 
 	DemandOrder selectDemandOrderByUidAndDemandId(String userId, String id);
 
-	void saveDemandOrder(String id);
+	void saveDemandOrder(DemandOrder order, DemandOrderLog dol);
 
 }

+ 1 - 3
src/main/java/com/goafanti/demand/service/impl/DemandOrderServiceImpl.java

@@ -27,8 +27,7 @@ public class DemandOrderServiceImpl implements DemandOrderService {
 	}
 
 	@Override
-	public void saveDemandOrder(String id) {
-		DemandOrder demandOrder = new DemandOrder();
+	public void saveDemandOrder(DemandOrder demandOrder, DemandOrderLog dol) {
 		demandOrder.setId(UUID.randomUUID().toString().toString());
 		Calendar now = Calendar.getInstance();
 		now.set(Calendar.MILLISECOND, 0);
@@ -38,7 +37,6 @@ public class DemandOrderServiceImpl implements DemandOrderService {
 		demandOrder.setStatus(DemandOrderStatus.CREATE.getCode());
 		demandOrderMapper.insert(demandOrder);
 		
-		DemandOrderLog dol = new DemandOrderLog();
 		dol.setId(UUID.randomUUID().toString());
 		dol.setDemandOrderId(demandOrder.getId());
 		dol.setRecordTime(demandOrder.getCreateTime());

+ 16 - 6
src/main/java/com/goafanti/portal/controller/PortalOrderApiController.java

@@ -1,8 +1,11 @@
 package com.goafanti.portal.controller;
 
 import javax.annotation.Resource;
+import javax.validation.Valid;
 
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
@@ -15,7 +18,9 @@ import com.goafanti.common.enums.DemandAuditStatus;
 import com.goafanti.common.enums.DemandReleaseStatus;
 import com.goafanti.common.model.Demand;
 import com.goafanti.common.model.DemandOrder;
+import com.goafanti.common.model.DemandOrderLog;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.demand.bo.InputDemandOrder;
 import com.goafanti.demand.service.DemandOrderService;
 import com.goafanti.demand.service.DemandService;
 
@@ -30,19 +35,19 @@ public class PortalOrderApiController extends CertifyApiController {
 	/**
 	 * "我要接单"
 	 */
-	@RequestMapping(value = "/order", method = RequestMethod.POST)
-	public Result order(String id) {
+	@RequestMapping(value = "/orderDemand", method = RequestMethod.POST)
+	public Result order(@Valid InputDemandOrder inputDemandOrder, BindingResult bindingResult) {
 		Result res = new Result();
-		if (StringUtils.isBlank(id)) {
+		if (StringUtils.isBlank(inputDemandOrder.getDemandId())) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
 			return res;
 		}
-		DemandOrder demandOrder = demandOrderService.selectDemandOrderByUidAndDemandId(TokenManager.getUserId(), id);
+		DemandOrder demandOrder = demandOrderService.selectDemandOrderByUidAndDemandId(TokenManager.getUserId(), inputDemandOrder.getDemandId());
 		if (null != demandOrder) {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "当前科技需求已接单!"));
 			return res;
 		}
-		Demand d = demandService.selectByPrimaryKey(id);
+		Demand d = demandService.selectByPrimaryKey(inputDemandOrder.getDemandId());
 		if (null == d || d.getDeletedSign().equals(DeleteStatus.DELETED.getCode())
 				|| !d.getAuditStatus().equals(DemandAuditStatus.AUDITED.getCode())
 				|| !d.getReleaseStatus().equals(DemandReleaseStatus.RELEASED.getCode())) {
@@ -50,7 +55,12 @@ public class PortalOrderApiController extends CertifyApiController {
 			return res;
 		}
 		
-		demandOrderService.saveDemandOrder(id);
+		DemandOrder order = new DemandOrder();
+		DemandOrderLog dol = new DemandOrderLog();
+		BeanUtils.copyProperties(inputDemandOrder, order);
+		BeanUtils.copyProperties(inputDemandOrder, dol);
+		
+		demandOrderService.saveDemandOrder(order, dol);
 		return res;
 	}
 }