wangyu 6 years ago
parent
commit
e2c33afd65

+ 16 - 15
diagbotman-service/src/main/java/com/diagbot/entity/ProductOrder.java

@@ -1,11 +1,12 @@
 package com.diagbot.entity;
 package com.diagbot.entity;
 
 
-import java.math.BigDecimal;
-import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
-import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.TableName;
+
 import java.io.Serializable;
 import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -34,12 +35,12 @@ public class ProductOrder implements Serializable {
     /**
     /**
      * 记录创建时间
      * 记录创建时间
      */
      */
-    private LocalDateTime gmtCreate;
+    private Date gmtCreate;
 
 
     /**
     /**
      * 记录修改时间,如果时间是1970年则表示纪录未修改
      * 记录修改时间,如果时间是1970年则表示纪录未修改
      */
      */
-    private LocalDateTime gmtModified;
+    private Date gmtModified;
 
 
     /**
     /**
      * 创建人,0表示无创建人值
      * 创建人,0表示无创建人值
@@ -59,12 +60,12 @@ public class ProductOrder implements Serializable {
     /**
     /**
      * 用户id
      * 用户id
      */
      */
-    private Integer userId;
+    private Long userId;
 
 
     /**
     /**
      * 下单时间(申请时间)
      * 下单时间(申请时间)
      */
      */
-    private LocalDateTime time;
+    private Date time;
 
 
     /**
     /**
      * 订单总价
      * 订单总价
@@ -88,19 +89,19 @@ public class ProductOrder implements Serializable {
         this.isDeleted = isDeleted;
         this.isDeleted = isDeleted;
     }
     }
 
 
-    public LocalDateTime getGmtCreate() {
+    public Date getGmtCreate() {
         return gmtCreate;
         return gmtCreate;
     }
     }
 
 
-    public void setGmtCreate(LocalDateTime gmtCreate) {
+    public void setGmtCreate(Date gmtCreate) {
         this.gmtCreate = gmtCreate;
         this.gmtCreate = gmtCreate;
     }
     }
 
 
-    public LocalDateTime getGmtModified() {
+    public Date getGmtModified() {
         return gmtModified;
         return gmtModified;
     }
     }
 
 
-    public void setGmtModified(LocalDateTime gmtModified) {
+    public void setGmtModified(Date gmtModified) {
         this.gmtModified = gmtModified;
         this.gmtModified = gmtModified;
     }
     }
 
 
@@ -128,19 +129,19 @@ public class ProductOrder implements Serializable {
         this.num = num;
         this.num = num;
     }
     }
 
 
-    public Integer getUserId() {
+    public Long getUserId() {
         return userId;
         return userId;
     }
     }
 
 
-    public void setUserId(Integer userId) {
+    public void setUserId(Long userId) {
         this.userId = userId;
         this.userId = userId;
     }
     }
 
 
-    public LocalDateTime getTime() {
+    public Date getTime() {
         return time;
         return time;
     }
     }
 
 
-    public void setTime(LocalDateTime time) {
+    public void setTime(Date time) {
         this.time = time;
         this.time = time;
     }
     }
 
 

+ 30 - 6
diagbotman-service/src/main/java/com/diagbot/facade/ProductOrderFacade.java

@@ -1,14 +1,19 @@
 package com.diagbot.facade;
 package com.diagbot.facade;
 
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.stereotype.Component;
-
 import com.diagbot.dto.ProductAuthProgressDTO;
 import com.diagbot.dto.ProductAuthProgressDTO;
 import com.diagbot.entity.ProductOrder;
 import com.diagbot.entity.ProductOrder;
+import com.diagbot.enums.VisibleIdTypeEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.idc.VisibleIdCreater;
 import com.diagbot.service.impl.ProductOrderServiceImpl;
 import com.diagbot.service.impl.ProductOrderServiceImpl;
+import com.diagbot.util.DateUtil;
 import com.diagbot.util.UserUtils;
 import com.diagbot.util.UserUtils;
+import com.diagbot.vo.AddOrderVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
 /**
  * 订单业务
  * 订单业务
@@ -17,7 +22,8 @@ import com.diagbot.util.UserUtils;
  */
  */
 @Component
 @Component
 public class ProductOrderFacade extends ProductOrderServiceImpl {
 public class ProductOrderFacade extends ProductOrderServiceImpl {
-	
+	@Autowired
+	private VisibleIdCreater visibleIdCreater;
 	
 	
 	public List<ProductAuthProgressDTO> productAuthProgress(){
 	public List<ProductAuthProgressDTO> productAuthProgress(){
 		List<ProductAuthProgressDTO> retList = new ArrayList<ProductAuthProgressDTO>();
 		List<ProductAuthProgressDTO> retList = new ArrayList<ProductAuthProgressDTO>();
@@ -33,4 +39,22 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
 		return retList;
 		return retList;
 	}
 	}
 
 
+	/**
+	 * @Description: 根据用户选择的产品生成订单
+	 * @Author: wangyu
+	 * @Date: 19:59 2018/9/18
+	 */
+	public CommonErrorCode addOrders(AddOrderVO addOrderVO){
+		/*Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());*/
+		ProductOrder productOrder =new ProductOrder();
+		productOrder.setCreator(/*UserUtils.getCurrentPrincipleID()*/"1");
+		productOrder.setGmtCreate(DateUtil.now());
+		String imgId = visibleIdCreater.getNextId(VisibleIdTypeEnum.IS_ORDER.getKey()).toString();
+		productOrder.setNum(imgId);
+		productOrder.setUserId(/*userId*/1l);
+		productOrder.setTime(DateUtil.now());
+		addOrder(productOrder);
+		return CommonErrorCode.OK;
+	}
+
 }
 }

+ 8 - 2
diagbotman-service/src/main/java/com/diagbot/mapper/ProductOrderMapper.java

@@ -1,11 +1,11 @@
 package com.diagbot.mapper;
 package com.diagbot.mapper;
 
 
-import java.util.List;
-
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.diagbot.dto.AuthDetailDTO;
 import com.diagbot.dto.AuthDetailDTO;
 import com.diagbot.entity.ProductOrder;
 import com.diagbot.entity.ProductOrder;
 
 
+import java.util.List;
+
 /**
 /**
  * <p>
  * <p>
  * 订单表 Mapper 接口
  * 订单表 Mapper 接口
@@ -20,4 +20,10 @@ public interface ProductOrderMapper extends BaseMapper<ProductOrder> {
 	
 	
 	List<AuthDetailDTO> getOrderDetails(String orderNum);
 	List<AuthDetailDTO> getOrderDetails(String orderNum);
 
 
+	/**
+	 * @Description: 添加用户订单
+	 * @Author: wangyu
+	 * @Date: 10:20 2018/9/20
+	 */
+	public ProductOrder addOrder(ProductOrder productOrder);
 }
 }

