From ee83ebbb7ec065ccf9ed1935f9c0d725d24715c7 Mon Sep 17 00:00:00 2001
From: phpcjl <phpcjl@gmail.com>
Date: 星期五, 13 十二月 2024 10:27:56 +0800
Subject: [PATCH] 1.后台管理-评论 2.后台管理-门店特殊价

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java      |    4 
 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipSettingClient.java            |    6 +
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java             |   85 ++++++++++++++++-----
 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/CouponInfoMapper.xml                           |   49 ++++++++++++
 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipSettingClientFallbackFactory.java |    7 +
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/CouponInfoServiceImpl.java          |    5 +
 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/CouponInfo.java                       |    4 +
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java      |   36 ++++-----
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java                  |   13 +++
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/CouponInfoMapper.java                     |    3 
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/CouponInfoService.java                   |    3 
 11 files changed, 172 insertions(+), 43 deletions(-)

diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/CouponInfo.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/CouponInfo.java
index 51b4517..f4eb5d1 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/CouponInfo.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/CouponInfo.java
@@ -115,5 +115,9 @@
     @TableField("person_ids")
     private String personIds;
 
+    @ApiModelProperty(value = "上架状态:0-下架 1-上架")
+    @TableField("shelf_status")
+    private Integer shelfStatus;
+
 
 }
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipSettingClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipSettingClientFallbackFactory.java
index 7c6872b..e7caad0 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipSettingClientFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipSettingClientFallbackFactory.java
@@ -5,6 +5,8 @@
 import com.ruoyi.other.api.feignClient.VipSettingClient;
 import org.springframework.cloud.openfeign.FallbackFactory;
 
+import java.util.List;
+
 /**
  * @author zhibing.pu
  * @Date 2024/12/10 13:53
@@ -18,6 +20,11 @@
 			public R<VipSetting> getVipSetting(Integer id) {
 				return R.fail("查询会员配置失败:" + cause.getMessage());
 			}
+
+			@Override
+			public R<List<VipSetting>> info() {
+				return R.fail("获取会员配置失败:" + cause.getMessage());
+			}
 		};
 	}
 }
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipSettingClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipSettingClient.java
index aafc0ff..8d66600 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipSettingClient.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipSettingClient.java
@@ -5,8 +5,11 @@
 import com.ruoyi.other.api.domain.VipSetting;
 import com.ruoyi.other.api.factory.VipSettingClientFallbackFactory;
 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.RequestParam;
+
+import java.util.List;
 
 /**
  * @author zhibing.pu
@@ -23,4 +26,7 @@
 	 */
 	@PostMapping("/vip-setting/getVipSetting")
 	R<VipSetting> getVipSetting(@RequestParam("id") Integer id);
+
+	@GetMapping("/vip-setting/info")
+	R<List<VipSetting>> info();
 }
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java
index 1dc9de0..25ff193 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java
@@ -1,9 +1,13 @@
 package com.ruoyi.other.controller;
 
 
+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.ruoyi.account.api.feignClient.AppUserClient;
 import com.ruoyi.account.api.model.AppUser;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.security.service.TokenService;
 import com.ruoyi.other.api.domain.CouponInfo;
 import com.ruoyi.other.service.CouponInfoService;
