package cn.com.ctop.kuaishou.modules.batch.service.impl;

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.entity.KuaiShouImageGet;
import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
import cn.com.ctop.kuaishou.modules.batch.entity.kuaishoustrategycampaignRel;
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouStrategyMapper;
import cn.com.ctop.kuaishou.modules.batch.service.*;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxl.job.core.enums.NoEn;
import lombok.extern.slf4j.Slf4j;
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;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 快手-优化评估策略表
 *
 * @author jeecg-boot
 * @version V1.0
 * @date 2020-12-10
 */
@Slf4j
@Service
public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMapper, KuaishouStrategy> implements IKuaishouStrategyService {
    @Autowired
    private KuaishouStrategyMapper kuaishouStrategyMapper;
    @Autowired
    private IKuaishouInterfaceService kuaishouInterfaceService;
    @Autowired
    private IKuaiShouImageGetService imageGetService;
    @Autowired
    private IKuaiShouMaterialUploadService uploadService;
    @Autowired
    private IKuaiShouUpdateService kuaiShouUpdateService;
    @Autowired
    private kuaishoustrategycampaignRelServiceImpl kuaishoustrategycampaignRelService;
    @Autowired
    private ICtopOauthTokenService tokenService;

    @Override
    public Result<?> shutDownPlan(JSONObject data) {
        JSONArray ids = data.getJSONArray("ids");
        Integer state = data.getInteger("state");
        JSONObject obj = new JSONObject();
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = null;
        if (!Check.isNull(sysUser)) {
            userId = sysUser.getId();
        }
        for (Object id : ids) {
            boolean flag = true;
            List<JSONObject> list = null;
            //开启
            if (state == 1) {
                list = kuaishoustrategycampaignRelService.queryPlanIdsByStrategyId(Long.valueOf(id.toString()));
            } else {
                list = kuaishouStrategyMapper.queryPlanIdsByStrategyId(Long.valueOf(id.toString()));
            }
            CtopOauthToken token = tokenService.getTokenByAccountId(list.get(0).getLong("accountId"));
            kuaishoustrategycampaignRel rel = new kuaishoustrategycampaignRel();
            rel.setAccountId(token.getAccountId());
            rel.setStrategyId(Long.valueOf(id.toString()));
            rel.setStrategyState(state.toString());
            for (JSONObject object : list) {
                rel.setId(object.getLong("id"));
                rel.setCampaignId(object.getLong("campaignId"));
                if (flag) {
                    flag = EditAdvertisingPlanStatus(token.getAccessToken(), token.getAccountId(), object.getLong("campaignId"), state, userId, NoEn.NO1.valueInt());
                } else {
                    EditAdvertisingPlanStatus(token.getAccessToken(), token.getAccountId(), object.getLong("campaignId"), state, userId, NoEn.NO1.valueInt());
                }
                kuaishoustrategycampaignRelService.saveOrUpdate(rel);
            }
            if (flag) {
                obj.put(id.toString(), true);
                QueryWrapper<KuaishouStrategy> strategyWrapper = new QueryWrapper<>();
                strategyWrapper.eq("id", id);
                KuaishouStrategy strategy = new KuaishouStrategy();
                strategy.setStrategyState(data.getString("state"));
                kuaishouStrategyMapper.update(strategy, strategyWrapper);
            } else {
                obj.put(id.toString(), false);
            }
        }
        return Result.ok(obj);
    }

    /**
     * @param
     * @return boolean
     * @throws
     * @author ZHAOXA
     */
    private boolean EditAdvertisingPlanStatus(String token, Long accountId, Long campaignId, Integer state, String userId, int count) {
        Map<String, Object> map = kuaiShouUpdateService.updateCampaignStatus(token, accountId, campaignId, state, userId);
        boolean success = (boolean) map.get("success");
        if (!success) {
            if (count < 3) {
                return EditAdvertisingPlanStatus(token, accountId, campaignId, state, userId, ++count);
            }
        }
        return success;
    }

    /**
     * @param oauthToken token签名
     * @param groupJson  广告计划
     * @return void
     * @throws
     * @author ZHAOXA
     */
    public Map<String, Object> createPlanLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
        JSONObject planJson = new JSONObject();
        /**计划类型
         * 2: 提升应用安装
         * 3：获取电商下单
         * 4：推广品牌活动
         * 5：收集销售线索
         * 7：提高应用活跃
         */
        if (Check.isNull(data.getInteger("type"))) {
            return getNullValueResult("广告组必填参数：type，计划类型为空");
        } else {
            planJson.put("type", data.getInteger("type"));
        }
        //单日预算金额
        if (!Check.isNull(data.getLong("dayBudget"))) {
            planJson.put("day_budget", data.getLong("dayBudget"));
        }
        //分日预算
        if (!Check.isNull(data.getJSONArray("dayBudgetSchedule"))) {
            planJson.put("day_budget_schedule", data.getJSONArray("dayBudgetSchedule"));
        }
        return kuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), planJson);
    }

    @Override
    public List<Long> queryActiveAccount() {
        return kuaishouStrategyMapper.queryActiveAccount();
    }

    public JSONArray createGroupLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
        JSONArray resultArr = new JSONArray();
        JSONArray groupInfo = data.getJSONArray("groupInfo");
        for (int i = 0; i < groupInfo.size(); i++) {
            Map<String, Object> resutlGroupMap = new HashMap<>();
            JSONObject groupJson = groupInfo.getJSONObject(i);
            try {
                resutlGroupMap = createGroupLevelAd(oauthToken, groupJson);
            } catch (Exception e) {
                log.error("unitName:{}，根据策略创建广告组异常", groupJson.get("unitName"), e);
            }
            if (!Check.isNull(resutlGroupMap)) {
                resutlGroupMap.put("unitName", groupJson.getString("unitName"));
                if ((boolean) resutlGroupMap.get("success")) {
                    JSONArray creativeInfo = groupJson.getJSONArray("creativeInfo");
                    if (Check.isNull(creativeInfo)) {
                        resutlGroupMap.put("desc", "入参数据缺失创意级信息，仅创建计划成功");
                    } else {
                        JSONArray resultCretiveList = new JSONArray();
                        for (int j = 0; j < creativeInfo.size(); j++) {
                            Map<String, Object> creativeMap = new HashMap<>();
                            JSONObject creativeJson = creativeInfo.getJSONObject(i);
                            creativeMap.put("creativeName", creativeJson.getString("creativeName"));
                            creativeJson.put("unitId", resutlGroupMap.get("unitId"));
                            try {
                                creativeMap = createCreativeLevelStrategy(oauthToken, creativeJson);
                            } catch (Exception e) {
                                log.error("unitId:{}，根据策略创建广告创意异常", resutlGroupMap.get("unitId"), e);
                            }
                            resultCretiveList.add(creativeMap);
                        }
                        resutlGroupMap.put("resultCretiveList", resultCretiveList);
                    }
                }
            }
            resultArr.add(resutlGroupMap);
        }
        return resultArr;
    }


    /**
     * 根据策略创建广告组
     *
     * @param oauthToken token签名
     * @param groupJson  广告计划
     * @return void
     * @throws
     * @author ZHAOXA
     */
    private Map<String, Object> createGroupLevelAd(CtopOauthToken oauthToken, JSONObject groupJson) throws Exception {
        JSONObject unitJson = new JSONObject();
        //广告计划ID
        if (!Check.isNull(groupJson.getLong("campaignId"))) {
            unitJson.put("campaign_id", groupJson.getLong("campaignId"));
        } else {
            return getNullValueResult("广告组必填参数：campaign_id，广告计划ID为空");
        }
        //广告组名称
        if (!Check.isNull(groupJson.getString("unitName"))) {
            unitJson.put("unit_name", groupJson.getString("unitName"));
        } else {
            return getNullValueResult("广告组必填参数：unit_name，广告组名称为空");
        }
        // 优化目标出价类型
        if (!Check.isNull(groupJson.getInteger("bidType"))) {
            unitJson.put("bid_type", groupJson.getInteger("bidType"));
        } else {
            return getNullValueResult("广告组必填参数：bid_type，优化目标出价类型为空");
        }
        /* 资源位置
        1：优选广告位
        3：视频播放页广告-便利贴广告（不支持深度转化目标的优化）；
        5：联盟广告，与其他类型互斥
        6：上下滑大屏广告；
        7：信息流广告；
        3、6、7可多选*/
        Integer sceneId = groupJson.getJSONArray("sceneId").getInteger(0);
        if (!Check.isNull(groupJson.getJSONArray("sceneId"))) {
            unitJson.put("scene_id", groupJson.getJSONArray("sceneId"));
        } else {
            return getNullValueResult("广告组必填参数：scene_id，资源位置为空");
        }
        // 资源创作方式  4: 自定义；5：程序化创意  7：程序化创意2.0
        if (!Check.isNull(groupJson.getInteger("unitType"))) {
            unitJson.put("unit_type", groupJson.getInteger("unitType"));
        } else {
            return getNullValueResult("广告组必填参数：unit_type，资源创作方式为空");
        }
        // 创意展现方式 1-轮播 2-优选
        if (!Check.isNull(groupJson.getInteger("showMode"))) {
            unitJson.put("show_mode", groupJson.getInteger("showMode"));
        } else {
            return getNullValueResult("广告组必填参数：show_mode，创意展现方式为空");
        }
        /**
         投放方式
         1 - 加速投放
         2 - 平滑投放
         3-优先低成本（投放时间范围只可为全天；预算不可为不限或空）
         */
        if (!Check.isNull(groupJson.getInteger("speed"))) {
            unitJson.put("speed", groupJson.getInteger("speed"));
        } else {
            return getNullValueResult("广告组必填参数：speed，投放方式为空");
        }
        // 封面点击出价
        if (!Check.isNull(groupJson.getLong("bid"))) {
            unitJson.put("bid", groupJson.getLong("bid"));
        }
        // 深度转化出价
        if (!Check.isNull(groupJson.getLong("cpaBid"))) {
            unitJson.put("cpa_bid", groupJson.getLong("cpaBid"));
        }
        // 深度转化目标出价
        if (!Check.isNull(groupJson.getLong("deepConversionBid"))) {
            unitJson.put("deep_conversion_bid", groupJson.getLong("deepConversionBid"));
        }
        // 深度转化目标
        if (!Check.isNull(groupJson.getInteger("deepConversionType"))) {
            unitJson.put("deep_conversion_type", groupJson.getInteger("deepConversionType"));
        }
        // 优化目标
        if (!Check.isNull(groupJson.getInteger("ocpxActionType"))) {
            unitJson.put("ocpx_action_type", groupJson.getInteger("ocpxActionType"));
        }
        //投放开始时间
        if (!Check.isNull(groupJson.getString("beginTime"))) {
            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
            boolean beginTimeBoolean = DateUtils.compare(groupJson.getString("beginTime"), nowDate);
            if (beginTimeBoolean) {
                unitJson.put("begin_time", nowDate);
            } else {
                unitJson.put("begin_time", groupJson.getString("beginTime"));
            }
        } else {
            return getNullValueResult("广告组必填参数：begin_time，投放开始时间为空");
        }
        // 投放结束时间
        if (!Check.isNull(groupJson.getString("endTime"))) {
            unitJson.put("end_time", groupJson.getString("beginTime"));
        }
        // 投放时间段
        if (!Check.isNull(groupJson.getString("scheduleTime"))) {
            unitJson.put("schedule_time", groupJson.getString("scheduleTime"));
        }
        //定向模板id(选)
        if (!Check.isNull(groupJson.getLong("templateId"))) {
            unitJson.put("template_id", groupJson.getLong("templateId"));
        }
        // 优先从系统应用商店下载 1：优先从系统应用商店下载使用，默认0
        if (!Check.isNull(groupJson.getInteger("useAppMarket"))) {
            unitJson.put("use_app_market", groupJson.getInteger("useAppMarket"));
        }
         /*应用商店列表
          华为：huawei,
          OPPO：oppo
          VIVO：vivo
         小米：xiaomi
         魅族：meizu
         锤子：smartisan*/
        if (!Check.isNull(groupJson.getJSONArray("appStore"))) {
            unitJson.put("app_store", groupJson.getJSONArray("appStore"));
        }
        // 转化目标id
        if (!Check.isNull(groupJson.getInteger("convertId"))) {
            unitJson.put("convert_id", groupJson.getInteger("convertId"));
        }
        // 广告组单日预算 指定0表示预算不限，默认为0；不小于100元，不超过100000000元，仅支持输入数字；
        if (!Check.isNull(groupJson.getLong("dayBudget"))) {
            unitJson.put("day_budget", groupJson.getLong("dayBudget"));
        }
        // url类型
        if (!Check.isNull(groupJson.getInteger("urlType"))) {
            unitJson.put("url_type", groupJson.getInteger("urlType"));
        }
        // url类型
        if (!Check.isNull(groupJson.getString("webUriType"))) {
            unitJson.put("web_uri_type", groupJson.getString("webUriType"));
        }
        // url
        if (!Check.isNull(groupJson.getString("url"))) {
            unitJson.put("url", groupJson.getString("url"));
        }
        // appId
        if (!Check.isNull(groupJson.getLong("appId"))) {
            unitJson.put("app_id", groupJson.getLong("appId"));
        }
        // 预约广告 1:IOS预约 缺省为不传或传0
        if (!Check.isNull(groupJson.getLong("siteType"))) {
            unitJson.put("site_type", groupJson.getLong("siteType"));
        }
        // 游戏礼包码
        if (!Check.isNull(groupJson.getLong("giftData"))) {
            unitJson.put("gift_data", groupJson.getLong("giftData"));
        }
        // -----------------用户定向-----------
        JSONObject targetJson = new JSONObject();
        // 地域
        if (!Check.isNull(groupJson.getJSONArray("region"))) {
            targetJson.put("region", groupJson.getJSONArray("region"));
        }
        // 自定义年龄段
        JSONArray ageArr = groupJson.getJSONArray("age");
        if (!Check.isNull(ageArr)) {
            JSONObject ageJson = new JSONObject();
            ageJson.put("min", ageArr.get(0));
            ageJson.put("max", ageArr.get(1));
            targetJson.put("age", ageJson);
        }
        // 固定年龄段
        if (!Check.isNull(groupJson.getJSONArray("agesRange"))) {
            targetJson.put("ages_range", groupJson.getJSONArray("agesRange"));
        }
        // 性别
        if (!Check.isNull(groupJson.getInteger("gender"))) {
            targetJson.put("gender", groupJson.getInteger("gender"));
        }
        //操作系统
        if (!Check.isNull(groupJson.getInteger("platformOs"))) {
            targetJson.put("platform_os", groupJson.getInteger("platformOs"));
        }
        //Android版本
        if (!Check.isNull(groupJson.getInteger("androidOsv"))) {
            targetJson.put("android_osv", groupJson.getInteger("androidOsv"));
        }
        // iOS版本
        if (!Check.isNull(groupJson.getInteger("iosOsv"))) {
            targetJson.put("ios_osv", groupJson.getInteger("iosOsv"));
        }
        //网络环境
        if (!Check.isNull(groupJson.getInteger("network"))) {
            targetJson.put("network", groupJson.getInteger("network"));
        }
        //设备品牌
        if (!Check.isNull(groupJson.getJSONArray("deviceBrand"))) {
            targetJson.put("device_brand", groupJson.getJSONArray("deviceBrand"));
        }
        //设备价格
        if (!Check.isNull(groupJson.getJSONArray("devicePrice"))) {
            targetJson.put("device_price", groupJson.getJSONArray("devicePrice"));
        }

        if (sceneId != 5) {
            //过滤已转化人群纬度
            if (!Check.isNull(groupJson.getInteger("filterConvertedLevel"))) {
                targetJson.put("filter_converted_level", groupJson.getInteger("filterConvertedLevel"));
            }
            //商业兴趣类型
            if (!Check.isNull(groupJson.getInteger("businessInterestType"))) {
                targetJson.put("business_interest_type", groupJson.getInteger("businessInterestType"));
            }
            // 商业兴趣
            if (!Check.isNull(groupJson.getJSONArray("businessInterest"))) {
                targetJson.put("business_interest", groupJson.getJSONArray("businessInterest"));
            }
            //网红粉丝
            if (!Check.isNull(groupJson.getJSONArray("fansStar"))) {
                targetJson.put("fans_star", groupJson.getJSONArray("fansStar"));
            }
            //兴趣视频用户
            if (!Check.isNull(groupJson.getJSONArray("interestVideo"))) {
                targetJson.put("interest_video", groupJson.getJSONArray("interestVideo"));
            }
            //智能扩量
            JSONObject intelliExtendJson = new JSONObject();
            // 开启智能扩量
            if (!Check.isNull(groupJson.getInteger("isOpen"))) {
                intelliExtendJson.put("is_open", groupJson.getInteger("isOpen"));
            }
            //不可突破年龄
            if (!Check.isNull(groupJson.getInteger("noAgeBreak"))) {
                intelliExtendJson.put("no_age_break", groupJson.getInteger("noAgeBreak"));
            }
            //不可突破性别
            if (!Check.isNull(groupJson.getInteger("noGenderBreak"))) {
                intelliExtendJson.put("no_gender_break", groupJson.getInteger("noGenderBreak"));
            }
            // 不可突破地域
            if (!Check.isNull(groupJson.getInteger("noAreaBreak"))) {
                intelliExtendJson.put("no_area_break", groupJson.getInteger("noAreaBreak"));
            }
            if (!Check.isNull(intelliExtendJson)) {
                targetJson.put("intelli_extend", intelliExtendJson);
            }
        }
        // APP行为-按分类
        if (!Check.isNull(groupJson.getJSONArray("appInterest"))) {
            targetJson.put("app_interest", groupJson.getJSONArray("appInterest"));
        }
        // APP行为-按APP名称
        if (!Check.isNull(groupJson.getJSONArray("appIds"))) {
            targetJson.put("app_ids", groupJson.getJSONArray("appIds"));
        }
        // 人群包定向
        if (!Check.isNull(groupJson.getJSONArray("population"))) {
            targetJson.put("population", groupJson.getJSONArray("population"));
        }
        // 人群包排除
        if (!Check.isNull(groupJson.getJSONArray("excludePopulation"))) {
            targetJson.put("exclude_population", groupJson.getJSONArray("excludePopulation"));
        }

        if (!Check.isNull(groupJson.getJSONArray("thirdPlatformCode"))) {
            targetJson.put("third_platform_code", groupJson.getJSONArray("thirdPlatformCode"));
        }
        unitJson.put("target", targetJson);
        return kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson, 1);
    }


    /**
     * 根据策略创建创意
     *
     * @param
     * @return com.alibaba.fastjson.JSONObject
     * @throws
     * @author ZHAOXA
     */
    private Map<String, Object> createCreativeLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
        Map<String, Object> resultMap = new HashMap<>();
        JSONObject creativeJson = new JSONObject();
        //广告组ID
        if (!Check.isNull(data.get("unitId"))) {
            creativeJson.put("unit_id", data.get("unitId"));
        } else {
            return getNullValueResult("广告创意必填参数：unit_id，广告组ID为空");
        }
        //创意名称
        if (!Check.isNull(data.get("creativeName"))) {
            creativeJson.put("creative_name", data.get("creativeName"));
        } else {
            return getNullValueResult("广告创意必填参数：creative_name，创意名称为空");
        }
        //视频ID
        if (!Check.isNull(data.get("photoId"))) {
            creativeJson.put("photo_id", data.get("photoId"));
        }
        /**
         * 素材类型
         * 1：竖版视频
         * 2：横版视频
         * 4：便利贴单图图片创意
         * 5：竖版图片
         * 6：横版图片
         */
        String creativeMaterialType = data.getString("creativeMaterialType");
        if (!Check.isNull(creativeMaterialType)) {
            creativeJson.put("creative_material_type", creativeMaterialType);
        } else {
            return getNullValueResult("广告创意必填参数：creative_material_type，素材类型为空");
        }
        //行动号召按钮文案
        if (!Check.isNull(data.getString("actionBarText"))) {
            creativeJson.put("action_bar_text", data.getString("actionBarText"));
        } else {
            return getNullValueResult("广告创意必填参数：action_bar_text，行动号召按钮文案为空");
        }
        //广告语
        if (!Check.isNull(data.getString("description"))) {
            creativeJson.put("description", data.getString("description"));
        } else {
            return getNullValueResult("广告创意必填参数：description，广告语为空");
        }
        //便利贴创意短广告语
        if (!Check.isNull(data.getString("shortSlogan"))) {
            creativeJson.put("short_slogan", data.getString("shortSlogan"));
        }
        //封面广告语标题
        if (!Check.isNull(data.getString("stickerTitle"))) {
            creativeJson.put("sticker_title", data.getString("stickerTitle"));
        }
        //贴纸样式类型
        if (!Check.isNull(data.getString("overlayType"))) {
            creativeJson.put("overlay_type", data.getString("overlayType"));
        }
        //广告标签
        if (!Check.isNull(data.getString("exposeTag"))) {
            creativeJson.put("expose_tag", data.getString("exposeTag"));
        }
        //广告标签2期
        if (!Check.isNull(data.getJSONArray("newExposeTag"))) {
            creativeJson.put("new_expose_tag", data.getJSONArray("newExposeTag"));
        }
        //安卓下载中间页ID
        if (!Check.isNull(data.getLong("siteId"))) {
            creativeJson.put("site_id", data.getLong("siteId"));
        }
        String imageToken = null;
        String signature = data.getString("signature");
        if (!Check.isNull(signature)) {
            QueryWrapper<KuaiShouImageGet> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("account_id", oauthToken.getAccountId());
            queryWrapper.eq("signature", signature);
            queryWrapper.last("limit 1");
            KuaiShouImageGet imageGet = imageGetService.getOne(queryWrapper);
            if (!Check.isNull(imageGet)) {
                imageToken = imageGet.getImageToken();
            } else {
                String url = imageGetService.getUrlByCode(signature);
                imageToken = uploadService.kuauiShouImageUpload(url, signature, oauthToken.getAccountId(), oauthToken.getAccessToken());
            }
            if (Check.isNull(imageToken)) {
                resultMap.put("success", false);
                resultMap.put("creativeName", data.get("creativeName"));
                resultMap.put("message", "获取图片文件失败");
                return resultMap;
            }
        }
        JSONArray tokenArr = new JSONArray();
        //封面图片token
        creativeJson.put("image_token", imageToken);
        //便利贴单图图片创意token
        tokenArr.add(imageToken);
        creativeJson.put("image_tokens", tokenArr);
        if (!Check.isNull(data.getString("clickTrackUrl"))) {
            //第三方点击检测链接
            creativeJson.put("click_track_url", data.getString("clickTrackUrl"));
            //第三方开始播放监测链接
            creativeJson.put("impression_url", data.getString("clickTrackUrl"));
        }
        //第三方有效播放监测链接
        if (!Check.isNull(data.getString("adPhotoPlayedT3sUrl"))) {
            creativeJson.put("ad_photo_played_t3s_url", data.getString("adPhotoPlayedT3sUrl"));
        }
        //第三方点击按钮监测链接
        if (!Check.isNull(data.getString("actionbarClickUrl"))) {
            creativeJson.put("actionbar_click_url", data.getString("actionbarClickUrl"));
        }
        //创意分类
        if (!Check.isNull(data.getString("creativeCategory"))) {
            creativeJson.put("creative_category", data.getString("creativeCategory"));
        }
        //创意标签
        if (!Check.isNull(data.getString("creativeTag"))) {
            creativeJson.put("creative_tag", data.getString("creative_tag"));
        }
        return kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), creativeJson, 1);
    }

    private Map<String, Object> getNullValueResult(String msg) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", -1);
        map.put("message", "error");
        map.put("desc", msg);
        map.put("success", false);
        return map;
    }

}
