package com.erp.order.client;

import com.erp.common.core.model.ApiResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(name = "stock-service", url = "${stock.service.url:http://stock-service}")
public interface StockClient {

    /**
     * 扣减库存（订单发货时调用）
     */
    @PostMapping("/api/stock/deduct")
    ApiResponse<?> deductStock(@RequestBody StockDeductRequest request);

    /**
     * 解锁库存（订单驳回/取消时调用）
     */
    @PostMapping("/api/stock/unlock")
    ApiResponse<?> unlockStock(@RequestBody StockUnlockRequest request);

    /**
     * 锁定库存（订单创建/审核时预占库存）
     */
    @PostMapping("/api/stock/lock")
    ApiResponse<?> lockStock(@RequestBody StockLockRequest request);

    class StockDeductRequest {
        private String skuCode;
        private Long warehouseId;
        private Integer quantity;
        private String relatedNo;
        private String remark;

        public String getSkuCode() { return skuCode; }
        public void setSkuCode(String skuCode) { this.skuCode = skuCode; }
        public Long getWarehouseId() { return warehouseId; }
        public void setWarehouseId(Long warehouseId) { this.warehouseId = warehouseId; }
        public Integer getQuantity() { return quantity; }
        public void setQuantity(Integer quantity) { this.quantity = quantity; }
        public String getRelatedNo() { return relatedNo; }
        public void setRelatedNo(String relatedNo) { this.relatedNo = relatedNo; }
        public String getRemark() { return remark; }
        public void setRemark(String remark) { this.remark = remark; }
    }

    class StockUnlockRequest {
        private String skuCode;
        private Long warehouseId;
        private Integer quantity;
        private String relatedNo;
        private String remark;

        public String getSkuCode() { return skuCode; }
        public void setSkuCode(String skuCode) { this.skuCode = skuCode; }
        public Long getWarehouseId() { return warehouseId; }
        public void setWarehouseId(Long warehouseId) { this.warehouseId = warehouseId; }
        public Integer getQuantity() { return quantity; }
        public void setQuantity(Integer quantity) { this.quantity = quantity; }
        public String getRelatedNo() { return relatedNo; }
        public void setRelatedNo(String relatedNo) { this.relatedNo = relatedNo; }
        public String getRemark() { return remark; }
        public void setRemark(String remark) { this.remark = remark; }
    }

    class StockLockRequest {
        private String skuCode;
        private Long warehouseId;
        private Integer quantity;
        private String relatedNo;
        private String remark;

        public String getSkuCode() { return skuCode; }
        public void setSkuCode(String skuCode) { this.skuCode = skuCode; }
        public Long getWarehouseId() { return warehouseId; }
        public void setWarehouseId(Long warehouseId) { this.warehouseId = warehouseId; }
        public Integer getQuantity() { return quantity; }
        public void setQuantity(Integer quantity) { this.quantity = quantity; }
        public String getRelatedNo() { return relatedNo; }
        public void setRelatedNo(String relatedNo) { this.relatedNo = relatedNo; }
        public String getRemark() { return remark; }
        public void setRemark(String remark) { this.remark = remark; }
    }
}
