From f5ef4dc87297dad9c238d18006d4cef022dd30f5 Mon Sep 17 00:00:00 2001
From: phpcjl <phpcjl@gmail.com>
Date: 星期三, 11 十二月 2024 14:33:42 +0800
Subject: [PATCH] 1.后台管理-商品管理

---
 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java            |    5 +
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java   |   29 +++++++--
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java              |    3 +
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java                |    3 
 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml                          |    5 +
 ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/TechnicianSubscribe.java                  |    5 +
 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java |    6 ++
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java             |   13 ++++
 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml            |    4 
 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml                           |    1 
 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java                 |    5 +
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java      |   16 +++++
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java            |    3 +
 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TechnicianSubscribe.java        |    2 
 ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml                    |   24 ++++++++
 15 files changed, 108 insertions(+), 16 deletions(-)

diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java
index c251413..5ef7a2b 100644
--- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java
@@ -13,6 +13,7 @@
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -242,6 +243,10 @@
     @TableField(exist = false)
     private Integer isSign;
 
+    @ApiModelProperty("绑定门店id列表")
+    @TableField(exist = false)
+    private Set<Integer> shopIds;
+
 
 
 
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TechnicianSubscribe.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TechnicianSubscribe.java
index 2d883b2..a750a50 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TechnicianSubscribe.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TechnicianSubscribe.java
@@ -55,7 +55,7 @@
     @TableField("user_address")
     private String userAddress;
 
-    @ApiModelProperty(value = "状态(0=待服务,1=已服务,2=已取消)")
+    @ApiModelProperty(value = "状态(0=待服务,1=已服务,2=已取消, 3=已到期)")
     @TableField("status")
     private Integer status;
 
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java
index 3a33ec3..926794a 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java
@@ -7,6 +7,7 @@
 import org.springframework.cloud.openfeign.FallbackFactory;
 
 import java.util.List;
+import java.util.Set;
 
 @Slf4j
 public class ShopClientFallbackFactory implements FallbackFactory<ShopClient> {
@@ -27,6 +28,11 @@
             public R<List<Shop>> getShopByUserIds(List<Long> userIds) {
                 return R.fail("根据用户id集合获取门店数据失败");
             }
+
+            @Override
+            public R<Set<Integer>> getShopIdByName(String shopName) {
+                return R.fail("根据门店名称获取门店id失败:" + cause.getMessage());
+            }
         };
     }
 }
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java
index bbc7986..2f9f937 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java
@@ -6,11 +6,13 @@
 import com.ruoyi.other.api.domain.Shop;
 import com.ruoyi.other.api.factory.ShopClientFallbackFactory;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * @author zhibing.pu
@@ -39,4 +41,7 @@
 
 	@PostMapping("/getShopByUserIds")
 	public R<List<Shop>> getShopByUserIds(@RequestBody List<Long> userIds);
+
+	@GetMapping("/getShopIdByName")
+    R<Set<Integer>> getShopIdByName(String shopName);
 }
diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/TechnicianSubscribe.java b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/TechnicianSubscribe.java
index cb0f7b5..9f3daa2 100644
--- a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/TechnicianSubscribe.java
+++ b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/TechnicianSubscribe.java
@@ -4,6 +4,7 @@
 import lombok.extern.log4j.Log4j2;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.util.Set;
@@ -19,9 +20,9 @@
     public void updateStatus() {
         long now = System.currentTimeMillis() / 1000; // 获取当前时间戳(秒)
         Set<String> subscribeIds = redisTemplate.opsForZSet().rangeByScore("delay_queue:subscribe", 0, now);
-        if (subscribeIds != null) {
+        if (!CollectionUtils.isEmpty(subscribeIds)) {
             subscribeIds.forEach(subscribeId -> {
-                technicianClient.updateStatus(2, Long.valueOf(subscribeId));
+                technicianClient.updateStatus(3, Long.valueOf(subscribeId));
             });
         }
     }
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
index c93014f..c725ad6 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -1,6 +1,7 @@
 package com.ruoyi.account.controller;
 
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ruoyi.account.api.model.AppUser;
 import com.ruoyi.account.api.model.UserCancellationLog;
 import com.ruoyi.account.api.model.UserCoupon;
@@ -327,5 +328,20 @@
 		return R.ok();
 	}
 
