Prechádzať zdrojové kódy

update: 修改商品sku表

Ben 1 rok pred
rodič
commit
ec541beab1
21 zmenil súbory, kde vykonal 793 pridanie a 6 odobranie
  1. 8 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/dataobject/sku/ProductSkuDO.java
  2. 5 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/mysql/sku/ProductSkuMapper.java
  3. 34 0
      feifan-module-mall/feifan-module-sale-api/pom.xml
  4. 18 0
      feifan-module-mall/feifan-module-sale-api/src/main/java/cn/newfeifan/mall/module/sale/enums/ErrorCodeConstants.java
  5. 77 0
      feifan-module-mall/feifan-module-sale-biz/pom.xml
  6. 95 0
      feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/controller/admin/shop/ShopController.java
  7. 34 0
      feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/controller/admin/shop/vo/ShopPageReqVO.java
  8. 40 0
      feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/controller/admin/shop/vo/ShopRespVO.java
  9. 30 0
      feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/controller/admin/shop/vo/ShopSaveReqVO.java
  10. 47 0
      feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/dal/dataobject/shop/ShopDO.java
  11. 35 0
      feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/dal/mysql/shop/ShopMapper.java
  12. 55 0
      feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/service/shop/ShopService.java
  13. 75 0
      feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/service/shop/ShopServiceImpl.java
  14. 12 0
      feifan-module-mall/feifan-module-sale-biz/src/main/resources/mapper/shop/ShopMapper.xml
  15. 146 0
      feifan-module-mall/feifan-module-sale-biz/src/test/java/cn/newfeifan/mall/module/sale/service/shop/ShopServiceImplTest.java
  16. 12 0
      feifan-module-mall/feifan-module-trade-biz/pom.xml
  17. 6 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java
  18. 55 5
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderUpdateServiceImpl.java
  19. 2 0
      feifan-module-mall/pom.xml
  20. 6 0
      feifan-server/pom.xml
  21. 1 1
      feifan-server/src/main/resources/application-local.yaml

+ 8 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/dataobject/sku/ProductSkuDO.java

