瀏覽代碼

增加非空判断

yousongbo 3 周之前
父節點
當前提交
fcc52e6a45

+ 1 - 1
suishenbang-system/src/main/java/com/dgtly/system/service/IAlertConfigurationService.java

@@ -20,7 +20,7 @@ public interface IAlertConfigurationService
      */
     public AlertConfiguration selectAlertConfigurationById(Long alertId);
 
-    public AlertConfiguration selectAlertConfigurationByAlertStatus(String salesLevel,String orgCode);
+    public AlertConfiguration selectAlertConfigurationByAlertStatus(String orgCode);
 
     /**
      * 查询弹框配置列表

+ 1 - 1
suishenbang-system/src/main/java/com/dgtly/system/service/impl/AlertConfigurationServiceImpl.java

@@ -37,7 +37,7 @@ public class AlertConfigurationServiceImpl implements IAlertConfigurationService
     }
 
     @Override
-    public AlertConfiguration selectAlertConfigurationByAlertStatus(String salesLevel,String orgCode) {
+    public AlertConfiguration selectAlertConfigurationByAlertStatus(String orgCode) {
         //查询有效弹窗
         List<AlertConfiguration> alertConfigurationList = alertConfigurationMapper.selectAlertConfigurationByAlertStatus();
         if(alertConfigurationList !=null && alertConfigurationList.size()> 0 ){

+ 30 - 37
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/WxAlertLogController.java

@@ -52,26 +52,18 @@ public class WxAlertLogController  extends ApiBaseController {
     })
     @PostMapping("/getAlert")
     public Object getAlertLog() throws ParseException {
-//        String userType="";
         ParameterObject obj = getParameterObject();
         Long userId = Long.valueOf(obj.getString("userId"));
+        Set<String> userTypeSet = new HashSet<>();
         SysUserExt sysUserExt = sysUserExtService.selectSysUserExtById(userId);
-        String salesLevel = sysUserExt.getSalesLevel();
-        List<String> userTypeList = new ArrayList<>();
         List<SysUserShopExt>  sysUserShopExt = sysUserShopExtService.selectSysUserShopExtById(obj.getString("userId"));
-        Set<String> userTypeSet = new HashSet<>();
-        for (SysUserShopExt shopExt : sysUserShopExt){
-            userTypeSet.add(shopExt.getIsShopType());
-        }
-
-        if(("customer_level").equals(salesLevel)||("reseller_level").equals(salesLevel) ){
-            userTypeList.add("1");
-        }else{
-            userTypeList.add("0");
+        if (sysUserShopExt != null && sysUserShopExt.size() > 0){
+            for (SysUserShopExt shopExt : sysUserShopExt){
+                userTypeSet.add(shopExt.getIsShopType());
+            }
         }
-
         //是否有启动弹窗
-        AlertConfiguration alertConfiguration1 = alertConfigurationService.selectAlertConfigurationByAlertStatus(sysUserExt.getSalesLevel(),sysUserExt.getOrgCode());
+        AlertConfiguration alertConfiguration1 = alertConfigurationService.selectAlertConfigurationByAlertStatus(sysUserExt.getOrgCode());
 
         if (alertConfiguration1!=null){
             //有启动
@@ -86,36 +78,37 @@ public class WxAlertLogController  extends ApiBaseController {
                 //满足时间
                 String[] split = alertConfiguration1.getUserType().split(",");
                 List<String> strings = Arrays.asList(split);
-                if ((strings.contains("1")  || strings.contains("2")) && sysUserExt.getSalesLevel().equals("customer_level")){
-                    //满足类型对应a
-                    AlertLog alertLog = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),"0");
-                    if (alertLog!=null){
-                        if (alertLog.getAlertNum()<alertConfiguration1.getAlertNum()){
-                            updateAlertLog(alertConfiguration1,alertLog,sdf,"1");
-                            return AjaxResult.success(alertConfiguration1);
+                if (sysUserExt != null){
+                    if ((strings.contains("1")  || strings.contains("2")) && sysUserExt.getSalesLevel().equals("customer_level")){
+                        //满足类型对应a
+                        AlertLog alertLog = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),"0");
+                        if (alertLog!=null){
+                            if (alertLog.getAlertNum()<alertConfiguration1.getAlertNum()){
+                                updateAlertLog(alertConfiguration1,alertLog,sdf,"1");
+                                return AjaxResult.success(alertConfiguration1);
+                            }else {
+                                return AjaxResult.warning("每日弹出次数已满");
+                            }
                         }else {
-                            return AjaxResult.warning("每日弹出次数已满");
+                            intAlertLog(alertConfiguration1,"1",now,sdf,userId,"1");
+                            return AjaxResult.success(alertConfiguration1);
                         }
-                    }else {
-                        intAlertLog(alertConfiguration1,"1",now,sdf,userId,"1");
-                        return AjaxResult.success(alertConfiguration1);
                     }
-                }
-                if((strings.contains("0") || strings.contains("2")) && !sysUserExt.getSalesLevel().equals("customer_level")){
-                    AlertLog alertLog = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),"0");
-                    if (alertLog!=null){
-                        if (alertLog.getAlertNum()<alertConfiguration1.getAlertNum()){
-                            updateAlertLog(alertConfiguration1,alertLog,sdf,"1");
-                            return AjaxResult.success(alertConfiguration1);
+                    if((strings.contains("0") || strings.contains("2")) && !sysUserExt.getSalesLevel().equals("customer_level")){
+                        AlertLog alertLog = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),"0");
+                        if (alertLog!=null){
+                            if (alertLog.getAlertNum()<alertConfiguration1.getAlertNum()){
+                                updateAlertLog(alertConfiguration1,alertLog,sdf,"1");
+                                return AjaxResult.success(alertConfiguration1);
+                            }else {
+                                return AjaxResult.warning("每日弹出次数已满");
+                            }
                         }else {
-                            return AjaxResult.warning("每日弹出次数已满");
+                            intAlertLog(alertConfiguration1,"1",now,sdf,userId,"0");
+                            return AjaxResult.success(alertConfiguration1);
                         }
-                    }else {
-                        intAlertLog(alertConfiguration1,"1",now,sdf,userId,"0");
-                        return AjaxResult.success(alertConfiguration1);
                     }
                 }
-
                 //判断该用户是否为金牌店或仿石漆
                 if (sysUserShopExt != null){
                     if((strings.contains("3") || strings.contains("2")) && userTypeSet.contains("0")){