zhaotx 1 ano atrás
pai
commit
ad4e5a0fac

+ 14 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/BytedanceProductUpdateMapper.java

@@ -20,4 +20,18 @@ public interface BytedanceProductUpdateMapper {
     JSONObject getVideoInfo(@Param("videoId") Long videoId);
     List<JSONObject> getVideoDetail(@Param("videoId") Long videoId);
 
+
+    List<Long> getUploadList();
+
+    JSONObject getDeveloperAccount();
+
+    int insertAlbumInfo(@Param("albumId") String albumId,
+                        @Param("videoId") Long videoId);
+
+    List<String> selectWaitingAlbums();
+
+    int updateAlbumInfo(@Param("albumId") String albumId,
+                        @Param("canPromotion") int status,
+                        @Param("cannotReason") String failReason);
+
 }

+ 27 - 3
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/BytedanceProductUpdateMapper.xml

@@ -1,11 +1,22 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="cn.com.ctop.job.bytedance.data.mapper.BytedanceProductUpdateMapper">
+    <insert id="insertAlbumInfo">
+        insert into deepthink.bytedance_upload_album
+        (album_id, ly_video_id)
+        values
+        (#{albumId}, #{videoId})
+    </insert>
     <update id="updateInstanceId">
         update deepthink.bytedance_product_main_advertiser
         set mini_instance_id = #{instanceId}
         where advertiser_id = #{advertiserId}
     </update>
+    <update id="updateAlbumInfo">
+        update deepthink.bytedance_upload_album
+        set can_promotion = #{canPromotion}, cannot_reason = #{cannotReason}
+        where album_id = #{albumId}
+    </update>
 
 
     <select id="getIAPPlatformList" resultType="com.alibaba.fastjson.JSONObject">
@@ -23,7 +34,7 @@
         where t1.`type`=1 and t1.`_status`=0
     </select>
     <select id="getIAPVideoList" resultType="com.alibaba.fastjson.JSONObject">
-        select third.album_id, detail.platform_config, video.id as video_id, detail.id as video_detail_id, video.name as name, video.cover_img as img,ifnull(category.name, '其他') as 'theme',
+        select third.album_id, detail.platform_config, video.id as video_id, detail.id as video_detail_id, video.name as name, video.cover_img as img,ifnull(category.name, '其他') as 'theme', video.play_platform,
         '天津星链视界信息技术有限公司' as copyright_owner, '其他' as playlet_gender, video.update_sort as playlet_num, '2' as playlet_duration,
         payinfo.sort as start_pay_playlet, '5' as membership_types, '1' as has_paid_content, '2' as has_motivation_types,
         payinfo.maxpay as max_charge, payinfo.minpay as min_charge, maxpay as recommended_charge, maxpay as price,
@@ -38,7 +49,7 @@
         where video.is_free = 1
     </select>
     <select id="getIAAVideoList" resultType="com.alibaba.fastjson.JSONObject">
-        select third.album_id, detail.platform_config, video.id as video_id, detail.id as video_detail_id, video.name as name, video.cover_img as img,ifnull(category.name, '其他') as 'theme',
+        select third.album_id, detail.platform_config, video.id as video_id, detail.id as video_detail_id, video.name as name, video.cover_img as img,ifnull(category.name, '其他') as 'theme', video.play_platform,
         '天津星链视界信息技术有限公司' as copyright_owner, '其他' as playlet_gender, video.update_sort as playlet_num, '2' as playlet_duration,
         '5' as membership_types, '1' as has_paid_content, '2' as has_motivation_types,payinfo.sort as starting_unlock_episode
         FROM (select * from thirtpart.ly_third_videos where submission_status=2
@@ -61,9 +72,22 @@
         where `type`=1
     </select>
     <select id="getVideoInfo" resultType="com.alibaba.fastjson.JSONObject">
-        select id, name, label, cover_img, sylloge from thirtpart.ly_videos where id = #{videoId};
+        select id, name, label, cover_img, sylloge from thirtpart.ly_videos where id = #{videoId}
     </select>
     <select id="getVideoDetail" resultType="com.alibaba.fastjson.JSONObject">
         select video_id, name, is_pay, pay_amount, url, sort from thirtpart.ly_video_details where video_id=#{videoId} order by sort
     </select>
+    <select id="getUploadList" resultType="java.lang.Long">
+        select id from thirtpart.ly_videos
+        where id not in
+        (select video_id from thirtpart.ly_third_videos where platform=2 and submission_status=2
+        and video_id in (select video_id from thirtpart.ly_video_audit_records where audit_status=2))
+        and id in (select video_id from thirtpart.ly_third_videos where platform=1)
+    </select>
+    <select id="getDeveloperAccount" resultType="com.alibaba.fastjson.JSONObject">
+        select app_id, secret as app_secret from deepthink.bytedance_auth_config where auth_status=1 limit 1
+    </select>
+    <select id="selectWaitingAlbums" resultType="java.lang.String">
+        select album_id from deepthink.bytedance_upload_album where can_promotion is null or can_promotion=0
+    </select>
 </mapper>

+ 252 - 105
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedanceProductUpdateServiceImpl.java

@@ -53,10 +53,14 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
 
     @Override
     public void test() throws Exception {
-        String token = "009970b1323314355756a4158f363be29676d5f0";
-        long videoId = 61073;
-        String albumId = uploadAlbum(videoId, token);
-        System.out.println(albumId);
+//        uploadAlbum(1077L, 1742489802322972L, "ee6a92328075a92d6819107e0a98ef047cb210f9");
+//        uploadAlbum();
+//        Thread.sleep(1000);
+//        refreshAlbumStatus();
+        List<String> errors = new ArrayList<>();
+        iapProductUpdate(errors);
+        System.out.println(errors);
+
     }
 
     public void initNew(List<JSONObject> platformList)  {
@@ -104,6 +108,10 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
         }
     }
 
+    /**
+     * 付费短剧更新
+     * @param errorBlanket
+     */
     private void iapProductUpdate(List<String> errorBlanket){
         //IAP
         List<JSONObject> iapPlatformList = bytedanceProductUpdateMapper.getIAPPlatformList();
@@ -138,68 +146,93 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
                 continue;
             }
             for (JSONObject platform : iapPlatformList) {
-                String url = "https://ad.oceanengine.com/open_api/2/dpa/product/update/";
-                Map<String, String> headers = new HashMap<>();
-                headers.put("Access-Token", platform.getString("access_token"));
-                headers.put("Content-Type", "application/json");
-
-                JSONObject request = new JSONObject();
-                String album_id = obj.getString("album_id");
-                request.put("product_id", obj.getLongValue("album_id"));
-                JSONObject product_info = new JSONObject();
-                product_info.put("name", obj.getString("name"));
-                product_info.put("image_url", obj.getString("img"));
-                product_info.put("status", 1);
-                product_info.put("stock", 1);
-                JSONObject productType = iapProductTypeMap.get(theme);
-                product_info.put("first_category_id", productType.getString("first_type_id"));
-                product_info.put("sub_category_id", productType.getString("second_type_id"));
-                product_info.put("third_category_id", productType.getString("third_type_id"));
-                product_info.put("first_category", productType.getString("first_type_name"));
-                product_info.put("sub_category", productType.getString("second_type_name"));
-                product_info.put("third_category", productType.getString("third_type_name"));
-                request.put("advertiser_id", platform.getLongValue("advertiser_id"));
-                request.put("platform_id", platform.getLongValue("platform_id"));
-                JSONObject profession = new JSONObject();
-                profession.put("copyright_owner", obj.getString("copyright_owner"));
-                profession.put("playlet_gender", "3");
-                profession.put("playlet_num", obj.getString("playlet_num"));
-                profession.put("playlet_duration", obj.getString("playlet_duration"));
-                profession.put("start_pay_playlet", obj.getString("start_pay_playlet"));
-                if (platform.getDouble("max_charge") > 0.0){
-                    profession.put("max_charge", platform.getString("max_charge"));
-                }
-                if (platform.getDouble("min_charge") > 0.0){
-                    profession.put("min_charge", platform.getString("min_charge"));
+                int rescode = uploadIapProduct(platform, obj, advertiserToLinkMap, errorBlanket, iapProductTypeMap.get(theme));
+                if (rescode!= 0){
+//                    return;
                 }
-                if (platform.getDouble("recommended_charge") > 0.0){
-                    profession.put("recommended_charge", platform.getString("recommended_charge"));
-                }
-                profession.put("has_paid_content", "1");
-                profession.put("has_motivation_content", "2");
-                profession.put("membership_types", platform.getString("membership_types"));
-                profession.put("micro_app_link", advertiserToLinkMap.get(platform.getString("advertiser_id")).get(album_id));
-                //price_info
-                JSONObject price_info = new JSONObject();
-                price_info.put("price", platform.getDoubleValue("single_price"));
-                product_info.put("price_info", price_info);
-                product_info.put("profession", profession);
-                request.put("product_info", product_info);
+//                System.out.println("\n\n\n");
+            }
+        }
+    }
 