+ 6 - 0
diagbotman-service/src/main/java/com/diagbot/service/ProductOrderService.java

@@ -13,4 +13,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
  */
 public interface ProductOrderService extends IService<ProductOrder> {
 public interface ProductOrderService extends IService<ProductOrder> {
 
 
+    /**
+     * @Description: 添加用户订单
+     * @Author: wangyu
+     * @Date: 10:20 2018/9/20
+     */
+    public ProductOrder addOrder(ProductOrder productOrder);
 }
 }

+ 5 - 0
diagbotman-service/src/main/java/com/diagbot/service/impl/ProductOrderServiceImpl.java

@@ -17,4 +17,9 @@ import org.springframework.stereotype.Service;
 @Service
 @Service
 public class ProductOrderServiceImpl extends ServiceImpl<ProductOrderMapper, ProductOrder> implements ProductOrderService {
 public class ProductOrderServiceImpl extends ServiceImpl<ProductOrderMapper, ProductOrder> implements ProductOrderService {
 
 
+    @Override
+    public ProductOrder addOrder(ProductOrder productOrder) {
+
+        return baseMapper.addOrder(productOrder);
+    }
 }
 }

+ 18 - 0
diagbotman-service/src/main/java/com/diagbot/vo/AddOrderVO.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @Description:
+ * @author: wangyu
+ * @time: 2018/9/20 10:30
+ */
+@Getter
+@Setter
+public class AddOrderVO {
+    @NotBlank(message = "请输入产品Id!")
+    private Long productId;
+}

+ 15 - 0
diagbotman-service/src/main/java/com/diagbot/web/MoreServiceController.java

@@ -5,11 +5,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.LantoneProduct;
 import com.diagbot.entity.LantoneProduct;
+import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.facade.LantoneProductFacade;
 import com.diagbot.facade.LantoneProductFacade;
+import com.diagbot.facade.ProductOrderFacade;
+import com.diagbot.vo.AddOrderVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
@@ -24,6 +28,8 @@ import org.springframework.web.bind.annotation.RestController;
 public class MoreServiceController {
 public class MoreServiceController {
     @Autowired
     @Autowired
     private LantoneProductFacade lantoneProductFacade;
     private LantoneProductFacade lantoneProductFacade;
+    @Autowired
+    private ProductOrderFacade productOrderFacade;
 
 
     @ApiOperation(value = "根据用户id查询已开通信息", notes = "根据用户id查询已开通信息")
     @ApiOperation(value = "根据用户id查询已开通信息", notes = "根据用户id查询已开通信息")
     @GetMapping("/showProductInfo")
     @GetMapping("/showProductInfo")
@@ -32,6 +38,15 @@ public class MoreServiceController {
         IPage<LantoneProduct> diagLantoneProducts =lantoneProductFacade.productLine(page);
         IPage<LantoneProduct> diagLantoneProducts =lantoneProductFacade.productLine(page);
         return RespDTO.onSuc(diagLantoneProducts);
         return RespDTO.onSuc(diagLantoneProducts);
     }
     }
+
+    @ApiOperation(value = "生成订单", notes = "根据用户所选择的产品生成订单")
+    @PostMapping("/addOrder")
+    @SysLogger("addOrder")
+    public RespDTO addOrder( AddOrderVO addOrderVO){
+        CommonErrorCode commonErrorCode = productOrderFacade.addOrders(addOrderVO);
+        return RespDTO.onSuc(commonErrorCode);
+    }
+
 }
 }
 
 
 
 

+ 3 - 0
diagbotman-service/src/main/resources/mapper/ProductOrderMapper.xml

@@ -33,4 +33,7 @@
 		and a.num=#{orderNum}
 		and a.num=#{orderNum}
 	</select>
 	</select>
 
 
+    <insert id="addOrder" parameterType="com.diagbot.mapper.ProductOrderMapper">
+        INSERT INTO `diag_product_order` (gmt_create ,creator,`num`, `user_id`, `time`, `total_prices`) VALUES (#{gmtCreate}, #{creator}, #{num}, #{userId}, #{time},#{totalPrices})
+    </insert>
 </mapper>
 </mapper>