From d20d9e3279e2929de6741eb0e997fb305469a566 Mon Sep 17 00:00:00 2001
From: rentaiming <806181062@qq.com>
Date: 星期五, 07 六月 2024 11:19:50 +0800
Subject: [PATCH] 用户端商品

---
 ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/controller/forepart/vo/ArticleVO.java |    3 +
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/MemberClient.java       |    4 +
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/PaylogServiceImpl.java       |   14 ++++
 ruoyi-modules/ruoyi-auction/src/main/resources/mapper/auction/AuctionSalesroomGoodsMapper.xml     |    4 
 ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/service/impl/ArticleServiceImpl.java  |   13 ++++
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/inner/MemberController.java  |    6 +
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/updMembeOneDTO.java      |   27 +++++++++
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/MemberFallbackFactory.java  |    6 ++
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/IMemberService.java             |    8 +-
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/MemberServiceImpl.java     |   64 ++++++++++++++++++++-
 10 files changed, 136 insertions(+), 13 deletions(-)

diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/updMembeOneDTO.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/updMembeOneDTO.java
new file mode 100644
index 0000000..770a770
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/updMembeOneDTO.java
@@ -0,0 +1,27 @@
+package com.ruoyi.system.api.domain.dto;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class updMembeOneDTO {
+
+
+    @ApiModelProperty(value = "会员id")
+    private Long memberId;
+
+    @ApiModelProperty(value = "1 增加,2 减少")
+    private Integer type;
+
+    @ApiModelProperty(value = "会员积分")
+    private Integer totalPoints;
+
+    @ApiModelProperty(value = "用户消费金额")
+    private BigDecimal money;
+
+
+
+}
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/MemberFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/MemberFallbackFactory.java
index fa75e4a..0bd58bc 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/MemberFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/MemberFallbackFactory.java
@@ -7,6 +7,7 @@
 import com.ruoyi.system.api.domain.dto.AppMiniLoginDTO;
 import com.ruoyi.system.api.domain.dto.AppMiniRegisterDTO;
 import com.ruoyi.system.api.domain.dto.MemberPointsDTO;
+import com.ruoyi.system.api.domain.dto.updMembeOneDTO;
 import com.ruoyi.system.api.feignClient.MemberClient;
 import java.util.List;
 import java.util.Set;
@@ -48,6 +49,11 @@
             public R<?> addMemberPoints(MemberPointsDTO memberPointsDTO) {
                 return R.fail("添加用户积分失败:" + cause.getMessage());
             }
+
+            @Override
+            public R<?> updMembeOne(updMembeOneDTO dMembeOneDTO) {
+                return R.fail("修改用户等级失败:" + cause.getMessage());
+            }
         };
 
         }
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/MemberClient.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/MemberClient.java
index 9c75dfb..6b78e9b 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/MemberClient.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/MemberClient.java
@@ -9,6 +9,7 @@
 import com.ruoyi.system.api.domain.dto.AppMiniLoginDTO;
 import com.ruoyi.system.api.domain.dto.AppMiniRegisterDTO;
 import com.ruoyi.system.api.domain.dto.MemberPointsDTO;
+import com.ruoyi.system.api.domain.dto.updMembeOneDTO;
 import com.ruoyi.system.api.factory.MemberFallbackFactory;
 import java.util.List;
 import java.util.Set;
@@ -41,4 +42,7 @@
     @PostMapping("/member-points/addMemberPoints")
     R<?> addMemberPoints(@RequestBody MemberPointsDTO memberPointsDTO);
 
+    @PostMapping("/member/updMembeOne")
+    R<?> updMembeOne(@RequestBody updMembeOneDTO dMembeOneDTO);
+
 }
diff --git a/ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/controller/forepart/vo/ArticleVO.java b/ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/controller/forepart/vo/ArticleVO.java
index 3fe66b0..723e56f 100644
--- a/ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/controller/forepart/vo/ArticleVO.java
+++ b/ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/controller/forepart/vo/ArticleVO.java
@@ -59,4 +59,7 @@
 
     @ApiModelProperty(value = "会员名称")
     private String memberNickname;
