1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395 |
- package com.ruixuan.isc.service.impl;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.google.common.collect.Lists;
- import com.kuaishou.merchant.open.api.KsMerchantApiException;
- import com.kuaishou.merchant.open.api.client.AccessTokenKsMerchantClient;
- 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.OpenDistributionCpsLeaderOrderDetailRequest;
- 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.OpenDistributionInvestmentActivityOpenListRequest;
- 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.OpenDistributionInvestmentActivityOpenItemListResponse;
- 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;
- import com.ruixuan.isc.entity.KuaishouAccessToken;
- import com.ruixuan.isc.entity.KuaishouSupplyChain;
- import com.ruixuan.isc.mapper.KuaishouItemListMapper;
- import com.ruixuan.isc.mapper.SupplyChainMapper;
- import com.ruixuan.isc.service.IAccessTokenService;
- import com.ruixuan.isc.service.ISupplyChainService;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.data.mongodb.core.MongoTemplate;
- import org.springframework.data.mongodb.core.query.Criteria;
- import org.springframework.data.mongodb.core.query.Query;
- import org.springframework.stereotype.Service;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- @Slf4j
- @Service
- public class SupplyChainServiceImpl implements ISupplyChainService {
- @Autowired
- private SupplyChainMapper supplyChainMapper;
- @Autowired
- private KuaishouItemListMapper itemListMapper;
- @Autowired
- private IAccessTokenService accessTokenService;
- @Value("${ownership.id}")
- private String ownershipId;
- @Autowired
- private MongoTemplate mongoTemplate;
- // 获取订单数据
- @Override
- public List<JSONObject> getOrderList(Map<String, Object> requestMap) {
- List<JSONObject> list = supplyChainMapper.getOrderList(requestMap);
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject jsonObject = list.get(i);
- String promoterId = jsonObject.getString("promoterId");
- requestMap.put("promoterId", promoterId);
- List<JSONObject> topOrders = supplyChainMapper.getTopOrders(requestMap);
- jsonObject.put("topOrders", topOrders);
- List<JSONObject> tags = supplyChainMapper.getPromoterId(Long.valueOf(promoterId));
- jsonObject.put("tags", tags);
- }
- }
- return list;
- }
- //达人带货详情
- @Override
- public List<JSONObject> anchorOrderDetail(Map<String, Object> requestMap) {
- return supplyChainMapper.anchorOrderDetail(requestMap);
- }
- //订单统计
- @Override
- public List<JSONObject> orderStatistics(Map<String, Object> requestMap) {
- return supplyChainMapper.orderStatistics(requestMap);
- }
- //商品列表
- @Override
- public List<JSONObject> itemList(Map<String, Object> requestMap) {
- List<JSONObject> list = supplyChainMapper.itemList(requestMap);
- return list;
- }
- @Override
- public List<JSONObject> itemBindList(Map<String, Object> requestMap) {
- return supplyChainMapper.itemBindList(requestMap);
- }
- @Override
- public List<JSONObject> itemDetail(Map<String, Object> requestMap) {
- return supplyChainMapper.itemDetail(requestMap);
- }
- @Override
- public List<JSONObject> itemServiceCharge(Map<String, Object> requestMap) {
- return supplyChainMapper.itemServiceCharge(requestMap);
- }
- @Override
- public JSONObject getOrderTotal(Map<String, Object> requestMap) {
- return supplyChainMapper.getOrderTotal(requestMap);
- }
- @Override
- public Double getOrderTotalRatio(Map<String, Object> ratioMap) {
- return supplyChainMapper.getOrderTotalRatio(ratioMap);
- }
- @Override
- public JSONObject getAmountTotal(Map<String, Object> requestMap) {
- return supplyChainMapper.getAmountTotal(requestMap);
- }
- @Override
- public Double getAmountTotalRatio(Map<String, Object> ratioMap) {
- return supplyChainMapper.getAmountTotalRatio(ratioMap);
- }
- @Override
- public JSONObject getServiceAmountTotal(Map<String, Object> requestMap) {
- return supplyChainMapper.getServiceAmountTotal(requestMap);
- }
- @Override
- public List<JSONObject> getOrderRankRatioList(Map<String, Object> requestMap) {
- return supplyChainMapper.getOrderRankRatioList(requestMap);
- }
- @Override
- public List<JSONObject> getOrderRankList(Map<String, Object> requestMap) {
- return supplyChainMapper.getOrderRankList(requestMap);
- }
- @Override
- public List<JSONObject> getPromoterRankRatioList(Map<String, Object> requestMap) {
- return supplyChainMapper.getPromoterRankRatioList(requestMap);
- }
- @Override
- public List<JSONObject> getPromoterRatioList(Map<String, Object> requestMap) {
- return supplyChainMapper.getPromoterRatioList(requestMap);
- }
- @Override
- public List<JSONObject> exportPromoterTotal(Map<String, Object> requestMap) {
- return supplyChainMapper.exportPromoterTotal(requestMap);
- }
- @Override
- public List<JSONObject> exportPromoter(Map<String, Object> requestMap) {
- return supplyChainMapper.exportPromoter(requestMap);
- }
- @Override
- public List<JSONObject> exportOrder(Map<String, Object> requestMap) {
- return supplyChainMapper.exportOrder(requestMap);
- }
- @Override
- public List<JSONObject> getTopPromoterByItemId(Map<String, Object> requestMap) {
- return supplyChainMapper.getTopPromoterByItemId(requestMap);
- }
- @Override
- public List<JSONObject> bindUserItemList(Map<String, Object> requestMap) {
- return supplyChainMapper.bindUserItemList(requestMap);
- }
- @Override
- public List<JSONObject> getSupplyChainUserList() {
- return supplyChainMapper.getSupplyChainUserList();
- }
- @Override
- public boolean unbindUser(Long itemId) {
- return supplyChainMapper.unbindUser(itemId);
- }
- @Override
- public boolean bindUser(Long itemId, Long userId, String nikeName) {
- return supplyChainMapper.bindUser(itemId, userId, nikeName);
- }
- @Override
- public List<JSONObject> adminReportList(Map<String, Object> requestMap) {
- return supplyChainMapper.adminReportList(requestMap);
- }
- @Override
- public List<JSONObject> userItemDetail(Map<String, Object> requestMap) {
- return supplyChainMapper.userItemDetail(requestMap);
- }
- @Override
- public JSONObject getTimeIntervalRatio(Map<String, Object> requestMap) {
- return supplyChainMapper.getTimeIntervalRatio(requestMap);
- }
- @Override
- public List<JSONObject> indexStatistics(Map<String, Object> requestMap) {
- return supplyChainMapper.indexStatistics(requestMap);
- }
- @Override
- public JSONObject itemBindSummary() {
- return supplyChainMapper.itemBindSummary();
- }
- @Override
- public JSONObject userItemTotal(Map<String, Object> requestMap) {
- return supplyChainMapper.userItemTotal(requestMap);
- }
- @Override
- public List<JSONObject> exportUserItemDetail(Map<String, Object> requestMap) {
- return supplyChainMapper.exportUserItemDetail(requestMap);
- }
- @Override
- public JSONObject selectOrderInfo(Map<String, Object> requestMap) {
- return supplyChainMapper.selectOrderInfo(requestMap);
- }
- @Override
- public JSONObject selectOrderRate(List<String> promoterIds, List<Long> itemIds, Long statDate, Long endDate, int hour) {
- return supplyChainMapper.selectOrderRate(promoterIds, itemIds, statDate, endDate, hour);
- }
- @Override
- public JSONObject selectOrderRateBytedance(List<String> promoterIds, List<Long> itemIds, Long statDate, Long endDate, int hour) {
- return supplyChainMapper.selectOrderRateBytedance(promoterIds, itemIds, statDate, endDate, hour);
- }
- @Override
- public List<JSONObject> getMonthOrderAmount(Map<String, Object> map) {
- return supplyChainMapper.getMonthOrderAmount(map);
- }
- @Override
- public List<JSONObject> getMonthOrderAmountBytedance(Map<String, Object> map) {
- return supplyChainMapper.getMonthOrderAmountBytedance(map);
- }
- @Override
- public JSONObject getMonthOrderAmountTotalBytedance(Map<String, Object> map) {
- return supplyChainMapper.getMonthOrderAmountTotalBytedance(map);
- }
- @Override
- public List<JSONObject> getMonthOrderAmountByItemsBytedance(Map<String, Object> map) {
- return supplyChainMapper.getMonthOrderAmountByItemsBytedance(map);
- }
- @Override
- public JSONObject getMonthOrderAmountTotalByItemsBytedance(Map<String, Object> map) {
- return supplyChainMapper.getMonthOrderAmountTotalByItemsBytedance(map);
- }
- @Override
- public List<JSONObject> getOrderRankRatioListBytedance(Map<String, Object> requestMap) {
- return supplyChainMapper.getOrderRankRatioListBytedance(requestMap);
- }
- @Override
- public List<JSONObject> getOrderRankListBytedance(Map<String, Object> requestMap) {
- return supplyChainMapper.getOrderRankListBytedance(requestMap);
- }
- @Override
- public List<JSONObject> getPromoterRankRatioListBytedance(Map<String, Object> requestMap) {
- return supplyChainMapper.getPromoterRankRatioListBytedance(requestMap);
- }
- @Override
- public List<JSONObject> getPromoterRatioListBytedance(Map<String, Object> requestMap) {
- return supplyChainMapper.getPromoterRatioListBytedance(requestMap);
- }
- @Override
- public JSONObject selectOrderInfoBytedance(Map<String, Object> parMap) {
- return supplyChainMapper.selectOrderInfoBytedance(parMap);
- }
- @Override
- public List<JSONObject> bdReportListV2ByBind(Map<String, Object> requestMap) {
- return supplyChainMapper.bdReportListV2ByBind(requestMap);
- }
- @Override
- public List<JSONObject> exportBindOrder(Map<String, Object> requestMap) {
- return supplyChainMapper.exportBindOrder(requestMap);
- }
- @Override
- public JSONObject getMonthOrderAmountTotal(Map<String, Object> map) {
- return supplyChainMapper.getMonthOrderAmountTotal(map);
- }
- @Override
- public JSONObject selectOrderInfoByItemIds(Map<String, Object> requestMap) {
- return supplyChainMapper.selectOrderInfoByItemIds(requestMap);
- }
- @Override
- public List<JSONObject> getMonthOrderAmountByItems(Map<String, Object> map) {
- return supplyChainMapper.getMonthOrderAmountByItems(map);
- }
- @Override
- public JSONObject getMonthOrderAmountTotalByItems(Map<String, Object> map) {
- return supplyChainMapper.getMonthOrderAmountTotalByItems(map);
- }
- @Override
- public List<JSONObject> bdReportList(Map<String, Object> requestMap) {
- return supplyChainMapper.bdReportList(requestMap);
- }
- @Override
- public List<JSONObject> bdDetailList(Map<String, Object> requestMap) {
- return supplyChainMapper.bdDetailList(requestMap);
- }
- @Override
- public List<JSONObject> bdTotal(Map<String, Object> requestMap) {
- return supplyChainMapper.bdTotal(requestMap);
- }
- @Override
- public List<JSONObject> exportBdDetail(Map<String, Object> requestMap) {
- return supplyChainMapper.exportBdDetail(requestMap);
- }
- @Override
- public String getUserName(Long promoterId) {
- return supplyChainMapper.getUserName(promoterId);
- }
- @Override
- public List<JSONObject> exportBdReportList(Map<String, Object> requestMap) {
- return supplyChainMapper.exportBdReportList(requestMap);
- }
- @Override
- public List<JSONObject> exportAdminReportList(Map<String, Object> requestMap) {
- return supplyChainMapper.exportAdminReportList(requestMap);
- }
- @Override
- public List<JSONObject> getSupplyChainCourtshipUserList() {
- return supplyChainMapper.getSupplyChainCourtshipUserList();
- }
- @Override
- public List<JSONObject> adminReportListByBind(Map<String, Object> requestMap) {
- return supplyChainMapper.adminReportListByBind(requestMap);
- }
- @Override
- public List<JSONObject> exportAdminReportListByBind(Map<String, Object> requestMap) {
- return supplyChainMapper.exportAdminReportListByBind(requestMap);
- }
- @Override
- public List<JSONObject> bdReportListV2(Map<String, Object> requestMap) {
- return supplyChainMapper.bdReportListV2(requestMap);
- }
- @Override
- public List<JSONObject> bdTotalV2(Map<String, Object> requestMap) {
- return supplyChainMapper.bdTotalV2(requestMap);
- }
- @Override
- public List<JSONObject> bdDetailListV2(Map<String, Object> requestMap) {
- List<JSONObject> jsonObjects = supplyChainMapper.bdDetailListV2(requestMap);
- if (!Check.isNull(jsonObjects)) {
- for (int i = 0; i < jsonObjects.size(); i++) {
- JSONObject jsonObject = jsonObjects.get(i);
- Long promoterId = jsonObject.getLong("promoterId");
- List<JSONObject> tags = supplyChainMapper.getPromoterId(promoterId);
- jsonObject.put("tags", tags);
- }
- }
- return jsonObjects;
- }
- @Override
- public JSONObject selectOrderInfoByItemIdsBytedance(Map<String, Object> requestMap) {
- return supplyChainMapper.selectOrderInfoByItemIdsBytedance(requestMap);
- }
- @Override
- public void updateOrder(JSONObject eventJSon) {
- try {
- JSONObject info = eventJSon.getJSONObject("info");
- if (!Check.isNull(info)) {
- Long oid = info.getLong("oid");
- Integer cpsOrderStatus = info.getInteger("cpsOrderStatus");
- if (cpsOrderStatus == 30) {
- return;
- }
- if (cpsOrderStatus == 60) {
- Integer i = updateOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (i > 0) {
- log.info("订单ID:{},状态:{} 修改成功", oid, cpsOrderStatus);
- } else {
- log.error("订单ID:{},状态:{} 修改失败", oid, cpsOrderStatus);
- }
- } else {
- Integer i = this.updateOrderStatus(oid, cpsOrderStatus);
- if (i > 0) {
- log.info("订单ID:{},状态:{} 修改成功", oid, cpsOrderStatus);
- } else {
- log.error("订单ID:{},状态:{} 修改失败", oid, cpsOrderStatus);
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- private Integer updateOrderStatus(Long oid, Integer cpsOrderStatus) {
- if ("ruixuan".equals(ownershipId)) {
- int ruixuan = supplyChainMapper.updateRuixuanOrder(oid, cpsOrderStatus);
- if (ruixuan > 0) {
- return ruixuan;
- }
- int mgs = supplyChainMapper.updateMgsOrder(oid, cpsOrderStatus);
- if (mgs > 0) {
- return mgs;
- }
- int rocket = supplyChainMapper.updateRocketOrder(oid, cpsOrderStatus);
- if (rocket > 0) {
- return rocket;
- }
- int yufu = supplyChainMapper.updateYufuOrder(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- int yuxiu = supplyChainMapper.updateYuXiuOrder(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int zhishui = supplyChainMapper.updateZhishuiOrder(oid, cpsOrderStatus);
- if (zhishui > 0) {
- return zhishui;
- }
- }
- if ("miaogousi".equals(ownershipId)) {
- int mgs = supplyChainMapper.updateMgsOrder(oid, cpsOrderStatus);
- if (mgs > 0) {
- return mgs;
- }
- int ruixuan = supplyChainMapper.updateRuixuanOrder(oid, cpsOrderStatus);
- if (ruixuan > 0) {
- return ruixuan;
- }
- int rocket = supplyChainMapper.updateRocketOrder(oid, cpsOrderStatus);
- if (rocket > 0) {
- return rocket;
- }
- int yufu = supplyChainMapper.updateYufuOrder(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- int yuxiu = supplyChainMapper.updateYuXiuOrder(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int zhishui = supplyChainMapper.updateZhishuiOrder(oid, cpsOrderStatus);
- if (zhishui > 0) {
- return zhishui;
- }
- }
- if ("rocket".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;
- }
- int yuxiu = supplyChainMapper.updateYuXiuOrder(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int zhishui = supplyChainMapper.updateZhishuiOrder(oid, cpsOrderStatus);
- if (zhishui > 0) {
- return zhishui;
- }
- }
- if ("yufu".equals(ownershipId)) {
- int yufu = supplyChainMapper.updateYufuOrder(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- int ruixuan = supplyChainMapper.updateRuixuanOrder(oid, cpsOrderStatus);
- if (ruixuan > 0) {
- return ruixuan;
- }
- int mgs = supplyChainMapper.updateMgsOrder(oid, cpsOrderStatus);
- if (mgs > 0) {
- return mgs;
- }
- int rocket = supplyChainMapper.updateRocketOrder(oid, cpsOrderStatus);
- if (rocket > 0) {
- return rocket;
- }
- int yuxiu = supplyChainMapper.updateYuXiuOrder(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int zhishui = supplyChainMapper.updateZhishuiOrder(oid, cpsOrderStatus);
- if (zhishui > 0) {
- return zhishui;
- }
- }
- if ("yuxiu".equals(ownershipId)) {
- int yuxiu = supplyChainMapper.updateYuXiuOrder(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int ruixuan = supplyChainMapper.updateRuixuanOrder(oid, cpsOrderStatus);
- if (ruixuan > 0) {
- return ruixuan;
- }
- int mgs = supplyChainMapper.updateMgsOrder(oid, cpsOrderStatus);
- if (mgs > 0) {
- return mgs;
- }
- int rocket = supplyChainMapper.updateRocketOrder(oid, cpsOrderStatus);
- if (rocket > 0) {
- return rocket;
- }
- int yufu = supplyChainMapper.updateYufuOrder(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- int zhishui = supplyChainMapper.updateZhishuiOrder(oid, cpsOrderStatus);
- if (zhishui > 0) {
- return zhishui;
- }
- }
- if ("zhishui".equals(ownershipId)) {
- int zhishui = supplyChainMapper.updateZhishuiOrder(oid, cpsOrderStatus);
- if (zhishui > 0) {
- return zhishui;
- }
- int yuxiu = supplyChainMapper.updateYuXiuOrder(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int ruixuan = supplyChainMapper.updateRuixuanOrder(oid, cpsOrderStatus);
- if (ruixuan > 0) {
- return ruixuan;
- }
- int mgs = supplyChainMapper.updateMgsOrder(oid, cpsOrderStatus);
- if (mgs > 0) {
- return mgs;
- }
- int rocket = supplyChainMapper.updateRocketOrder(oid, cpsOrderStatus);
- if (rocket > 0) {
- return rocket;
- }
- int yufu = supplyChainMapper.updateYufuOrder(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- }
- return 0;
- }
- private Integer updateOrderRegimentalSettleAmount(Long oid, Integer cpsOrderStatus) {
- if ("ruixuan".equals(ownershipId)) {
- int ruixuan = supplyChainMapper.updateRuiXuanOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (ruixuan > 0) {
- return ruixuan;
- }
- int mgs = supplyChainMapper.updateMgsOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (mgs > 0) {
- return mgs;
- }
- int rocket = supplyChainMapper.updateRocketOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (rocket > 0) {
- return rocket;
- }
- int yufu = supplyChainMapper.updateYufuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- int yuxiu = supplyChainMapper.updateYuxiuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int zhishui = supplyChainMapper.updateZhishuiOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (zhishui > 0) {
- return zhishui;
- }
- }
- if ("miaogousi".equals(ownershipId)) {
- int mgs = supplyChainMapper.updateMgsOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (mgs > 0) {
- return mgs;
- }
- int ruixuan = supplyChainMapper.updateRuiXuanOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (ruixuan > 0) {
- return ruixuan;
- }
- int rocket = supplyChainMapper.updateRocketOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (rocket > 0) {
- return rocket;
- }
- int yufu = supplyChainMapper.updateYufuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- int yuxiu = supplyChainMapper.updateYuxiuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int zhishui = supplyChainMapper.updateZhishuiOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (zhishui > 0) {
- return zhishui;
- }
- }
- if ("rocket".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;
- }
- int yuxiu = supplyChainMapper.updateYuxiuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int zhishui = supplyChainMapper.updateZhishuiOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (zhishui > 0) {
- return zhishui;
- }
- }
- if ("yufu".equals(ownershipId)) {
- int yufu = supplyChainMapper.updateYufuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- int ruixuan = supplyChainMapper.updateRuiXuanOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (ruixuan > 0) {
- return ruixuan;
- }
- int mgs = supplyChainMapper.updateMgsOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (mgs > 0) {
- return mgs;
- }
- int rocket = supplyChainMapper.updateRocketOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (rocket > 0) {
- return rocket;
- }
- int yuxiu = supplyChainMapper.updateYuxiuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int zhishui = supplyChainMapper.updateZhishuiOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (zhishui > 0) {
- return zhishui;
- }
- }
- if ("yuxiu".equals(ownershipId)) {
- int yuxiu = supplyChainMapper.updateYuxiuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int ruixuan = supplyChainMapper.updateRuiXuanOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (ruixuan > 0) {
- return ruixuan;
- }
- int mgs = supplyChainMapper.updateMgsOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (mgs > 0) {
- return mgs;
- }
- int rocket = supplyChainMapper.updateRocketOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (rocket > 0) {
- return rocket;
- }
- int yufu = supplyChainMapper.updateYufuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- int zhishui = supplyChainMapper.updateZhishuiOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (zhishui > 0) {
- return zhishui;
- }
- }
- if ("zhishui".equals(ownershipId)) {
- int zhishui = supplyChainMapper.updateZhishuiOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (zhishui > 0) {
- return zhishui;
- }
- int ruixuan = supplyChainMapper.updateRuiXuanOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (ruixuan > 0) {
- return ruixuan;
- }
- int mgs = supplyChainMapper.updateMgsOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (mgs > 0) {
- return mgs;
- }
- int rocket = supplyChainMapper.updateRocketOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (rocket > 0) {
- return rocket;
- }
- int yufu = supplyChainMapper.updateYufuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- int yuxiu = supplyChainMapper.updateYuxiuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- }
- return 0;
- }
- @Override
- public void updateItem(JSONObject eventJSon) {
- try {
- JSONObject info = eventJSon.getJSONObject("info");
- if (!Check.isNull(info)) {
- Long itemId = info.getLong("itemId");
- Integer status = info.getInteger("status");
- supplyChainMapper.updateItem(itemId, status);
- log.info("商品id:{},状态:{} 修改成功", itemId, status);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- @Override
- public void insertOrder(JSONObject eventJSon) {
- JSONObject info = eventJSon.getJSONObject("info");
- if (!Check.isNull(info)) {
- Integer messageType = info.getInteger("messageType");
- //新增
- if (1 == messageType) {
- KuaishouSupplyChain supplyChain = new KuaishouSupplyChain(info);
- 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();
- }
- // supplyChainMapper.replaceOne(ownership, supplyChain);
- supplyChainMapper.replaceOne("rocket", supplyChain);// todo 测试完 删除改行 放开上面 并修改数据表
- } //更新
- else if (2 == messageType) {
- Integer cpsOrderStatus = info.getInteger("cpsOrderStatus");
- Long oid = info.getLong("oid");
- if (cpsOrderStatus == 60 || cpsOrderStatus == 40) {
- // Integer i = updateOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- Integer i = updateOrderRegimentalSettleAmountCeshi(oid, cpsOrderStatus);// todo 测试完 删除改行 放开上面
- if (i <= 0) {
- log.error("订单ID:{},状态:{} 修改失败", oid, cpsOrderStatus);
- }
- } else {
- Integer i = this.updateOrderStatus(oid, cpsOrderStatus);
- if (i <= 0) {
- log.error("订单ID:{},状态:{} 修改失败", oid, cpsOrderStatus);
- }
- }
- }
- }
- }
- /*测完删除*/
- private Integer updateOrderRegimentalSettleAmountCeshi(Long oid, Integer cpsOrderStatus) {
- return supplyChainMapper.updateRocketOrderRegimentalSettleAmountCS(oid, cpsOrderStatus);
- }
- @Override
- public void addList(String beginDate, String endDate, String pcursor) throws InterruptedException {
- String url = KuaiShouConstants.KFX_URL;
- Long beginTime = DateUtils.getStartLongTime(beginDate);
- Long endTime = DateUtils.getEndLongTime(endDate);
- // Map<Long, Long> itemMap = getItemMap();
- List<KuaishouAccessToken> tokens = accessTokenService.getTokenInfos();
- for (KuaishouAccessToken accessToken : tokens) {
- getInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- Thread.sleep(3000);
- List<KuaishouAccessToken> mgsTokens = accessTokenService.getMgsTokenInfos();
- for (KuaishouAccessToken accessToken : mgsTokens) {
- getMgsInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- Thread.sleep(3000);
- List<KuaishouAccessToken> rocketTokens = accessTokenService.getRocketTokenInfos();
- for (KuaishouAccessToken accessToken : rocketTokens) {
- getRocketInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- Thread.sleep(3000);
- List<KuaishouAccessToken> yufuTokens = accessTokenService.getYufuTokenInfos();
- for (KuaishouAccessToken accessToken : yufuTokens) {
- getYufuInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- Thread.sleep(3000);
- List<KuaishouAccessToken> yuxiuTokens = accessTokenService.getYuxiuTokenInfos();
- for (KuaishouAccessToken accessToken : yuxiuTokens) {
- getYuxiuInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- Thread.sleep(3000);
- List<KuaishouAccessToken> zhishuiTokens = accessTokenService.getZhishuiTokenInfos();
- for (KuaishouAccessToken accessToken : zhishuiTokens) {
- getZhishuiInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- }
- @Override
- public void insertOrderList(Long tokenId, Integer queryType, String beginDate, String endDate) throws Exception {
- Long beginTime = DateUtils.getStartLongTime(beginDate);
- Long endTime = DateUtils.getEndLongTime(endDate);
- KuaishouAccessToken token = accessTokenService.getAccessToken(tokenId);
- insertRuixuanOrderList(queryType, token, beginTime, endTime, KuaiShouConstants.KFX_URL, "", 1);
- }
- public static void main(String[] args) {
- Long beginTime = DateUtils.getTimeStamp(DateUtils.getHourTime(-2));
- //当前时间
- Long endTime = DateUtils.getTimeStamp(DateUtils.getTime());
- System.err.println(beginTime);
- System.err.println(endTime);
- }
- @Override
- public void insertNowdayOrderList(Long tokenId) throws Exception {
- //2小时前 时间戳
- Long beginTime = DateUtils.getTimeStamp(DateUtils.getHourTime(-2));
- //当前时间
- Long endTime = DateUtils.getTimeStamp(DateUtils.getTime());
- 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<>();
- List<KuaishouSupplyChain> yufuList = new ArrayList<>();
- List<KuaishouSupplyChain> yuxiuList = new ArrayList<>();
- List<KuaishouSupplyChain> zhishuiList = 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(queryType);
- //分销订单状态 [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);
- 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();
- // }
- 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);
- }
- }
- }
- } else {
- log.error("===查询分销团长订单列表(open.distribution.cps.leader.order.cursor.list)失败,信息:{}", obj.getString("msg"));
- log.error("游标:{},执行次数:{}", pcursor, counts);
- if (counts <= 3) {
- 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 测试完 修改该方法数据表
- }
- if (!Check.isNull(mgsList)) {
- supplyChainMapper.replaceBatchOrder("miaogousi", mgsList);
- }
- if (!Check.isNull(rocketList)) {
- supplyChainMapper.replaceBatchOrder("rocket", rocketList);
- }
- if (!Check.isNull(yufuList)) {
- supplyChainMapper.replaceBatchOrder("yufu", yufuList);
- }
- if (!Check.isNull(yuxiuList)) {
- supplyChainMapper.replaceBatchOrder("yuxiu", yuxiuList);
- }
- if (!Check.isNull(zhishuiList)) {
- supplyChainMapper.replaceBatchOrder("zhishui", zhishuiList);
- }
- if (!"nomore".equals(pcursor)) {
- insertRuixuanOrderList(queryType, accessToken, beginTime, endTime, url, pcursor, 1);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- 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 {
- List<Long> ruixuanList = new ArrayList<>();
- List<Long> mgsList = new ArrayList<>();
- List<Long> rocketList = new ArrayList<>();
- List<Long> yufuList = new ArrayList<>();
- List<Long> yuxiuList = new ArrayList<>();
- List<Long> zhishuiList = 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");
- if (!Check.isNull(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)) {
- ruixuanList.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"));
- }
- if ("yuxiu".equals(ownership)) {
- yuxiuList.add(info.getLong("oid"));
- }
- if ("zhishui".equals(ownership)) {
- zhishuiList.add(info.getLong("oid"));
- }
- }
- }
- }
- }
- } else {
- log.error("===查询分销团长订单列表(open.distribution.cps.leader.order.cursor.list)失败,信息:{}", obj.getString("msg"));
- log.error("游标:{},执行次数:{}", pcursor, counts);
- if (counts <= 3) {
- getInfo(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(yufuList);
- }
- if (!Check.isNull(yuxiuList)) {
- supplyChainMapper.updateYuxiuKuaishouSupplyChain(yuxiuList);
- }
- if (!Check.isNull(zhishuiList)) {
- supplyChainMapper.updateZhishuiKuaishouSupplyChain(zhishuiList);
- }
- if (!"nomore".equals(pcursor)) {
- getInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- }
- private void getMgsInfo(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<>();
- List<Long> yuxiuList = new ArrayList<>();
- List<Long> zhishuiList = 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)) {
- mgsList.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"));
- }
- if ("yuxiu".equals(ownership)) {
- yuxiuList.add(info.getLong("oid"));
- }
- if ("zhishui".equals(ownership)) {
- zhishuiList.add(info.getLong("oid"));
- }
- }
- }
- }
- } else {
- log.error("===MGS查询分销团长订单列表(open.distribution.cps.leader.order.cursor.list)失败,信息:{}", obj.getString("error_msg"));
- log.error("MGS游标:{},执行次数:{}", pcursor, counts);
- if (counts <= 3) {
- getMgsInfo(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(yufuList);
- }
- if (!Check.isNull(yuxiuList)) {
- supplyChainMapper.updateYuxiuKuaishouSupplyChain(yuxiuList);
- }
- if (!Check.isNull(zhishuiList)) {
- supplyChainMapper.updateZhishuiKuaishouSupplyChain(zhishuiList);
- }
- if (!"nomore".equals(pcursor)) {
- getMgsInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- }
- private void getRocketInfo(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<>();
- List<Long> yuxiuList = new ArrayList<>();
- List<Long> zhishuiList = 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)) {
- rocketList.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"));
- }
- if ("yuxiu".equals(ownership)) {
- yuxiuList.add(info.getLong("oid"));
- }
- if ("zhishui".equals(ownership)) {
- zhishuiList.add(info.getLong("oid"));
- }
- }
- }
- }
- } else {
- log.error("===Rocket查询分销团长订单列表(open.distribution.cps.leader.order.cursor.list)失败,信息:{}", obj.getString("error_msg"));
- log.error("Rocket游标:{},执行次数:{}", 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(yufuList);
- }
- if (!Check.isNull(yuxiuList)) {
- supplyChainMapper.updateYuxiuKuaishouSupplyChain(yuxiuList);
- }
- if (!Check.isNull(zhishuiList)) {
- supplyChainMapper.updateZhishuiKuaishouSupplyChain(zhishuiList);
- }
- 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<>();
- List<Long> yuxiuList = new ArrayList<>();
- List<Long> zhishuiList = 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"));
- }
- if ("yuxiu".equals(ownership)) {
- yuxiuList.add(info.getLong("oid"));
- }
- if ("zhishui".equals(ownership)) {
- zhishuiList.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) {
- getYufuInfo(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(yufuList);
- }
- if (!Check.isNull(yuxiuList)) {
- supplyChainMapper.updateYuxiuKuaishouSupplyChain(yuxiuList);
- }
- if (!Check.isNull(zhishuiList)) {
- supplyChainMapper.updateZhishuiKuaishouSupplyChain(zhishuiList);
- }
- if (!"nomore".equals(pcursor)) {
- getYufuInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- }
- private void getYuxiuInfo(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<>();
- List<Long> yuxiuList = new ArrayList<>();
- List<Long> zhishuiList = 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)) {
- yuxiuList.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"));
- }
- if ("yuxiu".equals(ownership)) {
- yuxiuList.add(info.getLong("oid"));
- }
- if ("zhishui".equals(ownership)) {
- zhishuiList.add(info.getLong("oid"));
- }
- }
- }
- }
- } else {
- log.error("===yuxiu查询分销团长订单列表(open.distribution.cps.leader.order.cursor.list)失败,信息:{}", obj.getString("error_msg"));
- log.error("yuxiu游标:{},执行次数:{}", pcursor, counts);
- if (counts <= 3) {
- getYuxiuInfo(accessToken, beginTime, endTime, url, pcursor, counts + 1);
- }
- }
- if (!Check.isNull(yuxiuList)) {
- supplyChainMapper.updateYuxiuKuaishouSupplyChain(yuxiuList);
- }
- 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(yufuList);
- }
- if (!Check.isNull(zhishuiList)) {
- supplyChainMapper.updateZhishuiKuaishouSupplyChain(zhishuiList);
- }
- if (!"nomore".equals(pcursor)) {
- getYuxiuInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- }
- private void getZhishuiInfo(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<>();
- List<Long> yuxiuList = new ArrayList<>();
- List<Long> zhishuiList = 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)) {
- zhishuiList.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"));
- }
- if ("yuxiu".equals(ownership)) {
- yuxiuList.add(info.getLong("oid"));
- }
- if ("zhishui".equals(ownership)) {
- zhishuiList.add(info.getLong("oid"));
- }
- }
- }
- }
- } else {
- log.error("===zhishui查询分销团长订单列表(open.distribution.cps.leader.order.cursor.list)失败,信息:{}", obj.getString("error_msg"));
- log.error("zhishui游标:{},执行次数:{}", pcursor, counts);
- if (counts <= 3) {
- getZhishuiInfo(accessToken, beginTime, endTime, url, pcursor, counts + 1);
- }
- }
- if (!Check.isNull(zhishuiList)) {
- supplyChainMapper.updateZhishuiKuaishouSupplyChain(zhishuiList);
- }
- if (!Check.isNull(yuxiuList)) {
- supplyChainMapper.updateYuxiuKuaishouSupplyChain(yuxiuList);
- }
- 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(yufuList);
- }
- if (!"nomore".equals(pcursor)) {
- getZhishuiInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- }
- private KuaishouSupplyChain organizeData(JSONObject jsonObject, Map<Long, Long> itemMap) {
- KuaishouSupplyChain supplyChain = new KuaishouSupplyChain();
- supplyChain.setOid(jsonObject.getLong("oid"));
- JSONObject item = jsonObject.getJSONArray("cpsOrderProductView").getJSONObject(0);
- if (!Check.isNull(item)) {
- supplyChain.setItemId(item.getLong("itemId"));
- supplyChain.setItemTitle(item.getString("itemTitle"));
- supplyChain.setReservePrice(item.getLong("itemPrice"));
- supplyChain.setImageUrl(itemListMapper.getItemImgUrl(item.getLong("itemId")));
- supplyChain.setSellerId(item.getLong("sellerId"));
- }
- supplyChain.setOrderStatus(jsonObject.getInteger("cpsOrderStatus"));
- supplyChain.setOrderCreateTime(jsonObject.getLong("orderCreateTime"));
- supplyChain.setSendStatus(jsonObject.getInteger("sendStatus"));
- supplyChain.setSettlementBizType(jsonObject.getInteger("settlementBizType"));
- supplyChain.setSettlementBizTypeDesc(getSettlementBizTypeDesc(jsonObject.getInteger("settlementBizType")));
- supplyChain.setSendTime(jsonObject.getLong("sendTime"));
- supplyChain.setRecvTime(jsonObject.getLong("recvTime"));
- supplyChain.setPromoterId(jsonObject.getLong("promotionId"));
- supplyChain.setPromoterNickName(jsonObject.getString("promotionNickName"));
- supplyChain.setActivityId(jsonObject.getLong("activityId"));
- supplyChain.setOrderAmount(jsonObject.getLong("payAmount"));
- supplyChain.setPayAmount(jsonObject.getLong("payAmount"));
- supplyChain.setRegimentalPromotionRate(jsonObject.getLong("regimentalPromotionRate"));
- 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"));
- supplyChain.setStatDate(DateUtils.tempToDate(jsonObject.getLong("orderCreateTime")));
- supplyChain.setItemCommissionRate(itemMap.get(item.getLong("itemId")));
- return supplyChain;
- }
- private String getSettlementBizTypeDesc(Integer settlementBizType) {
- return settlementBizType == 1 ? "快分销" : "聚力计划";
- }
- // 获取订单佣金率
- public Map<Long, Long> getItemMap() {
- Map<Long, Long> returnMap = new HashMap<>();
- List<JSONObject> list = itemListMapper.itemList();
- if (!Check.isNull(list)) {
- for (int i = 0; i < list.size(); i++) {
- JSONObject jsonObject = list.get(i);
- returnMap.put(jsonObject.getLong("itemId"), jsonObject.getLong("itemCommissionRate"));
- }
- }
- return returnMap;
- }
- @Override
- public void addListKuaishouActivityInfo() throws InterruptedException {
- String url = KuaiShouConstants.KFX_URL;
- List<KuaishouAccessToken> mgsTokens = accessTokenService.getMgsTokenInfos();
- for (KuaishouAccessToken mgsToken : mgsTokens) {
- getMgsInfoKuaishouActivityInfo(mgsToken, url);
- }
- Thread.sleep(3000);
- List<KuaishouAccessToken> rocketTokens = accessTokenService.getRocketTokenInfos();
- for (KuaishouAccessToken token : rocketTokens) {
- getRocketInfoKuaishouActivityInfo(token, url);
- }
- Thread.sleep(3000);
- List<KuaishouAccessToken> tokens = accessTokenService.getTokenInfos();
- for (KuaishouAccessToken accessToken : tokens) {
- getInfoKuaishouActivityInfo(accessToken, url);
- }
- Thread.sleep(3000);
- List<KuaishouAccessToken> yufutokens = accessTokenService.getYufuTokenInfos();
- for (KuaishouAccessToken accessToken : yufutokens) {
- getYufuInfoKuaishouActivityInfo(accessToken, url);
- }
- Thread.sleep(3000);
- List<KuaishouAccessToken> yuxiutokens = accessTokenService.getYuxiuTokenInfos();
- for (KuaishouAccessToken accessToken : yuxiutokens) {
- getYuxiuInfoKuaishouActivityInfo(accessToken, url);
- }
- Thread.sleep(3000);
- List<KuaishouAccessToken> zhishuitokens = accessTokenService.getZhishuiTokenInfos();
- for (KuaishouAccessToken accessToken : zhishuitokens) {
- getZhishuiInfoKuaishouActivityInfo(accessToken, url);
- }
- }
- @Override
- public void addKuaishouActivityOpenItemList() throws InterruptedException {
- String url = KuaiShouConstants.KFX_URL;
- List<Long> mgsActivityIds = supplyChainMapper.getMgsKuaishouActivityInfoList();
- List<KuaishouAccessToken> mgsTokens = accessTokenService.getMgsTokenInfos();
- for (KuaishouAccessToken mgsToken : mgsTokens) {
- for (Long activityId : mgsActivityIds) {
- getKuaishouActivityOpenItemList(mgsToken, url, activityId, 1, "miaogousi");
- }
- }
- Thread.sleep(3000);
- List<Long> rocketActivityIds = supplyChainMapper.getRocketKuaishouActivityInfoList();
- List<KuaishouAccessToken> rocketTokens = accessTokenService.getRocketTokenInfos();
- for (KuaishouAccessToken token : rocketTokens) {
- for (Long activityId : rocketActivityIds) {
- getKuaishouActivityOpenItemList(token, url, activityId, 1, "rocket");
- }
- }
- Thread.sleep(3000);
- List<Long> activityIds = supplyChainMapper.getKuaishouActivityInfoList();
- List<KuaishouAccessToken> tokens = accessTokenService.getTokenInfos();
- for (KuaishouAccessToken accessToken : tokens) {
- for (Long activityId : activityIds) {
- getKuaishouActivityOpenItemList(accessToken, url, activityId, 1, "ruixuan");
- }
- }
- Thread.sleep(3000);
- List<Long> yufuActivityIds = supplyChainMapper.getYufuKuaishouActivityInfoList();
- List<KuaishouAccessToken> yufutokens = accessTokenService.getYufuTokenInfos();
- for (KuaishouAccessToken accessToken : yufutokens) {
- for (Long activityId : yufuActivityIds) {
- getKuaishouActivityOpenItemList(accessToken, url, activityId, 1, "yufu");
- }
- }
- Thread.sleep(30000);
- List<Long> yuxiuActivityIds = supplyChainMapper.getYuxiuKuaishouActivityInfoList();
- List<KuaishouAccessToken> yuxiutokens = accessTokenService.getYuxiuTokenInfos();
- for (KuaishouAccessToken accessToken : yuxiutokens) {
- for (Long activityId : yuxiuActivityIds) {
- getKuaishouActivityOpenItemList(accessToken, url, activityId, 1, "yuxiu");
- }
- }
- Thread.sleep(30000);
- List<Long> zhishuiActivityIds = supplyChainMapper.getZhishuiKuaishouActivityInfoList();
- List<KuaishouAccessToken> zhishuitokens = accessTokenService.getZhishuiTokenInfos();
- for (KuaishouAccessToken accessToken : zhishuitokens) {
- for (Long activityId : zhishuiActivityIds) {
- getKuaishouActivityOpenItemList(accessToken, url, activityId, 1, "zhishui");
- }
- }
- }
- @Override
- public List<JSONObject> getBytedanceOrderHourDataList(Long date) {
- return supplyChainMapper.getBytedanceOrderHourDataList(date);
- }
- @Override
- public List<JSONObject> getKuaishouOrderHourDataList(Long date) {
- return supplyChainMapper.getKuaishouOrderHourDataList(date);
- }
- @Override
- public List<JSONObject> getTopOrders(Map<String, Object> requestMap) {
- return supplyChainMapper.getTopOrders(requestMap);
- }
- @Override
- public List<JSONObject> exportItemDetail(Map<String, Object> requestMap) {
- return supplyChainMapper.exportItemDetail(requestMap);
- }
- @Override
- public List<JSONObject> getKsChannelGmvHourByDate(List<Long> userList, Integer nowDate, Integer hourType) {
- return supplyChainMapper.getKsChannelGmvHourByDate(userList, nowDate, hourType);
- }
- @Override
- public List<JSONObject> getKsCourtshipGmvHourByDate(List<Long> userList, Integer nowDate, Integer hourType) {
- return supplyChainMapper.getKsCourtshipGmvHourByDate(userList, nowDate, hourType);
- }
- @Override
- public List<JSONObject> getBytedanceChannelGmvHourByDate(List<Long> userList, Long date, Integer hourType) {
- return supplyChainMapper.getBytedanceChannelGmvHourByDate(userList, date, hourType);
- }
- @Override
- public List<JSONObject> getBytedanceCourtshipGmvHourByDate(List<Long> userList, Long data, Integer hourType) {
- return supplyChainMapper.getBytedanceCourtshipGmvHourByDate(userList, data, hourType);
- }
- @Override
- public List<JSONObject> shopList(Map<String, Object> requestMap) {
- return supplyChainMapper.shopList(requestMap);
- }
- @Override
- public List<JSONObject> shopDetail(Map<String, Object> requestMap) {
- return supplyChainMapper.shopDetail(requestMap);
- }
- @Override
- public List<Long> getItemIdsByUserId(Long userId) {
- return supplyChainMapper.getItemIdsByUserId(userId);
- }
- @Override
- public List<Long> getItemIdsByDeptId(Long deptId) {
- return supplyChainMapper.getItemIdsByDeptId(deptId);
- }
- @Override
- public List<JSONObject> getKsChannelGmvHourByDateRoi(List<Long> userList, Integer nowDate, Integer hourType) {
- return supplyChainMapper.getKsChannelGmvHourByDateRoi(userList, nowDate, hourType);
- }
- @Override
- public List<JSONObject> getKsCourtshipGmvHourByDateRoi(List<Long> userList, Integer nowDate, Integer hourType) {
- return supplyChainMapper.getKsCourtshipGmvHourByDateRoi(userList, nowDate, hourType);
- }
- @Override
- public List<JSONObject> getBytedanceChannelGmvHourByDateRoi(List<Long> userList, Long dataNow, Integer hourType) {
- return supplyChainMapper.getBytedanceChannelGmvHourByDateRoi(userList, dataNow, hourType);
- }
- @Override
- public List<JSONObject> getBytedanceCourtshipGmvHourByDateRoi(List<Long> userList, Long dataNow, Integer hourType) {
- return supplyChainMapper.getBytedanceCourtshipGmvHourByDateRoi(userList, dataNow, hourType);
- }
- private void getInfoKuaishouActivityInfo(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(200);
- 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("===团长查询招商活动列表(open.distribution.investment.activity.open.list)失败,tokenId:{},返回信息:{}", accessToken.getId(), obj.toJSONString());
- return;
- }
- if (Check.isNotNull(list) && list.size() > 0) {
- supplyChainMapper.replaceKuaishouActivityInfo(list);
- }
- }
- private void getKuaishouActivityOpenItemList(KuaishouAccessToken accessToken, String url, Long activityId, Integer page, String dbtype) {
- String appKey = accessToken.getAppKey();
- String signSecret = accessToken.getSignSecret();
- if (Check.isNull(signSecret) || Check.isNull(appKey)) {
- return;
- }
- AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(url, appKey, signSecret);
- OpenDistributionInvestmentActivityOpenItemListRequest request = new OpenDistributionInvestmentActivityOpenItemListRequest();
- request.setAccessToken(accessToken.getAccessToken());
- request.setApiMethodVersion(1L);
- //每页活动数量
- request.setLimit(200);
- Integer offset = (page - 1) * 200;
- request.setOffset(offset);
- request.setActivityId(activityId);
- OpenDistributionInvestmentActivityOpenItemListResponse response = null;
- try {
- Thread.sleep(1000);
- response = client.execute(request);
- } catch (Exception e) {
- e.printStackTrace();
- }
- JSONObject obj = JSONObject.parseObject(GsonUtils.toJSON(response));
- Integer total = null;
- String code = obj.getString("code");
- if ("1".equals(code)) {
- JSONObject data = obj.getJSONObject("data");
- JSONArray result = data.getJSONArray("activityItemDataList");
- total = data.getInteger("total");
- List<Long> itemIds = new ArrayList<>();
- List<KuaiShouActivityOpenItemList> list = new ArrayList<>();
- for (int i = 0; i < result.size(); i++) {
- JSONObject info = result.getJSONObject(i);
- //商品活动审核状态:1-待审核,2-审核通过,3-审核拒绝,5-已失效
- // if (info.getLong("itemAuditStatus") == 1 || info.getLong("itemAuditStatus") == 2) {
- KuaiShouActivityOpenItemList activityInfo = new KuaiShouActivityOpenItemList(info);
- list.add(activityInfo);
- // }
- //2-审核通过
- if (info.getLong("itemAuditStatus") == 2) {
- itemIds.add(info.getLong("itemId"));
- }
- }
- if (Check.isNotNull(list) && list.size() > 0) {
- if ("ruixuan".equals(dbtype)) {
- supplyChainMapper.replaceKuaiShouActivityOpenItemList(list);
- } else if ("miaogousi".equals(dbtype)) {
- supplyChainMapper.replaceMgsKuaiShouActivityOpenItemList(list);
- } else if ("rocket".equals(dbtype)) {
- supplyChainMapper.replaceRocketKuaiShouActivityOpenItemList(list);
- } else if ("yufu".equals(dbtype)) {
- supplyChainMapper.replaceYufuKuaiShouActivityOpenItemList(list);
- } else if ("yuxiu".equals(dbtype)) {
- supplyChainMapper.replaceYuxiuKuaiShouActivityOpenItemList(list);
- } else if ("zhishui".equals(dbtype)) {
- supplyChainMapper.replaceZhishuiKuaiShouActivityOpenItemList(list);
- }
- }
- List<List<Long>> splits = Lists.newArrayList(Lists.partition(itemIds, 10));
- for (List<Long> itIds : splits) {
- getActivityItemDetail(accessToken, url, activityId, itIds, dbtype);
- }
- } else {
- log.error("===团长招商活动已报名商品列表(open.distribution.investment.activity.open.item.list)失败,tokenId:{},活动ID:{}" +
- "\n返还信息:{}", accessToken.getId(), activityId, obj);
- return;
- }
- if (total - page * 200 > 0) {
- getKuaishouActivityOpenItemList(accessToken, url, activityId, page + 1, dbtype);
- }
- }
- /**
- * open.distribution.investment.activity.item.detail
- * 招商活动商品详情接口
- */
- private void getActivityItemDetail(KuaishouAccessToken accessToken, String url, Long activityId, List<Long> itemIds, String dbtype) {
- List<KuaiShouActivityOpenItemList> 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);
- OpenDistributionInvestmentActivityItemDetailRequest request = new OpenDistributionInvestmentActivityItemDetailRequest();
- request.setAccessToken(accessToken.getAccessToken());
- request.setApiMethodVersion(1L);
- request.setActivityId(activityId);
- request.setItemId(itemIds);
- OpenDistributionInvestmentActivityItemDetailResponse 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 data = obj.getJSONArray("data");
- for (int i = 0; i < data.size(); i++) {
- JSONObject info = data.getJSONObject(i);
- KuaiShouActivityOpenItemList activityInfo = new KuaiShouActivityOpenItemList(info);
- list.add(activityInfo);
- }
- if (Check.isNotNull(list) && list.size() > 0) {
- if ("ruixuan".equals(dbtype)) {
- for (KuaiShouActivityOpenItemList kuaiShouActivityOpenItemList : list) {
- supplyChainMapper.updateKuaiShouActivityOpenItemList(kuaiShouActivityOpenItemList);
- }
- } else if ("miaogousi".equals(dbtype)) {
- for (KuaiShouActivityOpenItemList kuaiShouActivityOpenItemList : list) {
- supplyChainMapper.updateMgsKuaiShouActivityOpenItemList(kuaiShouActivityOpenItemList);
- }
- } else if ("rocket".equals(dbtype)) {
- for (KuaiShouActivityOpenItemList kuaiShouActivityOpenItemList : list) {
- supplyChainMapper.updateRocketKuaiShouActivityOpenItemList(kuaiShouActivityOpenItemList);
- }
- } else if ("yufu".equals(dbtype)) {
- for (KuaiShouActivityOpenItemList kuaiShouActivityOpenItemList : list) {
- supplyChainMapper.updateYufuKuaiShouActivityOpenItemList(kuaiShouActivityOpenItemList);
- }
- } else if ("yuxiu".equals(dbtype)) {
- for (KuaiShouActivityOpenItemList kuaiShouActivityOpenItemList : list) {
- supplyChainMapper.updateYuxiuKuaiShouActivityOpenItemList(kuaiShouActivityOpenItemList);
- }
- } else if ("zhishui".equals(dbtype)) {
- for (KuaiShouActivityOpenItemList kuaiShouActivityOpenItemList : list) {
- supplyChainMapper.updateZhishuiKuaiShouActivityOpenItemList(kuaiShouActivityOpenItemList);
- }
- }
- }
- } else {
- log.error("===招商活动商品详情接口(open.distribution.investment.activity.item.detail)失败,信息:{}", obj.getString("error_msg"));
- return;
- }
- }
- private KuaiShouActivityInfo organizeKuaishouActivityInfo(JSONObject jsonObject) {
- KuaiShouActivityInfo activityInfo = new KuaiShouActivityInfo();
- activityInfo.setActivityId(jsonObject.getLong("activityId"));
- activityInfo.setRegimentalId(jsonObject.getLong("activityUserId"));
- activityInfo.setActivityTitle(jsonObject.getString("activityTitle"));
- activityInfo.setActivityType(jsonObject.getInteger("activityType"));
- activityInfo.setActivityBeginTime(DateUtils.tempToDate(jsonObject.getLong("activityBeginTime")));
- activityInfo.setActivityEndTime(DateUtils.tempToDate(jsonObject.getLong("activityEndTime")));
- activityInfo.setActivityStatus(jsonObject.getInteger("activityStatus"));
- JSONObject activityItemDataInfo = jsonObject.getJSONObject("activityItemDataView");
- if (!Check.isNull(activityItemDataInfo)) {
- activityInfo.setApplyItemCount(activityItemDataInfo.getInteger("applyItemCount"));
- activityInfo.setWaitAuditItemCount(activityItemDataInfo.getInteger("waitAuditItemCount"));
- activityInfo.setAuditPassItemCount(activityItemDataInfo.getInteger("auditPassItemCount"));
- }
- return activityInfo;
- }
- private void getMgsInfoKuaishouActivityInfo(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(200);
- 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("===团长查询招商活动列表(open.distribution.investment.activity.open.list)失败,信息:{}", obj.getString("msg"));
- return;
- }
- if (Check.isNotNull(list) && list.size() > 0) {
- supplyChainMapper.replaceMgsKuaishouActivityInfo(list);
- }
- }
- private void getRocketInfoKuaishouActivityInfo(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(200);
- 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("===Rocket团长查询招商活动列表(open.distribution.investment.activity.open.list)失败,信息:{}", obj.getString("msg"));
- return;
- }
- if (Check.isNotNull(list) && list.size() > 0) {
- 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(200);
- 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);
- }
- }
- private void getYuxiuInfoKuaishouActivityInfo(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(200);
- 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("===Yuxiu团长查询招商活动列表(open.distribution.investment.activity.open.list)失败,信息:{}", obj.getString("msg"));
- return;
- }
- if (Check.isNotNull(list) && list.size() > 0) {
- supplyChainMapper.replaceYuxiuKuaishouActivityInfo(list);
- }
- }
- private void getZhishuiInfoKuaishouActivityInfo(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(200);
- 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("===zhishui团长查询招商活动列表(open.distribution.investment.activity.open.list)失败,信息:{}", obj.getString("msg"));
- return;
- }
- if (Check.isNotNull(list) && list.size() > 0) {
- supplyChainMapper.replaceZhishuiKuaishouActivityInfo(list);
- }
- }
- }
|