@@ -22,7 +26,7 @@
 
 /**
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  *
  * @author luodangjia
@@ -37,18 +41,59 @@
     private TokenService tokenService;
     @Resource
     private AppUserClient appUserClient;
+
+    @PostMapping("/list")
+    @ApiOperation(value = "优惠劵管理-列表", tags = {"管理后台-活动管理"})
+    public R<IPage<CouponInfo>> list(@RequestParam("pageNum") Integer pageNum,
+                                     @RequestParam("pageSize") Integer pageSize,
+                                     CouponInfo couponInfo) {
+        return R.ok(couponInfoService.queryCouponInfoPage(Page.of(pageNum, pageSize), couponInfo));
+    }
+
+
     //查看详情
     @PostMapping("/detail")
-    @ApiOperation(value = "活动管理-优惠劵管理-详情", tags = {"管理后台"})
-    public R<CouponInfo> detail(@RequestParam("id") Integer id){
+    @ApiOperation(value = "优惠劵管理-详情", tags = {"管理后台-活动管理"})
+    public R<CouponInfo> detail(@RequestParam("id") Integer id) {
         CouponInfo byId = couponInfoService.getById(id);
         return R.ok(byId);
     }
 
+    // 删除优惠劵
+    @PostMapping("/delete")
+    @ApiOperation(value = "优惠劵管理-删除", tags = {"管理后台-活动管理"})
+    public R<Void> delete(@RequestParam("id") Integer id) {
+        couponInfoService.removeById(id);
+        return R.ok();
+    }
+
+    // 编辑优惠劵
+    @PostMapping("/edit")
+    @ApiOperation(value = "优惠劵管理-编辑", tags = {"管理后台-活动管理"})
+    public R<Void> edit(@RequestBody CouponInfo couponInfo) {
+        couponInfoService.updateById(couponInfo);
+        return R.ok();
+    }
+
+    // 修改上/下架状态
+    @PostMapping("/editStatus")
+    @ApiOperation(value = "优惠劵管理-修改上/下架状态", tags = {"管理后台-活动管理"})
+    public R<Void> editStatus(@RequestParam("id") Integer id,
+                               @RequestParam("shelfStatus") Integer shelfStatus) {
+        CouponInfo couponInfo = new CouponInfo();
+        couponInfo.setId(id);
+        couponInfo.setShelfStatus(shelfStatus);
+        couponInfoService.updateById(couponInfo);
+        return R.ok();
+    }
+
+
+
+
 
     @GetMapping("/gift/list")
     @ApiOperation(value = "待领取列表", tags = {"小程序-个人中心-优惠劵"})
-    public R<List<CouponInfo>> giftlist(){
+    public R<List<CouponInfo>> giftlist() {
         Long userid = tokenService.getLoginUserApplet().getUserid();
         AppUser appUserById = appUserClient.getAppUserById(userid);
         LocalDateTime now = LocalDateTime.now();
@@ -58,7 +103,7 @@
         List<CouponInfo> list1 = couponInfoService.lambdaQuery().le(CouponInfo::getSendStartTime, now).ge(CouponInfo::getSendEndTime, now).eq(CouponInfo::getPersonType, 2).apply("FIND_IN_SET('" + appUserById.getId() + "', person_ids)").list();
         //查出指定会员可领取优惠劵
         List<CouponInfo> list2 = couponInfoService.lambdaQuery().le(CouponInfo::getSendStartTime, now).ge(CouponInfo::getSendEndTime, now).eq(CouponInfo::getPersonType, 3).apply("FIND_IN_SET('" + appUserById.getVipId() + "', person_ids)").list();
-        List<CouponInfo> returnList=  new ArrayList<>();
+        List<CouponInfo> returnList = new ArrayList<>();
         count(userid, list, returnList);
         count(userid, list1, returnList);
         count(userid, list2, returnList);
@@ -70,26 +115,26 @@
     private void count(Long userid, List<CouponInfo> list1, List<CouponInfo> returnList) {
         for (CouponInfo couponInfo : list1) {
             Long count = appUserClient.getCouponCount(userid, couponInfo.getId()).getData();
-            couponInfo.setMaxNum(couponInfo.getMaxNum()-count.intValue());
+            couponInfo.setMaxNum(couponInfo.getMaxNum() - count.intValue());
             for (int i = 0; i < couponInfo.getMaxNum(); i++) {
                 returnList.add(couponInfo);
             }
         }
     }
 
-	
-	
-	/**
-	 * 根据id获取优惠券数据
-	 * @param ids
-	 * @return
-	 */
-	@ResponseBody
-	@PostMapping("/getCouponInfoList")
-	public R<List<CouponInfo>> getCouponInfoList(@RequestParam("ids") List<Integer> ids){
-		List<CouponInfo> couponInfos = couponInfoService.listByIds(ids);
-		return R.ok(couponInfos);
-	}
-	
+
+    /**
+     * 根据id获取优惠券数据
+     *
+     * @param ids
+     * @return
+     */
+    @ResponseBody
+    @PostMapping("/getCouponInfoList")
+    public R<List<CouponInfo>> getCouponInfoList(@RequestParam("ids") List<Integer> ids) {
+        List<CouponInfo> couponInfos = couponInfoService.listByIds(ids);
+        return R.ok(couponInfos);
+    }
+
 }
 
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java
index bce64c6..18c5f56 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java
@@ -64,8 +64,6 @@
     /**
      * 根据商品id和会员等级获取门店特价
      *
-     * @param goodsBargainPrice
-     * @return
      */
     @PostMapping("/getGoodsBargainPrice")
     public R<GoodsBargainPriceDetail> getGoodsBargainPrice(@RequestBody GetGoodsBargainPrice goodsBargainPrice) {
@@ -176,24 +174,22 @@
                 .eq(!CollectionUtils.isEmpty(goodsIds), GoodsBargainPrice::getGoodsId, goodsId)
                 .eq(auditStatus != null, GoodsBargainPrice::getAuditStatus, auditStatus));
 