+	/**
+	 * 获取用户列表
+	 */
+	@GetMapping("/getAppuserPage")
+	@ApiOperation(value = "用户列表", tags = {"后台管理"})
+	public R<IPage<AppUser>> getAppuserPage(@ApiParam("页码") @RequestParam Integer PageNum,
+								  @ApiParam("每一页数据大小") Integer pageSize,
+								  AppUser appUser)
+	{
+		IPage<AppUser> appuserPage = appUserService.getAppuserPage(PageNum, pageSize, appUser);
+		return R.ok(appuserPage);
+	}
+
+
+
 }
 
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java
index 030983c..f313602 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java
@@ -1,6 +1,7 @@
 package com.ruoyi.account.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ruoyi.account.api.model.AppUser;
 import com.ruoyi.account.vo.NearbyReferrer;
 import com.ruoyi.account.vo.NearbyReferrerVo;
@@ -25,6 +26,8 @@
 	 * @return
 	 */
 	List<NearbyReferrerVo> getNearbyReferrer(@Param("cityCode") String cityCode, @Param("nearbyReferrer") NearbyReferrer nearbyReferrer);
+
+	IPage<AppUser> getAppuserPage(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser);
 	
 	
 
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java
index 58ff323..d17c594 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java
@@ -1,5 +1,6 @@
 package com.ruoyi.account.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.account.api.model.AppUser;
 import com.ruoyi.account.vo.*;
@@ -79,4 +80,6 @@
 	 * 在线记录操作,用于赠送积分
 	 */
 	void onlineRecord();
+
+	IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser);
 }
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java
index ebb8cad..64a32a1 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java
@@ -3,6 +3,8 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.account.api.model.AppUserShop;
 import com.ruoyi.account.api.model.UserChangeLog;
@@ -31,8 +33,10 @@
 import com.ruoyi.system.api.feignClient.SysUserClient;
 import com.ruoyi.system.api.model.LoginUser;
 import org.apache.logging.log4j.core.util.UuidUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
@@ -89,13 +93,10 @@
 
 	@Resource
 	private UserPointService userPointService;