+
+    @ApiModelProperty(value = "头像")
+    private String memberAvatar;
 }
diff --git a/ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/service/impl/ArticleServiceImpl.java b/ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/service/impl/ArticleServiceImpl.java
index 0c82005..6f75caa 100644
--- a/ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/service/impl/ArticleServiceImpl.java
+++ b/ruoyi-modules/ruoyi-article/src/main/java/com/ruoyi/article/service/impl/ArticleServiceImpl.java
@@ -64,7 +64,9 @@
         if (articleDTO.getArticleType()!=0){
             wrapper.eq(Article::getArticleType,articleDTO.getArticleType());
         }
-        wrapper.like(Article::getTitle,articleDTO.getTitle());
+        if (articleDTO.getTitle()!=null){
+            wrapper.like(Article::getTitle,articleDTO.getTitle());
+        }
         wrapper.eq(Article::getStatus,2);
         wrapper.eq( Article::getDelFlag,0);
         wrapper.orderByDesc(Article::getCreateTime);
@@ -78,6 +80,7 @@
                         SecurityConstants.INNER);
                 Member data = membeOne.getData();
                 articleVO.setMemberNickname(data.getNickname());
+                articleVO.setMemberAvatar(data.getAvatar());
             }
             LambdaQueryWrapper<MemberLike> wrapper1 = Wrappers.lambdaQuery();
             wrapper1.eq(MemberLike::getMemberId, articleDTO.getMemberId());
@@ -110,6 +113,7 @@
         Page<Article> page = new Page<>(articleDTO.getPageCurr(), articleDTO.getPageSize());
         LambdaQueryWrapper< Article> wrapper= Wrappers.lambdaQuery();
         wrapper.eq(Article::getMemberId,articleDTO.getMemberId());
+        wrapper.eq(Article::getArticleType,2);
         wrapper.eq( Article::getDelFlag,0);
         wrapper.orderByDesc(Article::getCreateTime);
         Page<Article> page1 = this.page(page, wrapper);