+    /**
+     * 付费短剧更新
+     * @param platform 商品库信息
+     * @param album 剧信息
+     * @param advertiserToLinkMap
+     * @param errorBlanket
+     * @param productType 商品短剧类型
+     */
+    private int uploadIapProduct(JSONObject platform, JSONObject album,
+                                  Map<String, Map<String, String>> advertiserToLinkMap,
+                                  List<String> errorBlanket,
+                                  JSONObject productType){
+        String url = "https://ad.oceanengine.com/open_api/2/dpa/product/update/";
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", platform.getString("access_token"));
+        headers.put("Content-Type", "application/json");
 
-//                System.out.println("请求地址:" + url);
-//                System.out.println("请求头:" + headers);
-//                System.out.println("请求参数:" + request.toJSONString());
-                String res = HttpUtils.httpPostRequest(url, request, headers);
+        JSONObject request = new JSONObject();
+        String album_id = album.getString("album_id");
+        request.put("product_id", album.getLongValue("album_id"));
+        JSONObject product_info = new JSONObject();
+        product_info.put("name", album.getString("name"));
+        product_info.put("image_url", album.getString("img"));
+        product_info.put("status", 1);
+        product_info.put("stock", 1);
+        product_info.put("first_category_id", productType.getString("first_type_id"));
+        product_info.put("sub_category_id", productType.getString("second_type_id"));
+        product_info.put("third_category_id", productType.getString("third_type_id"));
+        product_info.put("first_category", productType.getString("first_type_name"));
+        product_info.put("sub_category", productType.getString("second_type_name"));
+        product_info.put("third_category", productType.getString("third_type_name"));
+        request.put("advertiser_id", platform.getLongValue("advertiser_id"));
+        request.put("platform_id", platform.getLongValue("platform_id"));
+        JSONObject profession = new JSONObject();
+        profession.put("copyright_owner", album.getString("copyright_owner"));
+        profession.put("playlet_gender", "3");
+        profession.put("playlet_num", album.getString("playlet_num"));
+        profession.put("playlet_duration", album.getString("playlet_duration"));
+        profession.put("start_pay_playlet", album.getString("start_pay_playlet"));
+        if (platform.getDouble("max_charge") > 0.0){
+            profession.put("max_charge", platform.getString("max_charge"));
+        }
+        if (platform.getDouble("min_charge") > 0.0){
+            profession.put("min_charge", platform.getString("min_charge"));
+        }
+        if (platform.getDouble("recommended_charge") > 0.0){
+            profession.put("recommended_charge", platform.getString("recommended_charge"));
+        }
+        profession.put("has_paid_content", "1");
+        profession.put("has_motivation_content", "2");
+        profession.put("membership_types", platform.getString("membership_types"));
+        profession.put("micro_app_link", advertiserToLinkMap.get(platform.getString("advertiser_id")).get(album_id));
+        String play_platform = album.getString("play_platform");
+        if (play_platform.contains("1")){
+            profession.put("ad_carrier", "字节小程序");
+        }else {
+            profession.put("ad_carrier", "字节小程序");
+        }
+
+        //price_info
+        JSONObject price_info = new JSONObject();
+        price_info.put("price", platform.getDoubleValue("single_price"));
+        product_info.put("price_info", price_info);
+        product_info.put("profession", profession);
+        request.put("product_info", product_info);
+
+
+                System.out.println("请求地址:" + url);
+                System.out.println("请求头:" + headers);
+                System.out.println("请求参数:" + request.toJSONString());
+        String res = HttpUtils.httpPostRequest(url, request, headers);
 //                System.out.println(res);
-                JSONObject btRes = JSONObject.parseObject(res);
-                int code = btRes.getIntValue("code");
-                if (code != 0){
-                    errorBlanket.add("上传付费商品失败,code: " + code + ", msg: " + btRes.getString("message")+", 关联剧目: " + obj.getString("name"));
-                }
-//                System.out.println("\n\n\n");
-            }
+        JSONObject btRes = JSONObject.parseObject(res);
+        int code = btRes.getIntValue("code");
+        if (code != 0){
+            errorBlanket.add("上传付费商品失败,code: " + code + ", msg: " + btRes.getString("message")+", 关联剧目: " + album.getString("name"));
         }
