AiBytedanceAdvertiserStrategyController.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. package ctop.bytedance.ad.advertise.controller;
  2. import com.alibaba.dubbo.config.annotation.Reference;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.core.metadata.IPage;
  5. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  6. import ctop.bytedance.ad.advertise.dockapi.MarketingService;
  7. import ctop.bytedance.ad.advertise.entity.AiBytedanceAdvertiserStrategy;
  8. import ctop.bytedance.ad.advertise.entity.RuleDataAccount;
  9. import ctop.bytedance.ad.advertise.entity.UpdAdStaOrCpaOrBudget;
  10. import ctop.bytedance.ad.advertise.service.IAiBytedanceAdvertiserStrategyService;
  11. import ctop.bytedance.ad.advertise.service.IRuleDataAccountService;
  12. import ctop.bytedance.ad.advertise.vo.AdConvertQueryVo;
  13. import ctop.bytedance.ad.advertise.vo.AdGroupSearchVo;
  14. import ctop.bytedance.ad.advertise.vo.PlanSearchVo;
  15. import ctop.bytedance.ad.common.constant.BytedanceConstant;
  16. import ctop.bytedance.ad.common.entity.CtopOauthToken;
  17. import ctop.bytedance.ad.common.entity.MaterialImageInfo;
  18. import ctop.bytedance.ad.common.service.ICtopOauthTokenService;
  19. import ctop.bytedance.ad.common.service.IMaterialImageInfoService;
  20. import ctop.bytedance.ad.common.utils.*;
  21. import io.swagger.annotations.Api;
  22. import io.swagger.annotations.ApiOperation;
  23. import io.swagger.annotations.ApiParam;
  24. import lombok.extern.slf4j.Slf4j;
  25. import org.apache.commons.lang3.StringUtils;
  26. import org.jeecg.common.api.vo.Result;
  27. import org.jeecg.common.system.api.ICommonService;
  28. import org.jeecg.common.system.query.QueryGenerator;
  29. import org.springframework.beans.factory.annotation.Autowired;
  30. import org.springframework.web.bind.annotation.*;
  31. import javax.servlet.http.HttpServletRequest;
  32. import java.math.BigDecimal;
  33. import java.util.Arrays;
  34. import java.util.HashMap;
  35. import java.util.List;
  36. import java.util.Map;
  37. import java.util.concurrent.ExecutorService;
  38. import java.util.concurrent.Executors;
  39. /**
  40. * 头条智能投放账户配置信息表
  41. * @author jeecg-boot
  42. * @date 2021-04-20
  43. * @version V1.0
  44. */
  45. @RestController
  46. @RequestMapping("/advertiser/aiBytedanceAdvertiserStrategy")
  47. @Api(tags="头条智能投放账户配置信息表")
  48. @Slf4j
  49. public class AiBytedanceAdvertiserStrategyController {
  50. @Autowired
  51. private IAiBytedanceAdvertiserStrategyService aiBytedanceAdvertiserStrategyService;
  52. @Autowired
  53. private IRuleDataAccountService ruleDataAccountService;
  54. @Autowired
  55. private IMaterialImageInfoService materialImageInfoService;
  56. @Reference
  57. private ICommonService commonService;
  58. @Autowired
  59. private MarketingService marketingService;
  60. @Autowired
  61. private ICtopOauthTokenService tokenService;
  62. /**
  63. * 分页列表查询
  64. * @param aiBytedanceAdvertiserStrategy
  65. * @param pageNo
  66. * @param pageSize
  67. * @param req
  68. * @return
  69. */
  70. @ApiOperation(value="头条智能投放账户配置信息表-分页列表查询", notes="头条智能投放账户配置信息表-分页列表查询")
  71. @GetMapping(value = "/list")
  72. public Result<IPage<AiBytedanceAdvertiserStrategy>> queryPageList(AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy,
  73. @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
  74. @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
  75. HttpServletRequest req) {
  76. Result<IPage<AiBytedanceAdvertiserStrategy>> result = new Result<>();
  77. QueryWrapper<AiBytedanceAdvertiserStrategy> queryWrapper = QueryGenerator.initQueryWrapper(aiBytedanceAdvertiserStrategy, req.getParameterMap());
  78. //获取用户角色code
  79. String roleCode = commonService.getRoleCodeByUserId(aiBytedanceAdvertiserStrategy.getLoginUserId());
  80. if(null != roleCode && !BytedanceConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)){
  81. queryWrapper.eq("user_id", aiBytedanceAdvertiserStrategy.getLoginUserId());
  82. }
  83. queryWrapper.orderByDesc("create_time");
  84. Page<AiBytedanceAdvertiserStrategy> page = new Page<>(pageNo, pageSize);
  85. //查询
  86. IPage<AiBytedanceAdvertiserStrategy> pageList = aiBytedanceAdvertiserStrategyService.page(page, queryWrapper);
  87. pageList.getRecords().forEach(pojo ->{
  88. if (!Check.isNull(pojo.getAccountId())){
  89. QueryWrapper<RuleDataAccount> ruleDataAccountQueryWrapper = new QueryWrapper<>();
  90. ruleDataAccountQueryWrapper.eq("account_id",pojo.getAccountId());
  91. //获取消耗 余额
  92. RuleDataAccount ruleDataAccountVo = ruleDataAccountService.getOne(ruleDataAccountQueryWrapper);
  93. if (!Check.isNull(ruleDataAccountVo)){
  94. //消耗
  95. pojo.setCost(ruleDataAccountVo.getCost());
  96. //余额
  97. pojo.setValidBalance(ruleDataAccountVo.getValidBalance());
  98. }else {
  99. pojo.setCost(new BigDecimal(0));
  100. pojo.setValidBalance(new BigDecimal(0));
  101. }
  102. //拼接 目标转化出价
  103. pojo.setAdCpaBidStr("FIX".equalsIgnoreCase(pojo.getAdBidCreateType()) ? pojo.getAdCpaBid().toString() : (pojo.getAdMinBid() + "~" + pojo.getAdMaxBid()));
  104. }
  105. });
  106. result.setSuccess(true);
  107. result.setResult(pageList);
  108. return result;
  109. }
  110. /**
  111. * 添加配置信息
  112. * @param aiBytedanceAdvertiserStrategy
  113. * @return
  114. */
  115. @ApiOperation(value="头条智能投放账户配置信息表-添加", notes="头条智能投放账户配置信息表-添加")
  116. @PostMapping(value = "/addBytedanceStrategy")
  117. public Result addBytedanceStrategy(@RequestBody AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy) {
  118. try {
  119. //复制功能 防止前端传id到后台
  120. aiBytedanceAdvertiserStrategy.setId(null);
  121. // 组名称 计划名称 是否重复
  122. /*Result<AiBytedanceAdvertiserStrategy> resultName = aiBytedanceAdvertiserStrategyService.getStrategyInfoByName(aiBytedanceAdvertiserStrategy);
  123. if (!resultName.isSuccess()) {
  124. return Result.error(resultName.getMessage());
  125. }*/
  126. return aiBytedanceAdvertiserStrategyService.addBytedanceStrategy(aiBytedanceAdvertiserStrategy);
  127. } catch (Exception e) {
  128. log.error(e.getMessage(),e);
  129. return Result.error("请求失败,请联系开发人员!");
  130. }
  131. }
  132. /**
  133. * 编辑
  134. * @param aiBytedanceAdvertiserStrategy
  135. * @return
  136. */
  137. @ApiOperation(value="头条智能投放账户配置信息表-编辑", notes="头条智能投放账户配置信息表-编辑")
  138. @PutMapping(value = "/edit")
  139. public Result<AiBytedanceAdvertiserStrategy> edit(@RequestBody AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy) {
  140. // 组名称 计划名称 是否重复
  141. /*
  142. Result<AiBytedanceAdvertiserStrategy> resultName = aiBytedanceAdvertiserStrategyService.getStrategyInfoByName(aiBytedanceAdvertiserStrategy);
  143. if (!resultName.isSuccess()) {
  144. return Result.errorMsg(resultName.getMessage());
  145. }
  146. */
  147. CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(aiBytedanceAdvertiserStrategy.getAccountId()));
  148. //修改后预算金额不能低于当前已消费金额的105%
  149. QueryWrapper<RuleDataAccount> ruleDataAccountQueryWrapper = new QueryWrapper<>();
  150. ruleDataAccountQueryWrapper.eq("account_id",aiBytedanceAdvertiserStrategy.getAccountId());
  151. //获取消耗 余额
  152. RuleDataAccount ruleDataAccountVo = ruleDataAccountService.getOne(ruleDataAccountQueryWrapper);
  153. // 值 为0 不限预算
  154. // !0 指定预算
  155. if (!aiBytedanceAdvertiserStrategy.getAccountBudget().equals(new BigDecimal("0"))){
  156. //花费 0 不校验
  157. int zero= Check.isNull(ruleDataAccountVo) ? 0 : ruleDataAccountVo.getCost().compareTo(BigDecimal.ZERO);
  158. if (zero != 0){
  159. // 前者 < 后者
  160. int a = aiBytedanceAdvertiserStrategy.getAccountBudget().compareTo(ruleDataAccountVo.getCost().multiply(new BigDecimal(1.05)));
  161. if (a == -1){
  162. return Result.errorMsg("预算金额不能低于当前已消费金额的105%");
  163. }
  164. }
  165. }
  166. //不修改用户id
  167. aiBytedanceAdvertiserStrategy.setUserId(null);
  168. //商品卖点
  169. aiBytedanceAdvertiserStrategy.setCreativeProductSellingPoints(StringUtils.join(aiBytedanceAdvertiserStrategy.getProductSellingPoints(), ","));
  170. //广告位置
  171. aiBytedanceAdvertiserStrategy.setCreativeInventoryType(StringUtils.join(aiBytedanceAdvertiserStrategy.getCreativeInventoryTypes(), ","));
  172. //创意标签
  173. aiBytedanceAdvertiserStrategy.setCreativeAdKeywords(StringUtils.join(aiBytedanceAdvertiserStrategy.getAdKeywords(), ","));
  174. AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategyEntity = aiBytedanceAdvertiserStrategyService.getById(aiBytedanceAdvertiserStrategy.getId());
  175. if (aiBytedanceAdvertiserStrategyEntity == null) {
  176. return Result.errorMsg("未找到对应实体");
  177. } else {
  178. boolean ok = aiBytedanceAdvertiserStrategyService.updateById(aiBytedanceAdvertiserStrategy);
  179. if (!ok) {
  180. return Result.errorMsg("修改失败!");
  181. }
  182. //账户预算 同步 头条
  183. //BUDGET_MODE_DAY-日预算
  184. // BUDGET_MODE_INFINITE-不限
  185. String accountBudgetMode = aiBytedanceAdvertiserStrategy.getAccountBudgetMode().equals("1") ? "BUDGET_MODE_INFINITE" : "BUDGET_MODE_DAY";
  186. Result resultBudget = marketingService.updateBudget(token,accountBudgetMode,aiBytedanceAdvertiserStrategy.getAccountBudget());
  187. /*if (!resultBudget.isSuccess()){
  188. return Result.errorMsg(resultBudget.getMessage());
  189. }*/
  190. }
  191. return Result.successMsg("修改成功!", null);
  192. }
  193. /**
  194. * 通过id删除
  195. * @param id
  196. * @return
  197. */
  198. @ApiOperation(value="头条智能投放账户配置信息表-通过id删除", notes="头条智能投放账户配置信息表-通过id删除")
  199. @DeleteMapping(value = "/delete")
  200. public Result<?> delete(@RequestParam(name="id") String id) {
  201. try {
  202. aiBytedanceAdvertiserStrategyService.removeById(id);
  203. } catch (Exception e) {
  204. log.error("删除失败",e);
  205. return Result.error("删除失败!");
  206. }
  207. return Result.successMsg("删除成功!",null);
  208. }
  209. /**
  210. * 批量删除
  211. * @param ids
  212. * @return
  213. */
  214. @ApiOperation(value="头条智能投放账户配置信息表-批量删除", notes="头条智能投放账户配置信息表-批量删除")
  215. @DeleteMapping(value = "/deleteBatch")
  216. public Result<AiBytedanceAdvertiserStrategy> deleteBatch(@RequestParam(name="ids") String ids) {
  217. Result<AiBytedanceAdvertiserStrategy> result = new Result<>();
  218. if(ids==null || "".equals(ids.trim())) {
  219. result.error500("参数不识别!");
  220. }else {
  221. this.aiBytedanceAdvertiserStrategyService.removeByIds(Arrays.asList(ids.split(",")));
  222. result.success("删除成功!");
  223. }
  224. return result;
  225. }
  226. /**
  227. * 通过id查询
  228. * @param id
  229. * @return
  230. */
  231. @ApiOperation(value="头条智能投放账户配置信息表-通过id查询", notes="头条智能投放账户配置信息表-通过id查询")
  232. @GetMapping(value = "/queryById")
  233. public Result<AiBytedanceAdvertiserStrategy> queryById(@RequestParam(name="id",required=true) String id) {
  234. Result<AiBytedanceAdvertiserStrategy> result = new Result<>();
  235. AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy = aiBytedanceAdvertiserStrategyService.getById(id);
  236. if(aiBytedanceAdvertiserStrategy==null) {
  237. result.error500("未找到对应实体");
  238. }else {
  239. //商品卖点
  240. if (!Check.isNull(aiBytedanceAdvertiserStrategy.getCreativeProductSellingPoints())){
  241. aiBytedanceAdvertiserStrategy.setProductSellingPoints(aiBytedanceAdvertiserStrategy.getCreativeProductSellingPoints().split(","));
  242. }
  243. //广告位置
  244. if (!Check.isNull(aiBytedanceAdvertiserStrategy.getCreativeInventoryType())){
  245. aiBytedanceAdvertiserStrategy.setCreativeInventoryTypes(aiBytedanceAdvertiserStrategy.getCreativeInventoryType().split(","));
  246. }
  247. //创意标签
  248. if (!Check.isNull(aiBytedanceAdvertiserStrategy.getCreativeAdKeywords())){
  249. aiBytedanceAdvertiserStrategy.setAdKeywords(aiBytedanceAdvertiserStrategy.getCreativeAdKeywords().split(","));
  250. }
  251. //素材图片url
  252. MaterialImageInfo materialImageInfo = materialImageInfoService.getByCode(aiBytedanceAdvertiserStrategy.getCreativeProductImageCode());
  253. if(null!=materialImageInfo){
  254. aiBytedanceAdvertiserStrategy.setImageUrl(materialImageInfo.getUrl());
  255. }
  256. result.setResult(aiBytedanceAdvertiserStrategy);
  257. result.setSuccess(true);
  258. }
  259. return result;
  260. }
  261. @ApiOperation(value="头条智能投放账户配置信息-修改状态(0开-1关)", notes="头条智能投放账户配置信息-修改状态(0开-1关)")
  262. @PutMapping(value = "/updStaById")
  263. public Result updStaById(@RequestParam("id")String id,
  264. @ApiParam("状态(0开-1关)") @RequestParam("state") String state,
  265. @ApiParam("账户id") @RequestParam("accountId") String accountId,
  266. @ApiParam("素材类型") @RequestParam("creativeImageMode") String creativeImageMode) {
  267. try {
  268. return aiBytedanceAdvertiserStrategyService.updStaById(id,state,accountId,creativeImageMode);
  269. }catch (Exception e){
  270. log.error("修改状态(0开-1关)失败",e);
  271. return Result.error("请求失败,请联系开发人员!");
  272. }
  273. }
  274. @ApiOperation(value="头条智能投放账户配置信息-修改出价;预算", notes="头条智能投放账户配置信息-修改出价;预算")
  275. @PutMapping(value = "/updStaOrCpaOrBudgetById")
  276. public Result updStaOrCpaOrBudgetById(UpdAdStaOrCpaOrBudget updAdStaOrCpaOrBudget) {
  277. try {
  278. return aiBytedanceAdvertiserStrategyService.updStaOrCpaOrBudgetById(updAdStaOrCpaOrBudget);
  279. }catch (Exception e){
  280. log.error("修改出价-预算失败",e);
  281. return Result.error("请求失败,请联系开发人员!");
  282. }
  283. }
  284. @ApiOperation(value="头条智能投放账户配置-获取行业类别", notes="头条智能投放账户配置-获取行业类别")
  285. @GetMapping(value = "/getIndustryList")
  286. public Result getIndustryList(@RequestParam("accountId") String accountId, @RequestParam(value = "type",defaultValue = "ADVERTISER") String type) {
  287. try {
  288. return aiBytedanceAdvertiserStrategyService.getIndustryList(accountId,type);
  289. }catch (Exception e){
  290. log.error("创建失败",e);
  291. return Result.error("请求失败,请联系开发人员!");
  292. }
  293. }
  294. @ApiOperation(value="头条智能投放账户配置-获取广告组", notes="头条智能投放账户配置-获取广告组")
  295. @PostMapping(value = "/getCampaignGroupList")
  296. public Result getCampaignGroup(List<AdGroupSearchVo> adGroupSearchVoList,
  297. @RequestParam("accountId") String accountId,
  298. @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
  299. @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
  300. try {
  301. return aiBytedanceAdvertiserStrategyService.getCampaignGroup(accountId,adGroupSearchVoList,pageNo,pageSize);
  302. }catch (Exception e){
  303. log.error("获取广告组异常。",e);
  304. return Result.error("请求失败,请联系开发人员!");
  305. }
  306. }
  307. @ApiOperation(value="头条智能投放账户配置-获取广告计划", notes="头条智能投放账户配置-获取广告计划")
  308. @PostMapping(value = "/getCampaignPlanList")
  309. public Result getCampaignPlanList(PlanSearchVo planSearchVoList,
  310. @RequestParam("accountId") String accountId,
  311. @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
  312. @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
  313. try {
  314. return aiBytedanceAdvertiserStrategyService.getCampaignPlan(accountId,planSearchVoList,pageNo,pageSize);
  315. }catch (Exception e){
  316. log.error("获取广告计划异常。",e);
  317. return Result.error("请求失败,请联系开发人员!");
  318. }
  319. }
  320. @ApiOperation(value="头条智能投放账户配置-获取创意详细信息", notes="头条智能投放账户配置-获取创意详细信息")
  321. @PostMapping(value = "/creativeReadInfo")
  322. public Result creativeReadInfo(@RequestParam("accountId") String accountId,@RequestParam("adId") String adId) {
  323. try {
  324. return aiBytedanceAdvertiserStrategyService.creativeReadInfo(accountId,adId);
  325. }catch (Exception e){
  326. log.error("获取广告组异常。",e);
  327. return Result.error("请求失败,请联系开发人员!");
  328. }
  329. }
  330. @ApiOperation(value="查询广告计划可用转化目标", notes="查询广告计划可用转化目标")
  331. @PostMapping(value = "/getToolConvert")
  332. public Result getToolConvert(@RequestBody AdConvertQueryVo adConvertQueryVo) {
  333. try {
  334. return aiBytedanceAdvertiserStrategyService.getToolConvert(adConvertQueryVo);
  335. }catch (Exception e){
  336. log.error("查询广告计划可用转化目标异常",e);
  337. return Result.error("请求失败,请联系开发人员!");
  338. }
  339. }
  340. @ApiOperation(value="智能投放测试创建计划", notes="智能投放测试创建计划")
  341. @GetMapping("testCreateCreativeLimit")
  342. public Map<String, Object> testCreateCreativeLimit(Long accountId, Integer hour) {
  343. Map<String, Object> result = new HashMap<>();
  344. List<AiBytedanceAdvertiserStrategy> strategys = aiBytedanceAdvertiserStrategyService.getByAccountId(accountId,0);
  345. strategys.forEach(strategy->{
  346. aiBytedanceAdvertiserStrategyService.customCreativeSupplement(strategy, hour,strategy.getAdOpenUrl());
  347. });
  348. ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
  349. return result;
  350. }
  351. static ExecutorService executorService = Executors.newFixedThreadPool(5);
  352. @GetMapping("autoCreateCreative")
  353. public Map<String, Object> autoCreateCreative(Integer hour) {
  354. Map<String, Object> result = new HashMap<>();
  355. List<AiBytedanceAdvertiserStrategy> strategys = aiBytedanceAdvertiserStrategyService.getByAccountId(null,0);
  356. if (strategys == null||strategys.isEmpty()) {
  357. ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
  358. return result;
  359. }
  360. strategys.forEach(strategy -> executorService.submit(()->{
  361. aiBytedanceAdvertiserStrategyService.customCreativeSupplement(strategy, hour,strategy.getAdOpenUrl());
  362. }));
  363. ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
  364. return result;
  365. }
  366. /**
  367. *
  368. * 根据下载链接获取应用包名
  369. *
  370. * @param urlPath 下载链接
  371. * @return org.jeecg.common.api.vo.Result
  372. * @author zianY
  373. */
  374. @ApiOperation(value="根据下载链接获取应用包名", notes="根据下载链接获取应用包名")
  375. @GetMapping(value = "/getPackageNameByUrl")
  376. public Result getPackageNameByUrl(@RequestParam("urlPath") String urlPath) {
  377. try {
  378. Map<String,Object> map = new HashMap();
  379. //根据下载链接上传附件
  380. urlPath = LoadFileUtil.downLoadFromUrl(urlPath, "appFiles");
  381. // android 根据附件地址 读取 apk 信息
  382. map = ApkUtils.readAPK(urlPath);
  383. if (!map.get("code").toString().equals("-1")){
  384. map.put("platform", "APP_ANDROID");
  385. }else {
  386. //ios
  387. map = ApkUtils.readIPA(urlPath);
  388. if (!map.get("code").toString().equals("-1")){
  389. map.put("platform", "APP_IOS");
  390. }
  391. }
  392. if (map.get("code").toString().equals("-1")){
  393. return Result.error(map.get("error").toString()+"请输入正确的链接。");
  394. }
  395. return Result.successMsg("根据下载链接获取应用包名成功", map);
  396. }catch (Exception e){
  397. log.error("根据下载链接获取应用包名异常",e);
  398. return Result.error("请求失败,请联系开发人员!");
  399. }
  400. }
  401. @ApiOperation(value="获取行动号召", notes="获取行动号召")
  402. @GetMapping(value = "/getAdActionText")
  403. public Result getAdActionText(@RequestParam(value = "accountId",required = false) String accountId,
  404. @RequestParam(value = "landingType",required = false) String landingType,
  405. @RequestParam(value = "advancedCreativeType",required = false) String advancedCreativeType) {
  406. try {
  407. if (Check.isNull(accountId)){
  408. return Result.errorMsg("请选择账户。");
  409. }
  410. if (Check.isNull(landingType)){
  411. return Result.errorMsg("投放内容不能为空");
  412. }
  413. return aiBytedanceAdvertiserStrategyService.getAdActionText(accountId,landingType,advancedCreativeType);
  414. }catch (Exception e){
  415. log.error("获取行动号召异常",e);
  416. return Result.error("请求失败,请联系开发人员!");
  417. }
  418. }
  419. @ApiOperation(value="获取定向包", notes="获取定向包")
  420. @GetMapping(value = "/getAdAudiencePackage")
  421. public Result getAdAudiencePackage(@RequestParam(value = "accountId",required = false) String accountId,
  422. @RequestParam(value = "landingType",required = false) String landingType,
  423. @RequestParam(value = "deliveryRange",required = false) String deliveryRange) {
  424. try {
  425. if (Check.isNull(accountId)){
  426. return Result.errorMsg("请选择账户。");
  427. }
  428. // 默认 定向包
  429. Result resultDefault = aiBytedanceAdvertiserStrategyService.getAdAudiencePackage(accountId,landingType,"DEFAULT");
  430. //穿山甲定向包
  431. Result resultUnion = aiBytedanceAdvertiserStrategyService.getAdAudiencePackage(accountId,landingType,"UNION");
  432. List listDefault = (List) resultDefault.getResult();
  433. List listUnion = (List) resultUnion.getResult();
  434. listDefault.addAll(listUnion);
  435. return Result.successMsg("获取定向包成功。",listDefault);
  436. }catch (Exception e){
  437. log.error("获取定向包异常",e);
  438. return Result.error("请求失败,请联系开发人员!");
  439. }
  440. }
  441. @ApiOperation(value="获取人群包列表信息", notes="获取人群包列表信息")
  442. @GetMapping(value = "/getDMPCustomAudience")
  443. public Result getDMPCustomAudience(@RequestParam(value = "accountId",required = false) String accountId) {
  444. try {
  445. if (Check.isNull(accountId)){
  446. return Result.errorMsg("请选择账户。");
  447. }
  448. return aiBytedanceAdvertiserStrategyService.getDMPCustomAudience(accountId);
  449. }catch (Exception e){
  450. log.error("获取人群包列表异常",e);
  451. return Result.error("请求失败,请联系开发人员!");
  452. }
  453. }
  454. @ApiOperation(value="创建定向包", notes="创建定向包")
  455. @PostMapping(value = "/createAudiencePackage")
  456. public Result createAudiencePackage(@RequestParam("accountId") String accountId) {
  457. try {
  458. return aiBytedanceAdvertiserStrategyService.createAudiencePackage(accountId);
  459. }catch (Exception e){
  460. log.error("创建定向包异常",e);
  461. return Result.error("请求失败,请联系开发人员!");
  462. }
  463. }
  464. @ApiOperation(value="获取橙子建站站点列表", notes="获取橙子建站站点列表")
  465. @GetMapping(value = "/getChengZiSite")
  466. public Result getChengZiSite(@RequestParam("accountId") String accountId) {
  467. try {
  468. return aiBytedanceAdvertiserStrategyService.getChengZiSite(accountId);
  469. }catch (Exception e){
  470. log.error("获取橙子建站站点列表异常",e);
  471. return Result.error("请求失败,请联系开发人员!");
  472. }
  473. }
  474. }