@@ -142,8 +146,15 @@
     public ArticleVO getMemberArticleInfo(ArticleDTO articleDTO) {
         Article article=this.getById(articleDTO.getId());
         ArticleVO articleVO=new ArticleVO();
+
         BeanUtils.copyProperties(article, articleVO);
 
+        R<Member> membeOne = memberClient.getMembeOne(articleVO.getMemberId(),
+                SecurityConstants.INNER);
+        Member data = membeOne.getData();
+        articleVO.setMemberNickname(data.getNickname());
+        articleVO.setMemberAvatar(data.getAvatar());
+
         LambdaQueryWrapper<MemberLike> wrapper1= Wrappers.lambdaQuery();
         wrapper1.eq(MemberLike::getMemberId,articleDTO.getMemberId());
         wrapper1.eq(MemberLike::getArticleId,article.getId());
diff --git a/ruoyi-modules/ruoyi-auction/src/main/resources/mapper/auction/AuctionSalesroomGoodsMapper.xml b/ruoyi-modules/ruoyi-auction/src/main/resources/mapper/auction/AuctionSalesroomGoodsMapper.xml
index 6f9093d..b525c61 100644
--- a/ruoyi-modules/ruoyi-auction/src/main/resources/mapper/auction/AuctionSalesroomGoodsMapper.xml
+++ b/ruoyi-modules/ruoyi-auction/src/main/resources/mapper/auction/AuctionSalesroomGoodsMapper.xml
@@ -13,12 +13,12 @@
       #{item.id}
     </foreach>
   </update>
-  <select id="pageMemberAuctionSalesroomList"
+  <select id="getAuctionSalesroomGoods"
     resultType="com.ruoyi.auction.domain.AuctionSalesroomGoods">
         SELECT * FROM t_auction_salesroom_goods ta
         WHERE ta.del_flag = 0
         <if test="param.auctionSalesroomId!=null and param.auctionSalesroomId != ''">
-            AND ta.auction_salesroom_id = #{and param.auctionSalesroomId}
+            AND ta.auction_salesroom_id = #{param.auctionSalesroomId}
         </if>
         ORDER BY
         CASE
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/inner/MemberController.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/inner/MemberController.java
index f84442c..0ea2219 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/inner/MemberController.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/inner/MemberController.java
@@ -7,6 +7,7 @@
 import java.util.List;
 import java.util.Set;
 
+import com.ruoyi.system.api.domain.dto.updMembeOneDTO;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.*;
@@ -37,8 +38,9 @@
 
     @PostMapping("/updMembeOne")
     @InnerAuth
-    public R updMembeOne(@RequestBody Long userId) {
-        return R.ok(memberService.getById(userId));
+    public R updMembeOne(@RequestBody updMembeOneDTO dMembeOneDTO) {
+        memberService.updMembeOne(dMembeOneDTO);
+        return R.ok();
     }
 
 }
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/IMemberService.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/IMemberService.java
index a3074a7..a7a0279 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/IMemberService.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/IMemberService.java
@@ -6,13 +6,11 @@
 import com.ruoyi.member.controller.management.vo.MgtMemberVO;
 import com.ruoyi.system.api.domain.AppMiniLoginVO;
 import com.ruoyi.system.api.domain.Member;
-import com.ruoyi.system.api.domain.dto.AppMiniLoginDTO;
-import com.ruoyi.system.api.domain.dto.AppMiniRegisterDTO;
-import com.ruoyi.system.api.domain.dto.MemberDTO;
+import com.ruoyi.system.api.domain.dto.*;
+
 import java.util.List;
 import java.util.Set;
 
-import com.ruoyi.system.api.domain.dto.MobileDTO;
 import org.springframework.web.bind.annotation.RequestBody;
 
 /**
@@ -45,4 +43,6 @@
      * @return PageDTO<MgtMemberVO>
      */
     PageDTO<MgtMemberVO> getMemberPage(MgtMemberQuery query);
+
+    void updMembeOne(@RequestBody updMembeOneDTO dMembeOneDTO);
 }
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/MemberServiceImpl.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/MemberServiceImpl.java
index 65ee508..8a1c8ec 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/MemberServiceImpl.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/MemberServiceImpl.java
@@ -27,7 +27,9 @@
 import com.ruoyi.common.security.utils.SecurityUtils;
 import com.ruoyi.member.controller.management.dto.MgtMemberQuery;
 import com.ruoyi.member.controller.management.vo.MgtMemberVO;
+import com.ruoyi.member.domain.MemberLevel;
 import com.ruoyi.member.mapper.MemberMapper;
+import com.ruoyi.member.service.IMemberLevelService;
 import com.ruoyi.member.service.IMemberService;
 import com.ruoyi.member.util.HttpUtils;
 import com.ruoyi.system.api.RemoteUserService;
@@ -35,11 +37,11 @@
 import com.ruoyi.system.api.domain.AppMiniLoginVO;
 import com.ruoyi.system.api.domain.Member;
 import com.ruoyi.system.api.domain.SysUser;
-import com.ruoyi.system.api.domain.dto.AppMiniLoginDTO;
-import com.ruoyi.system.api.domain.dto.AppMiniRegisterDTO;
-import com.ruoyi.system.api.domain.dto.MemberDTO;
+import com.ruoyi.system.api.domain.dto.*;
+
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.List;
@@ -48,7 +50,6 @@
 import java.util.concurrent.TimeUnit;
 import javax.annotation.Resource;
 
-import com.ruoyi.system.api.domain.dto.MobileDTO;
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
@@ -123,6 +124,9 @@
 
     @Resource
     private RedisService redisService;
+
+    @Resource
+    private IMemberLevelService iMemberLevelService;
 
 
     @Override
@@ -489,7 +493,59 @@
         }
         return PageDTO.of(page, MgtMemberVO.class);
     }
