Browse Source

商户的创建加入默认创建一个店铺模板

Yangzw 2 months ago
parent
commit
ec4efec913
16 changed files with 76 additions and 19 deletions
  1. 4 0
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/page/DiyPageCreateReqVO.java
  2. 6 0
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/page/DiyPagePageReqVO.java
  3. 1 3
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqByMerVO.java
  4. 2 1
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqVO.java
  5. 3 0
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/template/DiyTemplatePageReqVO.java
  6. 5 0
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/template/DiyTemplateRespVO.java
  7. 7 0
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/template/DiyTemplateUpdateReqVO.java
  8. 2 1
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/dal/dataobject/diy/DiyPageDO.java
  9. 2 0
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/dal/mysql/diy/DiyPageMapper.java
  10. 6 2
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/dal/mysql/diy/DiyTemplateMapper.java
  11. 1 1
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/service/diy/DiyTemplateService.java
  12. 16 5
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/service/diy/DiyTemplateServiceImpl.java
  13. 6 0
      feifan-module-sale/feifan-module-sale-biz/pom.xml
  14. 0 4
      feifan-module-sale/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/sale/controller/admin/merchant/vo/MerchantSaveReqVO.java
  15. 0 1
      feifan-module-sale/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/sale/controller/admin/merchantapply/vo/MerchantApplySaveReqVO.java
  16. 15 1
      feifan-module-sale/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/sale/service/merchant/MerchantServiceImpl.java

+ 4 - 0
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/page/DiyPageCreateReqVO.java

@@ -10,5 +10,9 @@ import lombok.ToString;
 @EqualsAndHashCode(callSuper = true)
 @ToString(callSuper = true)
 public class DiyPageCreateReqVO extends DiyPageBaseVO {
+    @Schema(description = "店铺ID",  example = "123")
+    private Long shopId;
 
+    @Schema(description = "商户ID", example = "12")
+    private Long merchantId;
 }

+ 6 - 0
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/page/DiyPagePageReqVO.java

@@ -20,6 +20,12 @@ public class DiyPagePageReqVO extends PageParam {
     @Schema(description = "页面名称", example = "王五")
     private String name;
 
+    @Schema(description = "店铺ID",  example = "123")
+    private Long shopId;
+
+    @Schema(description = "商户ID", example = "12")
+    private Long merchantId;
+
     @Schema(description = "创建时间")
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] createTime;

+ 1 - 3
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqByMerVO.java

@@ -5,8 +5,6 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
 
-import javax.validation.constraints.NotEmpty;
-import java.util.List;
 
 @Schema(description = "管理后台 - 装修模板创建 Request VO")
 @Data
@@ -18,6 +16,6 @@ public class DiyTemplateCreateReqByMerVO extends DiyTemplateBaseVO {
     private Long shopId;
 
     @Schema(description = "商户ID", example = "12")
-    private Long merId;
+    private Long merchantId;
 
 }

+ 2 - 1
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqVO.java

@@ -7,12 +7,13 @@ import lombok.*;
 @Data
 @EqualsAndHashCode(callSuper = true)
 @ToString(callSuper = true)
+@Builder
 public class DiyTemplateCreateReqVO extends DiyTemplateBaseVO {
 
     @Schema(description = "店铺ID",  example = "123")
     private Long shopId;
 
     @Schema(description = "商户ID", example = "12")
-    private Long merId;
+    private Long merchantId;
 
 }

+ 3 - 0
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/template/DiyTemplatePageReqVO.java

@@ -31,4 +31,7 @@ public class DiyTemplatePageReqVO extends PageParam {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] createTime;
 
+    @Schema(description = "是否是admin")
+    private Boolean isAdmin;
+
 }

+ 5 - 0
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/template/DiyTemplateRespVO.java

