|
@@ -144,7 +144,6 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public JSONObject createUnit(JSONObject requestJson) throws Exception {
|
|
public JSONObject createUnit(JSONObject requestJson) throws Exception {
|
|
- System.err.println(requestJson);
|
|
|
|
Long accountId = requestJson.getLong("accountId");
|
|
Long accountId = requestJson.getLong("accountId");
|
|
CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
if (Check.isNull(oauthToken)) {
|
|
if (Check.isNull(oauthToken)) {
|
|
@@ -152,15 +151,16 @@ public class BatchServiceImpl implements IBatchService {
|
|
}
|
|
}
|
|
|
|
|
|
JSONObject unitJson = new JSONObject();
|
|
JSONObject unitJson = new JSONObject();
|
|
- String type = requestJson.getString("type");
|
|
|
|
|
|
|
|
Long campaignId = requestJson.getLong("campaignId");
|
|
Long campaignId = requestJson.getLong("campaignId");
|
|
if (Check.isNull(campaignId)) {
|
|
if (Check.isNull(campaignId)) {
|
|
throw new Exception("请选择广告计划");
|
|
throw new Exception("请选择广告计划");
|
|
}
|
|
}
|
|
- Long copyToCampaignId = requestJson.getLong("copyToCampaignId");
|
|
|
|
- if (!Check.isNull(type) && "copy".equals(type)) {
|
|
|
|
- unitJson.put("campaign_id", copyToCampaignId);
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String type = requestJson.getString("type");
|
|
|
|
+ if ("copy".equals(type) && !Check.isNull(type)) {
|
|
|
|
+ unitJson.put("campaign_id", requestJson.getLong("copyToCampaignId"));
|
|
} else {
|
|
} else {
|
|
unitJson.put("campaign_id", campaignId);
|
|
unitJson.put("campaign_id", campaignId);
|
|
}
|
|
}
|
|
@@ -179,7 +179,21 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
|
|
|
//投放开始时间
|
|
//投放开始时间
|
|
if (!Check.isNull(requestJson.getString("beginTime"))) {
|
|
if (!Check.isNull(requestJson.getString("beginTime"))) {
|
|
- unitJson.put("begin_time", requestJson.getString("beginTime"));
|
|
|
|
|
|
+
|
|
|
|
+ if ("copy".equals(type)) {
|
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+ boolean beginTimeBoolean = DateUtils.compare(requestJson.getString("beginTime"), nowDate);
|
|
|
|
+ if (beginTimeBoolean) {
|
|
|
|
+ unitJson.put("begin_time", nowDate);
|
|
|
|
+ } else {
|
|
|
|
+ unitJson.put("begin_time", requestJson.getString("beginTime"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ unitJson.put("begin_time", requestJson.getString("beginTime"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
// 投放结束时间
|
|
// 投放结束时间
|
|
if (!Check.isNull(requestJson.getString("endTime"))) {
|
|
if (!Check.isNull(requestJson.getString("endTime"))) {
|
|
@@ -363,7 +377,7 @@ public class BatchServiceImpl implements IBatchService {
|
|
}
|
|
}
|
|
String unitName = groupJson.getString("unitName");
|
|
String unitName = groupJson.getString("unitName");
|
|
if (!Check.isNull(unitName)) {
|
|
if (!Check.isNull(unitName)) {
|
|
- unitJson.put("unit_name", unitName + RandomUtil.verifyCode());
|
|
|
|
|
|
+ unitJson.put("unit_name", unitName);
|
|
}
|
|
}
|
|
|
|
|
|
Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), accountId, unitJson);
|
|
Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), accountId, unitJson);
|
|
@@ -378,6 +392,7 @@ public class BatchServiceImpl implements IBatchService {
|
|
successJson.put("sceneId", scene_id);
|
|
successJson.put("sceneId", scene_id);
|
|
successJson.put("ocpxActionType", ocpx_action_type);
|
|
successJson.put("ocpxActionType", ocpx_action_type);
|
|
successArr.add(successJson);
|
|
successArr.add(successJson);
|
|
|
|
+
|
|
if (!Check.isNull(type) && "copy".equals(type)) {
|
|
if (!Check.isNull(type) && "copy".equals(type)) {
|
|
Long copyUnitId = requestJson.getLong("copyUnitId");
|
|
Long copyUnitId = requestJson.getLong("copyUnitId");
|
|
if (!Check.isNull(unitId) && !Check.isNull(copyUnitId)) {
|
|
if (!Check.isNull(unitId) && !Check.isNull(copyUnitId)) {
|
|
@@ -425,21 +440,13 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public JSONObject copyUnit(Long accountId, Long campaignId, Long unitId, Long copyToCampaignId) {
|
|
|
|
|
|
+ public JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId) {
|
|
JSONObject returnJson = new JSONObject();
|
|
JSONObject returnJson = new JSONObject();
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
|
- QueryWrapper<KuaiShouGroup> queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.eq("account_id", accountId);
|
|
|
|
- queryWrapper.eq("unit_id", unitId);
|
|
|
|
- KuaiShouGroup group = groupMapper.selectOne(queryWrapper);
|
|
|
|
- if (Check.isNull(group)) {
|
|
|
|
- throw new Exception("未获取到广告组信息");
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
|
|
- CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
|
|
|
+ CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(group.getAccountId());
|
|
if (Check.isNull(oauthToken)) {
|
|
if (Check.isNull(oauthToken)) {
|
|
throw new Exception("未获取到token信息");
|
|
throw new Exception("未获取到token信息");
|
|
}
|
|
}
|
|
@@ -462,7 +469,15 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
|
|
|
//投放开始时间
|
|
//投放开始时间
|
|
if (!Check.isNull(group.getBeginTime())) {
|
|
if (!Check.isNull(group.getBeginTime())) {
|
|
- unitJson.put("begin_time", group.getBeginTime());
|
|
|
|
|
|
+
|
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+ boolean beginTimeBoolean = DateUtils.compare(group.getBeginTime(), nowDate);
|
|
|
|
+ if (beginTimeBoolean) {
|
|
|
|
+ unitJson.put("begin_time", nowDate);
|
|
|
|
+ } else {
|
|
|
|
+ unitJson.put("begin_time", group.getBeginTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
// 投放结束时间
|
|
// 投放结束时间
|
|
if (!Check.isNull(group.getEndTime())) {
|
|
if (!Check.isNull(group.getEndTime())) {
|
|
@@ -498,8 +513,8 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
|
|
|
|
|
|
|
QueryWrapper<KuaiShouGroupTarget> targetQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<KuaiShouGroupTarget> targetQueryWrapper = new QueryWrapper<>();
|
|
- targetQueryWrapper.eq("account_id", accountId);
|
|
|
|
- targetQueryWrapper.eq("unit_id", unitId);
|
|
|
|
|
|
+ targetQueryWrapper.eq("account_id", group.getAccountId());
|
|
|
|
+ targetQueryWrapper.eq("unit_id", group.getUnitId());
|
|
targetQueryWrapper.last("limit 1");
|
|
targetQueryWrapper.last("limit 1");
|
|
KuaiShouGroupTarget groupTarget = targetMapper.selectOne(targetQueryWrapper);
|
|
KuaiShouGroupTarget groupTarget = targetMapper.selectOne(targetQueryWrapper);
|
|
if (!Check.isNull(groupTarget)) {
|
|
if (!Check.isNull(groupTarget)) {
|
|
@@ -645,14 +660,10 @@ public class BatchServiceImpl implements IBatchService {
|
|
}
|
|
}
|
|
String unitName = group.getUnitName();
|
|
String unitName = group.getUnitName();
|
|
if (!Check.isNull(unitName)) {
|
|
if (!Check.isNull(unitName)) {
|
|
- if (campaignId == copyToCampaignId) {
|
|
|
|
- unitJson.put("unit_name", unitName + RandomUtil.verifyCode());
|
|
|
|
- } else {
|
|
|
|
- unitJson.put("unit_name", unitName);
|
|
|
|
- }
|
|
|
|
|
|
+ unitJson.put("unit_name", unitName);
|
|
}
|
|
}
|
|
|
|
|
|
- Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), accountId, unitJson);
|
|
|
|
|
|
+ Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), group.getAccountId(), unitJson);
|
|
if (!Check.isNullMap(returnUnitMap)) {
|
|
if (!Check.isNullMap(returnUnitMap)) {
|
|
Integer code = (Integer) returnUnitMap.get("code");
|
|
Integer code = (Integer) returnUnitMap.get("code");
|
|
if (code == 0) {
|
|
if (code == 0) {
|
|
@@ -665,7 +676,7 @@ public class BatchServiceImpl implements IBatchService {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
try {
|
|
try {
|
|
- copyCreative(accountId, unitId, copyUnitId);
|
|
|
|
|
|
+ copyCreative(group.getAccountId(), group.getUnitId(), copyUnitId);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
@@ -700,7 +711,8 @@ public class BatchServiceImpl implements IBatchService {
|
|
* @param accountId
|
|
* @param accountId
|
|
* @param unitId
|
|
* @param unitId
|
|
*/
|
|
*/
|
|
- private void copyCreative(Long accountId, Long unitId, Long copyUnitId) throws Exception {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void copyCreative(Long accountId, Long unitId, Long copyUnitId) throws Exception {
|
|
// 查询当前复制组下的所有非程序化创意
|
|
// 查询当前复制组下的所有非程序化创意
|
|
|
|
|
|
QueryWrapper<KuaiShouCreative> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<KuaiShouCreative> queryWrapper = new QueryWrapper<>();
|
|
@@ -755,11 +767,7 @@ public class BatchServiceImpl implements IBatchService {
|
|
failArr.add(failJson);
|
|
failArr.add(failJson);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -973,7 +981,16 @@ public class BatchServiceImpl implements IBatchService {
|
|
}
|
|
}
|
|
//投放开始时间
|
|
//投放开始时间
|
|
if (!Check.isNull(requestJson.getString("beginTime"))) {
|
|
if (!Check.isNull(requestJson.getString("beginTime"))) {
|
|
- unitJson.put("begin_time", requestJson.getString("beginTime"));
|
|
|
|
|
|
+
|
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+ boolean beginTimeBoolean = DateUtils.compare(requestJson.getString("beginTime"), nowDate);
|
|
|
|
+ if (beginTimeBoolean) {
|
|
|
|
+ unitJson.put("begin_time", nowDate);
|
|
|
|
+ } else {
|
|
|
|
+ unitJson.put("begin_time", requestJson.getString("beginTime"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
// 投放结束时间
|
|
// 投放结束时间
|
|
if (!Check.isNull(requestJson.getString("endTime"))) {
|
|
if (!Check.isNull(requestJson.getString("endTime"))) {
|