Bläddra i källkod

朗通后台产品申请显示接口

wangyu 6 år sedan
förälder
incheckning
658f11b008

+ 0 - 14
diagbotman-service/src/main/java/com/diagbot/facade/OrderDetailsFacade.java

@@ -17,18 +17,4 @@ public class OrderDetailsFacade extends OrderDetailsServiceImpl{
         IPage<OrderDetails> orderDetailsIPage =this.orderDetialShow(page,orderDetails);
         return orderDetailsIPage;
     }
-
-    /**
-     * @Description: 添加订单明细
-     * @Author: wangyu
-     * @Date: 19:31 2018/9/20
-     */
-    public boolean addOrderDetails(OrderDetails orderDetails){
-        Boolean falg =true;
-        if(!save(orderDetails)){
-            falg =false;
-            return falg;
-        }
-        return falg;
-    }
 }

+ 11 - 26
diagbotman-service/src/main/java/com/diagbot/facade/ProductOrderFacade.java

@@ -5,16 +5,14 @@ import com.diagbot.dto.WaitExamOrderCouDTO;
 import com.diagbot.entity.LantoneProduct;
 import com.diagbot.entity.OrderDetails;
 import com.diagbot.entity.ProductOrder;
-import com.diagbot.entity.ServiceInfo;
 import com.diagbot.enums.VisibleIdTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.idc.VisibleIdCreater;
 import com.diagbot.service.impl.ProductOrderServiceImpl;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.UserUtils;
 import com.diagbot.vo.AddOrderVO;
-import com.diagbot.vo.ProductServiceSaveVO;
-import com.diagbot.vo.ServiceSaveVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
@@ -60,45 +58,32 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
 	 * @Date: 19:59 2018/9/18
 	 */
 	@Transactional
-	public CommonErrorCode addOrders(AddOrderVO addOrderVO){
+	public Boolean addOrders(AddOrderVO addOrderVO){
 		Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
 		ProductOrder productOrder =new ProductOrder();
 		productOrder.setCreator(UserUtils.getCurrentPrincipleID());
 		productOrder.setGmtCreate(DateUtil.now());
-		String imgId = visibleIdCreater.getNextId(VisibleIdTypeEnum.IS_ORDER.getKey()).toString();
-		productOrder.setNum(imgId);
+		String orderNum = visibleIdCreater.getNextId(VisibleIdTypeEnum.IS_ORDER.getKey()).toString();
+		productOrder.setNum(orderNum);
 		productOrder.setUserId(userId);
 		productOrder.setTime(DateUtil.now());
 		if(!save(productOrder)){
-			return CommonErrorCode.FAIL;
+			throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,"添加订单失败");
 		}
-		for (Long o:addOrderVO.getProductId()
-				) {
+		for (Long o:addOrderVO.getProductId()) {
 			LantoneProduct lantoneProduct = lantoneProductFacade.selectLanProduct(o);
 			if(null==lantoneProduct){
-				return CommonErrorCode.FAIL;
+				throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,"获取产品信息失败:"+o);
 			}
 			OrderDetails orderDetails =new OrderDetails();
 			orderDetails.setUserId(1l);
-			orderDetails.setOrderNum(imgId);
+			orderDetails.setOrderNum(orderNum);
 			orderDetails.setGmtCreate(DateUtil.now());
-			orderDetails.setCreator("");
+			orderDetails.setCreator(UserUtils.getCurrentPrincipleID());
 			orderDetails.setProductId(o);
-			if(orderDetailsFacade.addOrderDetails(orderDetails)){
-				ServiceSaveVO serviceSaveVO =new ServiceSaveVO();
-				ProductServiceSaveVO productServiceSaveVO =new ProductServiceSaveVO();
-				serviceSaveVO.setDescription(lantoneProduct.getDecription());
-				serviceSaveVO.setName(lantoneProduct.getName());
-				serviceSaveVO.setType(1);
-				ServiceInfo serviceInfo = serviceInfoFacade.createService(serviceSaveVO);
-				productServiceSaveVO.setProductId(o);
-				productServiceSaveVO.setServiceId(serviceInfo.getId());
-				productServiceSaveVO.setType(1);
-				productServiceFacade.genProductService(productServiceSaveVO);
-			}
+			orderDetailsFacade.save(orderDetails);
 		}
-
-		return CommonErrorCode.OK;
+		return true;
 	}
 
 	/**

+ 2 - 1
diagbotman-service/src/main/java/com/diagbot/vo/AddOrderVO.java

@@ -4,6 +4,7 @@ import lombok.Getter;
 import lombok.Setter;
 
 import javax.validation.constraints.NotBlank;
+import java.util.List;
 
 /**
  * @Description:
@@ -14,5 +15,5 @@ import javax.validation.constraints.NotBlank;
 @Setter
 public class AddOrderVO{
     @NotBlank(message = "请输入产品Id!")
-    private Long productId[];
+    private List<Long> productId;
 }

+ 3 - 4
diagbotman-service/src/main/java/com/diagbot/web/MoreServiceController.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.LantoneProduct;
-import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.facade.LantoneProductFacade;
 import com.diagbot.facade.ProductOrderFacade;
 import com.diagbot.vo.AddOrderVO;
@@ -14,6 +13,7 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -42,9 +42,8 @@ public class MoreServiceController {
     @ApiOperation(value = "生成订单", notes = "根据用户所选择的产品生成订单")
     @PostMapping("/addOrder")
     @SysLogger("addOrder")
-    public RespDTO addOrder( AddOrderVO addOrderVO){
-        CommonErrorCode commonErrorCode = productOrderFacade.addOrders(addOrderVO);
-        return RespDTO.onSuc(commonErrorCode);
+    public RespDTO addOrder( @RequestBody AddOrderVO addOrderVO){
+        return RespDTO.onSuc(productOrderFacade.addOrders(addOrderVO));
     }
 
 }