From 0e0738fea4275eb50c1014dea40ac5cf9f8cf845 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Thu, 13 Apr 2023 12:35:24 +0800
Subject: [PATCH] 后台修改

---
 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java |   67 ++++++++++++++++++++++++++++-----
 1 files changed, 57 insertions(+), 10 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java
index 3717948..9c61814 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java
@@ -199,7 +199,9 @@
 
     public String generateAsaToken(String token) {
         RSA rsa = new RSA(null, AppContants.PUBLIC_KEY);
-        return rsa.encryptBase64(token + "_" + System.currentTimeMillis(), KeyType.PublicKey);
+//        return rsa.encryptBase64(token + "_" + System.currentTimeMillis(), KeyType.PublicKey);
+        //去掉时间戳
+        return rsa.encryptBase64(token, KeyType.PublicKey);
     }
 
     @Override
@@ -265,6 +267,10 @@
             mallMemberVo.setIsAgent(1);
         }else if(ObjectUtil.isNotEmpty(mallAgentRecordAgree)){
             mallMemberVo.setIsAgent(2);
+            if(StrUtil.isNotEmpty(mallAgentRecordAgree.getAgentLevel())){
+                DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode("AGENT_LEVEL_APPLY", mallAgentRecordAgree.getAgentLevel());
+                mallMemberVo.setAgentLevelName(dataDictionaryCustom.getDescription());
+            }
         }else if(ObjectUtil.isNotEmpty(mallAgentRecordDisagree)){
             mallMemberVo.setIsAgent(3);
         }
@@ -616,8 +622,8 @@
                 }
             }
             String token = IdUtil.simpleUUID();
-            redisUtils.set(token, JSONObject.toJSONString(mallMember), 360000);
-            redisUtils.set(redisKey, token, 360000);
+            redisUtils.set(token, JSONObject.toJSONString(mallMember), -1);
+            redisUtils.set(redisKey, token, -1);
             Map<String, Object> authInfo = new HashMap<>();
             authInfo.put("token", token);
             authInfo.put("appid", xcxProperties.getXcxAppid());
@@ -746,11 +752,13 @@
         Integer type = apiRechargeWalletDto.getType();
         if(2 == type){
             //成为合伙人的充值金额
-            DataDictionaryCustom agentPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.PRICE_AMOUNT.getType(),
-                    DataDictionaryEnum.PRICE_AMOUNT.getCode());
-            String agentPrice = agentPriceDic.getValue();
-            BigDecimal price = new BigDecimal(agentPrice);
-            if(price.compareTo(amount) != 0){
+            MallAgentRecord mallAgentRecord = mallAgentRecordMapper.selectById(apiRechargeWalletDto.getAgentApplyId());
+            BigDecimal agentPrice = mallAgentRecord.getAmount();
+//            DataDictionaryCustom agentPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.PRICE_AMOUNT.getType(),
+//                    DataDictionaryEnum.PRICE_AMOUNT.getCode());
+//            String agentPrice = agentPriceDic.getValue();
+//            BigDecimal price = new BigDecimal(agentPrice);
+            if(agentPrice.compareTo(amount) != 0){
                 return new FebsResponse().fail().message("成为合伙人的金额为"+agentPrice);
             }
         }
@@ -780,15 +788,54 @@
     }
 
     @Override
-    public void updateMemberAgent(Long memberId) {
+    public void updateMemberAgent(Long memberId,String levelCode) {
         mallAgentRecordMapper.updateStateByMemberId(memberId);
 
         //更新用户表中的LEVEL
         MallMember mallMember = this.baseMapper.selectById(memberId);
-        mallMember.setLevel(AgentLevelEnum.FIRST_LEVEL.name());
+        mallMember.setLevel(levelCode);
         this.baseMapper.updateById(mallMember);
     }
 
+    @Override
+    public FebsResponse agentDetail() {
+        DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.AGENT_DETAILS.getType(), DataDictionaryEnum.AGENT_DETAILS.getCode());
+        Map<String, Object> map = new HashMap<>();
+        if(ObjectUtil.isNotEmpty(dataDictionaryCustom)){
+            map.put("agentDetail", dataDictionaryCustom.getValue());
+        }
+        return new FebsResponse().success().data(map);
+    }
+
+    @Override
+    public FebsResponse activityInfo() {
+        DataDictionaryCustom activityBulletinDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.ACTIVITY_BULLETIN.getType(), DataDictionaryEnum.ACTIVITY_BULLETIN.getCode());
+        DataDictionaryCustom giveAmountDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.GIVE_AMOUNT.getType(), DataDictionaryEnum.GIVE_AMOUNT.getCode());
+        DataDictionaryCustom giveStateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.GIVE_STATE.getType(), DataDictionaryEnum.GIVE_STATE.getCode());
+        Map<String, Object> map = new HashMap<>();
+        if(ObjectUtil.isNotEmpty(activityBulletinDic)){
+            map.put("activityBulletin",
+                    ObjectUtil.isEmpty(activityBulletinDic.getValue()) ? "暂无活动" : activityBulletinDic.getValue());
+        }
+        if(ObjectUtil.isNotEmpty(giveAmountDic)){
+            map.put("giveAmount",
+                    ObjectUtil.isEmpty(giveAmountDic.getValue()) ? 0 : giveAmountDic.getValue());
+        }
+        map.put("giveState",giveStateDic.getValue());
+        return new FebsResponse().success().data(map);
+    }
+
+    @Override
+    public FebsResponse agentApplyInfo() {
+        Long memberId = LoginUserUtil.getLoginUser().getId();
+        ApiMallAgentRecordVo apiMallAgentRecordVo = mallAgentRecordMapper.selectApiMallAgentRecordVoByMemberIdAndState(memberId,MallAgentRecord.APPLY_ING);
+        return new FebsResponse().success().data(apiMallAgentRecordVo);
+    }
+
     private  String getXcxLoginUrl(String code) {
         String wechatLoginUrl =xcxProperties.getWecharLoginUrl();
         return String.format(wechatLoginUrl, xcxProperties.getXcxAppid(), xcxProperties.getXcxSecret(), code);

--
Gitblit v1.9.1