-        page.getRecords().forEach(goodsBargainPrice -> {
-            goodsList.stream()
-                    .filter(goods -> goods.getId().equals(goodsBargainPrice.getGoodsId()))
-                    .findFirst().ifPresent(g -> {
-                        GoodsCategory goodsCategory = goodsCategoryService.getById(g.getGoodsCategoryId());
-                        Integer shopId = goodsBargainPrice.getShopId();
-                        Shop shop = shopService.getById(shopId);
-                        R<AppUser> r = appUserClient.getAppUserByPhone(shop.getPhone());
-                        if (R.isError(r)){
-                            throw new RuntimeException("获取店长信息失败");
-                        }
-                        goodsBargainPrice.setOwnerName(r.getData().getName());
-                        goodsBargainPrice.setOwnerPhone(shop.getPhone());
-                        goodsBargainPrice.setShopName(shop.getName());
-                        goodsBargainPrice.setGoodsName(g.getName());
-                        goodsBargainPrice.setCategoryName(goodsCategory.getName());
-                    });
-        });
+        page.getRecords().forEach(goodsBargainPrice -> goodsList.stream()
+                .filter(goods -> goods.getId().equals(goodsBargainPrice.getGoodsId()))
+                .findFirst().ifPresent(g -> {
+                    GoodsCategory goodsCategory = goodsCategoryService.getById(g.getGoodsCategoryId());
+                    Integer shopId = goodsBargainPrice.getShopId();
+                    Shop shop = shopService.getById(shopId);
+                    R<AppUser> r = appUserClient.getAppUserByPhone(shop.getPhone());
+                    if (R.isError(r)){
+                        throw new RuntimeException("获取店长信息失败");
+                    }
+                    goodsBargainPrice.setOwnerName(r.getData().getName());
+                    goodsBargainPrice.setOwnerPhone(shop.getPhone());
+                    goodsBargainPrice.setShopName(shop.getName());
+                    goodsBargainPrice.setGoodsName(g.getName());
+                    goodsBargainPrice.setCategoryName(goodsCategory.getName());
+                }));
 
         return R.ok(page);
     }
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
index f981d59..caf8d66 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
@@ -8,6 +8,8 @@
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.ruoyi.common.core.web.page.TableDataInfo;
 import com.ruoyi.other.api.domain.Goods;
+import com.ruoyi.other.api.domain.VipSetting;
+import com.ruoyi.other.api.feignClient.VipSettingClient;
 import com.ruoyi.other.service.GoodsService;
 import com.ruoyi.other.vo.GoodsVO;
 import io.swagger.annotations.Api;
