|
@@ -1,7 +1,13 @@
|
|
|
package cn.com.ctop.kuaishou.modules.report.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
+import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
|
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly;
|
|
|
import cn.com.ctop.kuaishou.modules.report.enums.CheckParametersEnum;
|
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouReportAccountDailyMapper;
|
|
@@ -10,7 +16,9 @@ import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportHourlyAccountMap
|
|
|
import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouReportAccountHourlyService;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -32,12 +40,20 @@ public class EtlKuaishouReportAccountHourlyServiceImpl extends ServiceImpl<EtlKu
|
|
|
|
|
|
@Autowired
|
|
|
private KuaishouReportHourlyAccountMapper hourlyAccountMapper;
|
|
|
+ @Autowired
|
|
|
+ private KuaiShouCreativeMapper kuaiShouCreativeMapper;
|
|
|
+ @Autowired
|
|
|
+ private UserAllocationMapper allocationMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private EtlKuaishouReportAccountHourlyMapper etlHourlyAccountMapper;
|
|
|
|
|
|
@Autowired
|
|
|
+ private IKuaishouInterfaceService iKuaishouInterfaceService;
|
|
|
+ @Autowired
|
|
|
private EtlKuaishouReportAccountDailyMapper etlDailyAccountMapper;
|
|
|
+ @Autowired
|
|
|
+ private ICtopOauthTokenService oauthTokenService;
|
|
|
|
|
|
@Override
|
|
|
public void queryEveryhourlyDataForAccount() {
|
|
@@ -121,8 +137,29 @@ public class EtlKuaishouReportAccountHourlyServiceImpl extends ServiceImpl<EtlKu
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result<Object> getMaxChargeAccountId() {
|
|
|
- Long accountId = etlDailyAccountMapper.getMaxChargeAccountId();
|
|
|
- return Result.ok(accountId);
|
|
|
+ public Result<Object> getMaxChargeAccountId(Long accountId) {
|
|
|
+ if (Check.isNull(accountId)) {
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ accountId = etlDailyAccountMapper.getMaxChargeAccountId(sysUser.getId());
|
|
|
+ }
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
+ if (Check.isNull(oauthToken)) {
|
|
|
+ log.warn("未获取到账户信息");
|
|
|
+ }
|
|
|
+ JSONObject fundJson = iKuaishouInterfaceService.fundGet(oauthToken);
|
|
|
+ if (!Check.isNull(fundJson)) {
|
|
|
+ obj.put("totalBalance", fundJson.getBigDecimal("balance")); // 余额
|
|
|
+ }
|
|
|
+ UserAllocation userAllocation = allocationMapper.getUserAllocation(accountId);
|
|
|
+ if (!Check.isNull(userAllocation)) {
|
|
|
+ obj.put("accountId", userAllocation.getAccountId());
|
|
|
+ obj.put("accountName", userAllocation.getAuthName());
|
|
|
+ obj.put("status", userAllocation.getAccountStatus());
|
|
|
+ obj.put("statusStr", userAllocation.getAccountStatus() == 0 ? "投放中" : "无效");
|
|
|
+ }
|
|
|
+ Integer counts = kuaiShouCreativeMapper.getRejectedCountsforAccountId(accountId);
|
|
|
+ obj.put("rejectedCounts", counts);
|
|
|
+ return Result.ok(obj);
|
|
|
}
|
|
|
}
|