把客户信息补充到数据库

This commit is contained in:
2026-05-03 13:12:58 +08:00
parent f833f373a8
commit 02453bbeb3
4 changed files with 266 additions and 12 deletions

View File

@@ -4,8 +4,10 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 高德周边 POI 中的一条商家记录(与 {@code AllShopCollectorV5} 解析字段一致)。
* 高德周边 POI 中的一条商家记录(与 {@code AllShopCollectorV5} 核心字段一致,并补充 distance 等 POI 字段)。
*/
@Data
@NoArgsConstructor
@@ -18,4 +20,53 @@ public class NearbyMerchantItem {
private String type;
/** 经纬度,格式 "lng,lat" */
private String location;
/** 高德 POI id */
private String id;
/** 距检索中心距离place/around 返回的 distance */
private String distance;
private String typecode;
/** 高德 business_area */
private String businessArea;
/** 高德 POI 照片链接extensions=all 时 photos[].url */
private List<String> photoUrls;
/**
* 与 {@link com.rj.gaode.AllShopCollectorV5#parseAndPrint} 单条输出格式一致(店名/地址/电话/行业/坐标),并附加扩展行。
*/
public String toDetailBlock() {
StringBuilder sb = new StringBuilder();
sb.append("店名:").append(dashIfEmpty(name));
sb.append("\n地址").append(dashIfEmpty(address));
sb.append("\n电话").append(dashIfEmpty(tel));
sb.append("\n行业").append(dashIfEmpty(type));
sb.append("\n坐标").append(dashIfEmpty(location));
if (isPresent(distance)) {
sb.append("\n距离(米)").append(distance);
}
if (isPresent(id)) {
sb.append("\nPOI ID").append(id);
}
if (isPresent(typecode)) {
sb.append("\n类型编码").append(typecode);
}
if (isPresent(businessArea)) {
sb.append("\n商圈").append(businessArea);
}
if (photoUrls != null && !photoUrls.isEmpty()) {
sb.append("\n照片URL");
for (int i = 0; i < photoUrls.size(); i++) {
sb.append("\n ").append(i + 1).append(". ").append(photoUrls.get(i));
}
}
sb.append("\n---------------------------");
return sb.toString();
}
private static boolean isPresent(String s) {
return s != null && !s.isEmpty();
}
private static String dashIfEmpty(String s) {
return isPresent(s) ? s : "";
}
}

View File

@@ -18,26 +18,37 @@ public class NearbyMerchantSearchResult {
private final List<NearbyMerchantItem> merchants;
/** 高德返回的本次检索总条数(字符串),可能大于已拉取页数之和 */
private final String totalCount;
/**
* 与 {@link com.rj.gaode.AllShopCollectorV5#parseAndPrint} 类似的商铺明细文本(含检索参数与每家店块)。
*/
private final String detailedReport;
/** 本次成功写入 {@code customer_management} 的条数(按 contact 匹配,含新增与更新) */
private final Integer customerInsertedCount;
private NearbyMerchantSearchResult(int httpStatus, boolean success, String message,
String centerLocation, List<NearbyMerchantItem> merchants, String totalCount) {
String centerLocation, List<NearbyMerchantItem> merchants, String totalCount,
String detailedReport, Integer customerInsertedCount) {
this.httpStatus = httpStatus;
this.success = success;
this.message = message;
this.centerLocation = centerLocation;
this.merchants = merchants == null ? Collections.emptyList() : merchants;
this.totalCount = totalCount;
this.detailedReport = detailedReport;
this.customerInsertedCount = customerInsertedCount;
}
public static NearbyMerchantSearchResult ok(String centerLocation, List<NearbyMerchantItem> merchants, String totalCount) {
return new NearbyMerchantSearchResult(200, true, "查询成功", centerLocation, merchants, totalCount);
public static NearbyMerchantSearchResult ok(String centerLocation, List<NearbyMerchantItem> merchants,
String totalCount, String detailedReport, int customerInsertedCount) {
return new NearbyMerchantSearchResult(200, true, "查询成功", centerLocation, merchants, totalCount,
detailedReport, customerInsertedCount);
}
public static NearbyMerchantSearchResult badRequest(String message) {
return new NearbyMerchantSearchResult(400, false, message, null, Collections.emptyList(), null);
return new NearbyMerchantSearchResult(400, false, message, null, Collections.emptyList(), null, null, null);
}
public static NearbyMerchantSearchResult serverError(String message) {
return new NearbyMerchantSearchResult(500, false, message, null, Collections.emptyList(), null);
return new NearbyMerchantSearchResult(500, false, message, null, Collections.emptyList(), null, null, null);
}
}