소스 검색

团购重构

jyc 1 일 전
부모
커밋
5d4b53b68f

+ 7 - 0
alien-entity/src/main/java/shop/alien/entity/store/LifeGroupBuyMain.java

@@ -25,6 +25,13 @@ public class LifeGroupBuyMain {
     private Integer id;
 
     /**
+     * 编号
+     */
+    @ApiModelProperty(value = "编号")
+    @TableField("group_no")
+    private String groupNo;
+
+    /**
      * 团购类型(1美食)
      */
     @ApiModelProperty(value = "团购类型(1美食)")

+ 7 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/LifeGroupBuyThaliVo.java

@@ -24,6 +24,13 @@ public class LifeGroupBuyThaliVo {
     private Integer id;
 
     /**
+     * 编号
+     */
+    @ApiModelProperty(value = "编号")
+    @TableField("group_no")
+    private String groupNo;
+
+    /**
      * 团购类型(1美食)
      */
     @ApiModelProperty(value = "团购类型(1美食)")

+ 1 - 1
alien-entity/src/main/java/shop/alien/mapper/LifeGroupBuyMainMapper.java

@@ -20,7 +20,7 @@ import shop.alien.entity.store.vo.LifeGroupBuyThaliVo;
 @Mapper
 public interface LifeGroupBuyMainMapper extends BaseMapper<LifeGroupBuyMain> {
 
-    @Select("select id,group_type,status,store_id,image_id,group_name,start_time_type,\n" +
+    @Select("select id,group_no,group_type,status,store_id,image_id,group_name,start_time_type,\n" +
             "        start_time_value,end_time,inventory_num,quota_type,quota_value,\n" +
             "        original_price,preferential_price,effective_date_type,effective_date_value,disable_date_type,\n" +
             "        disable_date_value,write_off,reservation_rules,use_rules,applicable_num,\n" +

+ 6 - 1
alien-store/src/main/java/shop/alien/store/service/impl/LifeGroupBuyServiceImpl.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
+import org.apache.http.client.utils.DateUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import shop.alien.entity.store.*;
@@ -51,6 +52,8 @@ public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper,
         LifeGroupBuyMain lifeGroupBuyMain = lifeGroupBuyDto.getLifeGroupBuyMain();
         List<LifeGroupBuyThali> lifeGroupBuyThalis = lifeGroupBuyDto.getLifeGroupBuyThalis();
         if (ObjectUtils.isEmpty(lifeGroupBuyMain.getId())) {
+            Integer count = lifeGroupBuyMainMapper.selectCount(new LambdaQueryWrapper<LifeGroupBuyMain>().like(LifeGroupBuyMain::getCreatedTime, DateUtils.formatDate(new Date(), "yyyy-MM-dd")).eq(LifeGroupBuyMain::getStoreId, lifeGroupBuyMain.getStoreId()));
+            lifeGroupBuyMain.setGroupNo("G" + DateUtils.formatDate(new Date(), "yyyyMMdd") + lifeGroupBuyMain.getStoreId() + org.apache.commons.lang3.StringUtils.leftPad(String.valueOf(count + 1), 5, "0"));
             lifeGroupBuyMain.setCreatedUserId(userId);
             lifeGroupBuyMainMapper.insert(lifeGroupBuyMain);
             if (ObjectUtils.isNotEmpty(lifeGroupBuyThalis)) {
@@ -90,7 +93,9 @@ public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper,
                 .eq("delete_flag", 0)
                 .orderByDesc("created_time");
         IPage<LifeGroupBuyThaliVo> lifeGroupBuyThaliVoIPage = new Page<>(page, size);
-        return lifeGroupBuyMainMapper.selectPageByThaliVo(lifeGroupBuyThaliVoIPage, queryWrapper);
+        IPage<LifeGroupBuyThaliVo> voIPage = lifeGroupBuyMainMapper.selectPageByThaliVo(lifeGroupBuyThaliVoIPage, queryWrapper);
+        voIPage.getRecords().forEach(this::getMainImgAndDisableDate);
+        return voIPage;
     }
 
     @Override