+        return code;
     }
 
     private void iaaProductUpdate(List<String> errorBlanket){
@@ -239,48 +272,9 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
 
 
             for (JSONObject platform : iaaPlatformList) {
-                String url = "https://ad.oceanengine.com/open_api/2/dpa/product/update/";
-                Map<String, String> headers = new HashMap<>();
-                headers.put("Access-Token", platform.getString("access_token"));
-                headers.put("Content-Type", "application/json");
-                String album_id = obj.getString("album_id");
-                JSONObject request = new JSONObject();
-                request.put("product_id", obj.getLongValue("album_id"));
-                JSONObject product_info = new JSONObject();
-                product_info.put("name", obj.getString("name"));
-                product_info.put("image_url", obj.getString("img"));
-                product_info.put("status", 1);
-                product_info.put("stock", 1);
-                JSONObject productType = iaaProductTypeMap.get(theme);
-                product_info.put("first_category_id", productType.getString("first_type_id"));
-                product_info.put("sub_category_id", productType.getString("second_type_id"));
-                product_info.put("third_category_id", productType.getString("third_type_id"));
-                product_info.put("first_category", productType.getString("first_type_name"));
-                product_info.put("sub_category", productType.getString("second_type_name"));
-                product_info.put("third_category", productType.getString("third_type_name"));
-                JSONObject profession = new JSONObject();
-                profession.put("copyright_owner", obj.getString("copyright_owner"));
-                profession.put("playlet_gender", "3");
-                profession.put("playlet_num", obj.getString("playlet_num"));
-                profession.put("playlet_duration", obj.getString("playlet_duration"));
-                profession.put("has_paid_content", "2");
-                profession.put("has_motivation_content", "2");
-                profession.put("membership_types", "5");
-                profession.put("starting_unlock_episode", obj.getString("starting_unlock_episode"));
-                profession.put("micro_app_link", advertiserToLinkMap.get(platform.getString("advertiser_id")).get(album_id));
-                product_info.put("profession", profession);
-                request.put("product_info", product_info);
-                request.put("advertiser_id", platform.getLongValue("advertiser_id"));
-                request.put("platform_id", platform.getLongValue("platform_id"));
-
-//                System.out.println("请求地址:" + url);
-//                System.out.println("请求头:" + headers);
-//                System.out.println("请求参数:" + request.toJSONString());
-                String res = HttpUtils.httpPostRequest(url, request, headers);
-                JSONObject btRes = JSONObject.parseObject(res);
-                int code = btRes.getIntValue("code");
-                if (code != 0){
-                    errorBlanket.add("上传免费商品失败,code: " + code + ", msg: " + btRes.getString("message")+", 关联剧目: " + obj.getString("name"));
+                int code = uploadIaaProduct(platform, obj, advertiserToLinkMap, errorBlanket, iaaProductTypeMap.get(theme));
+                if (code !=0){
+                    return;
                 }
 //                System.out.println(res);
 //                System.out.println("\n\n\n");
@@ -288,6 +282,61 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
         }
     }
 
+    private int uploadIaaProduct(JSONObject platform, JSONObject album, Map<String,
+            Map<String, String>> advertiserToLinkMap,
+                                  List<String> errorBlanket,
+                                  JSONObject productType){
+        String url = "https://ad.oceanengine.com/open_api/2/dpa/product/update/";
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", platform.getString("access_token"));
+        headers.put("Content-Type", "application/json");
+        String album_id = album.getString("album_id");
+        JSONObject request = new JSONObject();
+        request.put("product_id", album.getLongValue("album_id"));
+        JSONObject product_info = new JSONObject();
+        product_info.put("name", album.getString("name"));
+        product_info.put("image_url", album.getString("img"));
+        product_info.put("status", 1);
+        product_info.put("stock", 1);
+        product_info.put("first_category_id", productType.getString("first_type_id"));
+        product_info.put("sub_category_id", productType.getString("second_type_id"));
+        product_info.put("third_category_id", productType.getString("third_type_id"));
+        product_info.put("first_category", productType.getString("first_type_name"));
+        product_info.put("sub_category", productType.getString("second_type_name"));
+        product_info.put("third_category", productType.getString("third_type_name"));
+        JSONObject profession = new JSONObject();
+        profession.put("copyright_owner", album.getString("copyright_owner"));
+        profession.put("playlet_gender", "3");
+        profession.put("playlet_num", album.getString("playlet_num"));
+        profession.put("playlet_duration", album.getString("playlet_duration"));
+        profession.put("has_paid_content", "2");
+        profession.put("has_motivation_content", "2");
+        profession.put("membership_types", "5");
+        profession.put("starting_unlock_episode", album.getString("starting_unlock_episode"));
+        profession.put("micro_app_link", advertiserToLinkMap.get(platform.getString("advertiser_id")).get(album_id));
+        String play_platform = album.getString("play_platform");
+        if (play_platform.contains("1")){
+            profession.put("ad_carrier", "字节小程序,微信小程序");
+        }else {
+            profession.put("ad_carrier", "字节小程序");
+        }
+        product_info.put("profession", profession);
+        request.put("product_info", product_info);
+        request.put("advertiser_id", platform.getLongValue("advertiser_id"));
+        request.put("platform_id", platform.getLongValue("platform_id"));
+
+//                System.out.println("请求地址:" + url);
+//                System.out.println("请求头:" + headers);
+//                System.out.println("请求参数:" + request.toJSONString());
+        String res = HttpUtils.httpPostRequest(url, request, headers);
+        JSONObject btRes = JSONObject.parseObject(res);
+        int code = btRes.getIntValue("code");
+        if (code != 0){
+            errorBlanket.add("上传免费商品失败,code: " + code + ", msg: " + btRes.getString("message")+", 关联剧目: " + album.getString("name"));
+        }
+        return code;
+    }
+
     /**
      *
      * @param advertiserId 商品库主账户ID,也是创建字节小程序的ID
@@ -413,27 +462,98 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
     }
 
 
+    private void uploadAlbum(){
+        List<Long> videoIds = bytedanceProductUpdateMapper.getUploadList();
+        JSONObject developerAccount = bytedanceProductUpdateMapper.getDeveloperAccount();
+        Long appId = developerAccount.getLong("app_id");
+        String appAccessToken = getAppAccessToken(appId, developerAccount.getString("app_secret"));
+        if (appAccessToken == null){
+            System.out.println("获取app_access_token失败");
+            return;
+        }
+        for (Long videoId : videoIds){
+            String albumId = uploadAlbum(videoId, appId, appAccessToken);
+            if (albumId == null){
+                System.out.println("上传短剧失败,videoId: " + videoId);
+                continue;
+            }
+            bytedanceProductUpdateMapper.insertAlbumInfo(albumId, videoId);
+        }
+    }
+
+    private void refreshAlbumStatus(){
+        JSONObject developerAccount = bytedanceProductUpdateMapper.getDeveloperAccount();
+        Long app_id = developerAccount.getLong("app_id");
+        String app_secret = developerAccount.getString("app_secret");
+        String appAccessToken = getAppAccessToken(app_id, app_secret);
+        if (appAccessToken == null){
+            System.out.println("获取app_access_token失败");
+            return;
+        }
+
+        List<String> albums = bytedanceProductUpdateMapper.selectWaitingAlbums();
+        for (String al : albums){
+            String url = "https://api.oceanengine.com/open_api/v3.0/dpa/album_status/get/";
+            Map<String, String> headers = new HashMap<>();
+            headers.put("App-Access-Token", appAccessToken);
+            Map<String, Object> params = new HashMap<>();
+            params.put("album_id", al);
+            params.put("app_id", app_id);
+            String res = HttpUtils.httpGet(url, params, headers);
+            if (res == null || res.isEmpty()){
+                System.out.println("获取短剧状态失败,albumId: " + al);
+            }else {
+                JSONObject resObj = JSONObject.parseObject(res);
+                int code = resObj.getIntValue("code");
+                if (code != 0){
+                    System.out.println("获取短剧状态失败,code: " + code + ", msg: " + resObj.getString("message"));
+                    continue;
+                }else {
+                    JSONObject data = resObj.getJSONObject("data");
+                    boolean isSuccess = data.getBooleanValue("can_promotion");
+                    if (isSuccess) {
+                        //更新状态
+                        bytedanceProductUpdateMapper.updateAlbumInfo(al, 1, null);
+                    }else {
+                        String failReason = data.getString("can_not_promotion_reason");
+                        if ("RESOURCE_CREATING".equals(failReason) || "RESOURCE_AUDITING".equals(failReason)){
+                            //等待中
+                            bytedanceProductUpdateMapper.updateAlbumInfo(al, 0, failReason);
+                        }else {
+                            //失败
+                            bytedanceProductUpdateMapper.updateAlbumInfo(al, 2, failReason);
+                        }
+                    }
+
+                }
+            }
+        }
+    }
+
+
     /**
      * 上传短剧
      * @param videoId from ly_videos
      * @return albumId
      */
-    private String uploadAlbum(long videoId, String appAccessToken){
+    private String uploadAlbum(long videoId, Long appId, String appAccessToken){
         JSONObject video = bytedanceProductUpdateMapper.getVideoInfo(videoId);
         if (video == null){
+            System.out.println("没有找到视频信息,videoId: " + videoId);
             return null;
         }
         String videoName = video.getString("name");
         Integer sylloge = video.getInteger("sylloge");//总集数
         List<JSONObject> videoDetail = bytedanceProductUpdateMapper.getVideoDetail(videoId);
         if (videoDetail == null || videoDetail.isEmpty()){
+            System.out.println("没有找到视频剧集详情,videoId: " + videoId);
             return null;
         }
 
         JSONObject requestBody = new JSONObject();
         requestBody.put("album_title", videoName);
         requestBody.put("seq_num", sylloge);
-        requestBody.put("app_id", 1742489802322972L);
+        requestBody.put("app_id", appId);
 
         List<JSONObject> videoDetailList = new ArrayList<>();
         for (JSONObject obj : videoDetail){
@@ -457,6 +577,7 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
         System.out.println(requestBody.toJSONString());
 //        return null;
         String res = HttpUtils.httpPostRequest(url, requestBody, headers);
+        System.out.println(">>> "+res);
         if (res == null || res.isEmpty()){
             System.out.println("上传短剧失败, 返回null");
             return null;
@@ -474,4 +595,30 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
     }
 
 
+    private String getAppAccessToken(Long app_id, String app_secret){
+        String url = "https://open.oceanengine.com/open_api/oauth2/app_access_token/";
+        if (app_id == null || app_secret == null){
+            return null;
+        }
+        JSONObject body = new JSONObject();
+        body.put("app_id", app_id);
+        body.put("secret", app_secret);
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        String res = HttpUtils.httpPostRequest(url, body, headers);
+        if (res == null || res.isEmpty()){
+            return null;
+        }else {
+            JSONObject resObj = JSONObject.parseObject(res);
+            int code = resObj.getIntValue("code");
+            if (code != 0){
+                System.out.println("获取app_access_token失败,code: " + code + ", msg: " + resObj.getString("message"));
+                return null;
+            }else {
+                return resObj.getJSONObject("data").getString("access_token");
+            }
+        }
+    }
+
+
 }