Browse Source

Merge branch 'master' into test

yumeng 5 years ago
parent
commit
333d26b267

+ 179 - 179
jeecg-boot-base-common/src/main/java/org/jeecg/common/system/util/JwtUtil.java

@@ -6,15 +6,6 @@ import com.auth0.jwt.algorithms.Algorithm;
 import com.auth0.jwt.exceptions.JWTDecodeException;
 import com.auth0.jwt.exceptions.JWTDecodeException;
 import com.auth0.jwt.interfaces.DecodedJWT;
 import com.auth0.jwt.interfaces.DecodedJWT;
 import com.google.common.base.Joiner;
 import com.google.common.base.Joiner;
-
-import java.util.Date;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-
-import org.jeecg.common.constant.DataBaseConstant;
-import org.jeecg.common.exception.JeecgBootException;
-
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.constant.DataBaseConstant;
 import org.jeecg.common.constant.DataBaseConstant;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.exception.JeecgBootException;
@@ -23,6 +14,10 @@ import org.jeecg.common.system.vo.SysUserCacheInfo;
 import org.jeecg.common.util.SpringContextUtils;
 import org.jeecg.common.util.SpringContextUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.common.util.oConvertUtils;
 
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.Date;
+
 /**
 /**
  * @Author Scott
  * @Author Scott
  * @Date 2018-07-12 14:23
  * @Date 2018-07-12 14:23
@@ -33,174 +28,179 @@ public class JwtUtil {
     /**
     /**
      * 过期时间30分钟
      * 过期时间30分钟
      */
      */
