/**
 * 商品信息
 **/
export interface IGoods {
  productId: number
  productName: string
  productImages?: string
  price: number
  vipPrice?: number | null
  activityPrice?: number | null
  isVipPrice?: number               // 是否有VIP优惠 0-否 1-是
  productAmount?: number            // 购买数量
  delFlag?: number                 // 删除标记 -1-已下架
  goodsType?: string           // 商品类型 "05"： 课程 "02"： 电子书
}

/**
 * 获取优惠价格参数
 **/
export interface IGoodsDiscountParams {
  productId: number
  quantity: number
}

/**
 * 订单接口
 */
export interface IOrder {
  id: number
  orderSn: string
  orderMoney: number
  paymentMethod: string  // '4'-虚拟货币, '5'-真实货币
  createTime: string
  [key: string]: any
}

/**
 * 课程订单商品信息
 */
export interface IOrderGoods {
  productId: number
  productName: string
  productImages?: string
  price: number
  vipPrice?: number | null
  activityPrice?: number | null
  isVipPrice?: number          // 是否有VIP优惠 0-否 1-是
  productAmount?: number       // 购买数量
  goodsType: string           // 商品类型 "05" for course
}

/**
 * 优惠券实体信息
 */
export interface ICouponEntity {
  id: number
  couponName: string
  couponAmount: number
  useLevel: number            // 满多少可用
  couponRange: number         // 0-全场 1-指定课程 2-指定品类
  remark?: string
}

/**
 * 优惠券信息
 */
export interface ICoupon {
  id: number
  couponId: number
  canUse: number              // 0-不可用 1-可用
  canUseReason?: string
  effectType: number          // 0-永久有效
  endTime?: string
  couponEntity: ICouponEntity
}

/**
 * 课程订单创建参数
 */
export interface ICourseOrderCreateParams {
  buyType: number             // 0-商品页直接下单 1-购物车结算
  userId: number
  paymentMethod: number       // 4-天医币
  orderMoney: number          // 订单金额
  realMoney: number           // 实收金额
  jfDeduction: number         // 积分抵扣
  couponId?: number           // 优惠券ID
  couponName?: string         // 优惠券名称
  vipDiscountAmount: number   // VIP折扣金额
  districtMoney: number       // 地区优惠金额
  remark?: string             // 备注
  productList: Array<{
    productId: number
    quantity: number
  }>
  orderType: string           // "order"
  addressId: number           // 0 for course products
  appName: string             // "wumen"
  come: number                // 2
}

/**
 * 价格明细项
 */
export interface IPriceBreakdownItem {
  type: number                // 1-商品总价 2-运费 3-优惠券 4-积分 5-活动立减 6-VIP立减
  text: string
  imgUrl?: string
  icon?: string
}

/**
 * 订单状态
 */
export interface IOrderState {
  goodsList: IOrderGoods[]
  totalPrice: number
  vipPrice: number
  districtAmount: number
  actualPayment: number
  jfNumber: number
  jfNumberMax: number
  jfNumberShow: string
  couponList: ICoupon[]
  selectedCoupon: ICoupon | null
  showCouponPopup: boolean
  remark: string
  showRemarkPopup: boolean
  payType: number
  loading: boolean
  submitting: boolean
  buyingFlag: boolean
}

/**
 * 支付方式选项接口
 */
export interface IPaymentOption {
  value: '4' | '5'
  name: string
}

/**
 * 订单详情
 */
export interface IOrderDetail {
  id: number
  orderSn: string
  orderMoney: number
  realMoney: number
  paymentDate: string
  createTime: string
  orderType: string
  districtMoney?: number
  vipDiscountAmount?: number
  couponId?: number
  couponName?: string
  couponAmount?: number
  jfDeduction?: number
  remark?: string
  [key: string]: any
}

/**
 * 创建订单参数
 */
export interface ICreateOrderParams {
  buyType: number             // 0-商品页直接下单 1-购物车结算
  userId: number
  paymentMethod: number       // 4-天医币
  orderMoney: number          // 订单金额
  realMoney: number           // 实收金额
  jfDeduction: number         // 积分抵扣
  couponId?: number           // 优惠券ID
  couponName?: string         // 优惠券名称
  vipDiscountAmount: number   // VIP折扣金额
  districtMoney: number       // 地区优惠金额
  remark?: string             // 备注
  productList: Array<{
    productId: number
    quantity: number
  }>
  orderType: string           // "order"
  addressId: number           // 0 for course products
  appName: string             // "wumen"
  come: number                // 2
}

/**
 * 创建订单响应
 */
export interface ICreateOrderResponse {
  orderSn: string
  money: number
  [key: string]: any
}

/**
 * 订单初始化数据
 */
export interface IOrderInitData {
  goodsList: IOrderGoods[]
  totalPrice: number
  vipPrice: number
  districtAmount: number
  actualPayment: number
  jfNumber: number
  jfNumberMax: number
  jfNumberShow: string
  couponList: ICoupon[]
  selectedCoupon: ICoupon | null
  showCouponPopup: boolean
  remark: string
  showRemarkPopup: boolean
  payType: number
  loading: boolean
  submitting: boolean
  buyingFlag: boolean
  [key: string]: any
}
