From 84b8fc407854adfe0cbd1d73c0fb8ee1578fc88d Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Wed, 23 Dec 2020 17:23:56 +0800
Subject: [PATCH] modify
---
zq-erp/src/main/java/com/matrix/system/app/dto/CreateOrderDto.java | 39 +++++++++++++
zq-erp/src/main/java/com/matrix/system/app/dto/CreateOderItemDto.java | 63 +++++++++++++++++++++
zq-erp/src/main/java/com/matrix/system/hive/pojo/ShoppingCarItemsVo.java | 12 +++
zq-erp/src/main/java/com/matrix/system/app/vo/ShoppingGoodsListVo.java | 11 +++
zq-erp/src/main/java/com/matrix/system/app/action/ApiOrderAction.java | 38 ++++++++++++
zq-erp/src/main/resources/mybatis/mapper/hive/ShoppingGoodsDao.xml | 3
6 files changed, 161 insertions(+), 5 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiOrderAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiOrderAction.java
index c17e4c4..c2b6098 100644
--- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiOrderAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/app/action/ApiOrderAction.java
@@ -3,12 +3,18 @@
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.WebUtil;
+import com.matrix.system.app.dto.CreateOderItemDto;
+import com.matrix.system.app.dto.CreateOrderDto;
import com.matrix.system.app.dto.ShoppingGoodsListDto;
import com.matrix.system.app.vo.ShoppingGoodsListVo;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.hive.bean.ShoppingGoodsCategory;
+import com.matrix.system.hive.plugin.util.CollectionUtils;
+import com.matrix.system.hive.pojo.ShoppingCarItem;
+import com.matrix.system.hive.pojo.ShoppingCarItemsVo;
import com.matrix.system.hive.service.ShoppingGoodsCategoryService;
import com.matrix.system.hive.service.ShoppingGoodsService;
+import com.matrix.system.hive.service.SysOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
@@ -17,6 +23,7 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -33,6 +40,9 @@
@Autowired
private ShoppingGoodsService shoppingGoodsService;
+
+ @Autowired
+ private SysOrderService sysOrderService;
@ApiOperation(value = "获取商品类型列表", notes = "获取商品类型列表")
@ApiResponses({
@@ -57,9 +67,33 @@
return AjaxResult.buildSuccessInstance(shoppingGoodsService.findShoppingGoodsListForApi(shoppingGoodsListDto), shoppingGoodsService.findShoppingGoodsListTotalForApi(shoppingGoodsListDto));
}
+ @ApiOperation(value = "创建订单", notes = "创建订单")
@PostMapping(value = "/createOrder")
- public AjaxResult createOrder() {
- return null;
+ public AjaxResult createOrder(@RequestBody @Validated CreateOrderDto createOrderDto) {
+ SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
+
+ ShoppingCarItemsVo car = new ShoppingCarItemsVo();
+ car.setVipId(createOrderDto.getVipId());
+
+ if (CollectionUtils.isNotEmpty(createOrderDto.getItems())) {
+ List<ShoppingCarItem> list = new ArrayList<>();
+ for (CreateOderItemDto item : createOrderDto.getItems()) {
+ ShoppingCarItem carItem = new ShoppingCarItem();
+ carItem.setCount(item.getCount());
+ carItem.setGoodsId(item.getGoodsId());
+ carItem.setIsFree(item.getIsFree());
+ carItem.setType(item.getGoodsType());
+
+ carItem.setShoppingGoods(shoppingGoodsService.findById(item.getGoodsId()));
+ list.add(carItem);
+ }
+ }
+ int i = sysOrderService.createOrder(WebUtil.getSession(), car);
+ if (i > 0) {
+ return AjaxResult.buildSuccessInstance("下单成功");
+ }
+
+ return AjaxResult.buildFailInstance("下单失败");
}
}
diff --git a/zq-erp/src/main/java/com/matrix/system/app/dto/CreateOderItemDto.java b/zq-erp/src/main/java/com/matrix/system/app/dto/CreateOderItemDto.java
new file mode 100644
index 0000000..9ff080f
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/app/dto/CreateOderItemDto.java
@@ -0,0 +1,63 @@
+package com.matrix.system.app.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author wzy
+ * @date 2020-12-23
+ **/
+@ApiModel(value = "CreateOderItemDto", description = "提交订单明细接收类")
+public class CreateOderItemDto {
+
+ @NotNull(message = "商品ID不能为空")
+ @ApiModelProperty(value = "商品ID", example = "1234")
+ private Long goodsId;
+
+ @NotNull(message = "数量不能为空")
+ @ApiModelProperty(value = "购买数量", example = "1")
+ private Integer count;
+
+ @NotNull(message = "参数错误")
+ @ApiModelProperty(value = "是否赠送 是/否", example = "否")
+ private String isFree;
+
+ @NotNull(message = "参数错误")
+ @ApiModelProperty(value = "商品类型", example = "家居产品")
+ private String goodsType;
+
+ public String getGoodsType() {
+ return goodsType;
+ }
+
+ public void setGoodsType(String goodsType) {
+ this.goodsType = goodsType;
+ }
+
+ public Long getGoodsId() {
+ return goodsId;
+ }
+
+ public void setGoodsId(Long goodsId) {
+ this.goodsId = goodsId;
+ }
+
+ public Integer getCount() {
+ return count;
+ }
+
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+
+ public String getIsFree() {
+ return isFree;
+ }
+
+ public void setIsFree(String isFree) {
+ this.isFree = isFree;
+ }
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/app/dto/CreateOrderDto.java b/zq-erp/src/main/java/com/matrix/system/app/dto/CreateOrderDto.java
new file mode 100644
index 0000000..4b125c3
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/app/dto/CreateOrderDto.java
@@ -0,0 +1,39 @@
+package com.matrix.system.app.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * @author wzy
+ * @date 2020-12-23
+ **/
+@ApiModel(value = "CreateOrderDto", description = "提交订单接收类")
+public class CreateOrderDto {
+
+ @NotNull(message = "会员不能为空")
+ @ApiModelProperty(value = "会员Id", example = "361")
+ private Long vipId;
+
+
+ @ApiModelProperty(value = "购买商品明细")
+ private List<CreateOderItemDto> items;
+
+ public Long getVipId() {
+ return vipId;
+ }
+
+ public void setVipId(Long vipId) {
+ this.vipId = vipId;
+ }
+
+ public List<CreateOderItemDto> getItems() {
+ return items;
+ }
+
+ public void setItems(List<CreateOderItemDto> items) {
+ this.items = items;
+ }
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/app/vo/ShoppingGoodsListVo.java b/zq-erp/src/main/java/com/matrix/system/app/vo/ShoppingGoodsListVo.java
index 48504ed..731c77f 100644
--- a/zq-erp/src/main/java/com/matrix/system/app/vo/ShoppingGoodsListVo.java
+++ b/zq-erp/src/main/java/com/matrix/system/app/vo/ShoppingGoodsListVo.java
@@ -36,6 +36,17 @@
@ApiModelProperty(value = "商品图片")
private String img;
+ @ApiModelProperty(value = "商品类型")
+ private String goodsType;
+
+ public String getGoodsType() {
+ return goodsType;
+ }
+
+ public void setGoodsType(String goodsType) {
+ this.goodsType = goodsType;
+ }
+
public Long getId() {
return id;
}
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/pojo/ShoppingCarItemsVo.java b/zq-erp/src/main/java/com/matrix/system/hive/pojo/ShoppingCarItemsVo.java
index e27b98d..ca3e448 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/pojo/ShoppingCarItemsVo.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/pojo/ShoppingCarItemsVo.java
@@ -21,8 +21,16 @@
private Long beatuyId;
private String beatuyName;
-
-
+
+ private Long vipId;
+
+ public Long getVipId() {
+ return vipId;
+ }
+
+ public void setVipId(Long vipId) {
+ this.vipId = vipId;
+ }
public Long getBeatuyId() {
return beatuyId;
diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/ShoppingGoodsDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/ShoppingGoodsDao.xml
index 9baed01..30bfbb7 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/ShoppingGoodsDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/ShoppingGoodsDao.xml
@@ -1236,7 +1236,8 @@
seal_pice price,
is_present isPresent,
unit unit,
- measure measure
+ measure measure,
+ a.good_type goodsType
from shopping_goods a
where 1=1
<if test="record.queryKey != null and record.queryKey != ''">
--
Gitblit v1.9.1