Selaa lähdekoodia

修改token获取代码逻辑

syh 4 vuotta sitten
vanhempi
commit
9136f680bc

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/JeecgOneGui.java

@@ -16,5 +16,6 @@ public class JeecgOneGui {
     public static void main(String[] args) {
         new CodeWindow().pack();
     }
-
 }
+
+

+ 15 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BindAccountLoginController.java

@@ -4,6 +4,7 @@ import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.StringUtils;
@@ -45,7 +46,8 @@ public class BindAccountLoginController {
     private UserAllocationMapper userAllocationMapper;
     @Autowired
     private ICreateInternalService createInternalService;
-
+    @Autowired
+    private ISysRoleService sysRoleService;
     /**
      * @param json
      * @return
@@ -123,9 +125,20 @@ public class BindAccountLoginController {
                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                          HttpServletRequest req) {
         Result<IPage<BindAccountLogin>> result = new Result<>();
+        String accountName = bindAccountLogin.getAccountName();
+        String loginType = bindAccountLogin.getLoginType();
+        bindAccountLogin.setAccountName(null);
+        bindAccountLogin.setLoginType(null);
         QueryWrapper<BindAccountLogin> queryWrapper = QueryGenerator.initQueryWrapper(bindAccountLogin, req.getParameterMap());
+        if(null!=accountName&&!"".equals(accountName.trim())){
+            queryWrapper.like("account_name",accountName);
+        }
+        if(null != loginType&&!"".equals(loginType.trim())&&!"none".equals(loginType)){
+            queryWrapper.eq("login_type",loginType);
+        }
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        if (!Check.isNull(user)) {
+        String roleCode = sysRoleService.getRoleCodeByUserId(user.getId());
+        if(!roleCode.equals("admin")){
             queryWrapper.eq("user_id", user.getId());
         }
         queryWrapper.orderByDesc("id");

+ 3 - 5
module-common/src/main/java/cn/com/ctop/common/module/entity/BindAccountLogin.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.common.module.entity;
 
+import cn.com.ctop.common.module.annotation.Dict;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -51,11 +52,8 @@ public class BindAccountLogin {
     @Excel(name = "平台账户id", width = 15)
     @ApiModelProperty(value = "平台账户id")
     private String accountId;
-    /**
-     * 广告id
-     */
-    @Excel(name = "用户Id", width = 15)
-    @ApiModelProperty(value = "用户id")
+
+    @Dict(dicCode = "id",dictTable="sys_user",dicText="realname")
     private String userId;
     /**
      * 账号

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java

@@ -33,4 +33,6 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
     List<CtopOauthToken> getToutiaoTokenByCreateTime(String createTime);
 
     List<CtopOauthToken> getByProjectId(long projectId);
+
+    CtopOauthToken selectOneByMediaId(String platformTypeKuaishou);
 }

+ 9 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -219,6 +219,15 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
         return this.list(queryWrapper);
     }
 
+    @Override
+    public CtopOauthToken selectOneByMediaId(String platformTypeKuaishou) {
+        QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+        tokenQueryWrapper.eq("media_id", platformTypeKuaishou);
+        tokenQueryWrapper.orderByDesc("create_time");
+        tokenQueryWrapper.last("limit 1");
+        return this.getOne(tokenQueryWrapper);
+    }
+
     private Date addSecond(Date date, int seconds) {
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(date);

+ 30 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyFlowsJob.java

@@ -0,0 +1,30 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public class KuaishouDailyFlowsJob {
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+    @XxlJob("kuaishouDailyFlowsJob")
+    public ReturnT<String> execute(String param) {
+        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        if (!Check.isNull(tokens)) {
+            for (CtopOauthToken ctopOauthToken : tokens) {
+                kuaishouInterfaceService.getDailyFlows(ctopOauthToken);
+            }
+        }
+        return ReturnT.SUCCESS;
+    }
+}

+ 31 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouTargetingTagsJob.java

@@ -0,0 +1,31 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class KuaishouTargetingTagsJob {
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    /**
+     * 定时更新 快手 标签
+     * @throws JobExecutionException
+     */
+    @XxlJob("kuaishouTargetingTagsJob")
+    public ReturnT<String> execute(String params)throws Exception {
+        CtopOauthToken token = oauthTokenService.selectOneByMediaId(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+        kuaishouInterfaceService.getTargetingTags(token.getAccountId(), token.getAccessToken());
+        kuaishouInterfaceService.areaList(token.getAccessToken());
+        return ReturnT.SUCCESS;
+    }
+}

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/KuaishouBidWarningServiceImpl.java

@@ -61,6 +61,8 @@ public class KuaishouBidWarningServiceImpl implements IKuaishouBidWarningService
                         List<String> unitWarning = new ArrayList<>();
                         if ("2".equals(userAllocation.getMediaId())) {
                             unitWarning = groupMapper.selectWarningGroup(accountId, maxBid);
+                        }
+                        if (!Check.isNull(unitWarning)) {
                             sendMessage(project.getMediaId(), accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
                         }
                     }

+ 23 - 30
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceBidWarningServiceImpl.java

@@ -4,7 +4,6 @@ import cn.com.ctop.common.module.entity.MailLog;
 import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
-import cn.com.ctop.common.module.service.ICorpFeishuUserService;
 import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.BigDecimalUtil;
@@ -28,8 +27,6 @@ import java.util.List;
 @Slf4j
 public class BytedanceBidWarningServiceImpl implements IBytedanceBidWarningService {
     @Autowired
-    private ICorpFeishuUserService corpFeishuUserService;
-    @Autowired
     private IProjectService projectService;
     @Autowired
     private IUserAllocationService userAllocationService;
@@ -40,46 +37,42 @@ public class BytedanceBidWarningServiceImpl implements IBytedanceBidWarningServi
 
     @Override
     public void bidWarning() {
-        XxlJobLogger.log("---------头条出价预警定时任务开始----------");
+        XxlJobLogger.log("开始头条出价预警定时任务");
         long start = System.currentTimeMillis();
         try {
             List<Project> projects = projectService.list();
-            if (Check.isNull(projects)) {
-                XxlJobLogger.log("查询所属项目为空");
-                return ;
-            }
-            for (Project project : projects) {
-                if (Check.isNull(project)) {
-                    continue;
-                }
-                Long maxBid = project.getMaxBid();
-                Long projectId = project.getId();
-                List<UserAllocation> userAllocations = userAllocationService.getByParams(projectId,null,null);
-                if (Check.isNull(userAllocations)) {
-                    continue;
-                }
-                for (UserAllocation userAllocation : userAllocations) {
-                    if (userAllocation.getAccountStatus() == 1) {
+            if (!Check.isNull(projects)) {
+                for (Project project : projects) {
+                    if (Check.isNull(project)) {
                         continue;
                     }
-                    Long accountId = userAllocation.getAccountId();
-                    List<String> unitWarning = new ArrayList<>();
-                    if ("1".equals(userAllocation.getMediaId())) {
-                        BigDecimal bid = new BigDecimal(maxBid);
-                        BigDecimal bigDecimal = BigDecimalUtil.divideBigDecimal(bid, new BigDecimal(1000));
-                        unitWarning = byteDanceAdvertisePlanService.selectWarningGroup(accountId, bigDecimal);
-                        if (!Check.isNull(unitWarning)) {
-                            sendMessage(project.getMediaId(), accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
+                    Long maxBid = project.getMaxBid();
+                    Long projectId = project.getId();
+                    List<UserAllocation> userAllocations = userAllocationService.getByParams(projectId,null,null);
+                    if (!Check.isNull(userAllocations)) {
+                        for (UserAllocation userAllocation : userAllocations) {
+                            if (userAllocation.getAccountStatus() == 1) {
+                                continue;
+                            }
+                            Long accountId = userAllocation.getAccountId();
+                            List<String> unitWarning = new ArrayList<>();
+                            if ("1".equals(userAllocation.getMediaId())) {
+                                BigDecimal bid = new BigDecimal(maxBid);
+                                BigDecimal bigDecimal = BigDecimalUtil.divideBigDecimal(bid, new BigDecimal(1000));
+                                unitWarning = byteDanceAdvertisePlanService.selectWarningGroup(accountId, bigDecimal);
+                            }
+                            if (!Check.isNull(unitWarning)) {
+                                sendMessage(project.getMediaId(), accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
+                            }
                         }
                     }
                 }
             }
+
             XxlJobLogger.log("头条出价预警定时任务执行完毕,共耗时:{} s", (System.currentTimeMillis() - start) / 1000);
         } catch (Exception e) {
             e.printStackTrace();
         }
-
-
     }
 
     private void sendMessage(String mediaId, Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) {