From bc81cc344a48ba8e280bd38c8d0055348fe5eb31 Mon Sep 17 00:00:00 2001
From: xjs <1294405880@qq.com>
Date: Wed, 6 Apr 2022 17:03:12 +0800
Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=95=86=E5=9F=8E=E6=9C=8D=E5=8A=A1?=
=?UTF-8?q?=E5=95=86=E5=93=81=E4=B8=8A=E6=9E=B6=E5=8A=9F=E8=83=BD=E5=AE=9E?=
=?UTF-8?q?=E7=8E=B0=EF=BC=8C=E4=BD=BF=E7=94=A8ES=E5=81=9A=E6=A3=80?=
=?UTF-8?q?=E7=B4=A2=202=E3=80=81=E5=B7=A8=E5=9D=91=EF=BC=8Ces=E7=9A=84mav?=
=?UTF-8?q?en=E5=9D=90=E6=A0=87=E7=89=88=E6=9C=AC=E9=9C=80=E8=A6=81?=
=?UTF-8?q?=E4=B8=80=E7=9B=B4=EF=BC=8C=E5=90=A6=E5=88=99=E6=8A=A5=E9=94=99?=
=?UTF-8?q?=E3=80=82=20=E8=AF=A6=E6=83=85=E7=9C=8B=EF=BC=9Ahttps://blog.cs?=
=?UTF-8?q?dn.net/CSDN877425287/article/details/107287531?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
.../java/com/xjs/mall/RemoteSearchFeign.java | 24 ++++
.../java/com/xjs/mall/RemoteWareFeign.java | 22 ++++
.../java/com/xjs/mall/to/SkuHasStockVo.java | 21 ++++
.../java/com/xjs/mall/to/es/SkuEsModel.java | 104 ++++++++++++++++++
.../core/constant/ServiceNameConstants.java | 12 ++
ruoyi-ui/src/api/mall/product/spu-info.js | 9 ++
.../views/mall/product/maintain/spuinfo.vue | 61 +++++-----
.../src/main/java/com/xjs/consts/EsConst.java | 13 +++
.../java/com/xjs/consts/ProductConstant.java | 21 ++++
.../java/com/xjs/exception/BizCodeEnume.java | 1 +
.../product/controller/SpuInfoController.java | 7 ++
.../com/xjs/mall/product/dao/AttrDao.java | 8 +-
.../com/xjs/mall/product/dao/SpuInfoDao.java | 13 ++-
.../xjs/mall/product/service/AttrService.java | 7 ++
.../mall/product/service/SkuInfoService.java | 8 ++
.../mall/product/service/SpuInfoService.java | 6 +
.../product/service/impl/AttrServiceImpl.java | 5 +
.../service/impl/SkuInfoServiceImpl.java | 7 ++
.../service/impl/SpuInfoServiceImpl.java | 98 ++++++++++++++++-
.../main/resources/mapper/product/AttrDao.xml | 7 ++
.../resources/mapper/product/SpuInfoDao.xml | 6 +-
.../search/config/ElasticsearchConfig.java | 11 +-
.../controller/ElasticSaveController.java | 52 +++++++++
.../search/service/ProductSaveService.java | 21 ++++
.../service/impl/ProductSaveServiceImpl.java | 65 +++++++++++
.../src/main/resources/product-mapping.json | 69 ++++++++++++
.../ware/controller/WareSkuController.java | 12 +-
.../com/xjs/mall/ware/dao/WareSkuDao.java | 7 ++
.../xjs/mall/ware/service/WareSkuService.java | 10 ++
.../ware/service/impl/WareSkuServiceImpl.java | 13 +++
.../com/xjs/mall/ware/vo/SkuHasStockVo.java | 21 ++++
.../main/resources/mapper/ware/WareSkuDao.xml | 4 +
33 files changed, 698 insertions(+), 49 deletions(-)
create mode 100644 ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/RemoteSearchFeign.java
create mode 100644 ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/RemoteWareFeign.java
create mode 100644 ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/to/SkuHasStockVo.java
create mode 100644 ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/to/es/SkuEsModel.java
create mode 100644 xjs-business/xjs-business-common/src/main/java/com/xjs/consts/EsConst.java
create mode 100644 xjs-business/xjs-project-mall/mall-search/src/main/java/com/xjs/mall/search/controller/ElasticSaveController.java
create mode 100644 xjs-business/xjs-project-mall/mall-search/src/main/java/com/xjs/mall/search/service/ProductSaveService.java
create mode 100644 xjs-business/xjs-project-mall/mall-search/src/main/java/com/xjs/mall/search/service/impl/ProductSaveServiceImpl.java
create mode 100644 xjs-business/xjs-project-mall/mall-search/src/main/resources/product-mapping.json
create mode 100644 xjs-business/xjs-project-mall/mall-ware/src/main/java/com/xjs/mall/ware/vo/SkuHasStockVo.java
diff --git a/pom.xml b/pom.xml
index 8ba66956..73137127 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,7 +51,7 @@
5.7.1
0.7.5
2.2.0.RELEASE
- 7.2.0
+ 7.12.1
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/RemoteSearchFeign.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/RemoteSearchFeign.java
new file mode 100644
index 00000000..8dc64fe0
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/RemoteSearchFeign.java
@@ -0,0 +1,24 @@
+package com.xjs.mall;
+
+import com.ruoyi.common.core.constant.ServiceNameConstants;
+import com.xjs.mall.other.R;
+import com.xjs.mall.to.es.SkuEsModel;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
+
+/**
+ * 检索服务feign
+ * @author xiejs
+ * @since 2022-04-06
+ */
+@FeignClient(contextId = "remoteSearchFeign",
+ value = ServiceNameConstants.MALL_SEARCH_SERVICE)
+public interface RemoteSearchFeign {
+
+ @PostMapping("/search/product")
+ R productStatusUp(@RequestBody List skuEsModelList);
+
+}
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/RemoteWareFeign.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/RemoteWareFeign.java
new file mode 100644
index 00000000..f862854f
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/RemoteWareFeign.java
@@ -0,0 +1,22 @@
+package com.xjs.mall;
+
+import com.ruoyi.common.core.constant.ServiceNameConstants;
+import com.xjs.mall.to.SkuHasStockVo;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
+
+/**
+ * 仓库服务feign
+ * @author xiejs
+ * @since 2022-04-06
+ */
+@FeignClient(contextId = "remoteWareFeign",
+ value = ServiceNameConstants.MALL_WARE_SERVICE)
+public interface RemoteWareFeign {
+
+ @PostMapping("/ware/waresku/hasStock")
+ List getSkuHasStock(@RequestBody List skuIds);
+}
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/to/SkuHasStockVo.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/to/SkuHasStockVo.java
new file mode 100644
index 00000000..a21d8599
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/to/SkuHasStockVo.java
@@ -0,0 +1,21 @@
+package com.xjs.mall.to;
+
+import lombok.Data;
+
+/**
+ * sku库存查询vo
+ * @author xiejs
+ * @since 2022-04-06
+ */
+@Data
+public class SkuHasStockVo {
+ /**
+ * sku id
+ */
+ private Long skuId;
+
+ /**
+ * 是否有库存
+ */
+ private Boolean hasStock;
+}
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/to/es/SkuEsModel.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/to/es/SkuEsModel.java
new file mode 100644
index 00000000..6c64c096
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/xjs/mall/to/es/SkuEsModel.java
@@ -0,0 +1,104 @@
+package com.xjs.mall.to.es;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * spu es 模型
+ * @author xiejs
+ * @since 2022-04-06
+ */
+@Data
+public class SkuEsModel {
+
+ /**
+ * 商品sku id
+ */
+ private Long skuId;
+
+ /**
+ * 商品spu id
+ */
+ private Long spuId;
+
+ /**
+ * sku标题
+ */
+ private String skuTitle;
+
+ /**
+ * sku价格
+ */
+ private BigDecimal skuPrice;
+
+ /**
+ * sku默认图片
+ */
+ private String skuImg;
+
+ /**
+ * 销量
+ */
+ private Long saleCount;
+
+ /**
+ * 是否拥有库存
+ */
+ private Boolean hasStock;
+
+ /**
+ * 热度评分
+ */
+ private Long hotScore;
+
+ /**
+ * 品牌id
+ */
+ private Long brandId;
+
+ /**
+ * 分类id
+ */
+ private Long catalogId;
+
+ /**
+ * 品牌名
+ */
+ private String brandName;
+
+ /**
+ * 品牌logo
+ */
+ private String brandImg;
+
+ /**
+ * 分类名
+ */
+ private String catalogName;
+
+
+ private List attrs;
+
+
+ @Data
+ public static class Attrs{
+ /**
+ * 属性id
+ */
+ private Long attrId;
+
+ /**
+ * 属性名
+ */
+ private String attrName;
+
+ /**
+ * 属性值
+ */
+ private String attrValue;
+ }
+
+
+}
diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java
index 65fa1c72..4e695fb1 100644
--- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java
+++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java
@@ -52,5 +52,17 @@ public class ServiceNameConstants {
*/
public static final String MALL_PRODUCT_SERVICE = "xjs-mall-product";
+ /**
+ * 仓库服务的serviceid
+ */
+ public static final String MALL_WARE_SERVICE = "xjs-mall-ware";
+
+ /**
+ * 检索服务的serviceid
+ */
+ public static final String MALL_SEARCH_SERVICE = "xjs-mall-search";
+
+
+
}
diff --git a/ruoyi-ui/src/api/mall/product/spu-info.js b/ruoyi-ui/src/api/mall/product/spu-info.js
index 8dd9e35f..1fb3507c 100644
--- a/ruoyi-ui/src/api/mall/product/spu-info.js
+++ b/ruoyi-ui/src/api/mall/product/spu-info.js
@@ -18,3 +18,12 @@ export function getSpuList(data) {
})
}
+
+// 商品上架
+export function spuUp(spuId) {
+ return request({
+ url: `/mall-product/product/spuinfo/${spuId}/up`,
+ method: 'post',
+ })
+}
+
diff --git a/ruoyi-ui/src/views/mall/product/maintain/spuinfo.vue b/ruoyi-ui/src/views/mall/product/maintain/spuinfo.vue
index 1cb89152..a26cf1bf 100644
--- a/ruoyi-ui/src/views/mall/product/maintain/spuinfo.vue
+++ b/ruoyi-ui/src/views/mall/product/maintain/spuinfo.vue
@@ -8,28 +8,38 @@
style="width: 100%;"
>
-
-
-
-
-
-
+
+
+
+
+
+
新建
已上架
已下架
-
-
-
+
+
+
上架
+ >上架
+
规格
@@ -48,7 +58,7 @@