|
|
|
@ -3,16 +3,20 @@ package com.hchbox.task;
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import com.hchbox.config.MiProperties;
|
|
|
|
|
import com.hchbox.constant.DefaultNumberConstants;
|
|
|
|
|
import com.hchbox.constant.TaoBaoDataMethodConstants;
|
|
|
|
|
import com.hchbox.dto.SellerAccountDTO;
|
|
|
|
|
import com.hchbox.entity.master.TopOrder;
|
|
|
|
|
import com.hchbox.entity.master.TopTrade;
|
|
|
|
|
import com.hchbox.entity.slaver.JdpTrade;
|
|
|
|
|
import com.hchbox.enums.TradeEnum;
|
|
|
|
|
import com.hchbox.service.*;
|
|
|
|
|
import com.hchbox.uitl.TaoBaoEncryption;
|
|
|
|
|
import com.hchbox.util.CommConverter;
|
|
|
|
|
import com.taobao.api.ApiException;
|
|
|
|
|
import com.taobao.api.SecretException;
|
|
|
|
|
import com.taobao.api.domain.Trade;
|
|
|
|
|
import com.taobao.api.internal.util.TaobaoUtils;
|
|
|
|
|
import com.taobao.api.response.TradeFullinfoGetResponse;
|
|
|
|
@ -68,8 +72,8 @@ public class SyncTask {
|
|
|
|
|
*/
|
|
|
|
|
@Async("pullOrderTaskExecutor")
|
|
|
|
|
@Scheduled(cron = "0 0/10 * * * *")
|
|
|
|
|
//@Scheduled(cron = "0 0/1 * * * *")
|
|
|
|
|
public void pullOrdersRegularly() throws ApiException {
|
|
|
|
|
// @Scheduled(cron = "0 0/1 * * * *")
|
|
|
|
|
public void pullOrdersRegularly() throws ApiException, SecretException, NoSuchFieldException, IllegalAccessException {
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
log.info("====== [ the pull order start the time as {} ] ======", startTime);
|
|
|
|
|
DateTime date = DateUtil.date();
|
|
|
|
@ -88,7 +92,7 @@ public class SyncTask {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void syncOrder(Date date) throws ApiException {
|
|
|
|
|
public void syncOrder(Date date) throws ApiException, SecretException, NoSuchFieldException, IllegalAccessException {
|
|
|
|
|
count.incrementAndGet();
|
|
|
|
|
List<Trade> list = new ArrayList<>();
|
|
|
|
|
Date startTime;
|
|
|
|
@ -111,6 +115,14 @@ public class SyncTask {
|
|
|
|
|
// 卖家昵称分组
|
|
|
|
|
Map<String, List<Trade>> tradeListMap = list.stream().
|
|
|
|
|
collect(Collectors.groupingBy(Trade::getSellerNick));
|
|
|
|
|
List<String> fieldName = Lists.newArrayList(
|
|
|
|
|
TaoBaoDataMethodConstants.BUYER_NICK,
|
|
|
|
|
TaoBaoDataMethodConstants.BUYER_EMAIL,
|
|
|
|
|
TaoBaoDataMethodConstants.RECEIVER_NAME,
|
|
|
|
|
TaoBaoDataMethodConstants.RECEIVER_PHONE,
|
|
|
|
|
TaoBaoDataMethodConstants.BUYER_ALIPAY_NO,
|
|
|
|
|
TaoBaoDataMethodConstants.RECEIVER_ADDRESS,
|
|
|
|
|
TaoBaoDataMethodConstants.ENCRYPT_ALI_PAY_ID);
|
|
|
|
|
TopTrade syncTask;
|
|
|
|
|
for (Map.Entry<String, List<Trade>> stringListEntry : tradeListMap.entrySet()) {
|
|
|
|
|
String sellerNick = stringListEntry.getKey();
|
|
|
|
@ -120,6 +132,10 @@ public class SyncTask {
|
|
|
|
|
List<Trade> trades = stringListEntry.getValue();
|
|
|
|
|
log.info(" ========== the analyze the order quantity size as {} ========== ", trades.size());
|
|
|
|
|
if (!CollectionUtils.isEmpty(trades)) {
|
|
|
|
|
TaoBaoEncryption.decrypt(miProperties, sellerAccount.getSessionKey(), trades, fieldName);
|
|
|
|
|
// 手机号码单独解密
|
|
|
|
|
TaoBaoEncryption.decrypt(miProperties, sellerAccount.getSessionKey(), trades, TaoBaoDataMethodConstants.PHONE,
|
|
|
|
|
Trade.class.getDeclaredField(TaoBaoDataMethodConstants.RECEIVER_MOBILE));
|
|
|
|
|
for (Trade trade : trades) {
|
|
|
|
|
syncTask = new TopTrade();
|
|
|
|
|
BeanUtil.copyProperties(trade, syncTask);
|
|
|
|
@ -134,7 +150,10 @@ public class SyncTask {
|
|
|
|
|
sellerAccount.getMessageCount() : DefaultNumberConstants.ZERO_NUMBER;
|
|
|
|
|
int totalAmount = messageCount + trades.size();
|
|
|
|
|
sellerAccountService.updateMessageCount(sellerAccount.getId(), totalAmount);
|
|
|
|
|
// TODO 同步数据发送
|
|
|
|
|
if (sellerAccount.getMassNum() != null && totalAmount > sellerAccount.getMassNum()) {
|
|
|
|
|
log.info("======================== the massNum as {} trades size as {} ==================",
|
|
|
|
|
sellerAccount.getMassNum(), trades.size());
|
|
|
|
|
// 删除数据推送
|
|
|
|
|
taoBaoRdsPushService.deletePushUser(sellerNick);
|
|
|
|
|
// 修改账号状态
|
|
|
|
|