Ver código fonte

新增仿石漆与金牌店弹框和公告权限

yousongbo 4 semanas atrás
pai
commit
d1f9945d21

+ 10 - 0
suishenbang-admin/src/main/java/com/dgtly/web/controller/system/AlertConfigurationController.java

@@ -4,6 +4,8 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
+import com.dgtly.common.utils.StringUtils;
 import com.dgtly.system.domain.OrderSalesParameter;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -90,6 +92,10 @@ public class AlertConfigurationController extends BaseController
         if ( num==1){
             return error("弹幕通知只能有一个该组织下启动,请先关闭该组织下已启动的后重新添加");
         }*/
+        //如果userType为空,则添加所有人通知
+        if (StringUtils.isEmpty(alertConfiguration.getUserType())){
+            alertConfiguration.setUserType("2");
+        }
         return toAjax(alertConfigurationService.insertAlertConfiguration(alertConfiguration));
     }
 
@@ -112,6 +118,10 @@ public class AlertConfigurationController extends BaseController
     @ResponseBody
     public AjaxResult editSave(AlertConfiguration alertConfiguration)
     {
+        //如果userType为空,则添加所有人通知
+        if (StringUtils.isEmpty(alertConfiguration.getUserType())){
+            alertConfiguration.setUserType("2");
+        }
         if(("0").equals(alertConfiguration.getAlertStatus())){
             return toAjax(alertConfigurationService.updateAlertConfiguration(alertConfiguration));
         }

+ 1 - 1
suishenbang-system/src/main/java/com/dgtly/system/mapper/AlertConfigurationMapper.java

@@ -22,7 +22,7 @@ public interface AlertConfigurationMapper
      */
     public AlertConfiguration selectAlertConfigurationById(Long alertId);
 
-    public List<AlertConfiguration> selectAlertConfigurationByAlertStatus(@Param("userType") String userType);
+    public List<AlertConfiguration> selectAlertConfigurationByAlertStatus( List userTypeList);
 
 
     /**

+ 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 userType,String salesLevel,String orgCode);
+    public AlertConfiguration selectAlertConfigurationByAlertStatus(List<String> userTypeList ,String salesLevel,String orgCode);
 
     /**
      * 查询弹框配置列表

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

@@ -37,8 +37,8 @@ public class AlertConfigurationServiceImpl implements IAlertConfigurationService
     }
 
     @Override
-    public AlertConfiguration selectAlertConfigurationByAlertStatus(String userType,String salesLevel,String orgCode) {
-        List<AlertConfiguration> alertConfigurationList = alertConfigurationMapper.selectAlertConfigurationByAlertStatus(userType);
+    public AlertConfiguration selectAlertConfigurationByAlertStatus(List<String> userTypeList,String salesLevel,String orgCode) {
+        List<AlertConfiguration> alertConfigurationList = alertConfigurationMapper.selectAlertConfigurationByAlertStatus(userTypeList);
         if(alertConfigurationList !=null && alertConfigurationList.size()> 0 ){
             //判断弹框的组织 如果弹框有组织 对比该组织与员工的组织是否一致
             Iterator<AlertConfiguration> it = alertConfigurationList.iterator();

+ 5 - 3
suishenbang-system/src/main/resources/mapper/system/AlertConfigurationMapper.xml

@@ -60,9 +60,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectAlertConfigurationByAlertStatus" parameterType="Long" resultMap="AlertConfigurationResult">
         <include refid="selectAlertConfigurationVo"/>
         WHERE alert_status = 1
-        <if test="userType !=null and userType !=''  ">
-            and ( user_type =#{userType}  or user_type ='2')
-        </if>
+        and ( user_type  in
+        <foreach item="item" index="index" collection="list" separator=",">
+            #{item}
+        </foreach>
+        or user_type ='2')
         AND now() >=alert_start_time
         AND alert_end_time > now()
     </select>

+ 115 - 132
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/WxAlertLogController.java

@@ -18,10 +18,7 @@ import io.swagger.annotations.ApiOperation;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 /**
  * 弹框日志Controller
@@ -45,6 +42,9 @@ public class WxAlertLogController  extends ApiBaseController {
     @Autowired
     private IAlertUpvoteLogService alertUpvoteLogService;
 
+    @Autowired
+    private ISysUserShopExtService sysUserShopExtService;
+
 
     @ApiOperation(value = "微信弹框",notes = "参数:{userId:1}")
     @ApiImplicitParams({
@@ -52,18 +52,20 @@ public class WxAlertLogController  extends ApiBaseController {
     })
     @PostMapping("/getAlert")
     public Object getAlertLog() throws ParseException {
-        String userType="";
+//        String userType="";
         ParameterObject obj = getParameterObject();
         Long userId = Long.valueOf(obj.getString("userId"));
         SysUserExt sysUserExt = sysUserExtService.selectSysUserExtById(userId);
         String salesLevel = sysUserExt.getSalesLevel();
+        List<String> userTypeList = new ArrayList<>();
         if(("customer_level").equals(salesLevel)||("reseller_level").equals(salesLevel) ){
-            userType = "1";
+            userTypeList.add("1");
         }else{
-            userType = "0";
+            userTypeList.add("0");
         }
+
         //是否有启动
-        AlertConfiguration alertConfiguration1 = alertConfigurationService.selectAlertConfigurationByAlertStatus(userType,sysUserExt.getSalesLevel(),sysUserExt.getOrgCode());
+        AlertConfiguration alertConfiguration1 = alertConfigurationService.selectAlertConfigurationByAlertStatus(userTypeList,sysUserExt.getSalesLevel(),sysUserExt.getOrgCode());
 
         if (alertConfiguration1!=null){
             //有启动
@@ -78,155 +80,68 @@ 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")){
+                if ((strings.contains("1")  || strings.contains("2")) && sysUserExt.getSalesLevel().equals("customer_level")){
                     //满足类型对应a
                     AlertLog alertLog = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),"0");
-                    //AlertLog log = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),null);
-                  /*  if(log == null){
-                        alertConfiguration1.setIsClearCache(true);
-                    }*/
                     if (alertLog!=null){
                         if (alertLog.getAlertNum()<alertConfiguration1.getAlertNum()){
-                            Long count =alertLog.getAlertNum()+1;
-                            // 创建两个日期对象
-                            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                            Date date1 = dateFormat.parse(sdf.format(alertLog.getCreateTime()));
-                            Date date2 = dateFormat.parse(sdf.format(alertConfiguration1.getAlertEndTime()));
-                            // 设置时间部分为零点
-                            Calendar calendar = Calendar.getInstance();
-                            calendar.setTime(date1);
-                            calendar.set(Calendar.HOUR_OF_DAY, 0);
-                            calendar.set(Calendar.MINUTE, 0);
-                            calendar.set(Calendar.SECOND, 0);
-                            calendar.set(Calendar.MILLISECOND, 0);
-                            date1 = calendar.getTime();
-                            calendar.setTime(date2);
-                            calendar.set(Calendar.HOUR_OF_DAY, 0);
-                            calendar.set(Calendar.MINUTE, 0);
-                            calendar.set(Calendar.SECOND, 0);
-                            calendar.set(Calendar.MILLISECOND, 0);
-                            date2 = calendar.getTime();
-                            int clearT = date1.compareTo(date2);
-                            if(count == alertConfiguration1.getAlertNum() && clearT==0){
-                                alertConfiguration1.setIsClearCache(true);
-                                alertLog.setIsClearCache("1");
-                            }
-                            alertLog.setAlertNum(count);
-                            alertLogService.updateAlertLog(alertLog);
+                            updateAlertLog(alertConfiguration1,alertLog,sdf,"1");
                             return AjaxResult.success(alertConfiguration1);
                         }else {
                             return AjaxResult.warning("每日弹出次数已满");
                         }
                     }else {
-                        //加数据
-                        AlertLog alertLog1 = new AlertLog();
-                        alertLog1.setAlertId(alertConfiguration1.getAlertId());
-                        alertLog1.setUserId(userId);
-                        alertLog1.setUserType("1");
-                        alertLog1.setAlertNum(1L);
-                        // 创建两个日期对象
-                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                        Date date1 = dateFormat.parse(now);
-                        Date date2 = dateFormat.parse(sdf.format(alertConfiguration1.getAlertEndTime()));
-                        // 设置时间部分为零点
-                        Calendar calendar = Calendar.getInstance();
-                        calendar.setTime(date1);
-                        calendar.set(Calendar.HOUR_OF_DAY, 0);
-                        calendar.set(Calendar.MINUTE, 0);
-                        calendar.set(Calendar.SECOND, 0);
-                        calendar.set(Calendar.MILLISECOND, 0);
-                        date1 = calendar.getTime();
-                        calendar.setTime(date2);
-                        calendar.set(Calendar.HOUR_OF_DAY, 0);
-                        calendar.set(Calendar.MINUTE, 0);
-                        calendar.set(Calendar.SECOND, 0);
-                        calendar.set(Calendar.MILLISECOND, 0);
-                        date2 = calendar.getTime();
-                        int clearT = date1.compareTo(date2);
-                        if(clearT==0 && alertConfiguration1.getAlertNum()==1){
-                            alertConfiguration1.setIsClearCache(true);
-                            alertLog1.setIsClearCache("1");
-                        }
-                        alertLogService.insertAlertLog(alertLog1);
+                        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");
-                  /*  AlertLog log = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),null);
-                    if(log == null){
-                        alertConfiguration1.setIsClearCache(true);
-                    }*/
                     if (alertLog!=null){
                         if (alertLog.getAlertNum()<alertConfiguration1.getAlertNum()){
-                            Long count =alertLog.getAlertNum()+1;
-                            // 创建两个日期对象
-                            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                            Date date1 = dateFormat.parse(sdf.format(alertLog.getCreateTime()));
-                            Date date2 = dateFormat.parse(sdf.format(alertConfiguration1.getAlertEndTime()));
-                            // 设置时间部分为零点
-                            Calendar calendar = Calendar.getInstance();
-                            calendar.setTime(date1);
-                            calendar.set(Calendar.HOUR_OF_DAY, 0);
-                            calendar.set(Calendar.MINUTE, 0);
-                            calendar.set(Calendar.SECOND, 0);
-                            calendar.set(Calendar.MILLISECOND, 0);
-                            date1 = calendar.getTime();
-
-                            calendar.setTime(date2);
-                            calendar.set(Calendar.HOUR_OF_DAY, 0);
-                            calendar.set(Calendar.MINUTE, 0);
-                            calendar.set(Calendar.SECOND, 0);
-                            calendar.set(Calendar.MILLISECOND, 0);
-                            date2 = calendar.getTime();
-                            int clearT = date1.compareTo(date2);
-                            if(count == alertConfiguration1.getAlertNum() && clearT==0){
-                                alertConfiguration1.setIsClearCache(true);
-                                alertLog.setIsClearCache("1");
-                            }
-                            alertLog.setAlertNum(count);
-                            alertLogService.updateAlertLog(alertLog);
+                            updateAlertLog(alertConfiguration1,alertLog,sdf,"1");
                             return AjaxResult.success(alertConfiguration1);
                         }else {
                             return AjaxResult.warning("每日弹出次数已满");
                         }
                     }else {
-                        //加数据
-                        AlertLog alertLog1 = new AlertLog();
-                        alertLog1.setAlertId(alertConfiguration1.getAlertId());
-                        alertLog1.setUserId(userId);
-                        alertLog1.setUserType("0");
-                        alertLog1.setAlertNum(1L);
-                        // 创建两个日期对象
-                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                        Date date1 = dateFormat.parse(now);
-                        Date date2 = dateFormat.parse(sdf.format(alertConfiguration1.getAlertEndTime()));
-                        // 设置时间部分为零点
-                        Calendar calendar = Calendar.getInstance();
-                        calendar.setTime(date1);
-                        calendar.set(Calendar.HOUR_OF_DAY, 0);
-                        calendar.set(Calendar.MINUTE, 0);
-                        calendar.set(Calendar.SECOND, 0);
-                        calendar.set(Calendar.MILLISECOND, 0);
-                        date1 = calendar.getTime();
-                        calendar.setTime(date2);
-                        calendar.set(Calendar.HOUR_OF_DAY, 0);
-                        calendar.set(Calendar.MINUTE, 0);
-                        calendar.set(Calendar.SECOND, 0);
-                        calendar.set(Calendar.MILLISECOND, 0);
-                        date2 = calendar.getTime();
-                        int clearT = date1.compareTo(date2);
-                        if(clearT==0 && alertConfiguration1.getAlertNum()==1){
-                            alertConfiguration1.setIsClearCache(true);
-                            alertLog1.setIsClearCache("1");
-                        }
-                        alertLogService.insertAlertLog(alertLog1);
+                        intAlertLog(alertConfiguration1,"1",now,sdf,userId,"0");
                         return AjaxResult.success(alertConfiguration1);
                     }
                 }
+                SysUserShopExt sysUserShopExt = sysUserShopExtService.selectSysUserShopExtById(obj.getString("userId"));
+                //判断该用户是否为金牌店或仿石漆
+                if (sysUserShopExt != null){
+                    if((strings.contains("3") || strings.contains("2")) && "0".equals(sysUserShopExt.getIsShopType())){
+                        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 {
+                            intAlertLog(alertConfiguration1,"1",now,sdf,userId,"3");
+                            return AjaxResult.success(alertConfiguration1);
+                        }
+                    }
+                    if((strings.contains("4") || strings.contains("2")) && "1".equals(sysUserShopExt.getIsShopType())){
+                        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 {
+                            intAlertLog(alertConfiguration1,"1",now,sdf,userId,"4");
+                            return AjaxResult.success(alertConfiguration1);
+                        }
+                    }
+                }
                 return AjaxResult.warning("没有符合的弹框");
-
             } else {
                 //超时
                 return AjaxResult.warning("时间超时");
@@ -237,6 +152,74 @@ public class WxAlertLogController  extends ApiBaseController {
         }
     }
 
