根据手机号拉取买家订儿拉取买家订单。
This commit is contained in:
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.rj.dto.LbBuyerShoppingPullRequest;
|
||||
import com.rj.dto.hxr.HxrBuyerOrderApiContext;
|
||||
import com.rj.dto.hxr.HxrOrderRow;
|
||||
import com.rj.dto.hxr.HxrUserLoginApiContext;
|
||||
import com.rj.entity.LbBuyerShopping;
|
||||
import com.rj.mapper.LbBuyerShoppingMapper;
|
||||
@@ -21,7 +20,6 @@ import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -461,17 +459,19 @@ public class LbBuyerShoppingServiceImpl
|
||||
allMoney = pageResult.allMoney();
|
||||
}
|
||||
|
||||
List<HxrOrderRow> rows = pageResult.rows();
|
||||
if (rows == null || rows.isEmpty()) {
|
||||
List<LbBuyerShopping> orders = pageResult.orders();
|
||||
if (orders == null || orders.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
totalFetched += rows.size();
|
||||
totalFetched += orders.size();
|
||||
|
||||
for (HxrOrderRow row : rows) {
|
||||
LbBuyerShopping entity = toLbBuyerShopping(row, buyerMobile);
|
||||
for (LbBuyerShopping entity : orders) {
|
||||
if (entity.getId() == null) {
|
||||
continue;
|
||||
}
|
||||
if (entity.getBuyerMobile() == null || entity.getBuyerMobile().isBlank()) {
|
||||
entity.setBuyerMobile(buyerMobile);
|
||||
}
|
||||
applyDefaults(entity);
|
||||
if (entity.getCreatedAt() == null) {
|
||||
entity.setCreatedAt(LocalDateTime.now());
|
||||
@@ -492,7 +492,7 @@ public class LbBuyerShoppingServiceImpl
|
||||
int pageLimit = ctx.pageLimit() > 0 ? ctx.pageLimit() : 90;
|
||||
boolean hasMore = pageResult.hasMore();
|
||||
int lastPage = pageResult.lastPage();
|
||||
if (pageResult.rows().size() < pageLimit) {
|
||||
if (orders.size() < pageLimit) {
|
||||
break;
|
||||
}
|
||||
if (!hasMore || page >= lastPage) {
|
||||
@@ -526,56 +526,6 @@ public class LbBuyerShoppingServiceImpl
|
||||
}
|
||||
}
|
||||
|
||||
private static LbBuyerShopping toLbBuyerShopping(HxrOrderRow row, String fallbackBuyerMobile) {
|
||||
LbBuyerShopping entity = new LbBuyerShopping();
|
||||
entity.setId(row.id());
|
||||
entity.setSellerId(row.sellerId());
|
||||
entity.setMerchandiseId(row.merchandiseId());
|
||||
entity.setBuyerId(row.buyerId());
|
||||
entity.setOrderSn(row.orderSn());
|
||||
entity.setTotalMoney(parseMoney(row.totalMoney()));
|
||||
entity.setCreatedAt(parseFlexibleDateTime(row.createdAt()));
|
||||
entity.setBuyTime(parseFlexibleDateTime(row.buyTime()));
|
||||
entity.setConfirmTime(parseFlexibleDateTime(row.confirmTime()));
|
||||
entity.setSellerNickname(row.sellerName());
|
||||
entity.setSellerMobile(row.sellerPhone());
|
||||
entity.setBuyerNickname(row.buyerName());
|
||||
String buyerMobile = row.buyerPhone();
|
||||
if (buyerMobile == null || buyerMobile.isBlank()) {
|
||||
buyerMobile = fallbackBuyerMobile;
|
||||
}
|
||||
entity.setBuyerMobile(buyerMobile);
|
||||
return entity;
|
||||
}
|
||||
|
||||
private static BigDecimal parseMoney(String money) {
|
||||
if (money == null || money.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(money.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static LocalDateTime parseFlexibleDateTime(String text) {
|
||||
if (text == null || text.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String trimmed = text.trim();
|
||||
try {
|
||||
return LocalDateTime.parse(trimmed, DATE_TIME_FORMATTER);
|
||||
} catch (DateTimeParseException ignored) {
|
||||
// continue
|
||||
}
|
||||
try {
|
||||
return LocalDateTime.parse(trimmed, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
||||
} catch (DateTimeParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static int toInt(Object value) {
|
||||
if (value instanceof Number number) {
|
||||
return number.intValue();
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.rj.common.LbThirdIntegrationConstants;
|
||||
import com.rj.dto.LbThirdIntegrationCredentialUpdateRequest;
|
||||
import com.rj.dto.hxr.BuyerOrderListEndpoint;
|
||||
import com.rj.dto.hxr.HxrAdminOrderApiContext;
|
||||
import com.rj.dto.hxr.HxrAdminUserApiContext;
|
||||
import com.rj.dto.hxr.HxrBuyerOrderApiContext;
|
||||
@@ -418,11 +419,15 @@ public class LbThirdIntegrationConfigServiceImpl
|
||||
}
|
||||
|
||||
try {
|
||||
BuyerOrderListEndpoint endpoint =
|
||||
LbThirdIntegrationConfigUtil.resolveBuyerOrderListEndpoint(config);
|
||||
return Optional.of(new HxrBuyerOrderApiContext(
|
||||
LbThirdIntegrationConfigUtil.resolveBuyerOrderListBaseUrl(config),
|
||||
LbThirdIntegrationConfigUtil.resolveBuyerOrderListLimit(config),
|
||||
endpoint.baseUrl(),
|
||||
endpoint.pageLimit(),
|
||||
endpoint.cate(),
|
||||
endpoint.type(),
|
||||
LbThirdIntegrationConfigUtil.resolveGoodsApiOrigin(config),
|
||||
LbThirdIntegrationConfigUtil.resolveOrderReferer(config),
|
||||
LbThirdIntegrationConfigUtil.resolveGoodsApiReferer(config),
|
||||
token.trim(),
|
||||
appStr.trim()));
|
||||
} catch (IllegalStateException e) {
|
||||
|
||||
Reference in New Issue
Block a user