12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811 |
- 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.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.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.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.HashMap;
- import java.util.List;
- import java.util.Map;
- @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;
- }
- }
- 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;
- }
- }
- 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;
- }
- }
- if ("yufu".equals(ownershipId)) {
- int yufu = supplyChainMapper.updateYufuOrder(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- 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 yuxiu = supplyChainMapper.updateYuxiuOrder(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- }
- if ("yuxiu".equals(ownershipId)) {
- int yuxiu = supplyChainMapper.updateYuxiuOrder(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int yufu = supplyChainMapper.updateYufuOrder(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- 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;
- }
- }
- 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;
- }
- }
- 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;
- }
- }
- 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;
- }
- }
- if ("yufu".equals(ownershipId)) {
- int yufu = supplyChainMapper.updateYufuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- 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 yuxiu = supplyChainMapper.updateYuxiuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- }
- if ("yuxiu".equals(ownershipId)) {
- int yuxiu = supplyChainMapper.updateYuxiuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yuxiu > 0) {
- return yuxiu;
- }
- int rocket = supplyChainMapper.updateRocketOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (rocket > 0) {
- return rocket;
- }
- int ruixuan = supplyChainMapper.updateRuiXuanOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (ruixuan > 0) {
- return ruixuan;
- }
- int mgs = supplyChainMapper.updateMgsOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (mgs > 0) {
- return mgs;
- }
- int yufu = supplyChainMapper.updateYufuOrderRegimentalSettleAmount(oid, cpsOrderStatus);
- if (yufu > 0) {
- return yufu;
- }
- }
- return 0;
- }
- @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 addList(String beginDate, String endDate, String pcursor) throws InterruptedException {
- String url = "https://openapi.kwaixiaodian.com";
- 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(30000);
- List<KuaishouAccessToken> mgsTokens = accessTokenService.getMgsTokenInfos();
- for (KuaishouAccessToken accessToken : mgsTokens) {
- getMgsInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- Thread.sleep(30000);
- List<KuaishouAccessToken> rocketTokens = accessTokenService.getRocketTokenInfos();
- for (KuaishouAccessToken accessToken : rocketTokens) {
- getRocketInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- Thread.sleep(30000);
- List<KuaishouAccessToken> yufuTokens = accessTokenService.getYufuTokenInfos();
- for (KuaishouAccessToken accessToken : yufuTokens) {
- getYufuInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- Thread.sleep(30000);
- List<KuaishouAccessToken> yuxiuTokens = accessTokenService.getYuxiuTokenInfos();
- for (KuaishouAccessToken accessToken : yuxiuTokens) {
- getYuxiuInfo(accessToken, beginTime, endTime, url, pcursor, 1);
- }
- }
- private void getInfo(KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, Integer counts) throws InterruptedException {
- List<Long> ruixuanList = new ArrayList<>();
- List<Long> mgsList = new ArrayList<>();
- List<Long> rocketList = new ArrayList<>();
- List<Long> yufuList = new ArrayList<>();
- List<Long> yuxiuList = 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"));
- }
- }
- }
- }
- }
- } 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 (!"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<>();
- 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"));
- }
- }
- }
- }
- } 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 (!"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<>();
- 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"));
- }
- }
- }
- }
- } 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 (!"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<>();
- 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"));
- }
- }
- }
- }
- } 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 (!"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<>();
- 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"));
- }
- }
- }
- }
- } 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 (!"nomore".equals(pcursor)) {
- getYuxiuInfo(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"));
- supplyChain.setShareRate(jsonObject.getLong("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 = "https://openapi.kwaixiaodian.com";
- List<KuaishouAccessToken> mgsTokens = accessTokenService.getMgsTokenInfos();
- for (KuaishouAccessToken mgsToken : mgsTokens) {
- getMgsInfoKuaishouActivityInfo(mgsToken, url);
- }
- Thread.sleep(30000);
- List<KuaishouAccessToken> rocketTokens = accessTokenService.getRocketTokenInfos();
- for (KuaishouAccessToken token : rocketTokens) {
- getRocketInfoKuaishouActivityInfo(token, url);
- }
- Thread.sleep(30000);
- List<KuaishouAccessToken> tokens = accessTokenService.getTokenInfos();
- for (KuaishouAccessToken accessToken : tokens) {
- getInfoKuaishouActivityInfo(accessToken, url);
- }
- Thread.sleep(30000);
- List<KuaishouAccessToken> yufutokens = accessTokenService.getYufuTokenInfos();
- for (KuaishouAccessToken accessToken : yufutokens) {
- getYufuInfoKuaishouActivityInfo(accessToken, url);
- }
- Thread.sleep(30000);
- List<KuaishouAccessToken> yuxiutokens = accessTokenService.getYuxiuTokenInfos();
- for (KuaishouAccessToken accessToken : yuxiutokens) {
- getYuxiuInfoKuaishouActivityInfo(accessToken, url);
- }
- }
- @Override
- public void addKuaishouActivityOpenItemList() throws InterruptedException {
- String url = "https://openapi.kwaixiaodian.com";
- 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(30000);
- 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(30000);
- 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(30000);
- List<Long> yufuActivityIds = supplyChainMapper.getYufuKuaishouActivityInfoList();
- List<KuaishouAccessToken> yufutokens = accessTokenService.getYufuTokenInfos();
- for (KuaishouAccessToken accessToken : yufutokens) {
- for (Long activityId : yufuActivityIds) {
- getKuaishouActivityOpenItemList(accessToken, url, activityId, 1, "yufu");
- }
- }
- 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");
- }
- }
- }
- @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) {
- return supplyChainMapper.getKsChannelGmvHourByDate(userList, nowDate);
- }
- @Override
- public List<JSONObject> getKsCourtshipGmvHourByDate(List<Long> userList, Integer nowDate) {
- return supplyChainMapper.getKsCourtshipGmvHourByDate(userList, nowDate);
- }
- @Override
- public List<JSONObject> getBytedanceChannelGmvHourByDate(List<Long> userList, Long date) {
- return supplyChainMapper.getBytedanceChannelGmvHourByDate(userList, date);
- }
- @Override
- public List<JSONObject> getBytedanceCourtshipGmvHourByDate(List<Long> userList, Long data) {
- return supplyChainMapper.getBytedanceCourtshipGmvHourByDate(userList, data);
- }
- @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) {
- return supplyChainMapper.getKsChannelGmvHourByDateRoi(userList, nowDate);
- }
- @Override
- public List<JSONObject> getKsCourtshipGmvHourByDateRoi(List<Long> userList, Integer nowDate) {
- return supplyChainMapper.getKsCourtshipGmvHourByDateRoi(userList, nowDate);
- }
- @Override
- public List<JSONObject> getBytedanceChannelGmvHourByDateRoi(List<Long> userList, Long dataNow) {
- return supplyChainMapper.getBytedanceChannelGmvHourByDateRoi(userList, dataNow);
- }
- @Override
- public List<JSONObject> getBytedanceCourtshipGmvHourByDateRoi(List<Long> userList, Long dataNow) {
- return supplyChainMapper.getBytedanceCourtshipGmvHourByDateRoi(userList, dataNow);
- }
- 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(5000);
- OpenDistributionInvestmentActivityOpenListResponse response = null;
- try {
- response = client.execute(request);
- } catch (KsMerchantApiException e) {
- e.printStackTrace();
- }
- JSONObject obj = JSONObject.parseObject(GsonUtils.toJSON(response));
- String code = obj.getString("code");
- if ("1".equals(code)) {
- JSONObject data = obj.getJSONObject("data");
- JSONArray result = data.getJSONArray("result");
- for (int i = 0; i < result.size(); i++) {
- JSONObject info = result.getJSONObject(i);
- KuaiShouActivityInfo activityInfo = organizeKuaishouActivityInfo(info);
- list.add(activityInfo);
- }
- } else {
- log.error("===团长查询招商活动列表(open.distribution.investment.activity.open.list)失败,信息:{}", obj.getString("msg"));
- 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 {
- response = client.execute(request);
- } catch (KsMerchantApiException 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);
- }
- }
- 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)失败,信息:{}", obj.getString("error_msg"));
- return;
- }
- if (total - page * 200 > 0) {
- getKuaishouActivityOpenItemList(accessToken, url, activityId, page + 1, dbtype);
- }
- }
- 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 {
- 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(5000);
- OpenDistributionInvestmentActivityOpenListResponse response = null;
- try {
- response = client.execute(request);
- } catch (KsMerchantApiException e) {
- e.printStackTrace();
- }
- JSONObject obj = JSONObject.parseObject(GsonUtils.toJSON(response));
- String code = obj.getString("code");
- if ("1".equals(code)) {
- JSONObject data = obj.getJSONObject("data");
- JSONArray result = data.getJSONArray("result");
- for (int i = 0; i < result.size(); i++) {
- JSONObject info = result.getJSONObject(i);
- KuaiShouActivityInfo activityInfo = organizeKuaishouActivityInfo(info);
- list.add(activityInfo);
- }
- } else {
- log.error("===团长查询招商活动列表(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(5000);
- OpenDistributionInvestmentActivityOpenListResponse response = null;
- try {
- response = client.execute(request);
- } catch (KsMerchantApiException e) {
- e.printStackTrace();
- }
- JSONObject obj = JSONObject.parseObject(GsonUtils.toJSON(response));
- String code = obj.getString("code");
- if ("1".equals(code)) {
- JSONObject data = obj.getJSONObject("data");
- JSONArray result = data.getJSONArray("result");
- for (int i = 0; i < result.size(); i++) {
- JSONObject info = result.getJSONObject(i);
- KuaiShouActivityInfo activityInfo = organizeKuaishouActivityInfo(info);
- list.add(activityInfo);
- }
- } else {
- log.error("===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(5000);
- OpenDistributionInvestmentActivityOpenListResponse response = null;
- try {
- response = client.execute(request);
- } catch (KsMerchantApiException e) {
- e.printStackTrace();
- }
- JSONObject obj = JSONObject.parseObject(GsonUtils.toJSON(response));
- String code = obj.getString("code");
- if ("1".equals(code)) {
- JSONObject data = obj.getJSONObject("data");
- JSONArray result = data.getJSONArray("result");
- for (int i = 0; i < result.size(); i++) {
- JSONObject info = result.getJSONObject(i);
- KuaiShouActivityInfo activityInfo = organizeKuaishouActivityInfo(info);
- list.add(activityInfo);
- }
- } else {
- log.error("===Yufu团长查询招商活动列表(open.distribution.investment.activity.open.list)失败,信息:{}", obj.getString("msg"));
- return;
- }
- if (Check.isNotNull(list) && list.size() > 0) {
- supplyChainMapper.replaceYufuKuaishouActivityInfo(list);
- }
- }
- 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(5000);
- OpenDistributionInvestmentActivityOpenListResponse response = null;
- try {
- response = client.execute(request);
- } catch (KsMerchantApiException e) {
- e.printStackTrace();
- }
- JSONObject obj = JSONObject.parseObject(GsonUtils.toJSON(response));
- String code = obj.getString("code");
- if ("1".equals(code)) {
- JSONObject data = obj.getJSONObject("data");
- JSONArray result = data.getJSONArray("result");
- for (int i = 0; i < result.size(); i++) {
- JSONObject info = result.getJSONObject(i);
- KuaiShouActivityInfo activityInfo = organizeKuaishouActivityInfo(info);
- list.add(activityInfo);
- }
- } else {
- log.error("===Yuxiu团长查询招商活动列表(open.distribution.investment.activity.open.list)失败,信息:{}", obj.getString("msg"));
- return;
- }
- if (Check.isNotNull(list) && list.size() > 0) {
- supplyChainMapper.replaceYuxiuKuaishouActivityInfo(list);
- }
- }
- }
|