Browse Source

bugfix:打卡广场修改

lyx 2 days ago
parent
commit
b50d94b987

+ 8 - 7
alien-entity/src/main/java/shop/alien/entity/store/StoreClockIn.java

@@ -1,19 +1,16 @@
 package shop.alien.entity.store;
 
-import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
-import java.util.Date;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.annotation.TableLogic;
-import com.baomidou.mybatisplus.annotation.TableField;
-import java.io.Serializable;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
+import java.io.Serializable;
+import java.util.Date;
+
 /**
  * <p>
  * 店铺打卡
@@ -95,6 +92,10 @@ public class StoreClockIn extends Model<StoreClockIn> {
     @TableField("reason")
     private String reason;
 
+    @ApiModelProperty(value = "ai帮写内容(也可自己手写)")
+    @TableField("maybe_ai_content")
+    private String maybeAiContent;
+
 
     @Override
     protected Serializable pkVal() {

+ 8 - 12
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreClockInVo.java

@@ -62,17 +62,13 @@ public class StoreClockInVo extends StoreClockIn {
 
     @ApiModelProperty(value = "商家入口图")
     private String entranceImage;
-    //    @ApiModelProperty(value = "商家是否打卡")
-//    @ApiModelProperty(value = "该用户是否在该店铺打过卡")
-//    private String clockInStore;
-//
-//    @ApiModelProperty(value = "今天在该店铺是否打过卡")
-//    private String clockInStoreToday;
-//
-//    @ApiModelProperty(value = "在该店铺的打卡次数")
-//    private Long clockInStoreNum;
-//
-//    @ApiModelProperty(value = "该用户打卡的所有店铺次数")
-//    private int clockInNum;
 
+    @ApiModelProperty(value = "商家类型大类分")
+    private Integer storeTypeNew;
+
+    @ApiModelProperty(value = "门店地址")
+    private String storeAddress;
+
+    @ApiModelProperty(value = "分类名称")
+    private String businessClassifyName;
 }

+ 18 - 6
alien-store/src/main/java/shop/alien/store/controller/StoreClockInController.java

@@ -63,14 +63,26 @@ public class StoreClockInController {
         return 1 <= result ? R.success("设置成功") : R.fail("设置失败");
     }
 
-    @ApiOperation("设置图片")
+    @ApiOperation("设置图片和ai帮写内容")
     @ApiOperationSupport(order = 5)
-    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键id", dataType = "Integer", paramType = "query"), @ApiImplicitParam(name = "img", value = "打卡图片", dataType = "String", paramType = "query")})
-    @GetMapping("/setImg")
-    public R<IPage<StoreClockInVo>> setImg(int id, String img) {
-        log.info("StoreClockInController.setImg?id={},img={}", id, img);
-        int result = storeClockInService.setImg(id, img);
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键id", dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "imgUrl", value = "打卡图片", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "maybeAiContent", value = "ai帮写内容", dataType = "String", paramType = "query")})
+    @PostMapping("/setImgAndAiContent")
+    public R<IPage<StoreClockInVo>>  setImgAndAiContent(@RequestBody StoreClockIn storeClockIn) {
+        log.info("StoreClockInController.setImgAndAiContent?id={},img={},aiContent={}", storeClockIn.getId(), storeClockIn.getImgUrl(),storeClockIn.getMaybeAiContent());
+        int result = storeClockInService.setImgAndAiContent(storeClockIn.getId(), storeClockIn.getImgUrl(),storeClockIn.getMaybeAiContent());
         return 1 == result ? R.success("设置成功") : R.fail("设置失败");
     }
 
+    // 根据id查询打卡记录
+    @ApiOperation("根据id查询打卡记录")
+    @ApiOperationSupport(order = 6)
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键id", dataType = "Integer", paramType = "query")})
+    @GetMapping("/getStoreClockInById")
+    public R<StoreClockInVo> getStoreClockInById(Integer id) {
+        log.info("StoreClockInController.getStoreClockInById?id={}", id);
+        return R.data(storeClockInService.getStoreClockInById(id));
+    }
+
 }

+ 9 - 1
alien-store/src/main/java/shop/alien/store/service/StoreClockInService.java

@@ -26,7 +26,7 @@ public interface StoreClockInService extends IService<StoreClockIn> {
 
     int setPermission(int userId, Integer id, int permission);
 
-    int setImg(int id, String img);
+    int setImgAndAiContent(int id, String img,String aiContent);
 
     List<Map<Integer, Integer>> getStoreClockInCount();
     /**
@@ -35,4 +35,12 @@ public interface StoreClockInService extends IService<StoreClockIn> {
      * @return map
      */
     List<Map<Integer, Integer>> getStoreClockInWithCanLookCount();