-	public static final long EXPIRE_TIME = 30 * 60 * 1000;
-
-	/**
-	 * 校验token是否正确
-	 *
-	 * @param token  密钥
-	 * @param secret 用户的密码
-	 * @return 是否正确
-	 */
-	public static boolean verify(String token, String username, String secret) {
-		try {
-			// 根据密码生成JWT效验器
-			Algorithm algorithm = Algorithm.HMAC256(secret);
-			JWTVerifier verifier = JWT.require(algorithm).withClaim("username", username).build();
-			// 效验TOKEN
-			DecodedJWT jwt = verifier.verify(token);
-			return true;
-		} catch (Exception exception) {
-			return false;
-		}
-	}
-
-	/**
-	 * 获得token中的信息无需secret解密也能获得
-	 *
-	 * @return token中包含的用户名
-	 */
-	public static String getUsername(String token) {
-		try {
-			DecodedJWT jwt = JWT.decode(token);
-			return jwt.getClaim("username").asString();
-		} catch (JWTDecodeException e) {
-			return null;
-		}
-	}
-
-	/**
-	 * 生成签名,5min后过期
-	 *
-	 * @param username 用户名
-	 * @param secret   用户的密码
-	 * @return 加密的token
-	 */
-	public static String sign(String username, String secret) {
-		Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME);
-		Algorithm algorithm = Algorithm.HMAC256(secret);
-		// 附带username信息
-		return JWT.create().withClaim("username", username).withExpiresAt(date).sign(algorithm);
-
-	}
-
-	/**
-	 * 根据request中的token获取用户账号
-	 * 
-	 * @param request
-	 * @return
-	 * @throws JeecgBootException
-	 */
-	public static String getUserNameByToken(HttpServletRequest request) throws JeecgBootException {
-		String accessToken = request.getHeader("X-Access-Token");
-		String username = getUsername(accessToken);
-		if (oConvertUtils.isEmpty(username)) {
-			throw new JeecgBootException("未获取到用户");
-		}
-		return username;
-	}
-	
-	/**
-	  *  从session中获取变量
-	 * @param key
-	 * @return
-	 */
-	public static String getSessionData(String key) {
-		//${myVar}%
-		//得到${} 后面的值
-		String moshi = "";
-		if(key.indexOf("}")!=-1){
-			 moshi = key.substring(key.indexOf("}")+1);
-		}
-		String returnValue = null;
-		if (key.contains("#{")) {
-			key = key.substring(2,key.indexOf("}"));
-		}
-		if (oConvertUtils.isNotEmpty(key)) {
-			HttpSession session = SpringContextUtils.getHttpServletRequest().getSession();
-			returnValue = (String) session.getAttribute(key);
-		}
-		//结果加上${} 后面的值
-		if(returnValue!=null){returnValue = returnValue + moshi;}
-		return returnValue;
-	}
-	
-	/**
-	  * 从当前用户中获取变量
-	 * @param key
-	 * @param user
-	 * @return
-	 */
-
-	//TODO 急待改造 sckjkdsjsfjdk
-
-	public static String getUserSystemData(String key,SysUserCacheInfo user) {
-		if(user==null) {
-			user = JeecgDataAutorUtils.loadUserInfo();
-		}
-		//#{sys_user_code}%
-
-		// 获取登录用户信息
-		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-
-		String moshi = "";
-		if(key.indexOf("}")!=-1){
-			 moshi = key.substring(key.indexOf("}")+1);
-		}
-		String returnValue = null;
-		//针对特殊标示处理#{sysOrgCode},判断替换
-		if (key.contains("#{")) {
-			key = key.substring(2,key.indexOf("}"));
-		} else {
-			key = key;
-		}
-		//替换为系统登录用户帐号
-		if (key.equals(DataBaseConstant.SYS_USER_CODE)|| key.equals(DataBaseConstant.SYS_USER_CODE_TABLE)) {
-			if(user==null) {
-				returnValue = sysUser.getUsername();
-			}else {
-				returnValue = user.getSysUserCode();
-			}
-		}
-		//替换为系统登录用户真实名字
-		if (key.equals(DataBaseConstant.SYS_USER_NAME)|| key.equals(DataBaseConstant.SYS_USER_NAME_TABLE)) {
-			if(user==null) {
-				returnValue = sysUser.getRealname();
-			}else {
-				returnValue = user.getSysUserName();
-			}
-		}
-		
-		//替换为系统用户登录所使用的机构编码
-		if (key.equals(DataBaseConstant.SYS_ORG_CODE)|| key.equals(DataBaseConstant.SYS_ORG_CODE_TABLE)) {
-			if(user==null) {
-				returnValue = sysUser.getOrgCode();
-			}else {
-				returnValue = user.getSysOrgCode();
-			}
-
-		}
-		//替换为系统用户所拥有的所有机构编码
-		if (key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE)|| key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE)) {
-			if(user.isOneDepart()) {
-				returnValue = user.getSysMultiOrgCode().get(0);
-			}else {
-				returnValue = Joiner.on(",").join(user.getSysMultiOrgCode());
-			}
-		}
-		//替换为当前系统时间(年月日)
-		if (key.equals(DataBaseConstant.SYS_DATE)|| key.equals(DataBaseConstant.SYS_DATE_TABLE)) {
-			returnValue = user.getSysDate();
-		}
-		//替换为当前系统时间(年月日时分秒)
-		if (key.equals(DataBaseConstant.SYS_TIME)|| key.equals(DataBaseConstant.SYS_TIME_TABLE)) {
-			returnValue = user.getSysTime();
-		}
-		//流程状态默认值(默认未发起)
-		if (key.equals(DataBaseConstant.BPM_STATUS_TABLE)|| key.equals(DataBaseConstant.BPM_STATUS_TABLE)) {
-			returnValue = "1";
-		}
-		if(returnValue!=null){returnValue = returnValue + moshi;}
-		return returnValue;
-	}
+    public static final long EXPIRE_TIME = 30 * 60 * 1000;
+
+    /**
+     * 校验token是否正确
+     *
+     * @param token  密钥
+     * @param secret 用户的密码
+     * @return 是否正确
+     */
+    public static boolean verify(String token, String username, String secret) {
+        try {
+            // 根据密码生成JWT效验器
+            Algorithm algorithm = Algorithm.HMAC256(secret);
+            JWTVerifier verifier = JWT.require(algorithm).withClaim("username", username).build();
+            // 效验TOKEN
+            DecodedJWT jwt = verifier.verify(token);
+            return true;
+        } catch (Exception exception) {
+            return false;
+        }
+    }
+
+    /**
+     * 获得token中的信息无需secret解密也能获得
+     *
+     * @return token中包含的用户名
+     */
+    public static String getUsername(String token) {
+        try {
+            DecodedJWT jwt = JWT.decode(token);
+            return jwt.getClaim("username").asString();
+        } catch (JWTDecodeException e) {
+            return null;
+        }
+    }
+
+    /**
+     * 生成签名,5min后过期
+     *
+     * @param username 用户名
+     * @param secret   用户的密码
+     * @return 加密的token
+     */
+    public static String sign(String username, String secret) {
+        Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME);
+        Algorithm algorithm = Algorithm.HMAC256(secret);
+        // 附带username信息
+        return JWT.create().withClaim("username", username).withExpiresAt(date).sign(algorithm);
+
+    }
+
+    /**
+     * 根据request中的token获取用户账号
+     *
+     * @param request
+     * @return
+     * @throws JeecgBootException
+     */
+    public static String getUserNameByToken(HttpServletRequest request) throws JeecgBootException {
+        String accessToken = request.getHeader("X-Access-Token");
+        String username = getUsername(accessToken);
+        if (oConvertUtils.isEmpty(username)) {
+            throw new JeecgBootException("未获取到用户");
+        }
+        return username;
+    }
+
+    /**
+     * 从session中获取变量
+     *
+     * @param key
+     * @return
+     */
+    public static String getSessionData(String key) {
+        //${myVar}%
+        //得到${} 后面的值
+        String moshi = "";
+        if (key.indexOf("}") != -1) {
+            moshi = key.substring(key.indexOf("}") + 1);
+        }
+        String returnValue = null;
+        if (key.contains("#{")) {
+            key = key.substring(2, key.indexOf("}"));
+        }
+        if (oConvertUtils.isNotEmpty(key)) {
+            HttpSession session = SpringContextUtils.getHttpServletRequest().getSession();
+            returnValue = (String) session.getAttribute(key);
+        }
+        //结果加上${} 后面的值
+        if (returnValue != null) {
+            returnValue = returnValue + moshi;
+        }
+        return returnValue;
+    }
+
+    /**
+     * 从当前用户中获取变量
+     *
+     * @param key
+     * @param user
+     * @return
+     */
+
+    //TODO 急待改造 sckjkdsjsfjdk
+    public static String getUserSystemData(String key, SysUserCacheInfo user) {
+        if (user == null) {
+            user = JeecgDataAutorUtils.loadUserInfo();
+        }
+        //#{sys_user_code}%
+
+        // 获取登录用户信息
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+
+        String moshi = "";
+        if (key.indexOf("}") != -1) {
+            moshi = key.substring(key.indexOf("}") + 1);
+        }
+        String returnValue = null;
+        //针对特殊标示处理#{sysOrgCode},判断替换
+        if (key.contains("#{")) {
+            key = key.substring(2, key.indexOf("}"));
+        } else {
+            key = key;
+        }
+        //替换为系统登录用户帐号
+        if (key.equals(DataBaseConstant.SYS_USER_CODE) || key.equals(DataBaseConstant.SYS_USER_CODE_TABLE)) {
+            if (user == null) {
+                returnValue = sysUser.getUsername();
+            } else {
+                returnValue = user.getSysUserCode();
+            }
+        }
+        //替换为系统登录用户真实名字
+        if (key.equals(DataBaseConstant.SYS_USER_NAME) || key.equals(DataBaseConstant.SYS_USER_NAME_TABLE)) {
+            if (user == null) {
+                returnValue = sysUser.getRealname();
+            } else {
+                returnValue = user.getSysUserName();
+            }
+        }
+
+        //替换为系统用户登录所使用的机构编码
+        if (key.equals(DataBaseConstant.SYS_ORG_CODE) || key.equals(DataBaseConstant.SYS_ORG_CODE_TABLE)) {
+            if (user == null) {
+                returnValue = sysUser.getOrgCode();
+            } else {
+                returnValue = user.getSysOrgCode();
+            }
+
+        }
+        //替换为系统用户所拥有的所有机构编码
+        if (key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE) || key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE)) {
+            if (user.isOneDepart()) {
+                returnValue = user.getSysMultiOrgCode().get(0);
+            } else {
+                returnValue = Joiner.on(",").join(user.getSysMultiOrgCode());
+            }
+        }
+        //替换为当前系统时间(年月日)
+        if (key.equals(DataBaseConstant.SYS_DATE) || key.equals(DataBaseConstant.SYS_DATE_TABLE)) {
+            returnValue = user.getSysDate();
+        }
+        //替换为当前系统时间(年月日时分秒)
+        if (key.equals(DataBaseConstant.SYS_TIME) || key.equals(DataBaseConstant.SYS_TIME_TABLE)) {
+            returnValue = user.getSysTime();
+        }
+        //流程状态默认值(默认未发起)
+        if (key.equals(DataBaseConstant.BPM_STATUS_TABLE) || key.equals(DataBaseConstant.BPM_STATUS_TABLE)) {
+            returnValue = "1";
+        }
+        if (returnValue != null) {
+            returnValue = returnValue + moshi;
+        }
+        return returnValue;
+    }
 }
 }

