|
@@ -0,0 +1,211 @@
|
|
|
+package com.dgtly.wxportal.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.dgtly.common.annotation.ApiPassToken;
|
|
|
+import com.dgtly.common.core.controller.ApiBaseController;
|
|
|
+import com.dgtly.common.core.domain.AjaxResult;
|
|
|
+import com.dgtly.common.core.domain.ParameterObject;
|
|
|
+import com.dgtly.system.domain.AlertConfiguration;
|
|
|
+import com.dgtly.system.domain.AlertLog;
|
|
|
+import com.dgtly.system.domain.SysUserExt;
|
|
|
+import com.dgtly.system.service.IAlertConfigurationService;
|
|
|
+import com.dgtly.system.service.IAlertLogService;
|
|
|
+import com.dgtly.system.service.ISysUserExtService;
|
|
|
+import com.dgtly.system.service.ISysUserService;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+ * 弹框日志Controller
|
|
|
+ *
|
|
|
+ * @author chenyn
|
|
|
+ * @date 2023-06-13
|
|
|
+ */
|
|
|
+@Api(tags = "微信弹框相关接口")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/wxAlert")
|
|
|
+@ApiPassToken
|
|
|
+public class WxAlertLogController extends ApiBaseController {
|
|
|
+ @Autowired
|
|
|
+ private IAlertLogService alertLogService;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserExtService sysUserExtService;
|
|
|
+ @Autowired
|
|
|
+ private IAlertConfigurationService alertConfigurationService;
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "微信弹框",notes = "参数:{userId:1}")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "params" , paramType = "body")
|
|
|
+ })
|
|
|
+ @PostMapping("/getAlertLog")
|
|
|
+ public Object getAlertLog1(){
|
|
|
+ ParameterObject obj = getParameterObject();
|
|
|
+ Long userId = Long.valueOf(obj.getString("userId"));
|
|
|
+ AlertConfiguration alertConfiguration = null;
|
|
|
+
|
|
|
+ AlertConfiguration alertConfiguration1 = null;
|
|
|
+ alertLogService.selectAlertLogByUserId(userId);
|
|
|
+ if (alertLogService.selectAlertLogByUserId(userId)!=null){
|
|
|
+ AlertLog alertLog = alertLogService.selectAlertLogByUserId(userId);
|
|
|
+ Long alertId = alertLog.getAlertId();
|
|
|
+ alertConfiguration = alertConfigurationService.selectAlertConfigurationById(alertId);
|
|
|
+ if (alertConfiguration.getAlertStatus().equals("1")){
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+ int i = date.compareTo(alertConfiguration.getAlertStartTime());
|
|
|
+ int i1 = date.compareTo(alertConfiguration.getAlertEndTime());
|
|
|
+ if (i>=0&&i1<=0){
|
|
|
+
|
|
|
+ if (alertLog.getAlertNum()<alertConfiguration.getAlertNum()){
|
|
|
+
|
|
|
+ alertLog.setAlertNum(alertLog.getAlertNum()+1);
|
|
|
+ alertLogService.updateAlertLog(alertLog);
|
|
|
+ return AjaxResult.success().putKV("log", alertConfiguration);
|
|
|
+ }else {
|
|
|
+ return AjaxResult.success("不能弹");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return AjaxResult.success("不能弹");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+
|
|
|
+ return AjaxResult.success("不能弹");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+
|
|
|
+ alertConfiguration1 = alertConfigurationService.selectAlertConfigurationByAlertStatus(1);
|
|
|
+ SysUserExt sysUserExt = sysUserExtService.selectSysUserExtById(userId);
|
|
|
+ String salesLevel = sysUserExt.getSalesLevel();
|
|
|
+ if (alertConfiguration1!=null){
|
|
|
+ Date date = new Date();
|
|
|
+ int i = date.compareTo(alertConfiguration1.getAlertStartTime());
|
|
|
+ int i1 = date.compareTo(alertConfiguration1.getAlertEndTime());
|
|
|
+ if (i >= 0 && i1 <= 0) {
|
|
|
+
|
|
|
+ alertConfiguration1.getAlertStatus();
|
|
|
+ if (alertConfiguration1.getUserType().equals("1")&&salesLevel.equals("customer_level")){
|
|
|
+
|
|
|
+ AlertLog alertLog1 = new AlertLog();
|
|
|
+ alertLog1.setAlertId(alertConfiguration1.getAlertId());
|
|
|
+ alertLog1.setUserId(userId);
|
|
|
+ alertLog1.setUserType("1");
|
|
|
+ alertLog1.setAlertNum(0L);
|
|
|
+ alertLogService.insertAlertLog(alertLog1);
|
|
|
+ return AjaxResult.success().putKV("log",alertConfiguration1);
|
|
|
+ }else if(alertConfiguration1.getUserType().equals("0")&& !salesLevel.equals("customer_level")){
|
|
|
+
|
|
|
+ AlertLog alertLog1 = new AlertLog();
|
|
|
+ alertLog1.setAlertId(alertConfiguration1.getAlertId());
|
|
|
+ alertLog1.setUserId(userId);
|
|
|
+ alertLog1.setUserType("0");
|
|
|
+ alertLog1.setAlertNum(0L);
|
|
|
+ alertLogService.insertAlertLog(alertLog1);
|
|
|
+ return AjaxResult.success().putKV("log",alertConfiguration1);
|
|
|
+ }else {
|
|
|
+ return AjaxResult.success("不能弹");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return AjaxResult.success("不能弹");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return AjaxResult.success("不能弹");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "微信弹框",notes = "参数:{userId:1}")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "params" , paramType = "body")
|
|
|
+ })
|
|
|
+ @PostMapping("/getAlert")
|
|
|
+ public Object getAlertLog(){
|
|
|
+ ParameterObject obj = getParameterObject();
|
|
|
+ Long userId = Long.valueOf(obj.getString("userId"));
|
|
|
+
|
|
|
+ AlertConfiguration alertConfiguration1 = alertConfigurationService.selectAlertConfigurationByAlertStatus(1);
|
|
|
+ SysUserExt sysUserExt = sysUserExtService.selectSysUserExtById(userId);
|
|
|
+ String salesLevel = sysUserExt.getSalesLevel();
|
|
|
+ if (alertConfiguration1!=null){
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+ int i = date.compareTo(alertConfiguration1.getAlertStartTime());
|
|
|
+ int i1 = date.compareTo(alertConfiguration1.getAlertEndTime());
|
|
|
+ if (i >= 0 && i1 <= 0) {
|
|
|
+
|
|
|
+ String[] split = alertConfiguration1.getUserType().split(",");
|
|
|
+ List<String> strings = Arrays.asList(split);
|
|
|
+
|
|
|
+ if (strings.contains("1")&&sysUserExt.getSalesLevel().equals("customer_level")){
|
|
|
+
|
|
|
+ AlertLog alertLog = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId());
|
|
|
+ if (alertLog!=null){
|
|
|
+ if (alertLog.getAlertNum()<alertConfiguration1.getAlertNum()){
|
|
|
+ alertLog.setAlertNum(alertLog.getAlertNum()+1);
|
|
|
+ alertLogService.updateAlertLog(alertLog);
|
|
|
+ return AjaxResult.success(alertLog);
|
|
|
+ }else {
|
|
|
+ return AjaxResult.warning("每日弹出次数已满");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+
|
|
|
+ AlertLog alertLog1 = new AlertLog();
|
|
|
+ alertLog1.setAlertId(alertConfiguration1.getAlertId());
|
|
|
+ alertLog1.setUserId(userId);
|
|
|
+ alertLog1.setUserType("1");
|
|
|
+ alertLog1.setAlertNum(1L);
|
|
|
+ alertLogService.insertAlertLog(alertLog1);
|
|
|
+ return AjaxResult.success(alertConfiguration1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(strings.contains("0")&&!sysUserExt.getSalesLevel().equals("customer_level")){
|
|
|
+ AlertLog alertLog = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId());
|
|
|
+ if (alertLog!=null){
|
|
|
+ if (alertLog.getAlertNum()<alertConfiguration1.getAlertNum()){
|
|
|
+ alertLog.setAlertNum(alertLog.getAlertNum()+1);
|
|
|
+ alertLogService.updateAlertLog(alertLog);
|
|
|
+ return AjaxResult.success(alertLog);
|
|
|
+ }else {
|
|
|
+ return AjaxResult.warning("每日弹出次数已满");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+
|
|
|
+ AlertLog alertLog1 = new AlertLog();
|
|
|
+ alertLog1.setAlertId(alertConfiguration1.getAlertId());
|
|
|
+ alertLog1.setUserId(userId);
|
|
|
+ alertLog1.setUserType("0");
|
|
|
+ alertLog1.setAlertNum(1L);
|
|
|
+ alertLogService.insertAlertLog(alertLog1);
|
|
|
+ return AjaxResult.success(alertConfiguration1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return AjaxResult.warning("没有符合的弹框");
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ return AjaxResult.warning("时间超时");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+
|
|
|
+ return AjaxResult.warning("没有启动的弹框");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|