@@ -34,6 +34,14 @@ public class ProductSkuDO extends BaseDO {
      */
     @TableId
     private Long id;
+
+
+    /**
+     * 店铺ID,关联`sale_shop`表
+     * add by Ben 20240316
+     */
+    private Long shopId;
+
     /**
      * SPU 编号
      *

+ 5 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/mysql/sku/ProductSkuMapper.java

@@ -13,6 +13,11 @@ import java.util.List;
 @Mapper
 public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
 
+    // add by Ben 20240314
+    default List<ProductSkuDO> selectListBySKuId(Collection<Long> sKuIds) {
+        return selectList(ProductSkuDO::getId, sKuIds);
+    }
+
     default List<ProductSkuDO> selectListBySpuId(Long spuId) {
         return selectList(ProductSkuDO::getSpuId, spuId);
     }

+ 34 - 0
feifan-module-mall/feifan-module-sale-api/pom.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>cn.newfeifan.zx</groupId>
+        <artifactId>feifan-module-mall</artifactId>
+        <version>${revision}</version>
+    </parent>
+
+    <artifactId>feifan-module-sale-api</artifactId>
+    <packaging>jar</packaging>
+
+    <name>${project.artifactId}</name>
+    <description>
+        sale 模块 API,暴露给其它模块调用 add by Ben 20240315
+    </description>
+
+    <dependencies>
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-common</artifactId>
+        </dependency>
+
+        <!-- 参数校验 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+            <optional>true</optional>
+        </dependency>
+    </dependencies>
+
+</project>

+ 18 - 0
feifan-module-mall/feifan-module-sale-api/src/main/java/cn/newfeifan/mall/module/sale/enums/ErrorCodeConstants.java

@@ -0,0 +1,18 @@
+package cn.newfeifan.mall.module.sale.enums;
+
+import cn.newfeifan.mall.framework.common.exception.ErrorCode;
+
+/**
+ * Sale 错误码枚举类 add by Ben 20240315
+ * <p>
+ * Sale 系统,使用 1-101-000-000 段
+ * 第二段是模块编号,用101这么大,是不想与原来的编码重复
+ * 第三段是表编号,如:商户表、店铺表
+ * 第四段是表内的错误编号
+ */
+public interface ErrorCodeConstants {
+
+    //店铺表相关错误,表编号是1
+    ErrorCode SHOP_NOT_EXISTS = new ErrorCode(1_101_001_001, "店铺不存在");
+
+}

+ 77 - 0
feifan-module-mall/feifan-module-sale-biz/pom.xml

@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>cn.newfeifan.zx</groupId>
+        <artifactId>feifan-module-mall</artifactId>
+        <version>${revision}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>feifan-module-sale-biz</artifactId>
+    <packaging>jar</packaging>
+
+    <name>${project.artifactId}</name>
+    <description>
+        sale 模块,主要实现店铺、商户相关功能
+        店铺、商户表是新加的。add by Ben 20240315
+    </description>
+
+    <dependencies>
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-module-product-api</artifactId>
+            <version>${revision}</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-module-member-api</artifactId>
+            <version>${revision}</version>
+        </dependency>
+
+        <!-- 业务组件 -->
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-spring-boot-starter-biz-operatelog</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-spring-boot-starter-biz-dict</artifactId>
+        </dependency>
+
+        <!-- Web 相关 -->
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-spring-boot-starter-security</artifactId>
+        </dependency>
+
+        <!-- DB 相关 -->
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-spring-boot-starter-mybatis</artifactId>
+        </dependency>
+
+        <!-- Test 测试相关 -->
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-spring-boot-starter-test</artifactId>
+        </dependency>
+
+        <!-- 工具类相关 -->
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-spring-boot-starter-excel</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-module-sale-api</artifactId>
+            <version>2.0.0-jdk8-snapshot</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+
+</project>

+ 95 - 0
feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/controller/admin/shop/ShopController.java

@@ -0,0 +1,95 @@
+package cn.newfeifan.mall.module.sale.controller.admin.shop;
+
+import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import javax.validation.constraints.*;
+import javax.validation.*;
+import javax.servlet.http.*;
+import java.util.*;
+import java.io.IOException;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.pojo.CommonResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
+
+import cn.newfeifan.mall.framework.excel.core.util.ExcelUtils;
+
+import cn.newfeifan.mall.framework.operatelog.core.annotations.OperateLog;
+import static cn.newfeifan.mall.framework.operatelog.core.enums.OperateTypeEnum.*;
+
+import cn.newfeifan.mall.module.sale.controller.admin.shop.vo.*;
+import cn.newfeifan.mall.module.sale.dal.dataobject.shop.ShopDO;
+import cn.newfeifan.mall.module.sale.service.shop.ShopService;
+
+@Tag(name = "管理后台 - 店铺")
+@RestController
+@RequestMapping("/sale/shop")
+@Validated
+public class ShopController {
+
+    @Resource
+    private ShopService shopService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建店铺")
+    @PreAuthorize("@ss.hasPermission('sale:shop:create')")
+    public CommonResult<Long> createShop(@Valid @RequestBody ShopSaveReqVO createReqVO) {
+        return success(shopService.createShop(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新店铺")
+    @PreAuthorize("@ss.hasPermission('sale:shop:update')")
+    public CommonResult<Boolean> updateShop(@Valid @RequestBody ShopSaveReqVO updateReqVO) {
+        shopService.updateShop(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除店铺")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('sale:shop:delete')")
+    public CommonResult<Boolean> deleteShop(@RequestParam("id") Long id) {
+        shopService.deleteShop(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得店铺")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('sale:shop:query')")
+    public CommonResult<ShopRespVO> getShop(@RequestParam("id") Long id) {
+        ShopDO shop = shopService.getShop(id);
+        return success(BeanUtils.toBean(shop, ShopRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得店铺分页")
+    @PreAuthorize("@ss.hasPermission('sale:shop:query')")
+    public CommonResult<PageResult<ShopRespVO>> getShopPage(@Valid ShopPageReqVO pageReqVO) {
+        PageResult<ShopDO> pageResult = shopService.getShopPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, ShopRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出店铺 Excel")
+    @PreAuthorize("@ss.hasPermission('sale:shop:export')")
+    @OperateLog(type = EXPORT)
+    public void exportShopExcel(@Valid ShopPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<ShopDO> list = shopService.getShopPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "店铺.xls", "数据", ShopRespVO.class,
+                        BeanUtils.toBean(list, ShopRespVO.class));
+    }
+
+}

+ 34 - 0
feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/controller/admin/shop/vo/ShopPageReqVO.java

@@ -0,0 +1,34 @@
+package cn.newfeifan.mall.module.sale.controller.admin.shop.vo;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 店铺分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class ShopPageReqVO extends PageParam {
+
+    @Schema(description = "店铺名称", example = "李四")
+    private String name;
+
+    @Schema(description = "店铺状态", example = "1")
+    private Integer status;
+
+    @Schema(description = "商户id", example = "3447")
+    private Long merchantId;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "logo地址", example = "https://www.zhongxing.cn")
+    private String logoUrl;
+
+}

+ 40 - 0
feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/controller/admin/shop/vo/ShopRespVO.java

@@ -0,0 +1,40 @@
+package cn.newfeifan.mall.module.sale.controller.admin.shop.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import java.util.*;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+import com.alibaba.excel.annotation.*;
+
+@Schema(description = "管理后台 - 店铺 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class ShopRespVO {
+
+    @Schema(description = "店铺id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15084")
+    @ExcelProperty("店铺id")
+    private Long id;
+
+    @Schema(description = "店铺名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
+    @ExcelProperty("店铺名称")
+    private String name;
+
+    @Schema(description = "店铺状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    @ExcelProperty("店铺状态")
+    private Integer status;
+
+    @Schema(description = "商户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "3447")
+    @ExcelProperty("商户id")
+    private Long merchantId;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "logo地址", example = "https://www.zhongxing.cn")
+    @ExcelProperty("logo地址")
+    private String logoUrl;
+
+}

+ 30 - 0
feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/controller/admin/shop/vo/ShopSaveReqVO.java

@@ -0,0 +1,30 @@
+package cn.newfeifan.mall.module.sale.controller.admin.shop.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import javax.validation.constraints.*;
+
+@Schema(description = "管理后台 - 店铺新增/修改 Request VO")
+@Data
+public class ShopSaveReqVO {
+
+    @Schema(description = "店铺id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15084")
+    private Long id;
+
+    @Schema(description = "店铺名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
+    @NotEmpty(message = "店铺名称不能为空")
+    private String name;
+
+    @Schema(description = "店铺状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    @NotNull(message = "店铺状态不能为空")
+    private Integer status;
+
+    @Schema(description = "商户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "3447")
+    @NotNull(message = "商户id不能为空")
+    private Long merchantId;
+
+    @Schema(description = "logo地址", example = "https://www.zhongxing.cn")
+    private String logoUrl;
+
+}

+ 47 - 0
feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/dal/dataobject/shop/ShopDO.java

@@ -0,0 +1,47 @@
+package cn.newfeifan.mall.module.sale.dal.dataobject.shop;
+
+import lombok.*;
+import java.util.*;
+import java.time.LocalDateTime;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 店铺 DO
+ *
+ * @author 非繁人
+ */
+@TableName("sale_shop")
+@KeySequence("sale_shop_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class ShopDO extends BaseDO {
+
+    /**
+     * 店铺id
+     */
+    @TableId
+    private Long id;
+    /**
+     * 店铺名称
+     */
+    private String name;
+    /**
+     * 店铺状态
+     */
+    private Integer status;
+    /**
+     * 商户id
+     */
+    private Long merchantId;
+    /**
+     * logo地址
+     */
+    private String logoUrl;
+
+}

+ 35 - 0
feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/dal/mysql/shop/ShopMapper.java

@@ -0,0 +1,35 @@
+package cn.newfeifan.mall.module.sale.dal.mysql.shop;
+
+import java.util.*;
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
+import cn.newfeifan.mall.module.sale.dal.dataobject.shop.ShopDO;
+import org.apache.ibatis.annotations.Mapper;
+import cn.newfeifan.mall.module.sale.controller.admin.shop.vo.*;
+
+/**
+ * 店铺 Mapper
+ *
+ * @author 非繁人
+ * add by Ben 20240315
+ */
+@Mapper
+public interface ShopMapper extends BaseMapperX<ShopDO> {
+
+    default List<ShopDO> selectListById(Collection<Long> shopIds) {
+        return selectList(ShopDO::getId, shopIds);
+    }
+
+    default PageResult<ShopDO> selectPage(ShopPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<ShopDO>()
+                .likeIfPresent(ShopDO::getName, reqVO.getName())
+                .eqIfPresent(ShopDO::getStatus, reqVO.getStatus())
+                .eqIfPresent(ShopDO::getMerchantId, reqVO.getMerchantId())
+                .betweenIfPresent(ShopDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(ShopDO::getLogoUrl, reqVO.getLogoUrl())
+                .orderByDesc(ShopDO::getId));
+    }
+
+}

+ 55 - 0
feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/service/shop/ShopService.java

@@ -0,0 +1,55 @@
+package cn.newfeifan.mall.module.sale.service.shop;
+
+import java.util.*;
+import javax.validation.*;
+import cn.newfeifan.mall.module.sale.controller.admin.shop.vo.*;
+import cn.newfeifan.mall.module.sale.dal.dataobject.shop.ShopDO;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+
+/**
+ * 店铺 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface ShopService {
+
+    /**
+     * 创建店铺
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createShop(@Valid ShopSaveReqVO createReqVO);
+
+    /**
+     * 更新店铺
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateShop(@Valid ShopSaveReqVO updateReqVO);
+
+    /**
+     * 删除店铺
+     *
+     * @param id 编号
+     */
+    void deleteShop(Long id);
+
+    /**
+     * 获得店铺
+     *
+     * @param id 编号
+     * @return 店铺
+     */
+    ShopDO getShop(Long id);
+
+    /**
+     * 获得店铺分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 店铺分页
+     */
+    PageResult<ShopDO> getShopPage(ShopPageReqVO pageReqVO);
+
+}

+ 75 - 0
feifan-module-mall/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/module/sale/service/shop/ShopServiceImpl.java

@@ -0,0 +1,75 @@
+package cn.newfeifan.mall.module.sale.service.shop;
+
+import cn.newfeifan.mall.module.sale.enums.ErrorCodeConstants;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import cn.newfeifan.mall.module.sale.controller.admin.shop.vo.*;
+import cn.newfeifan.mall.module.sale.dal.dataobject.shop.ShopDO;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+
+import cn.newfeifan.mall.module.sale.dal.mysql.shop.ShopMapper;
+
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.module.sale.enums.ErrorCodeConstants.*;
+
+/**
+ * 店铺 Service 实现类
+ *
+ * @author 非繁人
+ */
+@Service
+@Validated
+public class ShopServiceImpl implements ShopService {
+
+    @Resource
+    private ShopMapper shopMapper;
+
+    @Override
+    public Long createShop(ShopSaveReqVO createReqVO) {
+        // 插入
+        ShopDO shop = BeanUtils.toBean(createReqVO, ShopDO.class);
+        shopMapper.insert(shop);
+        // 返回
+        return shop.getId();
+    }
+
+    @Override
+    public void updateShop(ShopSaveReqVO updateReqVO) {
+        // 校验存在
+        validateShopExists(updateReqVO.getId());
+        // 更新
+        ShopDO updateObj = BeanUtils.toBean(updateReqVO, ShopDO.class);
+        shopMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteShop(Long id) {
+        // 校验存在
+        validateShopExists(id);
+        // 删除
+        shopMapper.deleteById(id);
+    }
+
+    private void validateShopExists(Long id) {
+        if (shopMapper.selectById(id) == null) {
+            throw exception(ErrorCodeConstants.SHOP_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public ShopDO getShop(Long id) {
+        return shopMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<ShopDO> getShopPage(ShopPageReqVO pageReqVO) {
+        return shopMapper.selectPage(pageReqVO);
+    }
+
+}

+ 12 - 0
feifan-module-mall/feifan-module-sale-biz/src/main/resources/mapper/shop/ShopMapper.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.newfeifan.mall.module.sale.dal.mysql.shop.ShopMapper">
+
+    <!--
+        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
+        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
+        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
+        文档可见:https://www.zhongxing.cn/MyBatis/x-plugins/
+     -->
+
+</mapper>

+ 146 - 0
feifan-module-mall/feifan-module-sale-biz/src/test/java/cn/newfeifan/mall/module/sale/service/shop/ShopServiceImplTest.java

@@ -0,0 +1,146 @@
+package cn.newfeifan.mall.module.sale.service.shop;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.mock.mockito.MockBean;
+
+import javax.annotation.Resource;
+
+import cn.newfeifan.mall.framework.test.core.ut.BaseDbUnitTest;
+
+import cn.newfeifan.mall.module.sale.controller.admin.shop.vo.*;
+import cn.newfeifan.mall.module.sale.dal.dataobject.shop.ShopDO;
+import cn.newfeifan.mall.module.sale.dal.mysql.shop.ShopMapper;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+
+import javax.annotation.Resource;
+import org.springframework.context.annotation.Import;
+import java.util.*;
+import java.time.LocalDateTime;
+
+import static cn.hutool.core.util.RandomUtil.*;
+import static cn.newfeifan.mall.module.sale.enums.ErrorCodeConstants.*;
+import static cn.newfeifan.mall.framework.test.core.util.AssertUtils.*;
+import static cn.newfeifan.mall.framework.test.core.util.RandomUtils.*;
+import static cn.newfeifan.mall.framework.common.util.date.LocalDateTimeUtils.*;
+import static cn.newfeifan.mall.framework.common.util.object.ObjectUtils.*;
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.*;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.*;
+
+/**
+ * {@link ShopServiceImpl} 的单元测试类
+ *
+ * @author 非繁人
+ */
+@Import(ShopServiceImpl.class)
+public class ShopServiceImplTest extends BaseDbUnitTest {
+
+    @Resource
+    private ShopServiceImpl shopService;
+
+    @Resource
+    private ShopMapper shopMapper;
+
+    @Test
+    public void testCreateShop_success() {
+        // 准备参数
+        ShopSaveReqVO createReqVO = randomPojo(ShopSaveReqVO.class).setId(null);
+
+        // 调用
+        Long shopId = shopService.createShop(createReqVO);
+        // 断言
+        assertNotNull(shopId);
+        // 校验记录的属性是否正确
+        ShopDO shop = shopMapper.selectById(shopId);
+        assertPojoEquals(createReqVO, shop, "id");
+    }
+
+    @Test
+    public void testUpdateShop_success() {
+        // mock 数据
+        ShopDO dbShop = randomPojo(ShopDO.class);
+        shopMapper.insert(dbShop);// @Sql: 先插入出一条存在的数据
+        // 准备参数
+        ShopSaveReqVO updateReqVO = randomPojo(ShopSaveReqVO.class, o -> {
+            o.setId(dbShop.getId()); // 设置更新的 ID
+        });
+
+        // 调用
+        shopService.updateShop(updateReqVO);
+        // 校验是否更新正确
+        ShopDO shop = shopMapper.selectById(updateReqVO.getId()); // 获取最新的
+        assertPojoEquals(updateReqVO, shop);
+    }
+
+    @Test
+    public void testUpdateShop_notExists() {
+        // 准备参数
+        ShopSaveReqVO updateReqVO = randomPojo(ShopSaveReqVO.class);
+
+        // 调用, 并断言异常
+        assertServiceException(() -> shopService.updateShop(updateReqVO), SHOP_NOT_EXISTS);
+    }
+
+    @Test
+    public void testDeleteShop_success() {
+        // mock 数据
+        ShopDO dbShop = randomPojo(ShopDO.class);
+        shopMapper.insert(dbShop);// @Sql: 先插入出一条存在的数据
+        // 准备参数
+        Long id = dbShop.getId();
+
+        // 调用
+        shopService.deleteShop(id);
+       // 校验数据不存在了
+       assertNull(shopMapper.selectById(id));
+    }
+
+    @Test
+    public void testDeleteShop_notExists() {
+        // 准备参数
+        Long id = randomLongId();
+
+        // 调用, 并断言异常
+        assertServiceException(() -> shopService.deleteShop(id), SHOP_NOT_EXISTS);
+    }
+
+    @Test
+    @Disabled  // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
+    public void testGetShopPage() {
+       // mock 数据
+       ShopDO dbShop = randomPojo(ShopDO.class, o -> { // 等会查询到
+           o.setName(null);
+           o.setStatus(null);
+           o.setMerchantId(null);
+           o.setCreateTime(null);
+           o.setLogoUrl(null);
+       });
+       shopMapper.insert(dbShop);
+       // 测试 name 不匹配
+       shopMapper.insert(cloneIgnoreId(dbShop, o -> o.setName(null)));
+       // 测试 status 不匹配
+       shopMapper.insert(cloneIgnoreId(dbShop, o -> o.setStatus(null)));
+       // 测试 merchantId 不匹配
+       shopMapper.insert(cloneIgnoreId(dbShop, o -> o.setMerchantId(null)));
+       // 测试 createTime 不匹配
+       shopMapper.insert(cloneIgnoreId(dbShop, o -> o.setCreateTime(null)));
+       // 测试 logoUrl 不匹配
+       shopMapper.insert(cloneIgnoreId(dbShop, o -> o.setLogoUrl(null)));
+       // 准备参数
+       ShopPageReqVO reqVO = new ShopPageReqVO();
+       reqVO.setName(null);
+       reqVO.setStatus(null);
+       reqVO.setMerchantId(null);
+       reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
+       reqVO.setLogoUrl(null);
+
+       // 调用
+       PageResult<ShopDO> pageResult = shopService.getShopPage(reqVO);
+       // 断言
+       assertEquals(1, pageResult.getTotal());
+       assertEquals(1, pageResult.getList().size());
+       assertPojoEquals(dbShop, pageResult.getList().get(0));
+    }
+
+}

+ 12 - 0
feifan-module-mall/feifan-module-trade-biz/pom.xml

@@ -106,6 +106,18 @@
             <groupId>cn.newfeifan.zx</groupId>
             <artifactId>feifan-spring-boot-starter-biz-dict</artifactId>
         </dependency>
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-module-product-biz</artifactId>
+            <version>2.0.0-jdk8-snapshot</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-module-sale-biz</artifactId>
+            <version>2.0.0-jdk8-snapshot</version>
+            <scope>compile</scope>
+        </dependency>
 
     </dependencies>
 

+ 6 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java

@@ -8,11 +8,17 @@ import lombok.NoArgsConstructor;
 
 import javax.validation.constraints.NotNull;
 import java.util.List;
+import java.util.Map;
 
 @Schema(description = "用户 App - 交易订单结算信息 Response VO")
 @Data
 public class AppTradeOrderSettlementRespVO {
 
+    @Schema(description = "为键值对:根据店铺聚合的skuId列表,key为店铺id,value为商品skuid数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "{1:[12,23],2:[34,73]}") //key为店铺ID,value为skuid的List
+    Map<Long,List<Long>> shopSkuIds;
+    @Schema(description = "为键值对:商品对应的店铺id和店名,key为店铺id,value为店铺名", requiredMode = Schema.RequiredMode.REQUIRED, example = "{15:'中星直营店',23:'五行茶旗舰店'}") //key为店铺ID,value为skuid的List
+    Map<Long,String> shopNameMap;
+
     @Schema(description = "交易类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 对应 TradeOrderTypeEnum 枚举
     private Integer type;
 

+ 55 - 5
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderUpdateServiceImpl.java

@@ -19,6 +19,10 @@ import cn.newfeifan.mall.module.pay.api.order.dto.PayOrderRespDTO;
 import cn.newfeifan.mall.module.pay.enums.order.PayOrderStatusEnum;
 import cn.newfeifan.mall.module.product.api.comment.ProductCommentApi;
 import cn.newfeifan.mall.module.product.api.comment.dto.ProductCommentCreateReqDTO;
+import cn.newfeifan.mall.module.product.dal.dataobject.sku.ProductSkuDO;
+import cn.newfeifan.mall.module.product.dal.mysql.sku.ProductSkuMapper;
+import cn.newfeifan.mall.module.sale.dal.dataobject.shop.ShopDO;
+import cn.newfeifan.mall.module.sale.dal.mysql.shop.ShopMapper;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO;
@@ -50,16 +54,14 @@ import cn.newfeifan.mall.module.trade.service.price.bo.TradePriceCalculateReqBO;
 import cn.newfeifan.mall.module.trade.service.price.bo.TradePriceCalculateRespBO;
 import cn.newfeifan.mall.module.trade.service.price.calculator.TradePriceCalculatorHelper;
 import lombok.extern.slf4j.Slf4j;
+import org.ehcache.shadow.org.terracotta.offheapstore.HashingMap;
 import org.jetbrains.annotations.NotNull;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
+import java.util.*;
 
 import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.*;
@@ -78,6 +80,12 @@ import static cn.newfeifan.mall.module.trade.enums.ErrorCodeConstants.*;
 @Slf4j
 public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
 
+    @Resource
+    private ProductSkuMapper productSkuMapper;//add by ben 20240314
+
+    @Resource
+    private ShopMapper shopMapper;//add by ben 20240314
+
     @Resource
     private TradeOrderMapper tradeOrderMapper;
     @Resource
@@ -121,7 +129,49 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
         TradePriceCalculateRespBO calculateRespBO = calculatePrice(userId, settlementReqVO);
 
         // 3. 拼接返回
-        return TradeOrderConvert.INSTANCE.convert(calculateRespBO, address);
+        AppTradeOrderSettlementRespVO respVO = TradeOrderConvert.INSTANCE.convert(calculateRespBO, address);
+
+        // add by Ben 20240314
+        // 4. 查询每个sku对应的店铺ID,并传回页面
+        List<AppTradeOrderSettlementReqVO.Item> productSkuList = settlementReqVO.getItems();
+        List<Long> productSkuIdList = new ArrayList<>();
+        for(AppTradeOrderSettlementReqVO.Item skuItem : productSkuList){
+            productSkuIdList.add(skuItem.getSkuId());
+        }
+        // 查询每个skuid对应的sku对象
+        List<ProductSkuDO> productSkuDOList = productSkuMapper.selectListBySKuId(productSkuIdList);
+
+        //key为店铺ID,value为skuid的List
+        Map<Long,List<Long>> shopSkuIds = new HashMap<Long, List<Long>>();
+        for(ProductSkuDO sku:productSkuDOList){//把sku根据店聚合放到map中
+            Long skuId = sku.getId();
+            Long shopId = sku.getShopId();
+            List<Long> shopSkuList = shopSkuIds.get(shopId);
+            if(shopSkuList==null) {
+                shopSkuList = new ArrayList<Long>();
+                shopSkuIds.put(shopId,shopSkuList);
+            }
+            shopSkuList.add(skuId);//把sku根据店聚合放到map中
+        }
+
+        respVO.setShopSkuIds(shopSkuIds);//把sku根据店聚合放到map中
+
+        //把店铺id和店铺名称查出来放到map中
+        List<Long> shopIds = new ArrayList<Long>();
+        for (Long shopid : shopSkuIds.keySet()) {
+            shopIds.add(shopid);
+        }
+        List<ShopDO> shopDOList = shopMapper.selectListById(shopIds);
+        Map<Long,String> shopNameMap = new HashMap<Long,String>();//key为店铺id,value为店铺名
+        for (ShopDO shopDO : shopDOList) {
+            shopNameMap.put(shopDO.getId(),shopDO.getName());
+        }
+        respVO.setShopNameMap(shopNameMap);
+
+        System.out.println("shopSkuIds@@@@@@@@"+shopSkuIds);
+        System.out.println("shopNameMap@@@@@@@@"+shopNameMap);
+
+        return respVO;
     }
 
     /**

+ 2 - 0
feifan-module-mall/pom.xml

@@ -26,6 +26,8 @@
         <module>feifan-module-trade-biz</module>
         <module>feifan-module-statistics-api</module>
         <module>feifan-module-statistics-biz</module>
+        <module>feifan-module-sale-api</module>
+        <module>feifan-module-sale-biz</module>
     </modules>
 
 </project>

+ 6 - 0
feifan-server/pom.xml

@@ -87,6 +87,12 @@
             <version>${revision}</version>
         </dependency>
 
+        <dependency><!-- 店铺商户所在的新增模块 add by Ben 20240315 -->
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-module-sale-biz</artifactId>
+            <version>${revision}</version>
+        </dependency>
+
         <!-- CRM 相关模块。默认注释,保证编译速度 -->
 <!--        <dependency>-->
 <!--            <groupId>cn.newfeifan.zx</groupId>-->

+ 1 - 1
feifan-server/src/main/resources/application-local.yaml

@@ -47,7 +47,7 @@ spring:
       primary: master
       datasource:
         master:
-          name: mall-feifan
+          name: mall-feifan-dev
           url: jdbc:mysql://10.0.5.229:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
           username: wendao9t
           password: PA55W0RD