|
@@ -450,6 +450,10 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
if (rocket > 0) {
|
|
|
return rocket;
|
|
|
}
|
|
|
+ int yufu = supplyChainMapper.updateYufuOrder(oid, cpsOrderStatus);
|
|
|
+ if (yufu > 0) {
|
|
|
+ return yufu;
|
|
|
+ }
|
|
|
}
|
|
|
if ("miaogousi".equals(ownershipId)) {
|
|
|
int mgs = supplyChainMapper.updateMgsOrder(oid, cpsOrderStatus);
|
|
@@ -464,6 +468,10 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
if (rocket > 0) {
|
|
|
return rocket;
|
|
|
}
|
|
|
+ int yufu = supplyChainMapper.updateYufuOrder(oid, cpsOrderStatus);
|
|
|
+ if (yufu > 0) {
|
|
|
+ return yufu;
|
|
|
+ }
|
|
|
}
|
|
|
if ("rocket".equals(ownershipId)) {
|
|
|
int rocket = supplyChainMapper.updateRocketOrder(oid, cpsOrderStatus);
|
|
@@ -478,6 +486,28 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
if (mgs > 0) {
|
|
|
return mgs;
|
|
|
}
|
|
|
+ int yufu = supplyChainMapper.updateYufuOrder(oid, cpsOrderStatus);
|
|
|
+ if (yufu > 0) {
|
|
|
+ return yufu;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("yufu".equals(ownershipId)) {
|
|
|
+ int rocket = supplyChainMapper.updateRocketOrder(oid, cpsOrderStatus);
|
|
|
+ if (rocket > 0) {
|
|
|
+ return rocket;
|
|
|
+ }
|
|
|
+ int ruixuan = supplyChainMapper.updateRuixuanOrder(oid, cpsOrderStatus);
|
|
|
+ if (ruixuan > 0) {
|
|
|
+ return ruixuan;
|
|
|
+ }
|
|
|
+ int mgs = supplyChainMapper.updateMgsOrder(oid, cpsOrderStatus);
|
|
|
+ if (mgs > 0) {
|
|
|
+ return mgs;
|
|
|
+ }
|
|
|
+ int yufu = supplyChainMapper.updateYufuOrder(oid, cpsOrderStatus);
|
|
|
+ if (yufu > 0) {
|
|
|
+ return yufu;
|
|
|
+ }
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
@@ -497,6 +527,10 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
if (rocket > 0) {
|
|
|
return rocket;
|
|
|
}
|
|
|
+ int yufu = supplyChainMapper.updateYufuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
|
|
|
+ if (yufu > 0) {
|
|
|
+ return yufu;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if ("miaogousi".equals(ownershipId)) {
|
|
@@ -512,6 +546,10 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
if (rocket > 0) {
|
|
|
return rocket;
|
|
|
}
|
|
|
+ int yufu = supplyChainMapper.updateYufuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
|
|
|
+ if (yufu > 0) {
|
|
|
+ return yufu;
|
|
|
+ }
|
|
|
}
|
|
|
if ("rocket".equals(ownershipId)) {
|
|
|
int rocket = supplyChainMapper.updateRocketOrderRegimentalSettleAmount(oid, cpsOrderStatus);
|
|
@@ -526,6 +564,29 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
if (mgs > 0) {
|
|
|
return mgs;
|
|
|
}
|
|
|
+ int yufu = supplyChainMapper.updateYufuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
|
|
|
+ if (yufu > 0) {
|
|
|
+ return yufu;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("yufu".equals(ownershipId)) {
|
|
|
+ int rocket = supplyChainMapper.updateRocketOrderRegimentalSettleAmount(oid, cpsOrderStatus);
|
|
|
+ if (rocket > 0) {
|
|
|
+ return rocket;
|
|
|
+ }
|
|
|
+ int ruixuan = supplyChainMapper.updateRuiXuanOrderRegimentalSettleAmount(oid, cpsOrderStatus);
|
|
|
+ if (ruixuan > 0) {
|
|
|
+ return ruixuan;
|
|
|
+ }
|
|
|
+ int mgs = supplyChainMapper.updateMgsOrderRegimentalSettleAmount(oid, cpsOrderStatus);
|
|
|
+ if (mgs > 0) {
|
|
|
+ return mgs;
|
|
|
+ }
|
|
|
+ int yufu = supplyChainMapper.updateYufuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
|
|
|
+ if (yufu > 0) {
|
|
|
+ return yufu;
|
|
|
+ }
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
@@ -568,12 +629,19 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
getRocketInfo(accessToken, beginTime, endTime, url, pcursor, 1);
|
|
|
}
|
|
|
|
|
|
+ Thread.sleep(600000);
|
|
|
+ List<KuaishouAccessToken> youziTokens = accessTokenService.getYufuTokenInfos();
|
|
|
+ for (KuaishouAccessToken accessToken : rocketTokens) {
|
|
|
+ getYufuInfo(accessToken, beginTime, endTime, url, pcursor, 1);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void getInfo(KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, Integer counts) throws InterruptedException {
|
|
|
List<Long> ruixuanList = new ArrayList<>();
|
|
|
List<Long> mgsList = new ArrayList<>();
|
|
|
List<Long> rocketList = new ArrayList<>();
|
|
|
+ List<Long> yufuList = new ArrayList<>();
|
|
|
String appKey = accessToken.getAppKey();
|
|
|
String signSecret = accessToken.getSignSecret();
|
|
|
if (Check.isNull(signSecret) || Check.isNull(appKey)) {
|
|
@@ -635,7 +703,9 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
}
|
|
|
if ("rocket".equals(ownership)) {
|
|
|
rocketList.add(info.getLong("oid"));
|
|
|
-
|
|
|
+ }
|
|
|
+ if ("yufu".equals(ownership)) {
|
|
|
+ yufuList.add(info.getLong("oid"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -660,7 +730,9 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
if (!Check.isNull(rocketList)) {
|
|
|
supplyChainMapper.updateRocketKuaishouSupplyChain(rocketList);
|
|
|
}
|
|
|
-
|
|
|
+ if (!Check.isNull(yufuList)) {
|
|
|
+ supplyChainMapper.updateYufuKuaishouSupplyChain(rocketList);
|
|
|
+ }
|
|
|
if (!"nomore".equals(pcursor)) {
|
|
|
getInfo(accessToken, beginTime, endTime, url, pcursor, 1);
|
|
|
}
|
|
@@ -670,6 +742,7 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
List<Long> ruixuanList = new ArrayList<>();
|
|
|
List<Long> mgsList = new ArrayList<>();
|
|
|
List<Long> rocketList = new ArrayList<>();
|
|
|
+ List<Long> yufuList = new ArrayList<>();
|
|
|
|
|
|
String appKey = accessToken.getAppKey();
|
|
|
String signSecret = accessToken.getSignSecret();
|
|
@@ -731,7 +804,9 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
}
|
|
|
if ("rocket".equals(ownership)) {
|
|
|
rocketList.add(info.getLong("oid"));
|
|
|
-
|
|
|
+ }
|
|
|
+ if ("yufu".equals(ownership)) {
|
|
|
+ yufuList.add(info.getLong("oid"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -754,6 +829,9 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
supplyChainMapper.updateRocketKuaishouSupplyChain(rocketList);
|
|
|
}
|
|
|
|
|
|
+ if (!Check.isNull(yufuList)) {
|
|
|
+ supplyChainMapper.updateYufuKuaishouSupplyChain(rocketList);
|
|
|
+ }
|
|
|
if (!"nomore".equals(pcursor)) {
|
|
|
getMgsInfo(accessToken, beginTime, endTime, url, pcursor, 1);
|
|
|
}
|
|
@@ -763,6 +841,8 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
List<Long> ruixuanList = new ArrayList<>();
|
|
|
List<Long> mgsList = new ArrayList<>();
|
|
|
List<Long> rocketList = new ArrayList<>();
|
|
|
+ List<Long> yufuList = new ArrayList<>();
|
|
|
+
|
|
|
String appKey = accessToken.getAppKey();
|
|
|
String signSecret = accessToken.getSignSecret();
|
|
|
if (Check.isNull(signSecret) || Check.isNull(appKey)) {
|
|
@@ -823,6 +903,9 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
if ("rocket".equals(ownership)) {
|
|
|
rocketList.add(info.getLong("oid"));
|
|
|
}
|
|
|
+ if ("yufu".equals(ownership)) {
|
|
|
+ yufuList.add(info.getLong("oid"));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -842,12 +925,110 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
if (!Check.isNull(rocketList)) {
|
|
|
supplyChainMapper.updateRocketKuaishouSupplyChain(rocketList);
|
|
|
}
|
|
|
+ if (!Check.isNull(yufuList)) {
|
|
|
+ supplyChainMapper.updateYufuKuaishouSupplyChain(rocketList);
|
|
|
+ }
|
|
|
if (!"nomore".equals(pcursor)) {
|
|
|
getRocketInfo(accessToken, beginTime, endTime, url, pcursor, 1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private void getYufuInfo(KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, Integer counts) throws InterruptedException {
|
|
|
+ List<Long> ruixuanList = new ArrayList<>();
|
|
|
+ List<Long> mgsList = new ArrayList<>();
|
|
|
+ List<Long> rocketList = new ArrayList<>();
|
|
|
+ List<Long> yufuList = new ArrayList<>();
|
|
|
+ String appKey = accessToken.getAppKey();
|
|
|
+ String signSecret = accessToken.getSignSecret();
|
|
|
+ if (Check.isNull(signSecret) || Check.isNull(appKey)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(url, appKey, signSecret);
|
|
|
+ OpenDistributionCpsLeaderOrderCursorListRequest request = new OpenDistributionCpsLeaderOrderCursorListRequest();
|
|
|
+ request.setAccessToken(accessToken.getAccessToken());
|
|
|
+ request.setApiMethodVersion(1L);
|
|
|
+
|
|
|
+ //排序类型 [1:按指定查询类型降序] [2:按指定查询类型升序]
|
|
|
+ request.setSortType(1);
|
|
|
+ //查询类型 [1:按分销订单创建时间查询] [2:按分销订单更新时间查询][4:按订单实际创建时间查询]
|
|
|
+ request.setQueryType(2);
|
|
|
+ //分销订单状态 [0:全部订单] [30:已付款] [50:已收货] [60:已结算] [80:已失效]
|
|
|
+ request.setCpsOrderStatus(0);
|
|
|
+ request.setDistributorId(0l);
|
|
|
+ request.setBeginTime(beginTime);
|
|
|
+ request.setEndTime(endTime);
|
|
|
+ request.setPcursor(pcursor);
|
|
|
+ request.setPageize(100);
|
|
|
+ request.setFundType(1);
|
|
|
+
|
|
|
+ OpenDistributionCpsLeaderOrderCursorListResponse 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)) {
|
|
|
+ JSONObject data = obj.getJSONObject("data");
|
|
|
+ pcursor = data.getString("pcursor");
|
|
|
+ JSONArray orderView = data.getJSONArray("orderView");
|
|
|
+ for (int i = 0; i < orderView.size(); i++) {
|
|
|
+ JSONObject info = orderView.getJSONObject(i);
|
|
|
+ Integer sendStatus = info.getInteger("sendStatus");
|
|
|
+ if (Check.isNotNull(sendStatus) && sendStatus == 1) {
|
|
|
+ JSONArray cpsOrderProductView = info.getJSONArray("cpsOrderProductView");
|
|
|
+ JSONObject itemJson = cpsOrderProductView.getJSONObject(0);
|
|
|
+ Long itemId = itemJson.getLong("itemId");
|
|
|
+ Criteria criteria = new Criteria();
|
|
|
+ criteria = Criteria.where("_id").is(itemId);
|
|
|
+ Query query = new Query(criteria);
|
|
|
+ ItemCheck itemCheck = mongoTemplate.findOne(query, ItemCheck.class);
|
|
|
+ if (Check.isNull(itemCheck)) {
|
|
|
+ yufuList.add(info.getLong("oid"));
|
|
|
+ }
|
|
|
+ if (!Check.isNull(itemCheck)) {
|
|
|
+ String ownership = itemCheck.getOwnership();
|
|
|
+ if ("ruixuan".equals(ownership)) {
|
|
|
+ ruixuanList.add(info.getLong("oid"));
|
|
|
+ }
|
|
|
+ if ("miaogousi".equals(ownership)) {
|
|
|
+ mgsList.add(info.getLong("oid"));
|
|
|
+ }
|
|
|
+ if ("rocket".equals(ownership)) {
|
|
|
+ rocketList.add(info.getLong("oid"));
|
|
|
+ }
|
|
|
+ if ("yufu".equals(ownership)) {
|
|
|
+ yufuList.add(info.getLong("oid"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("===yufu查询分销团长订单列表(open.distribution.cps.leader.order.cursor.list)失败,信息:{}", obj.getString("error_msg"));
|
|
|
+ log.error("yufu游标:{},执行次数:{}", pcursor, counts);
|
|
|
+ if (counts <= 3) {
|
|
|
+ getRocketInfo(accessToken, beginTime, endTime, url, pcursor, counts + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!Check.isNull(ruixuanList)) {
|
|
|
+ supplyChainMapper.updateKuaishouSupplyChain(ruixuanList);
|
|
|
+ }
|
|
|
+ if (!Check.isNull(mgsList)) {
|
|
|
+ supplyChainMapper.updateMgsKuaishouSupplyChain(mgsList);
|
|
|
+ }
|
|
|
+ if (!Check.isNull(rocketList)) {
|
|
|
+ supplyChainMapper.updateRocketKuaishouSupplyChain(rocketList);
|
|
|
+ }
|
|
|
+ if (!Check.isNull(yufuList)) {
|
|
|
+ supplyChainMapper.updateYufuKuaishouSupplyChain(rocketList);
|
|
|
+ }
|
|
|
+ if (!"nomore".equals(pcursor)) {
|
|
|
+ getYufuInfo(accessToken, beginTime, endTime, url, pcursor, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private KuaishouSupplyChain organizeData(JSONObject jsonObject, Map<Long, Long> itemMap) {
|
|
|
KuaishouSupplyChain supplyChain = new KuaishouSupplyChain();
|
|
|
supplyChain.setOid(jsonObject.getLong("oid"));
|
|
@@ -918,6 +1099,11 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
for (KuaishouAccessToken accessToken : tokens) {
|
|
|
getInfoKuaishouActivityInfo(accessToken, url);
|
|
|
}
|
|
|
+ Thread.sleep(600000);
|
|
|
+ List<KuaishouAccessToken> yufutokens = accessTokenService.getYufuTokenInfos();
|
|
|
+ for (KuaishouAccessToken accessToken : yufutokens) {
|
|
|
+ getYufuInfoKuaishouActivityInfo(accessToken, url);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -949,6 +1135,15 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ Thread.sleep(30000);
|
|
|
+ List<Long> yufuActivityIds = supplyChainMapper.getYufuKuaishouActivityInfoList();
|
|
|
+ List<KuaishouAccessToken> yufutokens = accessTokenService.getYufuTokenInfos();
|
|
|
+ for (KuaishouAccessToken accessToken : yufutokens) {
|
|
|
+ for (Long activityId : yufuActivityIds) {
|
|
|
+ getKuaishouActivityOpenItemList(accessToken, url, activityId, 1, "yufu");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1083,6 +1278,8 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
supplyChainMapper.replaceMgsKuaiShouActivityOpenItemList(list);
|
|
|
} else if ("rocket".equals(dbtype)) {
|
|
|
supplyChainMapper.replaceRocketKuaiShouActivityOpenItemList(list);
|
|
|
+ } else if ("yufu".equals(dbtype)) {
|
|
|
+ supplyChainMapper.replaceYufuKuaiShouActivityOpenItemList(list);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1132,9 +1329,9 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
}
|
|
|
if (Check.isNotNull(list) && list.size() > 0) {
|
|
|
if ("ruixuan".equals(dbtype)) {
|
|
|
- for (KuaiShouActivityOpenItemList kuaiShouActivityOpenItemList : list) {
|
|
|
- supplyChainMapper.updateKuaiShouActivityOpenItemList(kuaiShouActivityOpenItemList);
|
|
|
- }
|
|
|
+ for (KuaiShouActivityOpenItemList kuaiShouActivityOpenItemList : list) {
|
|
|
+ supplyChainMapper.updateKuaiShouActivityOpenItemList(kuaiShouActivityOpenItemList);
|
|
|
+ }
|
|
|
} else if ("miaogousi".equals(dbtype)) {
|
|
|
for (KuaiShouActivityOpenItemList kuaiShouActivityOpenItemList : list) {
|
|
|
supplyChainMapper.updateMgsKuaiShouActivityOpenItemList(kuaiShouActivityOpenItemList);
|
|
@@ -1143,9 +1340,11 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
for (KuaiShouActivityOpenItemList kuaiShouActivityOpenItemList : list) {
|
|
|
supplyChainMapper.updateRocketKuaiShouActivityOpenItemList(kuaiShouActivityOpenItemList);
|
|
|
}
|
|
|
+ } else if ("yufu".equals(dbtype)) {
|
|
|
+ for (KuaiShouActivityOpenItemList kuaiShouActivityOpenItemList : list) {
|
|
|
+ supplyChainMapper.updateYufuKuaiShouActivityOpenItemList(kuaiShouActivityOpenItemList);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
} else {
|
|
|
log.error("===招商活动商品详情接口(open.distribution.investment.activity.item.detail)失败,信息:{}", obj.getString("error_msg"));
|
|
@@ -1254,5 +1453,46 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
|
|
|
supplyChainMapper.replaceRocketKuaishouActivityInfo(list);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void getYufuInfoKuaishouActivityInfo(KuaishouAccessToken accessToken, String url) {
|
|
|
+ List<KuaiShouActivityInfo> list = new ArrayList<>();
|
|
|
+ String appKey = accessToken.getAppKey();
|
|
|
+ String signSecret = accessToken.getSignSecret();
|
|
|
+ if (Check.isNull(signSecret) || Check.isNull(appKey)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(url, appKey, signSecret);
|
|
|
+ OpenDistributionInvestmentActivityOpenListRequest request = new OpenDistributionInvestmentActivityOpenListRequest();
|
|
|
+
|
|
|
+ request.setAccessToken(accessToken.getAccessToken());
|
|
|
+ request.setApiMethodVersion(1L);
|
|
|
+
|
|
|
+ //每页活动数量
|
|
|
+ request.setLimit(5000);
|
|
|
+ OpenDistributionInvestmentActivityOpenListResponse 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)) {
|
|
|
+ JSONObject data = obj.getJSONObject("data");
|
|
|
+ JSONArray result = data.getJSONArray("result");
|
|
|
+ for (int i = 0; i < result.size(); i++) {
|
|
|
+ JSONObject info = result.getJSONObject(i);
|
|
|
+ KuaiShouActivityInfo activityInfo = organizeKuaishouActivityInfo(info);
|
|
|
+ list.add(activityInfo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("===Yufu团长查询招商活动列表(open.distribution.investment.activity.open.list)失败,信息:{}", obj.getString("msg"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Check.isNotNull(list) && list.size() > 0) {
|
|
|
+ supplyChainMapper.replaceYufuKuaishouActivityInfo(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|