|
@@ -16,6 +16,7 @@ import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInve
|
|
|
import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityOpenListResponse;
|
|
|
import com.ruixuan.common.utils.Check;
|
|
|
import com.ruixuan.common.utils.DateUtils;
|
|
|
+import com.ruixuan.isc.constants.KuaiShouConstants;
|
|
|
import com.ruixuan.isc.entity.ItemCheck;
|
|
|
import com.ruixuan.isc.entity.KuaiShouActivityInfo;
|
|
|
import com.ruixuan.isc.entity.KuaiShouActivityOpenItemList;
|
|
@@ -37,8 +38,6 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
-import java.util.concurrent.Executors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -837,7 +836,7 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
|
|
|
@Override
|
|
|
public void addList(String beginDate, String endDate, String pcursor) throws InterruptedException {
|
|
|
- String url = "https://openapi.kwaixiaodian.com";
|
|
|
+ String url = KuaiShouConstants.KFX_URL;
|
|
|
Long beginTime = DateUtils.getStartLongTime(beginDate);
|
|
|
Long endTime = DateUtils.getEndLongTime(endDate);
|
|
|
// Map<Long, Long> itemMap = getItemMap();
|
|
@@ -877,59 +876,12 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- static ExecutorService ruixuanService = Executors.newFixedThreadPool(6);
|
|
|
- static ExecutorService miaogousiService = Executors.newFixedThreadPool(3);
|
|
|
- static ExecutorService rocketService = Executors.newFixedThreadPool(3);
|
|
|
- static ExecutorService yufuService = Executors.newFixedThreadPool(3);
|
|
|
- static ExecutorService yuxiuService = Executors.newFixedThreadPool(3);
|
|
|
- static ExecutorService zhishuiService = Executors.newFixedThreadPool(3);
|
|
|
-
|
|
|
@Override
|
|
|
- public void insertOrderList(Integer queryType, String beginDate, String endDate) throws Exception {
|
|
|
- String url = "https://openapi.kwaixiaodian.com";
|
|
|
+ public void insertOrderList(Long tokenId, Integer queryType, String beginDate, String endDate) throws Exception {
|
|
|
Long beginTime = DateUtils.getStartLongTime(beginDate);
|
|
|
Long endTime = DateUtils.getEndLongTime(endDate);
|
|
|
-
|
|
|
- /* List<KuaishouAccessToken> tokens = accessTokenService.getTokenInfos();
|
|
|
- tokens.forEach(token -> ruixuanService.submit(() -> {
|
|
|
- insertRuixuanOrderList(queryType, token, beginTime, endTime, url, "", 1);
|
|
|
- }));
|
|
|
- //秒构思
|
|
|
- Thread.sleep(3000);
|
|
|
- List<KuaishouAccessToken> mgsTokens = accessTokenService.getMgsTokenInfos();
|
|
|
- mgsTokens.forEach(token -> miaogousiService.submit(() -> {
|
|
|
- insertRuixuanOrderList(queryType, token, beginTime, endTime, url, "", 1);
|
|
|
- }));
|
|
|
- */
|
|
|
- //TODO 测完放开
|
|
|
- //王炸
|
|
|
- Thread.sleep(3000);
|
|
|
- List<KuaishouAccessToken> rocketTokens = accessTokenService.getRocketTokenInfos();
|
|
|
- rocketTokens.forEach(token -> rocketService.submit(() -> {
|
|
|
- insertRuixuanOrderList(queryType, token, beginTime, endTime, url, "", 1);
|
|
|
- }));
|
|
|
- //TODO 测完放开
|
|
|
- /*//预付
|
|
|
- Thread.sleep(3000);
|
|
|
- List<KuaishouAccessToken> yufuTokens = accessTokenService.getYufuTokenInfos();
|
|
|
- yufuTokens.forEach(token -> yufuService.submit(() -> {
|
|
|
- insertRuixuanOrderList(queryType, token, beginTime, endTime, url, "", 1);
|
|
|
- }));
|
|
|
-
|
|
|
- //毓秀
|
|
|
- Thread.sleep(3000);
|
|
|
- List<KuaishouAccessToken> yuxiuTokens = accessTokenService.getYuxiuTokenInfos();
|
|
|
- yuxiuTokens.forEach(token -> yuxiuService.submit(() -> {
|
|
|
- insertRuixuanOrderList(queryType, token, beginTime, endTime, url, "", 1);
|
|
|
- }));
|
|
|
-
|
|
|
- //止水
|
|
|
- Thread.sleep(3000);
|
|
|
- List<KuaishouAccessToken> zhishuiTokens = accessTokenService.getZhishuiTokenInfos();
|
|
|
- zhishuiTokens.forEach(token -> zhishuiService.submit(() -> {
|
|
|
- insertRuixuanOrderList(queryType, token, beginTime, endTime, url, "", 1);
|
|
|
- }));*/
|
|
|
-
|
|
|
+ KuaishouAccessToken token = accessTokenService.getAccessToken(tokenId);
|
|
|
+ insertRuixuanOrderList(queryType, token, beginTime, endTime, KuaiShouConstants.KFX_URL, "", 1);
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
@@ -941,56 +893,18 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void insertNowdayOrderList() throws Exception {
|
|
|
- String url = "https://openapi.kwaixiaodian.com";
|
|
|
+ public void insertNowdayOrderList(Long tokenId) throws Exception {
|
|
|
//2小时前 时间戳
|
|
|
Long beginTime = DateUtils.getTimeStamp(DateUtils.getHourTime(-2));
|
|
|
//当前时间
|
|
|
Long endTime = DateUtils.getTimeStamp(DateUtils.getTime());
|
|
|
- /* List<KuaishouAccessToken> tokens = accessTokenService.getTokenInfos();
|
|
|
- tokens.forEach(token -> ruixuanService.submit(() -> {
|
|
|
- insertRuixuanOrderList(queryType, token, beginTime, endTime, url, "", 1);
|
|
|
- }));
|
|
|
- //秒构思
|
|
|
- Thread.sleep(3000);
|
|
|
- List<KuaishouAccessToken> mgsTokens = accessTokenService.getMgsTokenInfos();
|
|
|
- mgsTokens.forEach(token -> miaogousiService.submit(() -> {
|
|
|
- insertRuixuanOrderList(queryType, token, beginTime, endTime, url, "", 1);
|
|
|
- }));
|
|
|
- */
|
|
|
- //TODO 测完放开
|
|
|
- //王炸
|
|
|
- Thread.sleep(3000);
|
|
|
- List<KuaishouAccessToken> rocketTokens = accessTokenService.getRocketTokenInfos();
|
|
|
- rocketTokens.forEach(token -> rocketService.submit(() -> {
|
|
|
- insertRuixuanOrderList(1, token, beginTime, endTime, url, "", 1);
|
|
|
- }));
|
|
|
- //TODO 测完放开
|
|
|
- /*//预付
|
|
|
- Thread.sleep(3000);
|
|
|
- List<KuaishouAccessToken> yufuTokens = accessTokenService.getYufuTokenInfos();
|
|
|
- yufuTokens.forEach(token -> yufuService.submit(() -> {
|
|
|
- insertRuixuanOrderList(queryType, token, beginTime, endTime, url, "", 1);
|
|
|
- }));
|
|
|
-
|
|
|
- //毓秀
|
|
|
- Thread.sleep(3000);
|
|
|
- List<KuaishouAccessToken> yuxiuTokens = accessTokenService.getYuxiuTokenInfos();
|
|
|
- yuxiuTokens.forEach(token -> yuxiuService.submit(() -> {
|
|
|
- insertRuixuanOrderList(queryType, token, beginTime, endTime, url, "", 1);
|
|
|
- }));
|
|
|
-
|
|
|
- //止水
|
|
|
- Thread.sleep(3000);
|
|
|
- List<KuaishouAccessToken> zhishuiTokens = accessTokenService.getZhishuiTokenInfos();
|
|
|
- zhishuiTokens.forEach(token -> zhishuiService.submit(() -> {
|
|
|
- insertRuixuanOrderList(queryType, token, beginTime, endTime, url, "", 1);
|
|
|
- }));*/
|
|
|
-
|
|
|
+ KuaishouAccessToken token = accessTokenService.getAccessToken(tokenId);
|
|
|
+ insertRuixuanOrderList(1, token, beginTime, endTime, KuaiShouConstants.KFX_URL, "", 1);
|
|
|
}
|
|
|
|
|
|
private void insertRuixuanOrderList(Integer queryType, KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, int counts) {
|
|
|
try {
|
|
|
+ List<KuaishouSupplyChain> commonlist = new ArrayList<>();
|
|
|
List<KuaishouSupplyChain> ruixuanList = new ArrayList<>();
|
|
|
List<KuaishouSupplyChain> mgsList = new ArrayList<>();
|
|
|
List<KuaishouSupplyChain> rocketList = new ArrayList<>();
|
|
@@ -1037,32 +951,31 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
KuaishouSupplyChain supplyChain = new KuaishouSupplyChain(info, "1");
|
|
|
|
|
|
String ownership = null;
|
|
|
- Criteria criteria = new Criteria();
|
|
|
- criteria = Criteria.where("_id").is(supplyChain.getItemId());
|
|
|
- Query query = new Query(criteria);
|
|
|
- ItemCheck itemCheck = mongoTemplate.findOne(query, ItemCheck.class);
|
|
|
- if (!Check.isNull(itemCheck)) {
|
|
|
- ownership = itemCheck.getOwnership();
|
|
|
- }
|
|
|
- //TODO 放开下面代码
|
|
|
- /* if (Check.isNull(ownership) || "ruixuan".equals(ownership)) {
|
|
|
- ruixuanList.add(supplyChain);
|
|
|
- }
|
|
|
- if ("miaogousi".equals(ownership)) {
|
|
|
- mgsList.add(supplyChain);
|
|
|
- }*/
|
|
|
- if ("rocket".equals(ownership)) {
|
|
|
- rocketList.add(supplyChain);
|
|
|
- }
|
|
|
- /*if ("yufu".equals(ownership)) {
|
|
|
- yufuList.add(supplyChain);
|
|
|
- }
|
|
|
- if ("yuxiu".equals(ownership)) {
|
|
|
- yuxiuList.add(supplyChain);
|
|
|
+// Criteria criteria = new Criteria();
|
|
|
+// criteria = Criteria.where("_id").is(supplyChain.getItemId());
|
|
|
+// Query query = new Query(criteria);
|
|
|
+// ItemCheck itemCheck = mongoTemplate.findOne(query, ItemCheck.class);
|
|
|
+// if (!Check.isNull(itemCheck)) {
|
|
|
+// ownership = itemCheck.getOwnership();
|
|
|
+// }
|
|
|
+
|
|
|
+ if (Check.isNull(ownership)) {
|
|
|
+ commonlist.add(supplyChain);
|
|
|
+ } else {
|
|
|
+ if ("ruixuan".equals(ownership)) {
|
|
|
+ ruixuanList.add(supplyChain);
|
|
|
+ } else if ("miaogousi".equals(ownership)) {
|
|
|
+ mgsList.add(supplyChain);
|
|
|
+ } else if ("rocket".equals(ownership)) {
|
|
|
+ rocketList.add(supplyChain);
|
|
|
+ } else if ("yufu".equals(ownership)) {
|
|
|
+ yufuList.add(supplyChain);
|
|
|
+ } else if ("yuxiu".equals(ownership)) {
|
|
|
+ yuxiuList.add(supplyChain);
|
|
|
+ } else if ("zhishui".equals(ownership)) {
|
|
|
+ zhishuiList.add(supplyChain);
|
|
|
+ }
|
|
|
}
|
|
|
- if ("zhishui".equals(ownership)) {
|
|
|
- zhishuiList.add(supplyChain);
|
|
|
- }*/
|
|
|
}
|
|
|
} else {
|
|
|
log.error("===查询分销团长订单列表(open.distribution.cps.leader.order.cursor.list)失败,信息:{}", obj.getString("msg"));
|
|
@@ -1071,6 +984,10 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
insertRuixuanOrderList(queryType, accessToken, beginTime, endTime, url, pcursor, counts + 1);
|
|
|
}
|
|
|
}
|
|
|
+ //入库操作
|
|
|
+ if (!Check.isNull(commonlist)) {
|
|
|
+ supplyChainMapper.replaceBatchOrder(null, commonlist);
|
|
|
+ }
|
|
|
if (!Check.isNull(ruixuanList)) {
|
|
|
supplyChainMapper.replaceBatchOrder("ruixuan", ruixuanList); //TODO 测试完 修改该方法数据表
|
|
|
}
|
|
@@ -1089,6 +1006,7 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
if (!Check.isNull(zhishuiList)) {
|
|
|
supplyChainMapper.replaceBatchOrder("zhishui", zhishuiList);
|
|
|
}
|
|
|
+
|
|
|
if (!"nomore".equals(pcursor)) {
|
|
|
insertRuixuanOrderList(queryType, accessToken, beginTime, endTime, url, pcursor, 1);
|
|
|
}
|
|
@@ -1793,7 +1711,9 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
supplyChain.setOrderAmount(jsonObject.getLong("payAmount"));
|
|
|
supplyChain.setPayAmount(jsonObject.getLong("payAmount"));
|
|
|
supplyChain.setRegimentalPromotionRate(jsonObject.getLong("regimentalPromotionRate"));
|
|
|
- supplyChain.setShareRate(jsonObject.getLong("shareRateStr"));
|
|
|
+ if (!jsonObject.getString("shareRateStr").contains("正在计算中")) {
|
|
|
+ supplyChain.setShareRate(jsonObject.getString("shareRateStr"));
|
|
|
+ }
|
|
|
supplyChain.setBaseAmount(jsonObject.getLong("baseAmount"));
|
|
|
supplyChain.setRegimentalPromotionAmount(jsonObject.getLong("regimentalPromotionAmount") / 1000);
|
|
|
supplyChain.setTotalRegimentalSettleAmount(jsonObject.getLong("settlementAmount"));
|
|
@@ -1822,7 +1742,7 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
|
|
|
@Override
|
|
|
public void addListKuaishouActivityInfo() throws InterruptedException {
|
|
|
- String url = "https://openapi.kwaixiaodian.com";
|
|
|
+ String url = KuaiShouConstants.KFX_URL;
|
|
|
List<KuaishouAccessToken> mgsTokens = accessTokenService.getMgsTokenInfos();
|
|
|
for (KuaishouAccessToken mgsToken : mgsTokens) {
|
|
|
getMgsInfoKuaishouActivityInfo(mgsToken, url);
|
|
@@ -1858,7 +1778,7 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
|
|
|
@Override
|
|
|
public void addKuaishouActivityOpenItemList() throws InterruptedException {
|
|
|
- String url = "https://openapi.kwaixiaodian.com";
|
|
|
+ String url = KuaiShouConstants.KFX_URL;
|
|
|
List<Long> mgsActivityIds = supplyChainMapper.getMgsKuaishouActivityInfoList();
|
|
|
List<KuaishouAccessToken> mgsTokens = accessTokenService.getMgsTokenInfos();
|
|
|
for (KuaishouAccessToken mgsToken : mgsTokens) {
|