+ 3 - 10
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java

@@ -13,16 +13,6 @@ import cn.com.ctop.toutiao.entity.ByteDanceAdvertiser;
 import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import lombok.val;
-import me.chanjar.weixin.common.error.WxErrorException;
-import me.chanjar.weixin.cp.api.WxCpOAuth2Service;
-import me.chanjar.weixin.cp.api.WxCpUserService;
-import me.chanjar.weixin.cp.api.impl.WxCpOAuth2ServiceImpl;
-import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
-import me.chanjar.weixin.cp.api.impl.WxCpUserServiceImpl;
-import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
-import me.chanjar.weixin.cp.bean.WxCpUser;
-import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.constant.CommonConstant;
@@ -119,6 +109,7 @@ public class CallbackController {
         result.success("登录成功");
         result.success("登录成功");
         return result;
         return result;
     }
     }
+
     /**
     /**
      * TODO 授权绑定成功/失败 需要跳转特定页面
      * TODO 授权绑定成功/失败 需要跳转特定页面
      *
      *
@@ -255,6 +246,7 @@ public class CallbackController {
         param.put("secret", PropertiesUtils.getValue("bytedance_config", "bytedance_secret"));
         param.put("secret", PropertiesUtils.getValue("bytedance_config", "bytedance_secret"));
         param.put("grant_type", "auth_code");
         param.put("grant_type", "auth_code");
         param.put("auth_code", authCode);
         param.put("auth_code", authCode);
+        logger.info("authCode:{}", authCode);
         logger.info("state:{}", state);
         logger.info("state:{}", state);
         Map<String, Object> returnMap = new HashMap<>();
         Map<String, Object> returnMap = new HashMap<>();
         try {
         try {
@@ -264,6 +256,7 @@ public class CallbackController {
             }
             }
             String result = HttpUtils.httpPostRequest(PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + BytedanceInterfaceConstant.AUTH_TOKEN, param, new HashMap<>());
             String result = HttpUtils.httpPostRequest(PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + BytedanceInterfaceConstant.AUTH_TOKEN, param, new HashMap<>());
             JSONObject resultObject = JSONObject.parseObject(result);
             JSONObject resultObject = JSONObject.parseObject(result);
+            logger.info("返回信息:{}", resultObject);
             Integer code = resultObject.getInteger("code");
             Integer code = resultObject.getInteger("code");
             String message = resultObject.getString("message");
             String message = resultObject.getString("message");
             if (null == code || code != 0) {
             if (null == code || code != 0) {

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java

@@ -132,7 +132,7 @@ public class ProjectController {
 
 
         String roleCode = materialReportMapper.getRoleCodeByUserId(sysUser.getId());
         String roleCode = materialReportMapper.getRoleCodeByUserId(sysUser.getId());
         if (!"admin".equals(roleCode)) {
         if (!"admin".equals(roleCode)) {
-            queryWrapper.eq("responsible_id", sysUser.getId());
+            queryWrapper.eq("user_id", sysUser.getId());
             queryWrapper.orderByDesc("create_time");
             queryWrapper.orderByDesc("create_time");
         }
         }
         IPage<Project> pageList = projectService.page(page, queryWrapper);
         IPage<Project> pageList = projectService.page(page, queryWrapper);

+ 9 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/shiro/authc/ShiroRealm.java

@@ -1,7 +1,7 @@
 package org.jeecg.modules.shiro.authc;
 package org.jeecg.modules.shiro.authc;
 
 
-import java.util.Set;
-
+import cn.com.ctop.common.module.utils.Check;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.authc.AuthenticationException;
 import org.apache.shiro.authc.AuthenticationException;
 import org.apache.shiro.authc.AuthenticationInfo;
 import org.apache.shiro.authc.AuthenticationInfo;
 import org.apache.shiro.authc.AuthenticationToken;
 import org.apache.shiro.authc.AuthenticationToken;
@@ -22,7 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
-import lombok.extern.slf4j.Slf4j;
+import java.util.Set;
 
 
 /**
 /**
  * @Description: 用户登录鉴权和获取用户授权
  * @Description: 用户登录鉴权和获取用户授权
@@ -99,13 +99,18 @@ public class ShiroRealm extends AuthorizingRealm {
      * @param token
      * @param token
      */
      */
     public LoginUser checkUserTokenIsEffect(String token) throws AuthenticationException {
     public LoginUser checkUserTokenIsEffect(String token) throws AuthenticationException {
+        if (Check.isNull(token)) {
+            log.error("token为空");
+            return null;
+
+        }
+
         // 解密获得username,用于和数据库进行对比
         // 解密获得username,用于和数据库进行对比
         String username = JwtUtil.getUsername(token);
         String username = JwtUtil.getUsername(token);
         if (username == null) {
         if (username == null) {
             log.error("token非法无效!");
             log.error("token非法无效!");
             // throw new AuthenticationException("token非法无效!");
             // throw new AuthenticationException("token非法无效!");
         }
         }
-
         // 查询用户信息
         // 查询用户信息
         LoginUser loginUser = new LoginUser();
         LoginUser loginUser = new LoginUser();
         SysUser sysUser = sysUserService.getUserByName(username);
         SysUser sysUser = sysUserService.getUserByName(username);

+ 0 - 1
module-common/pom.xml

@@ -83,6 +83,5 @@
                 <directory>src/main/resources</directory>
                 <directory>src/main/resources</directory>
             </resource>
             </resource>
         </resources>
         </resources>
-
     </build>
     </build>
 </project>
 </project>

+ 11 - 3
module-common/src/main/java/cn/com/ctop/common/module/service/impl/BindAccountAuthServiceImpl.java

@@ -1,11 +1,12 @@
 package cn.com.ctop.common.module.service.impl;
 package cn.com.ctop.common.module.service.impl;
 
 
-import cn.com.ctop.common.module.utils.BytedanceInterfaceConstant;
-import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
-import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.common.module.entity.BindAccountAuth;
 import cn.com.ctop.common.module.entity.BindAccountAuth;
 import cn.com.ctop.common.module.mapper.BindAccountAuthMapper;
 import cn.com.ctop.common.module.mapper.BindAccountAuthMapper;
 import cn.com.ctop.common.module.service.IBindAccountAuthService;
 import cn.com.ctop.common.module.service.IBindAccountAuthService;
+import cn.com.ctop.common.module.utils.BytedanceInterfaceConstant;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -70,10 +71,17 @@ public class BindAccountAuthServiceImpl extends ServiceImpl<BindAccountAuthMappe
     @Override
     @Override
     public String getByteDanceCodeUrl(String state) throws UnsupportedEncodingException {
     public String getByteDanceCodeUrl(String state) throws UnsupportedEncodingException {
         StringBuffer sb = new StringBuffer();
         StringBuffer sb = new StringBuffer();
+        JSONArray jsonArray = new JSONArray();
+        jsonArray.add("100");
+        jsonArray.add("2");
+        jsonArray.add("3");
+        jsonArray.add("4");
+        jsonArray.add("5");
         sb.append(PropertiesUtils.getValue("bytedance_config", "bytedance_auth_url"))
         sb.append(PropertiesUtils.getValue("bytedance_config", "bytedance_auth_url"))
                 .append(BytedanceInterfaceConstant.AUTH_PATH)
                 .append(BytedanceInterfaceConstant.AUTH_PATH)
                 .append("?app_id=" + PropertiesUtils.getValue("bytedance_config", "bytedance_appid"))
                 .append("?app_id=" + PropertiesUtils.getValue("bytedance_config", "bytedance_appid"))
                 .append("&state=" + URLEncoder.encode(state))
                 .append("&state=" + URLEncoder.encode(state))
+                .append("&scope=" + jsonArray)
                 .append("&redirect_uri=" + URLEncoder.encode(PropertiesUtils.getValue("bytedance_config", "bytedance_callback_url"), "UTF-8"));
                 .append("&redirect_uri=" + URLEncoder.encode(PropertiesUtils.getValue("bytedance_config", "bytedance_callback_url"), "UTF-8"));
         return sb.toString();
         return sb.toString();
     }
     }

+ 50 - 49
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -14,7 +14,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-// import it.sauronsoftware.jave.Encoder;
+ // import it.sauronsoftware.jave.Encoder;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -146,7 +146,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                     }
                     }
                 }
                 }
             }
             }