+
+    /**
+     * 根据id查询打卡记录
+     *
+     * @param id 主键id
+     * @return 打卡记录
+     */
+    StoreClockInVo getStoreClockInById(Integer id);
 }

+ 51 - 1
alien-store/src/main/java/shop/alien/store/service/impl/StoreClockInServiceImpl.java

@@ -1,5 +1,6 @@
 package shop.alien.store.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -15,6 +16,7 @@ import shop.alien.mapper.*;
 import shop.alien.store.service.StoreClockInService;
 import shop.alien.store.service.StoreCommentService;
 
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -43,6 +45,10 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
 
     private final LifeCollectMapper lifeCollectMapper;
 
+    private final StoreInfoMapper storeInfoMapper;
+
+     private final StoreImgMapper storeImgMapper;
+
     @Override
     public StoreClockIn addStoreClockIn(StoreClockIn storeClockIn) {
         LifeUser user = lifeUserMapper.selectById(storeClockIn.getUserId());
@@ -198,9 +204,10 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
     }
 
     @Override
-    public int setImg(int id, String img) {
+    public int setImgAndAiContent(int id, String img,String aiContent) {
         LambdaUpdateWrapper<StoreClockIn> wrapper = new LambdaUpdateWrapper<>();
         wrapper.set(StoreClockIn::getImgUrl, img);
+        wrapper.set(StoreClockIn::getMaybeAiContent,aiContent);
         wrapper.eq(StoreClockIn::getId, id);
         return storeClockInMapper.update(null, wrapper);
     }
@@ -224,4 +231,47 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
     public List<Map<Integer, Integer>> getStoreClockInWithCanLookCount() {
         return storeClockInMapper.getStoreClockInWithCanLookCount();
     }
+
+    @Override
+    public StoreClockInVo getStoreClockInById(Integer id) {
+        StoreClockIn storeClockIn = storeClockInMapper.selectById(id);
+        StoreClockInVo storeClockInVo = BeanUtil.copyProperties(storeClockIn, StoreClockInVo.class);
+        if (null == storeClockIn) {
+            return null;
+        }
+
+        StoreInfo storeInfo = storeInfoMapper.selectById(storeClockIn.getStoreId());
+        // 店铺名称
+        storeClockInVo.setStoreName(storeInfo.getStoreName());
+        // 店铺头像
+        LambdaQueryWrapper<StoreImg> eq = new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 10).eq(StoreImg::getStoreId, storeInfo.getId());
+        StoreImg storeImg = storeImgMapper.selectOne(eq);
+        storeClockInVo.setEntranceImage(storeImg != null ? storeImg.getImgUrl() : "");
+        // 店铺评分
+        storeClockInVo.setScore(storeInfo.getScoreAvg());
+        // 设置店铺大类
+        String businessSectionName = storeInfo.getBusinessSectionName();
+        if(Arrays.asList("酒吧", "KTV", "洗浴汗蒸", "按摩足疗").contains(businessSectionName)){
+            storeClockInVo.setStoreTypeNew(1);
+        } else if (Arrays.asList("丽人美发", "运动健身").contains(businessSectionName)){
+            storeClockInVo.setStoreTypeNew(2);
+        } else if (Arrays.asList("特色美食").contains(businessSectionName)){
+            storeClockInVo.setStoreTypeNew(3);
+        }
+        // 最小分类
+        storeClockInVo.setBusinessClassifyName(storeInfo.getBusinessClassifyName());
+        // 地址
+        storeClockInVo.setStoreAddress(storeInfo.getStoreAddress());
+        // 是否收藏
+        // 查询我的收藏
+        LambdaQueryWrapper<LifeCollect> collectWrapper = new LambdaQueryWrapper<>();
+        collectWrapper.eq(LifeCollect::getUserId, String.valueOf(storeClockInVo.getUserId()));
+        List<LifeCollect> lifeCollectList = lifeCollectMapper.selectList(collectWrapper);
+        List<String> collectList = lifeCollectList.stream().map(LifeCollect::getStoreId).collect(Collectors.toList());
+        storeClockInVo.setIsCollect("0");
+        if (collectList.contains(storeClockInVo.getStoreId().toString())){
+            storeClockInVo.setIsCollect("1");
+        }
+        return storeClockInVo;
+    }
 }