+
+    @Override
+    public void updMembeOne(updMembeOneDTO dMembeOneDTO) {
+        Member byId = this.getById(dMembeOneDTO.getMemberId());
+        if (dMembeOneDTO.getMoney()!=null){
+            if (dMembeOneDTO.getType()==1){
+                BigDecimal big=byId.getMoney().add(dMembeOneDTO.getMoney());
+                byId.setMoney(big);
+            }else {
+                BigDecimal big=byId.getMoney().subtract(dMembeOneDTO.getMoney());
+                byId.setMoney(big);
+            }
+        }  if (dMembeOneDTO.getTotalPoints()!=null){
+            if (dMembeOneDTO.getType()==1){
+                Integer big=byId.getTotalPoints()+dMembeOneDTO.getTotalPoints();
+                byId.setTotalPoints(big);
+            }else {
+                Integer big=byId.getTotalPoints()-dMembeOneDTO.getTotalPoints();
+                byId.setTotalPoints(big);
+            }
+        }
+        this.updateById(byId);
+
+        List<MemberLevel> list = iMemberLevelService.list();
+        for (int i=0;i<list.size();i++){
+            if (i==0){
+                int ia = byId.getMoney().compareTo(list.get(0).getCumulativeConsumption());
+                if (ia<0){
+                    byId.setLevel(0);
+                    break;
+                }
+            }
+            if (i==list.size()-1){
+                BigDecimal cumulative = list.get(i - 1).getCumulativeConsumption();
+                BigDecimal cumulative1 = list.get(i).getCumulativeConsumption();
+                if (cumulative.compareTo(byId.getMoney()) <= 0 && cumulative1.compareTo(byId.getMoney()) >= 0) {
+                    byId.setLevel(list.get(i).getLevel());
+                }else{
+                    byId.setLevel(list.get(i).getLevel());
+                }
+            }else {
+                BigDecimal cumulative = list.get(i - 1).getCumulativeConsumption();
+                BigDecimal cumulative1 = list.get(i).getCumulativeConsumption();
+                if (cumulative.compareTo(byId.getMoney()) <= 0 && cumulative1.compareTo(byId.getMoney()) >= 0) {
+                    byId.setLevel(list.get(i).getLevel());
+                }
+            }
+
+        }
+
+    }
 }
 
 
 
+
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/PaylogServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/PaylogServiceImpl.java
index 4c496f4..1cea2f1 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/PaylogServiceImpl.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/PaylogServiceImpl.java
@@ -33,6 +33,7 @@
 import com.ruoyi.system.api.domain.dto.BondDTO;
 import com.ruoyi.system.api.domain.dto.MemberPointsDTO;
 import com.ruoyi.system.api.domain.dto.RefundDTO;
+import com.ruoyi.system.api.domain.dto.updMembeOneDTO;
 import com.ruoyi.system.api.feignClient.AuctionClient;
 import com.ruoyi.system.api.feignClient.MemberClient;
 import com.ruoyi.system.api.feignClient.OrderClient;
@@ -162,6 +163,13 @@
                            memberPointsDTO.setPointsStatus(PointStatusEnum.INCREASE);
                            memberPointsDTO.setPoints(page1.getPoints());
                            memberClient.addMemberPoints(memberPointsDTO);
+                          updMembeOneDTO MembeOneDTO=new updMembeOneDTO();
+                        MembeOneDTO.setType(1);
+                        MembeOneDTO.setMemberId(page1.getMemberId());
+                        MembeOneDTO.setMoney(page1.getTotalAmount());
+                        MembeOneDTO.setTotalPoints(page1.getPoints());
+                        memberClient.updMembeOne(MembeOneDTO);
+
 
                     }
 
@@ -270,6 +278,12 @@
                         memberPointsDTO.setPoints(page1.getPoints());
                         memberClient.addMemberPoints(memberPointsDTO);
 
+                        updMembeOneDTO MembeOneDTO=new updMembeOneDTO();
+                        MembeOneDTO.setType(1);
+                        MembeOneDTO.setMemberId(page1.getMemberId());
+                        MembeOneDTO.setMoney(page1.getTotalAmount());
+                        MembeOneDTO.setTotalPoints(page1.getPoints());
+                        memberClient.updMembeOne(MembeOneDTO);
 
                         log.debug("WxpayController.notify__回调处理成功:SUCCESS");
                         response.getOutputStream().print("success");

--
Gitblit v1.7.1