@@ -32,6 +34,8 @@
 public class GoodsController extends BaseController {
     @Resource
     private GoodsService goodsService;
+    @Resource
+    private VipSettingClient settingClient;
 
     /**
      * 添加商品
@@ -83,6 +87,15 @@
         return R.ok();
     }
 
+    /**
+     * 获取会员等级信息
+     */
+    @GetMapping("/getVipSetting")
+    @ApiOperation(value = "会员等级信息", tags = {"小程序-个人中心-优惠劵"})
+    public R<List<VipSetting>> getVipSetting(){
+        return settingClient.info();
+    }
+
 
 
     /**
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java
index 37ec498..34517d1 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java
@@ -62,7 +62,7 @@
 	 * 删除活动
 	 */
 	@PostMapping("/delete")
-	@ApiOperation(value = "删除活动", tags = {"管理后台-活动管理-订单优惠活动-"})
+	@ApiOperation(value = "删除活动", tags = {"管理后台-活动管理-订单优惠活动"})
 	public R<Void> deleteActivityConfig(@RequestParam("id") Long id){
 		orderActivityInfoService.removeById(id);
 		return R.ok();
@@ -72,7 +72,7 @@
 	 * 修改活动
 	 */
 	@PostMapping("/update")
-	@ApiOperation(value = "修改活动", tags = {"管理后台-活动管理-订单优惠活动-"})
+	@ApiOperation(value = "修改活动", tags = {"管理后台-活动管理-订单优惠活动"})
 	public R<Void> updateActivityConfig(@RequestBody OrderActivityInfo orderActivityInfo){
 		orderActivityInfoService.updateById(orderActivityInfo);
 		return R.ok();
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/CouponInfoMapper.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/CouponInfoMapper.java
index fd17103..90b27a0 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/CouponInfoMapper.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/CouponInfoMapper.java
@@ -1,6 +1,7 @@
 package com.ruoyi.other.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ruoyi.other.api.domain.CouponInfo;
 
 /**
@@ -12,5 +13,5 @@
  * @since 2024-11-20
  */
 public interface CouponInfoMapper extends BaseMapper<CouponInfo> {
-
+    IPage<CouponInfo> queryCouponInfoPage(IPage<CouponInfo> page, CouponInfo couponInfo);
 }
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/CouponInfoService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/CouponInfoService.java
index fdd24a5..5908a82 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/CouponInfoService.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/CouponInfoService.java
@@ -1,5 +1,6 @@
 package com.ruoyi.other.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.other.api.domain.CouponInfo;
 
@@ -13,4 +14,6 @@
  */
 public interface CouponInfoService extends IService<CouponInfo> {
 
+    IPage<CouponInfo> queryCouponInfoPage(IPage<CouponInfo> page, CouponInfo couponInfo);
+
 }
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/CouponInfoServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/CouponInfoServiceImpl.java
index 610aa39..d843b2d 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/CouponInfoServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/CouponInfoServiceImpl.java
@@ -1,5 +1,6 @@
 package com.ruoyi.other.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.other.mapper.CouponInfoMapper;
 import com.ruoyi.other.api.domain.CouponInfo;
@@ -17,4 +18,8 @@
 @Service
 public class CouponInfoServiceImpl extends ServiceImpl<CouponInfoMapper, CouponInfo> implements CouponInfoService {
 
+    @Override
+    public IPage<CouponInfo> queryCouponInfoPage(IPage<CouponInfo> page, CouponInfo couponInfo) {
+        return this.baseMapper.queryCouponInfoPage(page, couponInfo);
+    }
 }
diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/CouponInfoMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/CouponInfoMapper.xml
new file mode 100644
index 0000000..4c34d60
--- /dev/null
+++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/CouponInfoMapper.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.other.mapper.CouponInfoMapper">
+
+    <select id="queryCouponInfoPage" resultType="com.ruoyi.other.api.domain.CouponInfo">
+        SELECT
+            tci.id,
+            tci.create_time,
+            tci.coupon_name,
+            tci.coupon_type,
+            tci.condition_amount,
+            tci.discount_amount,
+            tci.money_amount,
+            tci.discount,
+            tci.for_good_ids,
+            tci.send_num,
+            tci.max_num,
+            tci.period_type,
+            tci.period_start_time,
+            tci.period_end_time,
+            tci.period_days,
+            tci.send_start_time,
+            tci.send_end_time,
+            tci.send_type,
+            tci.need_point,
+            tci.person_type,
+            tci.person_ids
+        FROM
+            t_coupon_info tci
+        <where>
+            tci.del_flag = 0
+            <if test="couponInfo.couponName != null and couponInfo.couponName != ''">
+                AND tci.coupon_name LIKE concat('%', #{couponInfo.couponName}, '%')
+            </if>
+            <if test="couponInfo.couponType != null">
+                AND tci.coupon_type = #{couponInfo.couponType}
+            </if>
+            <if test="couponInfo.send_type != null">
+                AND tci.send_type = #{couponInfo.send_type}
+            </if>
+            <if test="couponInfo.personType != null">
+                AND tci.person_type = #{couponInfo.personType}
+            </if>
+            <if test="couponInfo.shelfStatus != null">
+                AND tci.shelf_status = #{couponInfo.shelfStatus}
+            </if>
+        </where>
+    </select>
+</mapper>
\ No newline at end of file

--
Gitblit v1.7.1