diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderController.java b/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderController.java
index adca53b0..de54afed 100644
--- a/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderController.java
+++ b/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderController.java
@@ -2,10 +2,24 @@ package com.ghy.web.controller.order;
import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult;
+import com.ghy.common.utils.StringUtils;
+import com.ghy.customer.domain.Customer;
+import com.ghy.customer.service.CustomerService;
+import com.ghy.goods.service.GoodsService;
+import com.ghy.order.domain.OrderMaster;
+import com.ghy.order.request.AppOrderRequest;
+import com.ghy.order.service.OrderDetailService;
+import com.ghy.order.service.OrderMasterService;
+import com.ghy.payment.service.FinancialDetailService;
+import com.ghy.payment.service.FinancialMasterService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
+import java.math.BigDecimal;
+import java.util.List;
+
/**
* @author clunt
* 下单接口
@@ -14,19 +28,46 @@ import org.springframework.web.bind.annotation.RequestMapping;
@RequestMapping("/order")
public class OrderController extends BaseController {
- @PostMapping("/app")
- public AjaxResult appOrder(){
- //TODO 校验商品信息(库存)
+ @Autowired
+ private CustomerService customerService;
- //TODO 计算商品费用和运费汇总
+ @Autowired
+ private GoodsService goodsService;
- //TODO 生成主单
+ @Autowired
+ private OrderMasterService orderMasterService;
+ @Autowired
+ private OrderDetailService orderDetailService;
+
+ @Autowired
+ private FinancialMasterService financialMasterService;
+
+ @Autowired
+ private FinancialDetailService financialDetailService;
+
+
+ @PostMapping("/server/app")
+ public AjaxResult appOrder(AppOrderRequest appOrderRequest){
+ // 校验用户信息
+ Customer customer = customerService.selectByCustomerId(appOrderRequest.getCustomerId());
+ if(StringUtils.isNull(customer)){
+ return AjaxResult.error("用户不存在!");
+ }
+ // 校验商品信息(库存)
+ boolean flag = goodsService.checkStore(appOrderRequest.getGoodsList());
+ if(!flag){
+ return AjaxResult.error("库存不足!");
+ }
+ // 计算商品费用
+ BigDecimal totalPay = goodsService.calculate(appOrderRequest.getGoodsList());
+ //TODO 生成主单 and 细单
+ OrderMaster orderMaster = orderMasterService.createMasterOrder(appOrderRequest);
//TODO 生成细单
//TODO 生成财务主单
- //TODO 生成财务细单
+ //TODO 生成财务细单(含分销等.)
return AjaxResult.success();
}
diff --git a/ghy-custom/src/main/java/com/ghy/customer/domain/Customer.java b/ghy-custom/src/main/java/com/ghy/customer/domain/Customer.java
index 54bf65e5..1f0edcaa 100644
--- a/ghy-custom/src/main/java/com/ghy/customer/domain/Customer.java
+++ b/ghy-custom/src/main/java/com/ghy/customer/domain/Customer.java
@@ -4,6 +4,8 @@ import com.ghy.common.annotation.Excel;
import com.ghy.common.core.domain.BaseEntity;
import lombok.Data;
+import java.util.List;
+
/**
* @author clunt
* 消费者实体
@@ -37,5 +39,10 @@ public class Customer extends BaseEntity {
@Excel(name = "用户头像", cellType = Excel.ColumnType.STRING)
private String customerLogoUrl;
+ @Excel(name = "上级分销人", cellType = Excel.ColumnType.NUMERIC)
+ private Long customerPlace;
+
+ @Excel(name = "祖级分销人", cellType = Excel.ColumnType.NUMERIC)
+ private Long parentCustomerPlace;
}
diff --git a/ghy-custom/src/main/java/com/ghy/customer/domain/CustomerPlace.java b/ghy-custom/src/main/java/com/ghy/customer/domain/CustomerPlace.java
deleted file mode 100644
index a103479e..00000000
--- a/ghy-custom/src/main/java/com/ghy/customer/domain/CustomerPlace.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.ghy.customer.domain;
-
-import com.ghy.common.annotation.Excel;
-import com.ghy.common.core.domain.BaseEntity;
-import lombok.Data;
-
-/**
- * @author clunt
- * 用户多级分销,最多不超过3级
- */
-@Data
-public class CustomerPlace extends BaseEntity {
-
- private static final long serialVersionUID = 1L;
-
- @Excel(name = "分销id", cellType = Excel.ColumnType.NUMERIC)
- private Long customerPlaceId;
-
- @Excel(name = "用户id", cellType = Excel.ColumnType.NUMERIC)
- private Long customerId;
-
- @Excel(name = "父级id", cellType = Excel.ColumnType.NUMERIC)
- private Long parentCustomerId;
-
- @Excel(name = "分销类型", cellType = Excel.ColumnType.STRING)
- private Integer placeType;
-
- @Excel(name = "分销比例", cellType = Excel.ColumnType.STRING)
- private String placeRate;
-
- @Excel(name = "分销金额", cellType = Excel.ColumnType.STRING)
- private String placeMoney;
-
-}
diff --git a/ghy-custom/src/main/java/com/ghy/customer/mapper/CustomerPlaceMapper.java b/ghy-custom/src/main/java/com/ghy/customer/mapper/CustomerPlaceMapper.java
deleted file mode 100644
index 0ca4876f..00000000
--- a/ghy-custom/src/main/java/com/ghy/customer/mapper/CustomerPlaceMapper.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.ghy.customer.mapper;
-
-/**
- * @author clunt
- * 多级分销接口类
- */
-public interface CustomerPlaceMapper {
-
-
-
-}
diff --git a/ghy-custom/src/main/java/com/ghy/customer/service/CustomerPlaceService.java b/ghy-custom/src/main/java/com/ghy/customer/service/CustomerPlaceService.java
deleted file mode 100644
index 2bdb5dc2..00000000
--- a/ghy-custom/src/main/java/com/ghy/customer/service/CustomerPlaceService.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.ghy.customer.service;
-
-/**
- * @author clunt
- * 多级分销
- */
-public interface CustomerPlaceService {
-
- // 新增分销用户
-
- // 获取用户分销关系
-
- // 设置分销比例
-
-}
diff --git a/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerPlaceServiceImpl.java b/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerPlaceServiceImpl.java
deleted file mode 100644
index 095f6067..00000000
--- a/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerPlaceServiceImpl.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.ghy.customer.service.impl;
-
-import com.ghy.customer.service.CustomerPlaceService;
-import org.springframework.stereotype.Service;
-
-/**
- * @author clunt
- * 多级分销实现类
- */
-@Service
-public class CustomerPlaceServiceImpl implements CustomerPlaceService {
-
-
-
-}
diff --git a/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerServiceImpl.java b/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerServiceImpl.java
index ce69ee59..0bd08b1c 100644
--- a/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerServiceImpl.java
+++ b/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerServiceImpl.java
@@ -5,7 +5,6 @@ import com.ghy.common.exception.ServiceException;
import com.ghy.customer.domain.Customer;
import com.ghy.customer.mapper.CustomerMapper;
import com.ghy.customer.service.CustomerService;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -18,7 +17,7 @@ import java.util.List;
@Service
public class CustomerServiceImpl implements CustomerService {
- @Autowired
+ @Resource
private CustomerMapper customerMapper;
@Override
diff --git a/ghy-custom/src/main/resources/mapper/customer/CustomerMapper.xml b/ghy-custom/src/main/resources/mapper/customer/CustomerMapper.xml
index 7dc098d5..099b628a 100644
--- a/ghy-custom/src/main/resources/mapper/customer/CustomerMapper.xml
+++ b/ghy-custom/src/main/resources/mapper/customer/CustomerMapper.xml
@@ -11,6 +11,9 @@
+
+
+
@@ -20,7 +23,7 @@
SELECT customer_id, name, account, phone, open_id, password, status,
- customer_logo_url, create_by, create_time, remark
+ customer_logo_url, customer_place, parent_customer_place, create_by, create_time, remark
FROM customer
diff --git a/ghy-custom/src/main/resources/mapper/customer/CustomerPlaceMapper.xml b/ghy-custom/src/main/resources/mapper/customer/CustomerPlaceMapper.xml
deleted file mode 100644
index bf4025b9..00000000
--- a/ghy-custom/src/main/resources/mapper/customer/CustomerPlaceMapper.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ghy-goods/src/main/java/com/ghy/goods/mapper/GoodsMapper.java b/ghy-goods/src/main/java/com/ghy/goods/mapper/GoodsMapper.java
index 1b45b5d8..3be03bbc 100644
--- a/ghy-goods/src/main/java/com/ghy/goods/mapper/GoodsMapper.java
+++ b/ghy-goods/src/main/java/com/ghy/goods/mapper/GoodsMapper.java
@@ -1,6 +1,7 @@
package com.ghy.goods.mapper;
import com.ghy.goods.domain.Goods;
+import com.ghy.goods.request.AppGoodsRequest;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -11,6 +12,12 @@ import java.util.List;
*/
public interface GoodsMapper {
+ /**
+ * @param goods 商品信息
+ * @return 校验是否满足库存
+ */
+ int checkAGoodsStore(AppGoodsRequest goods);
+
/**
* @param goods 商品属性
* @return 成功条数
diff --git a/ghy-goods/src/main/java/com/ghy/goods/request/AppGoodsRequest.java b/ghy-goods/src/main/java/com/ghy/goods/request/AppGoodsRequest.java
new file mode 100644
index 00000000..a632b013
--- /dev/null
+++ b/ghy-goods/src/main/java/com/ghy/goods/request/AppGoodsRequest.java
@@ -0,0 +1,21 @@
+package com.ghy.goods.request;
+
+import lombok.Data;
+
+
+/**
+ * 小程序下单请求体
+ * @author clunt
+ */
+@Data
+public class AppGoodsRequest {
+
+ // 商品id
+ private Long goodsId;
+
+ // 数量
+ private Integer num;
+
+}
+
+
diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/GoodsService.java b/ghy-goods/src/main/java/com/ghy/goods/service/GoodsService.java
index 10bf5263..6ef60a5d 100644
--- a/ghy-goods/src/main/java/com/ghy/goods/service/GoodsService.java
+++ b/ghy-goods/src/main/java/com/ghy/goods/service/GoodsService.java
@@ -1,7 +1,9 @@
package com.ghy.goods.service;
import com.ghy.goods.domain.Goods;
+import com.ghy.goods.request.AppGoodsRequest;
+import java.math.BigDecimal;
import java.util.List;
/**
@@ -11,6 +13,18 @@ import java.util.List;
*/
public interface GoodsService {
+ /**
+ * @param goodsList 需要校验库存的商品list
+ * @return 校验结果
+ */
+ boolean checkStore(List goodsList);
+
+ /**
+ * @param goodsList 需要校验库存的商品list
+ * @return 商品总价
+ */
+ BigDecimal calculate(List goodsList);
+
/**
* @param goods 商品属性
* @return 成功条数
diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/impl/GoodsServiceImpl.java b/ghy-goods/src/main/java/com/ghy/goods/service/impl/GoodsServiceImpl.java
index 8d53c7c8..f9f201ed 100644
--- a/ghy-goods/src/main/java/com/ghy/goods/service/impl/GoodsServiceImpl.java
+++ b/ghy-goods/src/main/java/com/ghy/goods/service/impl/GoodsServiceImpl.java
@@ -6,12 +6,14 @@ import com.ghy.common.exception.ServiceException;
import com.ghy.common.utils.StringUtils;
import com.ghy.goods.domain.Goods;
import com.ghy.goods.mapper.GoodsMapper;
+import com.ghy.goods.request.AppGoodsRequest;
import com.ghy.goods.service.GoodsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import javax.annotation.Resource;
+import java.math.BigDecimal;
import java.util.List;
/**
@@ -25,6 +27,27 @@ public class GoodsServiceImpl implements GoodsService {
@Resource
private GoodsMapper goodsMapper;
+ @Override
+ public boolean checkStore(List goodsList) {
+ for (AppGoodsRequest goods : goodsList) {
+ int num = goodsMapper.checkAGoodsStore(goods);
+ if (num == 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public BigDecimal calculate(List goodsList) {
+ BigDecimal totalPay = BigDecimal.ZERO;
+ for (AppGoodsRequest appGoodsRequest : goodsList){
+ Goods goods = goodsMapper.selectById(appGoodsRequest.getGoodsId());
+ totalPay = totalPay.add(goods.getGoodsPrice().multiply(BigDecimal.valueOf(appGoodsRequest.getNum())));
+ }
+ return totalPay;
+ }
+
@Override
@Transactional(rollbackFor = Exception.class)
public int insertGoods(Goods goods) {
diff --git a/ghy-goods/src/main/resources/mapper/goods/GoodsMapper.xml b/ghy-goods/src/main/resources/mapper/goods/GoodsMapper.xml
index ff0ec65d..d23a63b8 100644
--- a/ghy-goods/src/main/resources/mapper/goods/GoodsMapper.xml
+++ b/ghy-goods/src/main/resources/mapper/goods/GoodsMapper.xml
@@ -30,6 +30,12 @@
FROM goods
+
+
UPDATE goods
diff --git a/ghy-order/pom.xml b/ghy-order/pom.xml
index 5816f19b..fd44c1fb 100644
--- a/ghy-order/pom.xml
+++ b/ghy-order/pom.xml
@@ -23,6 +23,11 @@
ghy-common
+
+ com.ghy
+ ghy-goods
+
+
diff --git a/ghy-order/src/main/java/com/ghy/order/request/AppOrderRequest.java b/ghy-order/src/main/java/com/ghy/order/request/AppOrderRequest.java
new file mode 100644
index 00000000..86a5240a
--- /dev/null
+++ b/ghy-order/src/main/java/com/ghy/order/request/AppOrderRequest.java
@@ -0,0 +1,36 @@
+package com.ghy.order.request;
+
+import com.ghy.goods.request.AppGoodsRequest;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 小程序下单请求体
+ * @author clunt
+ */
+@Data
+public class AppOrderRequest {
+
+ // 消费者id
+ private Long customerId;
+
+ // 用于计算价格等
+ private List goodsList;
+
+ // 预约上门时间
+ private String serverTime;
+
+ // 地址
+ private Long addressId;
+
+ // 支付方式
+ private Integer payType;
+
+ //是否需要发票
+ private Integer isNeedBill;
+
+ // 备注
+ private String remark;
+
+}
diff --git a/ghy-order/src/main/java/com/ghy/order/service/OrderMasterService.java b/ghy-order/src/main/java/com/ghy/order/service/OrderMasterService.java
index 22039065..f0f5be7a 100644
--- a/ghy-order/src/main/java/com/ghy/order/service/OrderMasterService.java
+++ b/ghy-order/src/main/java/com/ghy/order/service/OrderMasterService.java
@@ -1,6 +1,7 @@
package com.ghy.order.service;
import com.ghy.order.domain.OrderMaster;
+import com.ghy.order.request.AppOrderRequest;
import java.util.List;
@@ -11,6 +12,8 @@ import java.util.List;
*/
public interface OrderMasterService {
+ OrderMaster createMasterOrder(AppOrderRequest appOrderRequest);
+
/**
* @param orderMaster 主订单属性
* @return 成功条数
diff --git a/ghy-order/src/main/java/com/ghy/order/service/impl/OrderMasterServiceImpl.java b/ghy-order/src/main/java/com/ghy/order/service/impl/OrderMasterServiceImpl.java
index 829ef00b..fc0cdb8c 100644
--- a/ghy-order/src/main/java/com/ghy/order/service/impl/OrderMasterServiceImpl.java
+++ b/ghy-order/src/main/java/com/ghy/order/service/impl/OrderMasterServiceImpl.java
@@ -4,6 +4,7 @@ import com.ghy.common.constant.UserConstants;
import com.ghy.common.core.text.Convert;
import com.ghy.order.domain.OrderMaster;
import com.ghy.order.mapper.OrderMasterMapper;
+import com.ghy.order.request.AppOrderRequest;
import com.ghy.order.service.OrderMasterService;
import org.springframework.stereotype.Service;
@@ -21,6 +22,11 @@ public class OrderMasterServiceImpl implements OrderMasterService {
@Resource
private OrderMasterMapper orderMasterMapper;
+ @Override
+ public OrderMaster createMasterOrder(AppOrderRequest appOrderRequest) {
+ return null;
+ }
+
@Override
public int insertOrderMaster(OrderMaster orderMaster) {
return orderMasterMapper.insertOrderMaster(orderMaster);