package com.erp.warehouse.client;

import com.erp.warehouse.dto.PurchaseOrderDTO;
import com.erp.warehouse.dto.SaleOrderDTO;

/**
 * 云仓WMS客户端接口
 * 定义统一的云仓操作方法
 */
public interface CloudWmsClient {

    /**
     * 测试连接
     * @return 店铺信息列表
     */
    Object testConnection();

    /**
     * 获取商品列表
     * @param page 页码
     * @param pageSize 每页数量
     * @return 商品列表
     */
    Object getGoodsList(int page, int pageSize);

    /**
     * 获取商品详情
     * @param itemId 商品ID
     * @return 商品详情
     */
    Object getGoodsDetail(String itemId);

    /**
     * 获取库存列表
     * @param warehouseCode 仓库编码
     * @param page 页码
     * @param pageSize 每页数量
     * @return 库存列表
     */
    Object getStockList(String warehouseCode, int page, int pageSize);

    /**
     * 查询单SKU库存
     * @param skuCode SKU编码
     * @param warehouseCode 仓库编码
     * @return 库存信息
     */
    Object queryStock(String skuCode, String warehouseCode);

    /**
     * 推送采购单
     * @param purchaseOrder 采购单数据
     * @return 推送结果
     */
    CloudWmsResponse pushPurchaseOrder(PurchaseOrderDTO purchaseOrder);

    /**
     * 确认采购入库
     * @param poOrderNo 采购单号
     * @return 确认结果
     */
    CloudWmsResponse confirmPurchaseOrder(String poOrderNo);

    /**
     * 推送销售订单
     * @param saleOrder 销售订单数据
     * @return 推送结果
     */
    CloudWmsResponse pushSaleOrder(SaleOrderDTO saleOrder);

    /**
     * 查询物流轨迹
     * @param logisticsNo 物流单号
     * @return 物流轨迹
     */
    Object getLogisticsTrace(String logisticsNo);

    /**
     * 库存调整
     * @param warehouseCode 仓库编码
     * @param skuCode SKU编码
     * @param type 调整类型: 1=增加, 2=减少
     * @param quantity 调整数量
     * @param reason 调整原因
     * @return 调整结果
     */
    CloudWmsResponse adjustStock(String warehouseCode, String skuCode, int type, int quantity, String reason);

    /**
     * 获取仓库列表
     * @return 仓库列表
     */
    Object getWarehouseList();

    /**
     * 云仓响应结果
     */
    class CloudWmsResponse {
        private boolean success;
        private Integer code;
        private String message;
        private Object data;

        public CloudWmsResponse() {}

        public CloudWmsResponse(boolean success, Integer code, String message, Object data) {
            this.success = success;
            this.code = code;
            this.message = message;
            this.data = data;
        }

        public static CloudWmsResponse success(Object data) {
            return new CloudWmsResponse(true, 0, "success", data);
        }

        public static CloudWmsResponse error(Integer code, String message) {
            return new CloudWmsResponse(false, code, message, null);
        }

        public boolean isSuccess() { return success; }
        public void setSuccess(boolean success) { this.success = success; }
        public Integer getCode() { return code; }
        public void setCode(Integer code) { this.code = code; }
        public String getMessage() { return message; }
        public void setMessage(String message) { this.message = message; }
        public Object getData() { return data; }
        public void setData(Object data) { this.data = data; }
    }
}
