|  | @@ -5,14 +5,19 @@ import cn.com.ctop.common.module.utils.Check;
 | 
	
		
			
				|  |  |  import cn.com.ctop.common.module.utils.HttpUtils;
 | 
	
		
			
				|  |  |  import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 | 
	
		
			
				|  |  |  import cn.com.ctop.common.module.utils.PropertiesUtils;
 | 
	
		
			
				|  |  | +import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 | 
	
		
			
				|  |  |  import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProgramCreative;
 | 
	
		
			
				|  |  |  import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouProgramCreativeMapper;
 | 
	
		
			
				|  |  | +import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
 | 
	
		
			
				|  |  | +import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
 | 
	
		
			
				|  |  |  import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouProgramCreativeService;
 | 
	
		
			
				|  |  |  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 lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  |  import lombok.var;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.util.ArrayList;
 | 
	
	
		
			
				|  | @@ -31,6 +36,12 @@ import java.util.Map;
 | 
	
		
			
				|  |  |  @Slf4j
 | 
	
		
			
				|  |  |  public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProgramCreativeMapper, KuaishouProgramCreative> implements IKuaishouProgramCreativeService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private IKuaiShouImageGetService imageGetService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private IKuaiShouMaterialUploadService uploadService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void getProgramCreative(Long accountId, Long unitId, String accessToken, String startDate, String endDate, Integer page) {
 | 
	
		
			
				|  |  |          String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PROGRAM_LIST;
 | 
	
	
		
			
				|  | @@ -58,7 +69,6 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          String result = HttpUtils.httpPostRequest(url, param, headers);
 | 
	
		
			
				|  |  |          JSONObject resultJson = JSONObject.parseObject(result);
 | 
	
		
			
				|  |  | -        System.err.println(resultJson);
 | 
	
		
			
				|  |  |          Integer code = resultJson.getInteger("code");
 | 
	
		
			
				|  |  |          String message = resultJson.getString("message");
 | 
	
		
			
				|  |  |          if (null == code || code != 0) {
 | 
	
	
		
			
				|  | @@ -90,7 +100,7 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          this.saveOrUpdateBatch(programCreativeList);
 | 
	
		
			
				|  |  | -        getProgramCreative(accountId, unitId, accessToken, startDate, endDate, page + 1);
 | 
	
		
			
				|  |  | +    //    getProgramCreative(accountId, unitId, accessToken, startDate, endDate, page + 1);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -111,7 +121,7 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
 | 
	
		
			
				|  |  |              JSONObject pramsJson = new JSONObject();
 | 
	
		
			
				|  |  |              pramsJson.put("advertiser_id", oauthToken.getAccountId());
 | 
	
		
			
				|  |  |              pramsJson.put("unit_id", requestJson.getLong("unitId"));
 | 
	
		
			
				|  |  | -            pramsJson.put("package_name", requestJson.getLong("packageName"));
 | 
	
		
			
				|  |  | +            pramsJson.put("package_name", requestJson.getString("packageName"));
 | 
	
		
			
				|  |  |              pramsJson.put("horizontal_photo_ids", requestJson.getJSONArray("horizontalPhotoIds"));
 | 
	
		
			
				|  |  |              pramsJson.put("vertical_photo_ids", requestJson.getJSONArray("verticalPhotoIds"));
 | 
	
		
			
				|  |  |              pramsJson.put("cover_image_tokens", requestJson.getJSONArray("coverImageTokens"));
 | 
	
	
		
			
				|  | @@ -127,7 +137,7 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
 | 
	
		
			
				|  |  |                  pramsJson.put("cover_slogans", requestJson.getJSONArray("coverSlogans"));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            pramsJson.put("action_bar", requestJson.getString("actionBar"));
 | 
	
		
			
				|  |  | +            pramsJson.put("action_bar", requestJson.getString("actionBarText"));
 | 
	
		
			
				|  |  |              pramsJson.put("captions", requestJson.getJSONArray("captions"));
 | 
	
		
			
				|  |  |              if (!Check.isNull(requestJson.getString("clickUrl"))) {
 | 
	
		
			
				|  |  |                  pramsJson.put("click_url", requestJson.getString("clickUrl"));
 | 
	
	
		
			
				|  | @@ -139,7 +149,52 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
 | 
	
		
			
				|  |  |              headers.put("Content-Type", "application/json");
 | 
	
		
			
				|  |  |              headers.put("Access-Token", oauthToken.getAccessToken());
 | 
	
		
			
				|  |  |              String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PROGRAM_CREATE;
 | 
	
		
			
				|  |  | -            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            JSONArray coverImageTokens = requestJson.getJSONArray("coverImageTokens");
 | 
	
		
			
				|  |  | +            JSONArray cover_image_tokens = new JSONArray();
 | 
	
		
			
				|  |  | +            requestJson.remove(coverImageTokens);
 | 
	
		
			
				|  |  | +            if (!Check.isNull(coverImageTokens)) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                for (int i = 0; i < coverImageTokens.size(); i++) {
 | 
	
		
			
				|  |  | +                    String signature = coverImageTokens.getString(i);
 | 
	
		
			
				|  |  | +                    if (Check.isNull(signature)) {
 | 
	
		
			
				|  |  | +                        continue;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    String imageToken = null;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    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 imageUrl = imageGetService.getUrlByCode(signature);
 | 
	
		
			
				|  |  | +                            imageToken = uploadService.kuauiShouImageUpload(imageUrl, signature, oauthToken.getAccountId(), oauthToken.getAccessToken());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        cover_image_tokens.add(imageToken);
 | 
	
		
			
				|  |  | +                        /*if (Check.isNull(imageToken)) {
 | 
	
		
			
				|  |  | +                            JSONObject failJson = new JSONObject();
 | 
	
		
			
				|  |  | +                            failJson.put("creativeName", name);
 | 
	
		
			
				|  |  | +                            failJson.put("failMessage", "获取图片文件失败");
 | 
	
		
			
				|  |  | +                            failArr.add(failJson);
 | 
	
		
			
				|  |  | +                            continue;
 | 
	
		
			
				|  |  | +                        }*/
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            pramsJson.put("cover_image_tokens", cover_image_tokens);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            String result = HttpUtils.kuaiShouhttpPostRequest(url, pramsJson.toJSONString(), headers);
 | 
	
		
			
				|  |  | +            System.err.println(result);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          } catch (Exception e) {
 | 
	
		
			
				|  |  |              e.printStackTrace();
 |