From 9281fbf6f5ed3f86aad99518c583a6f09d7054c0 Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期三, 21 二月 2024 16:36:13 +0800
Subject: [PATCH] Merge branch 'master-fwq-金额规则配置' into chenjiahe-爆款活动

---
 phi_platform_user/src/main/java/com/hx/phip/controller/user/UserMoneyUnclaimedController.java |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/phi_platform_user/src/main/java/com/hx/phip/controller/user/UserMoneyUnclaimedController.java b/phi_platform_user/src/main/java/com/hx/phip/controller/user/UserMoneyUnclaimedController.java
index ba7db66..c83e41b 100644
--- a/phi_platform_user/src/main/java/com/hx/phip/controller/user/UserMoneyUnclaimedController.java
+++ b/phi_platform_user/src/main/java/com/hx/phip/controller/user/UserMoneyUnclaimedController.java
@@ -1,14 +1,17 @@
 package com.hx.phip.controller.user;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.hx.common.BaseController;
 import com.hx.exception.TipsException;
 import com.hx.mybatisTool.SqlSentence;
 import com.hx.phiappt.common.PlatformConstants;
+import com.hx.phiappt.constants.enums.SysFunctionLimitEnum;
 import com.hx.phiappt.constants.tool.employee.EmployeeTool;
 import com.hx.phiappt.constants.tool.money.UserMoneyTool;
 import com.hx.phiappt.dao.mapper.UserMoneyUnclaimedMapper;
+import com.hx.phiappt.dto.money.MoneyRuleValueDto;
 import com.hx.phiappt.model.BaseEntity;
 import com.hx.phiappt.model.User;
 import com.hx.phiappt.model.UserIntegralRecord;
@@ -262,6 +265,16 @@
                             }
                         }
                     }
+
+                    //鏌ヨ涓嶅彲浣跨敤鍘熷洜
+                    userMoneyUnclaimedInfo.setIsShowNotUse(0);
+                    if (userMoneyUnclaimed.getIsSelectNotUse() != null && userMoneyUnclaimed.getIsSelectNotUse().equals(BaseEntity.YES)){
+                        String canUseReason = getCanUseReason(userMoneyUnclaimedInfo);
+                        if (StringUtils.noNull(canUseReason)){
+                            userMoneyUnclaimedInfo.setIsShowNotUse(1);
+                            userMoneyUnclaimedInfo.setNotUseReason(canUseReason);
+                        }
+                    }
                 }
             }
         }
@@ -289,6 +302,49 @@
         return PlatformResult.success(data);
     }
 
+    /**鑾峰彇涓嶅彲棰嗗彇鍘熷洜*/
+    private String getCanUseReason(UserMoneyUnclaimed userMoneyUnclaimed) {
+        if (userMoneyUnclaimed.getIsReceiveLimit() != null && userMoneyUnclaimed.getIsReceiveLimit().equals(BaseEntity.YES)){
+            // 鍏蜂綋闄愬埗绫诲瀷
+            if (userMoneyUnclaimed.getReceiveLimitType() != null){
+                List<MoneyRuleValueDto> limitList = JSONArray.parseArray(userMoneyUnclaimed.getReceiveLimitData(), MoneyRuleValueDto.class);
+                if (limitList != null && limitList.size() > 0){
+                    //鍒ゆ柇鏍¢獙閫昏緫
+                    if (userMoneyUnclaimed.getReceiveLimitType().equals(BaseEntity.YES)){
+                        boolean isPass = false;
+                        StringBuilder msg = new StringBuilder();
+                        //婊¤冻鍏朵竴
+                        for (MoneyRuleValueDto moneyRuleValueDto : limitList) {
+                            //婊¤冻涓�涓垯璁句负閫氳繃,閫�鍑哄惊鐜�
+                            if (SysFunctionLimitEnum.checkPassByCode(moneyRuleValueDto.getFunctionCode()
+                                    ,userMoneyUnclaimed.getUserId(),userMoneyUnclaimed.getOrderId())){
+                                if (msg.length() > 0){
+                                    msg.append(",");
+                                }
+                                msg.append(SysFunctionLimitEnum.getNameByCode(moneyRuleValueDto.getFunctionCode()));
+                                isPass = true;
+                                break;
+                            }
+                        }
+                        if (!isPass){
+                            return "鏈揪鎴愬叾涓竴涓潯浠讹細" + msg;
+                        }
+                    } else if (userMoneyUnclaimed.getReceiveLimitType().equals(BaseEntity.NO)){
+                        //閮借婊¤冻
+                        for (MoneyRuleValueDto moneyRuleValueDto : limitList) {
+                            //瀛樺湪涓�涓笉婊¤冻鍒欓��鍑哄惊鐜�
+                            if (!SysFunctionLimitEnum.checkPassByCode(moneyRuleValueDto.getFunctionCode()
+                                    ,userMoneyUnclaimed.getUserId(),userMoneyUnclaimed.getOrderId())){
+                                return "鏈揪鎴愭潯浠讹細"+SysFunctionLimitEnum.getNameByCode(moneyRuleValueDto.getFunctionCode());
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
     /**
      * 棰嗗彇鐢ㄦ埛璧勪骇
      * @param request 璇锋眰

--
Gitblit v1.8.0