@@ -25,4 +25,9 @@ public class DiyTemplateRespVO extends DiyTemplateBaseVO {
     @Schema(description = "使用时间", example = "使用时间")
     private LocalDateTime usedTime;
 
+    @Schema(description = "店铺id")
+    private Long shopId;
+    @Schema(description = "商户id")
+    private Long merchantId;
+
 }

+ 7 - 0
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/admin/diy/vo/template/DiyTemplateUpdateReqVO.java

@@ -1,6 +1,7 @@
 package cn.newfeifan.mall.module.promotion.controller.admin.diy.vo.template;
 
 import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Builder;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
@@ -11,10 +12,16 @@ import javax.validation.constraints.NotNull;
 @Data
 @EqualsAndHashCode(callSuper = true)
 @ToString(callSuper = true)
+@Builder
 public class DiyTemplateUpdateReqVO extends DiyTemplateBaseVO {
 
     @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209")
     @NotNull(message = "装修模板编号不能为空")
     private Long id;
 
+    @Schema(description = "店铺ID",  example = "123")
+    private Long shopId;
+
+    @Schema(description = "商户ID", example = "12")
+    private Long merchantId;
 }

+ 2 - 1
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/dal/dataobject/diy/DiyPageDO.java

@@ -32,7 +32,6 @@ public class DiyPageDO extends BaseDO {
     private Long id;
     /**
      * 装修模板编号
-     *
      * 关联 {@link DiyTemplateDO#getId()}
      */
     private Long templateId;
@@ -53,5 +52,7 @@ public class DiyPageDO extends BaseDO {
      * 页面属性,JSON 格式
      */
     private String property;
+    private Long shopId;
+    private Long merchantId;
 
 }

+ 2 - 0
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/dal/mysql/diy/DiyPageMapper.java

@@ -19,6 +19,8 @@ public interface DiyPageMapper extends BaseMapperX<DiyPageDO> {
 
     default PageResult<DiyPageDO> selectPage(DiyPagePageReqVO reqVO) {
         return selectPage(reqVO, new LambdaQueryWrapperX<DiyPageDO>()
+                .eqIfPresent(DiyPageDO::getShopId, reqVO.getShopId())
+                .eqIfPresent(DiyPageDO::getMerchantId, reqVO.getMerchantId())
                 .likeIfPresent(DiyPageDO::getName, reqVO.getName())
                 .betweenIfPresent(DiyPageDO::getCreateTime, reqVO.getCreateTime())
                 // 模板下面的页面,在模板中管理

+ 6 - 2
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/dal/mysql/diy/DiyTemplateMapper.java

@@ -16,13 +16,17 @@ import org.apache.ibatis.annotations.Mapper;
 public interface DiyTemplateMapper extends BaseMapperX<DiyTemplateDO> {
 
     default PageResult<DiyTemplateDO> selectPage(DiyTemplatePageReqVO reqVO) {
-        return selectPage(reqVO, new LambdaQueryWrapperX<DiyTemplateDO>()
+        LambdaQueryWrapperX<DiyTemplateDO> queryWrapper = new LambdaQueryWrapperX<DiyTemplateDO>()
                 .likeIfPresent(DiyTemplateDO::getName, reqVO.getName())
                 .eqIfPresent(DiyTemplateDO::getUsed, reqVO.getUsed())
                 .betweenIfPresent(DiyTemplateDO::getUsedTime, reqVO.getUsedTime())
                 .betweenIfPresent(DiyTemplateDO::getCreateTime, reqVO.getCreateTime())
                 .orderByDesc(DiyTemplateDO::getUsed) // 排序规则1:已使用的排到最前面
-                .orderByDesc(DiyTemplateDO::getId)); // 排序规则2:新创建的排到前面
+                .orderByDesc(DiyTemplateDO::getId);
+        if(!reqVO.getIsAdmin()){
+            queryWrapper.eq(DiyTemplateDO::getUsed, false);
+        }
+        return selectPage(reqVO, queryWrapper); // 排序规则2:新创建的排到前面
     }
 
     default DiyTemplateDO selectByUsed(boolean used) {

+ 1 - 1
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/service/diy/DiyTemplateService.java

@@ -70,6 +70,6 @@ public interface DiyTemplateService {
      *
      * @return 装修模板
      */
-    DiyTemplateDO getUsedDiyTemplate();
+    DiyTemplateDO getUsedDiyTemplate(Long merchantId);
 
 }

+ 16 - 5
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/service/diy/DiyTemplateServiceImpl.java

@@ -3,11 +3,13 @@ package cn.newfeifan.mall.module.promotion.service.diy;
 import cn.hutool.core.util.BooleanUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+import cn.newfeifan.mall.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO;
 import cn.newfeifan.mall.module.promotion.controller.admin.diy.vo.template.*;
-import cn.newfeifan.mall.module.promotion.convert.diy.DiyPageConvert;
 import cn.newfeifan.mall.module.promotion.convert.diy.DiyTemplateConvert;
 import cn.newfeifan.mall.module.promotion.dal.dataobject.diy.DiyTemplateDO;
 import cn.newfeifan.mall.module.promotion.dal.mysql.diy.DiyTemplateMapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
@@ -58,8 +60,16 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
      */
     private void createDefaultPage(DiyTemplateDO diyTemplate) {
         String remark = String.format("模板【%s】自动创建", diyTemplate.getName());
-        diyPageService.createDiyPage(DiyPageConvert.INSTANCE.convertCreateVo(diyTemplate.getId(), "首页", remark));
-        diyPageService.createDiyPage(DiyPageConvert.INSTANCE.convertCreateVo(diyTemplate.getId(), "我的", remark));
+        DiyPageCreateReqVO home = BeanUtils.toBean(diyTemplate, DiyPageCreateReqVO.class);
+        home.setName("首页");
+        home.setTemplateId(diyTemplate.getId());
+        home.setRemark(remark);
+        DiyPageCreateReqVO my = BeanUtils.toBean(diyTemplate, DiyPageCreateReqVO.class);
+        my.setName("我的");
+        my.setTemplateId(diyTemplate.getId());
+        my.setRemark(remark);
+        diyPageService.createDiyPage(home);
+        diyPageService.createDiyPage(my);
     }
 
     @Override
@@ -163,8 +173,9 @@ public class DiyTemplateServiceImpl implements DiyTemplateService {
     }
 
     @Override
-    public DiyTemplateDO getUsedDiyTemplate() {
-        return diyTemplateMapper.selectByUsed(true);
+    public DiyTemplateDO getUsedDiyTemplate(Long merchantId) {
+        return diyTemplateMapper.selectOne(new LambdaQueryWrapper<DiyTemplateDO>()
+                .eq(DiyTemplateDO::getMerchantId, merchantId));
     }
 
 }

+ 6 - 0
feifan-module-sale/feifan-module-sale-biz/pom.xml

@@ -110,5 +110,11 @@
             <groupId>cn.newfeifan.zx</groupId>
             <artifactId>feifan-spring-boot-starter-biz-ip</artifactId>
         </dependency>
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-module-promotion-biz</artifactId>
+            <version>2.0.0-jdk8-snapshot</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>

+ 0 - 4
feifan-module-sale/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/sale/controller/admin/merchant/vo/MerchantSaveReqVO.java

@@ -92,19 +92,15 @@ public class MerchantSaveReqVO {
     private List<String> otherCertificate;
 
     @Schema(description = "法人", requiredMode = Schema.RequiredMode.REQUIRED)
-    @NotEmpty(message = "法人不能为空")
     private String legalPerson;
 
     @Schema(description = "法人电话", requiredMode = Schema.RequiredMode.REQUIRED)
-    @NotEmpty(message = "法人电话不能为空")
     private String legalPersonNumber;
 
     @Schema(description = "身份证正面", requiredMode = Schema.RequiredMode.REQUIRED)
-    @NotEmpty(message = "身份证正面不能为空")
     private String identityCardFront;
 
     @Schema(description = "身份证反面", requiredMode = Schema.RequiredMode.REQUIRED)
-    @NotEmpty(message = "身份证反面不能为空")
     private String identityCardReverseSide;
 
 

+ 0 - 1
feifan-module-sale/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/sale/controller/admin/merchantapply/vo/MerchantApplySaveReqVO.java

@@ -48,7 +48,6 @@ public class MerchantApplySaveReqVO {
     private String customerServiceHotline;
 
     @Schema(description = "邮箱")
-    @Email(message = "邮箱格式不正确")
     private String email;
 
     @Schema(description = "营业执照图片路径")

+ 15 - 1
feifan-module-sale/feifan-module-sale-biz/src/main/java/cn/newfeifan/mall/sale/service/merchant/MerchantServiceImpl.java

@@ -8,6 +8,10 @@ import cn.newfeifan.mall.module.product.dal.dataobject.spuapply.SpuApplyDO;
 import cn.newfeifan.mall.module.product.enums.spu.ProductSpuStatusEnum;
 import cn.newfeifan.mall.module.product.service.sku.ProductSkuService;
 import cn.newfeifan.mall.module.product.service.spuapply.SpuApplyService;
+import cn.newfeifan.mall.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO;
+import cn.newfeifan.mall.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO;
+import cn.newfeifan.mall.module.promotion.dal.dataobject.diy.DiyTemplateDO;
+import cn.newfeifan.mall.module.promotion.service.diy.DiyTemplateService;
 import cn.newfeifan.mall.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
 import cn.newfeifan.mall.module.system.dal.dataobject.user.AdminUserDO;
 import cn.newfeifan.mall.module.system.dal.mysql.user.AdminUserMapper;
@@ -23,7 +27,6 @@ import cn.newfeifan.mall.sale.dal.dataobject.merchantapply.MerchantApplyDO;
 import cn.newfeifan.mall.sale.dal.mysql.merchant.MerchantMapper;
 import cn.newfeifan.mall.sale.dal.mysql.merchantapply.MerchantApplyMapper;
 import cn.newfeifan.mall.sale.dal.redis.ShopMessage;
-import cn.newfeifan.mall.sale.service.merchantapply.MerchantApplyService;
 import cn.newfeifan.mall.sale.service.shop.ShopService;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
@@ -70,6 +73,8 @@ public class MerchantServiceImpl implements MerchantService {
     private StringRedisTemplate stringRedisTemplate;
     @Resource
     private MerchantApplyMapper merchantApplyMapper;
+    @Resource
+    private DiyTemplateService diyTemplateService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -102,6 +107,11 @@ public class MerchantServiceImpl implements MerchantService {
         HashMap<String, Long> stringLongHashMap = new HashMap<>();
         stringLongHashMap.put("shopId", shopId);
         stringLongHashMap.put("merId", merchant.getId());
+
+        // 创建店铺模板
+        DiyTemplateCreateReqVO build = DiyTemplateCreateReqVO.builder().merchantId(merchant.getId()).shopId(shopId).build();
+        build.setName(merchant.getName());
+        diyTemplateService.createDiyTemplate(build);
         return stringLongHashMap;
     }
 
@@ -116,6 +126,10 @@ public class MerchantServiceImpl implements MerchantService {
         MerchantApplyDO bean = BeanUtils.toBean(updateReqVO, MerchantApplyDO.class);
         bean.setId(updateObj.getMerchantApplyId());
         merchantApplyMapper.updateById(bean);
+
+        DiyTemplateDO usedDiyTemplate = diyTemplateService.getUsedDiyTemplate(updateObj.getId());
+        usedDiyTemplate.setName(updateObj.getName());
+        diyTemplateService.updateDiyTemplate(BeanUtils.toBean(usedDiyTemplate, DiyTemplateUpdateReqVO.class));
     }
 
     @Override