瀏覽代碼

Merge remote-tracking branch 'origin/master'

wxd 1 周之前
父節點
當前提交
0e6df3dc11

+ 4 - 0
alien-entity/src/main/java/shop/alien/entity/store/StoreInfo.java

@@ -172,4 +172,8 @@ public class StoreInfo {
     @ApiModelProperty(value = "原因")
     @TableField("reason")
     private String reason;
+
+    @ApiModelProperty(value = "注销code")
+    @TableField("logout_code")
+    private String logoutCode;
 }

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreInfoVo.java

@@ -166,4 +166,7 @@ public class StoreInfoVo extends StoreInfo {
 
     @ApiModelProperty(value = "是否营业中(0否1是)")
     private Integer yyFlag;
+
+    @ApiModelProperty(value = "验证码")
+    private String verificationCode;
 }

+ 9 - 7
alien-second/src/main/java/shop/alien/second/controller/SecondShieldController.java

@@ -3,7 +3,6 @@ package shop.alien.second.controller;
 import com.alibaba.fastjson.JSONObject;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
 import io.swagger.annotations.ApiSort;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -11,7 +10,6 @@ import org.apache.poi.ss.formula.functions.T;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
 import shop.alien.entity.second.SecondShield;
-import shop.alien.entity.second.vo.SecondGoodsVo;
 import shop.alien.mapper.second.SecondShieldMapper;
 import shop.alien.util.common.JwtUtil;
 
@@ -62,11 +60,15 @@ public class SecondShieldController {
      * 取消拉黑
      */
     @PostMapping("/deleteGoodsShield")
-    @ApiOperation("取消拉黑")
-    public R<Void> deleteGoodsShield(@ApiParam("取消拉黑") @RequestBody SecondGoodsVo secondGoods) {
-        log.info("SecondShieldController.GoodsShield?secondGoods={}", secondGoods.toString());
-        mapper.deleteById(secondGoods.getShieldId());
-        return R.success("取消拉黑成功");
+    public R<T> deleteGoodsShield(
+            @RequestParam(value = "id", required = false) Integer id) {
+        Integer num = mapper.deleteById(id);
+
+        if(num == 1) {
+            return R.success("取消拉黑成功");
+        }
+        return R.fail("取消拉黑失败");
+
     }
 
 }

+ 60 - 2
alien-second/src/main/java/shop/alien/second/service/impl/SecondRecommendServiceImpl.java

@@ -192,13 +192,25 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
             List<StoreImg> storeImgs = storeImgMapper.selectList(query);
             // 设置图片信息
             if (storeImgs.size() > 0) {
-                item.setImgList(storeImgs.stream().map(StoreImg::getImgUrl).toArray(String[]::new));
+                // 先按视频后缀排序,再按ImgSort排序
+                String[] items = storeImgs.stream()
+                        .sorted((o1, o2) -> {
+                            boolean o1IsMp4 = isVideoUrl(o1.getImgUrl());
+                            boolean o2IsMp4 = isVideoUrl(o2.getImgUrl());
+                            // 如果都是.mp4或都不是.mp4,则按ImgSort排序
+                            if (o1IsMp4 && o2IsMp4 || !o1IsMp4 && !o2IsMp4) {
+                                return o1.getImgSort().compareTo(o2.getImgSort());
+                            }
+                            // 否则,.mp4的排在前面
+                            return o1IsMp4 ? -1 : 1;
+                        }).map(StoreImg::getImgUrl).toArray(String[]::new);
+                item.setImgList(items);
             }
 
             // 查看是否关注
             QueryWrapper<LifeFans> query1 = new QueryWrapper<>();
             query1.lambda()
-                    .eq(LifeFans::getFollowedId, item.getUserPhone()) // 商品 图片
+                    .eq(LifeFans::getFollowedId, item.getUserPhone()) // 商品图片
                     .eq(LifeFans::getDeleteFlag, 0)
                     .eq(LifeFans::getFansId, "user_" + phoneId);
             List<LifeFans> lifeFans = lifeFansMapper.selectList(query1);
@@ -217,4 +229,50 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
             throw new Exception(e);
         }
     }