-          //  getFile(info);
+            //  getFile(info);
             ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
             ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
         } catch (Exception e) {
         } catch (Exception e) {
             ResultMapUtils.setResultMap(resultMap, StatusCode.MATERIAL_UPLOAD_FAIL.getCode());
             ResultMapUtils.setResultMap(resultMap, StatusCode.MATERIAL_UPLOAD_FAIL.getCode());
@@ -253,60 +253,61 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     private MaterialParameterMapper materialParameterMapper;
     private MaterialParameterMapper materialParameterMapper;
 
 
    /* public void getFile(MaterialInfo materialInfo) {
    /* public void getFile(MaterialInfo materialInfo) {
-        uploadExecutorService.submit(new Runnable() {
+       *//* uploadExecutorService.submit(new Runnable() {
             @Override
             @Override
-            public void run() {
-                try {
-                    System.err.println("开始获取素材基本信息");
-                    System.err.println(materialInfo);
-                    if (!Check.isNull(materialInfo)) {
-                        String url = materialInfo.getUrl();
-                        long l = System.currentTimeMillis();
-                        //PropertiesUtils.getValue("kuaishou_config", "video_sava_path")
-                        String localUrl = LoadFileUtil.downLoadFromUrl(url, PropertiesUtils.getValue("kuaishou_config", "video_sava_path"));
-                        File file = new File(localUrl);
-                        it.sauronsoftware.jave.Encoder encoder = new Encoder();
-                        *//*try {*//*
-                        it.sauronsoftware.jave.MultimediaInfo m = encoder.getInfo(file);
-                        long duration = m.getDuration();
-                        long secondDuration = duration / 1000;
-                        MaterialParameter materialParameter = new MaterialParameter();
-                        materialParameter.setMaterialId(materialInfo.getId());
-                        // 视频秒数
-                        materialParameter.setSecond(secondDuration);
-                        // 视频格式
-                        materialParameter.setFormat(m.getFormat());
-                        // 视频宽
-                        materialParameter.setWidth(String.valueOf(m.getVideo().getSize().getWidth()));
-                        // 视频高
-                        materialParameter.setHeight(String.valueOf(m.getVideo().getSize().getHeight()));
-
-                        FileInputStream fis = new FileInputStream(file);
-                        FileChannel fc = fis.getChannel();
-                        BigDecimal fileSize = new BigDecimal(fc.size());
-                        String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
-                        materialParameter.setSize(size);
-
-                        Map<String, Object> deleteMap = new HashMap<>();
-                        deleteMap.put("material_id", materialInfo.getId());
-                        materialParameterMapper.deleteByMap(deleteMap);
-
-                        int insert = materialParameterMapper.insert(materialParameter);
-                        if (insert > 0) {
-                            log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
-
-                        }
+            public void run() {*//*
+        try {
+            System.err.println("开始获取素材基本信息");
+            System.err.println(materialInfo);
+            if (!Check.isNull(materialInfo)) {
+                String url = materialInfo.getUrl();
+                long l = System.currentTimeMillis();
+                //PropertiesUtils.getValue("kuaishou_config", "video_sava_path")
+                String localUrl = LoadFileUtil.downLoadFromUrl(url, PropertiesUtils.getValue("kuaishou_config", "video_sava_path"));
+                File file = new File(localUrl);
+                it.sauronsoftware.jave.Encoder encoder = new Encoder();
+                *//*try {*//*
+                it.sauronsoftware.jave.MultimediaInfo m = encoder.getInfo(file);
+                long duration = m.getDuration();
+                long secondDuration = duration / 1000;
+                MaterialParameter materialParameter = new MaterialParameter();
+                materialParameter.setMaterialId(materialInfo.getId());
+                // 视频秒数
+                materialParameter.setSecond(secondDuration);
+                // 视频格式
+                materialParameter.setFormat(m.getFormat());
+                // 视频宽
+                materialParameter.setWidth(String.valueOf(m.getVideo().getSize().getWidth()));
+                // 视频高
+                materialParameter.setHeight(String.valueOf(m.getVideo().getSize().getHeight()));
+
+                FileInputStream fis = new FileInputStream(file);
+                FileChannel fc = fis.getChannel();
+                BigDecimal fileSize = new BigDecimal(fc.size());
+                String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
+                materialParameter.setSize(size);
+
+                Map<String, Object> deleteMap = new HashMap<>();
+                deleteMap.put("material_id", materialInfo.getId());
+                materialParameterMapper.deleteByMap(deleteMap);
+
+                int insert = materialParameterMapper.insert(materialParameter);
+                if (insert > 0) {
+                    log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
+
+                }
+                System.err.println(2222222);
                *//* } catch (Exception e) {
                *//* } catch (Exception e) {
                     e.printStackTrace();
                     e.printStackTrace();
                 } *//**//*finally {
                 } *//**//*finally {
                     file.delete();
                     file.delete();
                 }*//*
                 }*//*
-                    }
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
             }
             }
-        });
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+       *//*     }
+        });*//*
     }*/
     }*/
 
 
 
 