-	
-	
-	
-	
-	
-	
-	
+    @Autowired
+    private AppUserMapper appUserMapper;
+
+
 	/**
 	 * 小程序一键登录
 	 * @param appletLogin
@@ -610,4 +611,18 @@
 			}
 		}
 	}
+
+	@Override
+	public IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser) {
+		if (StringUtils.isNotEmpty(appUser.getShopName())){
+			R<Set<Integer>> shopR = shopClient.getShopIdByName(appUser.getShopName());
+			if (R.isSuccess(shopR)){
+				Set<Integer> shopIds = shopR.getData();
+				if (!CollectionUtils.isEmpty(shopIds)){
+					appUser.setShopIds(shopIds);
+				}
+			}
+		}
+		return appUserMapper.getAppuserPage(new Page<>(pageNum, pageSize), appUser);
+	}
 }
diff --git a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml
index 2e1a6e4..6919c53 100644
--- a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml
+++ b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml
@@ -51,4 +51,28 @@
             </if>
         ) as aa order by aa.distance
     </select>
+
+    <select id="getAppuserPage" resultType="com.ruoyi.account.api.model.AppUser">
+        SELECT ta.id, ta.`name`, ta.vip_id, ta.shop_id
+        FROM t_app_user ta
+        <where>
+            ta.del_flag = 0
+            <if test="null != appUser.name and '' != appUser.name">
+                and ta.`name` like CONCAT('%',#{appUser.name},'%')
+            </if>
+            <if test="null != appUser.phone and '' != appUser.phone">
+                and ta.phone like CONCAT('%',#{appUser.phone},'%')
+            </if>
+            <if test="null != appUser.vipId">
+                and ta.vip_id = #{appUser.vipId}
+            </if>
+            <if test="null != appUser.shopIds and appUser.shopIds.size() > 0">
+                and ta.shop_id in
+                <foreach collection="appUser.shopIds" item="shopId" open="(" separator="," close=")">
+                    #{shopId}
+                </foreach>
+            </if>
+        </where>
+
+    </select>
 </mapper>
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
index 314a5cc..5e03fce 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -28,6 +28,7 @@
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -79,7 +80,10 @@
         AppUserShop appUserShop = new AppUserShop();
         appUserShop.setAppUserId(loginUserApplet.getUserid());
         appUserShop.setShopId(shop.getId());
-        appUserClient.addAppUserShop(appUserShop);
+        R<Void> r = appUserClient.addAppUserShop(appUserShop);
+        if (R.isError(r)){
+            throw new RuntimeException("添加失败");
+        }
         return R.ok();
     }
 
@@ -206,5 +210,12 @@
         return R.ok(list);
     }
 
+    @GetMapping("/getShopIdByName")
+    R<Set<Integer>> getShopIdByName(@RequestParam String shopName){
+        List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>()
+                .like(Shop::getName, shopName));
+        return R.ok(list.stream().map(Shop::getId).collect(Collectors.toSet()));
+    }
+
 }
 
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java
index 3edfa0c..7e7a80e 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java
@@ -6,7 +6,8 @@
 public enum TechnicianStatus {
     UNSUBSCRIBE(0, "待服务"),
     SERVE(1, "已服务"),
-    CANCEL(2, "已取消");
+    CANCEL(2, "已取消"),
+    EXPIRED(3, "已到期");
     private final Integer code;
     private final String message;
 
diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml
index 3e51380..5398449 100644
--- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml
+++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml
@@ -16,7 +16,7 @@
             t_shop ts
                 LEFT JOIN t_goods_shop tgs ON ts.id = tgs.shop_id
                 LEFT JOIN t_goods tg ON tg.id = tgs.goods_id
-        where ts.id = #{shopId}
+        where ts.id = #{shopId} and ts.del_flag = 0
         <if test="vip != null">
             and FIND_IN_SET(#{vip}, commodity_authority) > 0
         </if>
@@ -35,7 +35,8 @@
             t_goods tg
                 LEFT JOIN t_goods_category tgc ON tg.goods_category_id = tgc.id
         <where>
-            <if test="">
+                tg.del_flag = 0
+            <if test="goods.id != null">
                 <if test="goods.id != null">
                     and tg.id = #{goods.id}
                 </if>
diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml
index 0703c40..9420ce5 100644
--- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml
+++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml
@@ -16,7 +16,7 @@
             t_seckill_activity_info tsai
                 LEFT JOIN t_goods tg ON tsai.good_id = tg.id
                 LEFT JOIN t_goods_seckill tgs ON tgs.seckill_activity_info_id = tsai.id
-        WHERE tsai.end_time >= NOW()
+        WHERE tsai.end_time >= NOW() AND tsai.del_flag = 0
         <if test="name != null and name != ''">
             AND tg.`name` LIKE concat('%',#{goodsName},'%')
         </if>
@@ -44,6 +44,6 @@
             t_seckill_activity_info tsai
                 LEFT JOIN t_goods tg ON tsai.good_id = tg.id
                 LEFT JOIN t_goods_seckill tgs ON tgs.seckill_activity_info_id = tsai.id
-        WHERE tsai.id = #{seckillActivityId}
+        WHERE tsai.id = #{seckillActivityId} AND tsai.del_flag = 0
     </select>
 </mapper>
\ No newline at end of file
diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml
index da21049..3b93eeb 100644
--- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml
+++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml
@@ -66,6 +66,7 @@
             `qijisheng_other`.t_shop ts
                 LEFT JOIN `qijisheng_account`.t_app_user tau ON ts.app_user_id = tau.id
         <where>
+            ts.del_flag = 0
             <if test="shop.name != null and shop.name != ''">
                 and ts.name like concat('%',#{shop.name},'%')
             </if>

--
Gitblit v1.7.1