+
+    public static void main(String[] args) {
+        List<StoreImg> storeImgs = new ArrayList<>();
+        StoreImg storeImg = new StoreImg();
+        storeImg.setImgSort(4);
+        storeImg.setImgUrl("11111.mp4");
+        storeImgs.add(storeImg);
+        StoreImg storeImg1 = new StoreImg();
+        storeImg1.setImgSort(3);
+        storeImg1.setImgUrl("22222.jpg");
+        storeImgs.add(storeImg1);
+        StoreImg storeImg2 = new StoreImg();
+        storeImg2.setImgSort(2);
+        storeImg2.setImgUrl("33333.jpg");
+        storeImgs.add(storeImg2);
+        StoreImg storeImg3 = new StoreImg();
+        storeImg3.setImgSort(1);
+        storeImg3.setImgUrl("44444.mp4");
+        storeImgs.add(storeImg3);
+
+        // 先按视频后缀排序,再按ImgSort排序
+        String[] items = storeImgs.stream()
+                .sorted((o1, o2) -> {
+                    boolean o1IsMp4 = isVideoUrl(o1.getImgUrl());
+                    boolean o2IsMp4 = isVideoUrl(o2.getImgUrl());
+                    // 如果都是.mp4或都不是.mp4,则按ImgSort排序
+                    if (o1IsMp4 && o2IsMp4 || !o1IsMp4 && !o2IsMp4) {
+                        return o1.getImgSort().compareTo(o2.getImgSort());
+                    }
+                    // 否则,.mp4的排在前面
+                    return o1IsMp4 ? -1 : 1;
+                }).map(StoreImg::getImgUrl).toArray(String[]::new);
+
+        System.out.println(items);
+    }
+
+    private static boolean isVideoUrl(String url) {
+        if (url == null) return false;
+        url = url.toLowerCase();
+        return url.endsWith(".mp4") ||
+                url.endsWith(".avi") ||
+                url.endsWith(".mov") ||
+                url.endsWith(".flv") ||
+                url.endsWith(".wmv") ||
+                url.endsWith(".mkv");
+    }
 }

+ 7 - 20
alien-store/src/main/java/shop/alien/store/controller/StoreInfoController.java