+ 1 - 3
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java

@@ -180,7 +180,7 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                             }
                                             }
                                         }
                                         }
 
 
-                                        log.info("素材同步完成,accountId:{},code:{}", accountId, materialInfo.getCode());
+                                        log.info("素材同步完成,accountId:{},code:{},返回信息:{}", accountId, materialInfo.getCode(), resultJson);
                                     } else {
                                     } else {
                                         log.error("同步素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
                                         log.error("同步素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
                                     }
                                     }
@@ -209,8 +209,6 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
     }
     }
 
 
 
 
-
-
     @Autowired
     @Autowired
     private RestTemplate rest;
     private RestTemplate rest;
 
 

+ 1 - 0
module-kuaishou/pom.xml

@@ -52,4 +52,5 @@
             </resource>
             </resource>
         </resources>
         </resources>
     </build>
     </build>
+
 </project>
 </project>

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreateServiceImpl.java

@@ -381,7 +381,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                     imageJson.put("positionType", requestJson.getString("positionType"));
                     imageJson.put("positionType", requestJson.getString("positionType"));
                     String imagePath = imageService.localInsert(imageJson);
                     String imagePath = imageService.localInsert(imageJson);
 
 
-                    Map<String, Object> imageMap = kuaishouInterfaceService.imageUpload(accountId, accessToken, imagePath, 0);
+                    Map<String, Object> imageMap = kuaishouInterfaceService.imageUpload(accountId, accessToken, imagePath, 2);
                     if ((Integer) imageMap.get("code") != 0) {
                     if ((Integer) imageMap.get("code") != 0) {
                         return imageMap;
                         return imageMap;
                     }
                     }
@@ -479,7 +479,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                         imageJson.put("loginId", requestJson.getString("loginId"));
                         imageJson.put("loginId", requestJson.getString("loginId"));
                         imageJson.put("videoUploadType", requestJson.getString("singlePicTiepianType"));
                         imageJson.put("videoUploadType", requestJson.getString("singlePicTiepianType"));
                         String imagePath = imageService.localInsert(imageJson);
                         String imagePath = imageService.localInsert(imageJson);
