|
@@ -7,10 +7,12 @@ import com.kuaishou.merchant.open.api.KsMerchantApiException;
|
|
import com.kuaishou.merchant.open.api.client.AccessTokenKsMerchantClient;
|
|
import com.kuaishou.merchant.open.api.client.AccessTokenKsMerchantClient;
|
|
import com.kuaishou.merchant.open.api.common.utils.GsonUtils;
|
|
import com.kuaishou.merchant.open.api.common.utils.GsonUtils;
|
|
import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionCpsLeaderOrderCursorListRequest;
|
|
import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionCpsLeaderOrderCursorListRequest;
|
|
|
|
+import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionCpsLeaderOrderDetailRequest;
|
|
import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityItemDetailRequest;
|
|
import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityItemDetailRequest;
|
|
import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityOpenItemListRequest;
|
|
import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityOpenItemListRequest;
|
|
import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityOpenListRequest;
|
|
import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityOpenListRequest;
|
|
import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionCpsLeaderOrderCursorListResponse;
|
|
import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionCpsLeaderOrderCursorListResponse;
|
|
|
|
+import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionCpsLeaderOrderDetailResponse;
|
|
import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityItemDetailResponse;
|
|
import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityItemDetailResponse;
|
|
import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityOpenItemListResponse;
|
|
import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityOpenItemListResponse;
|
|
import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityOpenListResponse;
|
|
import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityOpenListResponse;
|
|
@@ -35,9 +37,12 @@ import org.springframework.data.mongodb.core.query.Query;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
@@ -1015,6 +1020,70 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ static ExecutorService insertShopInfoService = Executors.newFixedThreadPool(6);
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void insertShopInfo(Long tokenId, String bdtype, Integer date) throws Exception {
|
|
|
|
+ KuaishouAccessToken token = accessTokenService.getAccessTokenBybd(tokenId, bdtype);
|
|
|
|
+ List<JSONObject> list = supplyChainMapper.getAllOid(bdtype, date);
|
|
|
|
+ list.forEach(data -> insertShopInfoService.submit(() -> {
|
|
|
|
+ try {
|
|
|
|
+ insertShopInfo(data, token, KuaiShouConstants.KFX_URL);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void insertShopInfo(JSONObject data, KuaishouAccessToken accessToken, String url) {
|
|
|
|
+ try {
|
|
|
|
+ String appKey = accessToken.getAppKey();
|
|
|
|
+ String signSecret = accessToken.getSignSecret();
|
|
|
|
+ if (Check.isNull(signSecret) || Check.isNull(appKey)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(url, appKey, signSecret);
|
|
|
|
+
|
|
|
|
+ OpenDistributionCpsLeaderOrderDetailRequest request = new OpenDistributionCpsLeaderOrderDetailRequest();
|
|
|
|
+ request.setAccessToken(accessToken.getAccessToken());
|
|
|
|
+ request.setApiMethodVersion(1L);
|
|
|
|
+
|
|
|
|
+ request.setOid(data.getLong("oid"));
|
|
|
|
+ request.setSellerId(data.getLong("seller_id"));
|
|
|
|
+ request.setFundType(1);
|
|
|
|
+
|
|
|
|
+ OpenDistributionCpsLeaderOrderDetailResponse response = null;
|
|
|
|
+ try {
|
|
|
|
+ response = client.execute(request);
|
|
|
|
+ } catch (KsMerchantApiException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ JSONObject obj = JSONObject.parseObject(GsonUtils.toJSON(response));
|
|
|
|
+ String code = obj.getString("code");
|
|
|
|
+ if ("1".equals(code)) {
|
|
|
|
+ JSONArray arr = obj.getJSONArray("data");
|
|
|
|
+ for (int i = 0; i < arr.size(); i++) {
|
|
|
|
+ JSONObject info = arr.getJSONObject(i);
|
|
|
|
+ addKuaishouActivityShopInfo(info);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void addKuaishouActivityShopInfo(JSONObject info) {
|
|
|
|
+ List<JSONObject> list = new ArrayList<>();
|
|
|
|
+ JSONArray cpsOrderProductView = info.getJSONArray("cpsOrderProductView");
|
|
|
|
+ for (int i = 0; i < cpsOrderProductView.size(); i++) {
|
|
|
|
+ JSONObject object = cpsOrderProductView.getJSONObject(i);
|
|
|
|
+ list.add(object);
|
|
|
|
+ }
|
|
|
|
+ if (Check.isNotNull(list) && list.size() > 0) {
|
|
|
|
+ supplyChainMapper.replaceBatchShopInfo(list);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void getInfo(KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, Integer counts) throws InterruptedException {
|
|
private void getInfo(KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, Integer counts) throws InterruptedException {
|
|
List<Long> ruixuanList = new ArrayList<>();
|
|
List<Long> ruixuanList = new ArrayList<>();
|
|
List<Long> mgsList = new ArrayList<>();
|
|
List<Long> mgsList = new ArrayList<>();
|