@@ -59,14 +59,6 @@ public class StoreInfoController {
     public R saveOrUpdate(@RequestBody StoreInfo storeInfo) {
         log.info("StoreInfoController.saveOrUpdate?storeInfo={}", storeInfo);
         return R.data(storeInfoService.saveOrUpdateStoreInfo(storeInfo));
-//        Integer id = storeInfo.getId();
-//        if (storeInfoService.saveOrUpdate(storeInfo)) {
-//            if (null != id) {
-//                return R.success("修改成功");
-//            }
-//            return R.success("新增成功");
-//        }
-//        return R.fail("失败");
     }
 
     @ApiOperation("web端新增门店")
@@ -405,32 +397,27 @@ public class StoreInfoController {
     @ApiOperation(value = "注销店铺")
     @ApiOperationSupport(order = 14)
     @PostMapping("/logoutStore")
-    public R logoutStore(@RequestBody StoreInfo storeInfo) {
-        log.info("StoreInfoController.logoutStore?id={},reason={}", storeInfo.getId(), storeInfo.getLogoutReason());
+    public R logoutStore(@RequestBody StoreInfoVo storeInfo) {
+        log.info("StoreInfoController.logoutStore?storeInfo={}", storeInfo);
         try {
-            if (storeInfoService.logoutStore(storeInfo.getId(), storeInfo.getLogoutReason())) {
-                return R.success("注销成功");
-            }
-
-            return R.fail("注销失败");
+            storeInfoService.logoutStore(storeInfo);
         } catch (Exception e) {
             return R.fail(e.getMessage());
         }
+        return R.success("注销成功");
     }
 
     @ApiOperation(value = "取消注销店铺")
     @ApiOperationSupport(order = 15)
     @PostMapping("/cancelLogoutStore")
-    public R cancelLogoutStore(@RequestBody StoreInfo storeInfo) {
+    public R cancelLogoutStore(@RequestBody StoreInfoVo  storeInfo) {
         log.info("StoreInfoController.cancelLogoutStore?id={}", storeInfo.getId());
         try {
-            if (storeInfoService.cancelLogoutStore(storeInfo.getId())) {
-                return R.success("取消注销成功");
-            }
-            return R.fail("取消注销失败");
+            storeInfoService.cancelLogoutStore(storeInfo);
         } catch (Exception e) {
             return R.fail(e.getMessage());
         }
+        return R.success("撤销注销成功");
     }
 
     /**

+ 12 - 0
alien-store/src/main/java/shop/alien/store/controller/UserViolationController.java

@@ -6,9 +6,11 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
+import shop.alien.entity.store.LifeNotice;
 import shop.alien.entity.store.LifeUserViolation;
 import shop.alien.entity.store.UserLoginInfo;
 import shop.alien.entity.store.dto.LifeUserViolationDto;
+import shop.alien.mapper.LifeNoticeMapper;
 import shop.alien.store.service.LifeUserViolationService;
 import shop.alien.util.common.TokenInfo;
 import springfox.documentation.annotations.ApiIgnore;
@@ -34,6 +36,8 @@ public class UserViolationController {
 
     private final LifeUserViolationService lifeUserViolationService;
 
+    private final LifeNoticeMapper lifeNoticeMapper;
+
     @ApiOperation("举报")
     @ApiOperationSupport(order = 1)
     @PostMapping("/reporting")
@@ -43,6 +47,14 @@ public class UserViolationController {
         if (0 == reporting) {
             return R.fail("举报失败");
         } else {
+            LifeNotice lifeNotice = new LifeNotice();
+            lifeNotice.setSenderId("system");
+            lifeNotice.setReceiverId(lifeuserViolation.getReportingUserId());
+            lifeNotice.setBusinessId(lifeuserViolation.getId());
+            lifeNotice.setTitle("平台已受理");
+            lifeNotice.setContext("平台已受理,感谢您的反馈!");
+            lifeNotice.setNoticeType(1);
+            lifeNoticeMapper.insert(lifeNotice);
             return R.data("举报成功");
         }
     }

+ 4 - 5
alien-store/src/main/java/shop/alien/store/service/StoreInfoService.java

@@ -187,19 +187,18 @@ public interface StoreInfoService extends IService<StoreInfo> {
     /**
      * 注销店铺
      *
-     * @param storeId 店铺ID
-     * @param reason  注销原因
+     * @param storeInfo 店铺Vo
      * @return boolean
      */
-    boolean logoutStore(Integer storeId, String reason);
+    void logoutStore(StoreInfoVo storeInfo);
 
     /**
      * 取消注销店铺
      *
-     * @param storeId 店铺ID
+     * @param storeInfo 店铺Vo
      * @return boolean
      */
-    boolean cancelLogoutStore(Integer storeId);
+    void cancelLogoutStore(StoreInfoVo storeInfo);
 
     /**
      * web-查询店铺信息根据门店电话

+ 72 - 26
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -40,6 +40,7 @@ import shop.alien.util.common.DistanceUtil;
 
 import java.io.IOException;
 import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatterBuilder;
@@ -1375,37 +1376,82 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
     }
 
     @Override
-    public boolean logoutStore(Integer storeId, String reason) {
-        StoreInfo storeInfo = this.getById(storeId);
-        if (storeInfo == null) {
-            throw new RuntimeException("店铺不存在");
-        }
-        if (storeInfo.getLogoutFlag() == 1) {
-            throw new RuntimeException("店铺已经注销");
+    public void logoutStore(StoreInfoVo storeInfo) {
+        String key = "verification_" + storeInfo.getStorePhone();
+        String redisVerificationCode = baseRedisService.getString(key);
+        if(redisVerificationCode.equals(storeInfo.getVerificationCode())){
+            // 通过id获取当前店铺信息
+            LambdaQueryWrapper<StoreInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+            lambdaQueryWrapper.eq(StoreInfo::getId, storeInfo.getId());
+            StoreInfo storeIn = storeInfoMapper.selectOne(lambdaQueryWrapper);
+            if(storeIn!=null){
+                // 添加注销原因
+                storeIn.setLogoutReason(storeIn.getLogoutReason());
+                // 添加注销code
+                storeIn.setLogoutCode(storeIn.getLogoutCode());
+                // 注销中状态
+                storeIn.setStoreStatus(-1);
+                // 添加注销申请时间
+                storeIn.setLogoutTime(new Date());
+                // 更新logout_flag状态为1
+                storeIn.setLogoutFlag(1);
+                int num = storeInfoMapper.updateById(storeIn);
+                if(num>0){
+                    // 发送通知
+                    LifeNotice lifeMessage = new LifeNotice();
+                    lifeMessage.setReceiverId("store_" + storeInfo.getStorePhone());
+                    String text = "您提交的店铺注销申请已成功提交, 系统将按流程进行处理. 注销申请提交后, 将进入7天的冷静期. 期间您可以随时在" +
+                            "[门店装修]-[操作]中撤回申请. 冷静期结束后, 系统将正式开始注销操作. 店铺内所有数据将被永久清除, 且无法恢复." +
+                            "如有疑问, 可联系客服咨询. 感谢您使用我们的服务.";
+                    lifeMessage.setContext(text);
+                    lifeMessage.setTitle("注销通知");
+                    lifeMessage.setSenderId("system");
+                    lifeMessage.setIsRead(0);
+                    lifeMessage.setNoticeType(1);
+                    lifeNoticeMapper.insert(lifeMessage);
+                }
+            }
+        }else{
+            throw new RuntimeException("验证码错误");
         }
-
-        storeInfo.setLogoutFlag(1);
-        storeInfo.setLogoutReason(reason);
-        storeInfo.setLogoutTime(new Date());
-
-        return this.updateById(storeInfo);
     }
 
     @Override
-    public boolean cancelLogoutStore(Integer storeId) {
-        StoreInfo storeInfo = this.getById(storeId);
-        if (storeInfo == null) {
-            throw new RuntimeException("店铺不存在");
-        }
-        if (storeInfo.getLogoutFlag() == 0) {
-            throw new RuntimeException("店铺未注销");
+    public void cancelLogoutStore(StoreInfoVo storeInfo) {
+        // 通过id获取当前商家账号信息
+        LambdaQueryWrapper<StoreInfo> storeUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        storeUserLambdaQueryWrapper.eq(StoreInfo::getId, storeInfo.getId());
+        StoreInfo storeIn = storeInfoMapper.selectOne(storeUserLambdaQueryWrapper);
+        // 修改注销标记为0
+        storeIn.setLogoutFlag(0);
+        // 注销状态变为可用
+        storeIn.setStoreStatus(0);
+        // 清空注销原因
+        storeIn.setLogoutReason(null);
+        // 清空注销code
+        storeIn.setLogoutCode(null);
+        // 清空注销申请时间
+        storeIn.setLogoutTime(null);
+        // 更新logout_flag状态为0
+        storeIn.setLogoutFlag(0);
+        int num = storeInfoMapper.updateById(storeIn);
+        if (num > 0) {
+            // 发送通知
+            LifeNotice lifeMessage = new LifeNotice();
+            lifeMessage.setReceiverId("store_" + storeInfo.getStorePhone());
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String storeDate = simpleDateFormat.format(storeInfo.getCreatedTime());
+            String text = "处理结果:已撤回注销申请" +
+                    "处理时间:" + storeDate +
+                    "当前账号状态已恢复正常. 您可以继续使用该店铺登录并享受各项服务, 所有店铺数据均已妥善保留." +
+                    "若您后续仍有注销需求, 可随时通过门店装修页面重新提交申请. 感谢您的理解与支持!";
+            lifeMessage.setContext(text);
+            lifeMessage.setTitle("撤销注销通知");
+            lifeMessage.setSenderId("system");
+            lifeMessage.setIsRead(0);
+            lifeMessage.setNoticeType(1);
+            lifeNoticeMapper.insert(lifeMessage);
         }
-
-        storeInfo.setLogoutFlag(0);
-        storeInfo.setLogoutReason(null);
-        storeInfo.setLogoutTime(null);
-
-        return this.updateById(storeInfo);
     }
 
     @Override