-                        Map<String, Object> imageMap = kuaishouInterfaceService.imageUpload(accountId, accessToken, imagePath, 0);
+                        Map<String, Object> imageMap = kuaishouInterfaceService.imageUpload(accountId, accessToken, imagePath, 3);
                         if ((Integer) imageMap.get("code") != 0) {
                         if ((Integer) imageMap.get("code") != 0) {
                             log.error("上传后贴片单张图片素材失败,accountId:{}", accountId);
                             log.error("上传后贴片单张图片素材失败,accountId:{}", accountId);
                             return imageMap;
                             return imageMap;

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -2041,7 +2041,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                             }
                             }
                         }
                         }
                     }
                     }
-                    log.info("获取视频信息完成,advertiserId:{}", advertiserId);
+                    log.info("获取视频信息完成,advertiserId:{},返回信息:{}", advertiserId,resultJson);
                 } else {
                 } else {
                     log.error("获取广告视频失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
                     log.error("获取广告视频失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
                 }
                 }

+ 21 - 2
module-report/src/main/java/cn/com/ctop/bytedance/mapper/AccountReportMapper.java

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 
 
 /**
 /**
  * @author jeecg-boot
  * @author jeecg-boot
@@ -26,7 +27,7 @@ public interface AccountReportMapper {
     /**
     /**
      * 今日消耗
      * 今日消耗
      *
      *
-     * @param date 日期
+     * @param date       日期
      * @param accountIds
      * @param accountIds
      * @return 今日消耗
      * @return 今日消耗
      */
      */
@@ -36,7 +37,7 @@ public interface AccountReportMapper {
     /**
     /**
      * 查询明细
      * 查询明细
      *
      *
-     * @param date 日期
+     * @param date       日期
      * @param accountIds
      * @param accountIds
      * @return 查询明细
      * @return 查询明细
      */
      */
@@ -54,6 +55,7 @@ public interface AccountReportMapper {
 
 
     /**
     /**
      * 查询全部消耗 包括今日消耗
      * 查询全部消耗 包括今日消耗
+     *
      * @param accountIds
      * @param accountIds
      * @return
      * @return
      */
      */
@@ -94,6 +96,7 @@ public interface AccountReportMapper {
 
 
     /**
     /**
      * 查询所有按月统计数据
      * 查询所有按月统计数据
+     *
      * @param accountIds
      * @param accountIds
      * @return
      * @return
      */
      */
@@ -124,6 +127,7 @@ public interface AccountReportMapper {
 
 
     /**
     /**
      * 用户报表信息
      * 用户报表信息
+     *
      * @param accountIds
      * @param accountIds
      * @param discount
      * @param discount
      * @return
      * @return
@@ -145,10 +149,25 @@ public interface AccountReportMapper {
 
 
     /**
     /**
      * 按月统计
      * 按月统计
+     *
      * @param startDate
      * @param startDate
      * @param endDate
      * @param endDate
      * @param accountIds
      * @param accountIds
      * @return
      * @return
      */
      */
     List<JSONObject> selectDayDetailByMonth(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("accountIds") JSONArray accountIds);
     List<JSONObject> selectDayDetailByMonth(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("accountIds") JSONArray accountIds);
+
+
+    /**
+     * 查询分天汇总
+     *
+     * @param queryMap
+     * @return
+     */
+
+    JSONObject selectSummaryByMap(Map<String, Object> queryMap);
+
+    List<JSONObject> selectReportDetailGroupAccountIdByDate(@Param("statDate") String anotherDay,@Param("accountIds") JSONArray accountIds);
+
+    JSONObject selectHourSummaryByMap(Map<String, Object> queryMap);
 }
 }

+ 213 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/AccountReportMapper.xml

@@ -120,6 +120,34 @@
     </select>
     </select>
 
 
 
 
+    <select id="selectReportDetailGroupAccountIdByDate" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost, -- 消耗
+        sum(photo_show) photoShow, -- 封面展示
+        sum(photo_click) photoClick, -- 封面点击
+        sum(aclick) aclick, -- 素材曝光数
+        (sum(photo_click) / sum(photo_show)) photoClickRatio, -- 封面点击率
+        (sum(form_count) / sum(bclick)) cvr,
+        ((sum(charge) / (sum(photo_show)) * 1000)) cpm,
+        sum(bclick) bClick,-- 行为数
+        sum(form_count) formCount,
+        (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
+        sum(activation) activationCount, -- 激活数
+        (sum(charge) / sum(activation)) activationPrice, -- 激活单价
+        account_id accountId,
+        (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
+        from
+        ctop_kuaishou_report_daily_account
+        where stat_date = #{statDate}
+        and account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        group by account_id;
+    </select>
+
+
     <select id="selectMaxHourByDate" resultType="java.lang.Integer">
     <select id="selectMaxHourByDate" resultType="java.lang.Integer">
         select
         select
         max(stat_hour)
         max(stat_hour)
@@ -298,4 +326,189 @@
     </select>
     </select>
 
 
 
 
+    <select id="selectSummaryByMap" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        sum(charge) cost, -- 消耗
+        (case
+        when sum(charge) != 0
+        then (sum(charge) / #{discount})
+        else 0
+        end
+        ) discountCost, -- 封面点击率
+
+        sum(photo_show) photoShow, -- 封面展示
+        sum(photo_click) photoClick, -- 封面点击
+        sum(aclick) aclick, -- 素材曝光数
+
+        (case
+        when sum(photo_show) != 0
+        then (sum(photo_click) / sum(photo_show))
+        else 0
+        end
+        ) photoClickRatio, -- 封面点击率
+
+        (case
+        when sum(bclick) != 0
+        then (sum(form_count) / sum(bclick))
+        else 0
+        end
+        ) cvr,
+
+        (case
+        when sum(photo_show) != 0
+        then ((sum(charge) / (sum(photo_show)) * 1000))
+        else 0
+        end
+        ) cpm,
+
+        sum(bclick) bClick,-- 行为数
+        (
+        CASE
+        WHEN sum(form_count) != 0 THEN
+        sum(form_count)
+        WHEN sum(activation) != 0 THEN
+        sum(activation)
+        ELSE
+        0
+        END
+        ) conversions, -- 转化数
+        (
+        CASE
+        WHEN sum(form_count) != 0 THEN
+        sum(charge) / sum(form_count)
+        WHEN sum(activation) != 0 THEN
+        sum(charge) / sum(activation)
+        ELSE
+        0
+        END
+        ) conversionPrice, -- 转化单价
+        (
+        CASE
+        WHEN sum(form_count) != 0 THEN
+        (sum(charge) / sum(form_count)) / #{discount}
+        WHEN sum(activation) != 0 THEN
+        (sum(charge) / sum(activation)) / #{discount}
+        ELSE
+        0
+        END
+        ) discountConversionPrice
+
+        from
+        ctop_kuaishou_report_daily_account
+
+        <where>
+            <if test="statDate != null">
+                and stat_date = #{statDate}
+            </if>
+            <if test="startDate != null">
+                and stat_date &gt;= #{startDate}
+            </if>
+            <if test="endDate != null">
+                and stat_date &lt;= #{endDate}
+            </if>
+
+            <if test="accountIds != null">
+                and account_id in
+                <foreach collection="accountIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+
+            </if>
+        </where>
+    </select>
+
+
+    <select id="selectHourSummaryByMap" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject">
+
+        select
+        sum(charge) cost, -- 消耗
+        (case
+        when sum(charge) != 0
+        then (sum(charge) / #{discount})
+        else 0
+        end
+        ) discountCost, -- 封面点击率
+
+        sum(photo_show) photoShow, -- 封面展示
+        sum(photo_click) photoClick, -- 封面点击
+        sum(aclick) aclick, -- 素材曝光数
+
+        (case
+        when sum(photo_show) != 0
+        then (sum(photo_click) / sum(photo_show))
+        else 0
+        end
+        ) photoClickRatio, -- 封面点击率
+
+        (case
+        when sum(bclick) != 0
+        then (sum(form_count) / sum(bclick))
+        else 0
+        end
+        ) cvr,
+
+        (case
+        when sum(photo_show) != 0
+        then ((sum(charge) / (sum(photo_show)) * 1000))
+        else 0
+        end
+        ) cpm,
+
+        sum(bclick) bClick,-- 行为数
+        (
+        CASE
+        WHEN sum(form_count) != 0 THEN
+        sum(form_count)
+        WHEN sum(activation) != 0 THEN
+        sum(activation)
+        ELSE
+        0
+        END
+        ) conversions, -- 转化数
+        (
+        CASE
+        WHEN sum(form_count) != 0 THEN
+        sum(charge) / sum(form_count)
+        WHEN sum(activation) != 0 THEN
+        sum(charge) / sum(activation)
+        ELSE
+        0
+        END
+        ) conversionPrice, -- 转化单价
+        (
+        CASE
+        WHEN sum(form_count) != 0 THEN
+        (sum(charge) / sum(form_count)) / #{discount}
+        WHEN sum(activation) != 0 THEN
+        (sum(charge) / sum(activation)) / #{discount}
+        ELSE
+        0
+        END
+        ) discountConversionPrice
+
+        from
+        ctop_kuaishou_report_hourly_account
+
+        <where>
+            <if test="statDate != null">
+                and stat_date = #{statDate}
+            </if>
+            <if test="statHour != null">
+                and stat_hour &lt;= #{statHour}
+            </if>
+
+            <if test="accountIds != null">
+                and account_id in
+                <foreach collection="accountIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+
+            </if>
+        </where>
+
+
+    </select>
+
 </mapper>
 </mapper>

+ 56 - 1
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/AccountReportServiceImpl.java

@@ -12,7 +12,9 @@ import org.springframework.stereotype.Service;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 
 
 /**
 /**
  * @author yumeng
  * @author yumeng
@@ -257,6 +259,9 @@ public class AccountReportServiceImpl implements IAccountReportService {
                 return null;
                 return null;
             }
             }
 
 
+            Map<String, Object> queryMap = new HashMap<>();
+            queryMap.put("discount", discount);
+            String statDate = "";
             List<JSONObject> accountDetail = new ArrayList<>();
             List<JSONObject> accountDetail = new ArrayList<>();
             Integer statHour = json.getInteger("statHour");
             Integer statHour = json.getInteger("statHour");
             Integer hour;
             Integer hour;
@@ -270,6 +275,7 @@ public class AccountReportServiceImpl implements IAccountReportService {
                 }
                 }
                 JSONObject chainRatioJson = new JSONObject();
                 JSONObject chainRatioJson = new JSONObject();
                 accountDetail = accountReportMapper.selectReportDetailGroupAccountId(nowDate, accountIds, hour);
                 accountDetail = accountReportMapper.selectReportDetailGroupAccountId(nowDate, accountIds, hour);
+                statDate = nowDate;
                 JSONObject nowAccountSummary = accountReportMapper.selectSummaryByAccountId(nowDate, accountIds, hour, discount);
                 JSONObject nowAccountSummary = accountReportMapper.selectSummaryByAccountId(nowDate, accountIds, hour, discount);
                 if (!Check.isNull(nowAccountSummary)) {
                 if (!Check.isNull(nowAccountSummary)) {
                     returnJson.put("now", nowAccountSummary);
                     returnJson.put("now", nowAccountSummary);
@@ -493,33 +499,82 @@ public class AccountReportServiceImpl implements IAccountReportService {
                     }
                     }
                 }
                 }
             } else if (type == 2) {
             } else if (type == 2) {
+                queryMap.put("statDate", anotherDay);
+                queryMap.put("accountIds", accountIds);
+                JSONObject ratioJson;
                 if (Check.isNull(statHour)) {
                 if (Check.isNull(statHour)) {
-                    accountDetail = accountReportMapper.selectReportDetailGroupAccountId(anotherDay, accountIds, 23);
+                    accountDetail = accountReportMapper.selectReportDetailGroupAccountIdByDate(anotherDay, accountIds);
+                    statDate = anotherDay;
+                    ratioJson = accountReportMapper.selectSummaryByMap(queryMap);
+
                 } else {
                 } else {
                     accountDetail = accountReportMapper.selectReportDetailGroupAccountId(anotherDay, accountIds, statHour);
                     accountDetail = accountReportMapper.selectReportDetailGroupAccountId(anotherDay, accountIds, statHour);
+                    queryMap.put("statHour", statHour);
+                    statDate = anotherDay;
+                    ratioJson = accountReportMapper.selectHourSummaryByMap(queryMap);
                 }
                 }
+
+                returnJson.put("ratioJson", ratioJson);
             } else if (type == 3) {
             } else if (type == 3) {
                 String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
                 String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
                 accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
                 accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
+                statDate = endDate + " ~ " + anotherDay;
+
+
+                queryMap.put("startDate", endDate);
+                queryMap.put("endDate", anotherDay);
+                queryMap.put("accountIds", accountIds);
+
+
             } else if (type == 4) {
             } else if (type == 4) {
                 String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
                 String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
                 accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
                 accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
+                statDate = endDate + " ~ " + anotherDay;
+                queryMap.put("startDate", endDate);
+                queryMap.put("endDate", anotherDay);
+                queryMap.put("accountIds", accountIds);
+
             } else if (type == 5) {
             } else if (type == 5) {
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
                 accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
                 accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
+                statDate = endDate + " ~ " + anotherDay;
+                queryMap.put("startDate", endDate);
+                queryMap.put("endDate", anotherDay);
+                queryMap.put("accountIds", accountIds);
             } else if (type == 6) {
             } else if (type == 6) {
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
                 accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
                 accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
+                statDate = endDate + " ~ " + anotherDay;
+                queryMap.put("startDate", endDate);
+                queryMap.put("endDate", anotherDay);
+                queryMap.put("accountIds", accountIds);
             } else if (type == 7) {
             } else if (type == 7) {
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
                 accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
                 accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
+                statDate = endDate + " ~ " + anotherDay;
+                queryMap.put("startDate", endDate);
+                queryMap.put("endDate", anotherDay);
+                queryMap.put("accountIds", accountIds);
             } else if (type == 8) {
             } else if (type == 8) {
                 accountDetail = accountReportMapper.selectAccountReport(accountIds, discount);
                 accountDetail = accountReportMapper.selectAccountReport(accountIds, discount);
+                statDate = "合计";
+                queryMap.put("accountIds", accountIds);
             } else if (type == 9) {
             } else if (type == 9) {
                 String startDate = json.getString("startDate");
                 String startDate = json.getString("startDate");
                 String endDate = json.getString("endDate");
                 String endDate = json.getString("endDate");
                 accountDetail = accountReportMapper.selectAccountReportByDate(startDate, endDate, accountIds, discount);
                 accountDetail = accountReportMapper.selectAccountReportByDate(startDate, endDate, accountIds, discount);
+                statDate = endDate + " ~ " + startDate;
+                queryMap.put("startDate", endDate);
+                queryMap.put("endDate", startDate);
+                queryMap.put("accountIds", accountIds);
             }
             }
+
+            if ((type != 1 && type != 2) && type != null) {
+                JSONObject ratioJson = accountReportMapper.selectSummaryByMap(queryMap);
+                returnJson.put("ratioJson", ratioJson);
+            }
+
+            returnJson.put("statDate", statDate);
             returnJson.put("accountDetail", accountDetail);
             returnJson.put("accountDetail", accountDetail);
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();

+ 2 - 1
module-toutiao/src/main/resources/bytedance_config.properties

@@ -1,6 +1,8 @@
 #release
 #release
 bytedance_appid=1635316529903624
 bytedance_appid=1635316529903624
+# bytedance_appid=1634953881401358
 bytedance_secret=0c51523e90d6166418fc8421a4896808e90e26f4
 bytedance_secret=0c51523e90d6166418fc8421a4896808e90e26f4
+# bytedance_secret=34bc59f53955c66871ce111a1f15a6051cfa3f12
 #release
 #release
 bytedance_api_url=https://ad.oceanengine.com/open_api
 bytedance_api_url=https://ad.oceanengine.com/open_api
 bytedance_auth_url=https://ad.oceanengine.com/openapi
 bytedance_auth_url=https://ad.oceanengine.com/openapi
@@ -22,7 +24,6 @@ bytedance_v2_campaign_update=/2/campaign/update
 bytedance_v2_dmp_custom_audience_select=/2/dmp/custom_audience/select/
 bytedance_v2_dmp_custom_audience_select=/2/dmp/custom_audience/select/
 bytedance_v2_file_video_ad=/2/file/video/ad/
 bytedance_v2_file_video_ad=/2/file/video/ad/
 bytedance_v2_file_image_ad=/2/file/image/ad/
 bytedance_v2_file_image_ad=/2/file/image/ad/
-
 bytedance_v2_creative_update_status=/2/creative/update/status/
 bytedance_v2_creative_update_status=/2/creative/update/status/
 bytedance_v2_creative_material_get=/2/creative/material/read
 bytedance_v2_creative_material_get=/2/creative/material/read
 bytedance_v2_creative_create_v2=/2/creative/create_v2/
 bytedance_v2_creative_create_v2=/2/creative/create_v2/