+    public void  updateAlertLog(AlertConfiguration alertConfiguration,AlertLog alertLog,SimpleDateFormat sdf,String isClearCache)throws ParseException {
+        Long count =alertLog.getAlertNum()+1;
+        // 创建两个日期对象
+        Date date1 = getTimeStampV1(null,sdf,alertLog.getCreateTime());
+        Date date2 = getTimeStampV2(sdf,alertConfiguration.getAlertEndTime());
+        int clearT = date1.compareTo(date2);
+        if(count == alertConfiguration.getAlertNum() && clearT==0){
+            alertConfiguration.setIsClearCache(true);
+            alertLog.setIsClearCache(isClearCache);
+        }
+        alertLog.setAlertNum(count);
+        alertLogService.updateAlertLog(alertLog);
+    }
+    //初始化AlertLog对象
+    public  void intAlertLog(AlertConfiguration alertConfiguration,String isClearCache,String now,SimpleDateFormat sdf,Long userId,String userType) throws ParseException {
+        //加数据
+        AlertLog alertLog1 = initAlertLog(userId,alertConfiguration.getAlertId());
+        alertLog1.setUserType(userType);
+        // 创建两个日期对象
+        Date date1 = getTimeStampV1(now,null,null);
+        Date date2 = getTimeStampV2(sdf,alertConfiguration.getAlertEndTime());
+        int clearT = date1.compareTo(date2);
+        if(clearT==0 && alertConfiguration.getAlertNum() == 1){
+            alertConfiguration.setIsClearCache(true);
+            alertLog1.setIsClearCache(isClearCache);
+        }
+        alertLogService.insertAlertLog(alertLog1);
+    }
+
+    //创建两个日期对象1
+    public static Date getTimeStampV1(String now,SimpleDateFormat sdf,Date lertEndTime) throws ParseException {
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        // 设置时间部分为零点
+        Calendar calendar = Calendar.getInstance();
+        if (StringUtils.isEmpty(now)){
+            calendar.setTime(dateFormat.parse(sdf.format(lertEndTime)));
+        }else {
+            calendar.setTime(dateFormat.parse(now));
+        }
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        Date date = calendar.getTime();
+        return date;
+    }
+
+    //创建两个日期对象2
+    public static Date getTimeStampV2(SimpleDateFormat sdf,Date lertEndTime) throws ParseException {
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(dateFormat.parse(sdf.format(lertEndTime)));
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        Date date = calendar.getTime();
+        return date;
+    }
+    //封装相同逻辑
+    public AlertLog initAlertLog(Long userId,Long alertId){
+        AlertLog alertLog1 = new AlertLog();
+        alertLog1.setAlertId(alertId);
+        alertLog1.setUserId(userId);
+        alertLog1.setAlertNum(1L);
+        return alertLog1;
+    }
+
 
     @ApiOperation(value = "点赞状态",notes = "参数:{userId:1,alertId:1,status:1}")
     @ApiImplicitParams({

+ 29 - 8
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/WxPortalController.java

@@ -11,6 +11,7 @@ import com.dgtly.common.core.domain.AjaxResult;
 import com.dgtly.common.core.domain.ParameterObject;
 import com.dgtly.common.core.domain.Ztree;
 import com.dgtly.common.enums.BusinessType;
+import com.dgtly.common.utils.StringUtils;
 import com.dgtly.system.domain.*;
 import com.dgtly.system.service.*;
 import com.dgtly.wxportal.domain.HelpCenter;
@@ -64,6 +65,9 @@ public class WxPortalController extends ApiBaseController {
     @Autowired
     private ISysUserExtService sysUserExtService;
 
+    @Autowired
+    private ISysUserShopExtService sysUserShopExtService;
+
 
     @Autowired
     JdbcTemplate jdbcTemplate;
@@ -111,26 +115,43 @@ public class WxPortalController extends ApiBaseController {
     })
     @PostMapping("/ridingLantern")
     public Object getRidingLantern(){
-        String userType="";
+//        String userType="";
         ParameterObject obj = getParameterObject();
         Long userId = Long.valueOf(obj.getString("userId"));
         SysUserExt sysUserExt = sysUserExtService.selectSysUserExtById(userId);
         String salesLevel = sysUserExt.getSalesLevel();
+        List<String> userTypeList = new ArrayList<>();
         if(("customer_level").equals(salesLevel)||("reseller_level").equals(salesLevel) ){
-            userType = "1";
+            userTypeList.add("1");
         }else{
-            userType = "0";
+            userTypeList.add("0");
+        }
+        SysUserShopExt sysUserShopExt = sysUserShopExtService.selectSysUserShopExtById(obj.getString("userId"));
+        if (sysUserShopExt != null){
+            if ("0".equals(sysUserShopExt.getIsShopType())){
+                userTypeList.add("2");
+            }else {
+                userTypeList.add("3");
+            }
         }
         List<SysRidingLantern> lanternList = sysRidingLanternService.selectLanternList();
         List<SysRidingLantern> lanternListhow=new ArrayList<>();
         if (lanternList != null && lanternList.size() > 0) {
-            String finalUserType = userType;
             lanternList.forEach(lantern->{
-                String[] split = lantern.getUserType().split(",");
-                boolean exists = Arrays.stream(split)
-                        .anyMatch(str -> str.equals(String.valueOf(finalUserType)));
-                if (exists){
+                //如果userType为空,则添加通知,
+                if (StringUtils.isEmpty(lantern.getUserType())){
                     lanternListhow.add(lantern);
+                }else {
+                    String[] split = lantern.getUserType().split(",");
+                    for (String userTypeStr : userTypeList){
+                        boolean exists = Arrays.stream(split)
+                                .anyMatch(str -> str.equals(userTypeStr));
+                        if (exists){
+                            if (!lanternListhow.contains(lantern)){
+                                lanternListhow.add(lantern);
+                            }
+                        }
+                    }
                 }
             });
             return AjaxResult.success().putKV("lanterns", lanternListhow);