|
@@ -2,8 +2,12 @@ package cn.com.ctop.bytedance.service.impl;
|
|
|
|
|
|
import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
|
|
|
import cn.com.ctop.bytedance.service.IMaterialReportService;
|
|
|
+import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -21,6 +25,9 @@ public class MaterialReportServiceImpl implements IMaterialReportService {
|
|
|
@Autowired
|
|
|
private MaterialReportMapper materialReportMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserAllocationMapper userAllocationMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public String getRoleCodeByUserId(String userId) {
|
|
|
return materialReportMapper.getRoleCodeByUserId(userId);
|
|
@@ -142,10 +149,14 @@ public class MaterialReportServiceImpl implements IMaterialReportService {
|
|
|
return null;
|
|
|
}
|
|
|
Integer type = json.getInteger("type");
|
|
|
+ String accountId = json.getString("accountId");
|
|
|
String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
|
|
|
Map<String, Object> paramsMap = new HashMap<>();
|
|
|
paramsMap.put("signature", signature);
|
|
|
+ if (!Check.isNull(accountId)) {
|
|
|
+ paramsMap.put("accountId", accountId);
|
|
|
+ }
|
|
|
String beContrastDate = "";
|
|
|
String contrastStartDate = "";
|
|
|
String beContrastStartDate = "";
|
|
@@ -430,4 +441,119 @@ public class MaterialReportServiceImpl implements IMaterialReportService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询 所有绑定账号
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<UserAllocation> selectAccountIds(String userId) {
|
|
|
+ String roleCode = materialReportMapper.getRoleCodeByUserId(userId);
|
|
|
+ QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("media_id", 2);
|
|
|
+ if ("operator".equals(roleCode)) {
|
|
|
+ queryWrapper.eq("userId", userId);
|
|
|
+ }
|
|
|
+ queryWrapper.isNotNull("account_id");
|
|
|
+ queryWrapper.groupBy("account_id");
|
|
|
+ queryWrapper.orderByAsc("advertiser_name");
|
|
|
+
|
|
|
+ List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
|
|
|
+ return userAllocations;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据账号 查询素材报表
|
|
|
+ *
|
|
|
+ * @param json
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<JSONObject> selectReportByAccountIds(JSONObject json) {
|
|
|
+
|
|
|
+
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+
|
|
|
+ List<JSONObject> marketJsonList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ if (Check.isNull(json)) {
|
|
|
+ return marketJsonList;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray accountIds = json.getJSONArray("accountIds");
|
|
|
+ if (Check.isNull(accountIds)) {
|
|
|
+ return marketJsonList;
|
|
|
+ }
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
+ String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
|
|
|
+ Integer type = json.getInteger("type");
|
|
|
+
|
|
|
+ Map<String, Object> paramsMap = new HashMap<>();
|
|
|
+ paramsMap.put("accountIds", accountIds);
|
|
|
+ if (type == 1) { // 今天分时数据
|
|
|
+ Integer maxHour = materialReportMapper.selectMaxHourByDate(nowDate);
|
|
|
+ if (Check.isNull(maxHour) || maxHour == 0) {
|
|
|
+ return marketJsonList;
|
|
|
+ }
|
|
|
+ Integer statHour = maxHour - 1;
|
|
|
+ paramsMap.put("statHour", statHour);
|
|
|
+ paramsMap.put("statDate", nowDate);
|
|
|
+ marketJsonList = materialReportMapper.selectHourMaterialList(paramsMap);
|
|
|
+
|
|
|
+ } else if (type == 2) {
|
|
|
+ paramsMap.put("startDate", anotherDay);
|
|
|
+ paramsMap.put("endDate", anotherDay);
|
|
|
+ marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
|
|
|
+
|
|
|
+ } else if (type == 3) {
|
|
|
+ String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
|
|
|
+ paramsMap.put("startDate", startDate);
|
|
|
+ paramsMap.put("endDate", anotherDay);
|
|
|
+ marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
|
|
|
+
|
|
|
+ } else if (type == 4) {
|
|
|
+ String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
|
|
|
+ paramsMap.put("startDate", startDate);
|
|
|
+ paramsMap.put("endDate", anotherDay);
|
|
|
+ marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
|
|
|
+
|
|
|
+ } else if (type == 5) {// 近一个月
|
|
|
+ String startDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
|
|
|
+ paramsMap.put("startDate", startDate);
|
|
|
+ paramsMap.put("endDate", anotherDay);
|
|
|
+ marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
|
|
|
+
|
|
|
+ } else if (type == 6) {// 近三个月
|
|
|
+ String startDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
|
|
|
+ paramsMap.put("startDate", startDate);
|
|
|
+ paramsMap.put("endDate", anotherDay);
|
|
|
+ marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
|
|
|
+
|
|
|
+ } else if (type == 7) {// 近六个月
|
|
|
+ String startDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
|
|
|
+ paramsMap.put("startDate", startDate);
|
|
|
+ paramsMap.put("endDate", anotherDay);
|
|
|
+ marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
|
|
|
+
|
|
|
+ } else if (type == 9) { // 自定义查询日期
|
|
|
+ String startDate = json.getString("startDate");
|
|
|
+ String endDate = json.getString("endDate");
|
|
|
+ paramsMap.put("startDate", startDate);
|
|
|
+ paramsMap.put("endDate", endDate);
|
|
|
+ marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("账户维度素材数据请求所用时长------------->: {} ms", System.currentTimeMillis() - startTime);
|
|
|
+ return marketJsonList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|