package com.ghy.shop.domain;

import lombok.Data;
import java.io.Serializable;

/**
 * 店铺距离查询请求实体类
 */
@Data
public class ShopDistanceQuery implements Serializable {
    
    private Long shopId; // 店铺ID (必填)
    private Double latitude; // 当前纬度 (可选，如果有地址信息)
    private Double longitude; // 当前经度 (可选，如果有地址信息)
    
    // 地址相关参数（用于查询经纬度）
    private Long provinceId; // 省份ID
    private String provinceName; // 省份名称
    private Long cityId; // 城市ID
    private String cityName; // 城市名称
    private Long countryId; // 区县ID
    private String countryName; // 区县名称
    private Long streetId; // 街道ID
    private String streetName; // 街道名称
    private String address; // 详细地址
    
    // 可选参数，用于扩展
    private String unit; // 距离单位：km(公里)、m(米)
    private Boolean updateShopLocation; // 是否更新店铺的经纬度信息
    
    public ShopDistanceQuery() {}
    
    public ShopDistanceQuery(Long shopId, Double latitude, Double longitude) {
        this.shopId = shopId;
        this.latitude = latitude;
        this.longitude = longitude;
    }
    
    /**
     * 构建完整地址字符串
     */
    public String getFullAddress() {
        StringBuilder fullAddress = new StringBuilder();
        if (provinceName != null) fullAddress.append(provinceName);
        if (cityName != null) fullAddress.append(cityName);
        if (countryName != null) fullAddress.append(countryName);
        if (streetName != null) fullAddress.append(streetName);
        if (address != null) fullAddress.append(address);
        return fullAddress.toString();
    }
    
    /**
     * 检查是否有地址信息
     */
    public boolean hasAddressInfo() {
        return (provinceName != null && !provinceName.trim().isEmpty()) ||
               (cityName != null && !cityName.trim().isEmpty()) ||
               (countryName != null && !countryName.trim().isEmpty()) ||
               (streetName != null && !streetName.trim().isEmpty()) ||
               (address != null && !address.trim().isEmpty());
    }
    
    /**
     * 检查是否有坐标信息
     */
    public boolean hasCoordinateInfo() {
        return latitude != null && longitude != null;
    }
    
    /**
     * 检查是否有足够的信息来计算距离
     */
    public boolean hasEnoughInfo() {
        return hasAddressInfo() || hasCoordinateInfo();
    }
}
