import request from '../utils/request.js'

class WelfareMall extends request {

  /**
   * 获取订单
   */
  static getOrder(params) {
    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/get`, params);
  }

  /**
   * 取消订单
   */
  static cancelOrder(params) {
    return this.postRequest(`${this.BASE_URL}open/activity/order-cancel`, params);
  }

  /**
   * 订单列表
   */
  static getOrderList(params) {
    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/list`, params);
  }

    /**
   * 订单退款
   */
  static orderRefund(params) {
    return this.postRequest(`${this.BASE_URL}open/activity/order-refund`, params);
  }

   /**
   * 获得订单支付参数
   */
  static getPayParams(params) {
    return this.postRequest(`${this.BASE_URL}open/welfare-mall/activity/get-pay-params`, params);
  }

   /**
   * 获取订单的退款单信息
   */
  static getRefundOrderList(params) {
    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/get-refund-order-list`, params);
  }

  /**
   * 获取订单的退款单状态
   */
  static getRefundOrderStatus(params) {
    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/get-refund-order-status`, params);
  }

  /**
   * 添加反馈
   */
  static feedBackAdd(params) {
    return this.postRequest(`${this.BASE_URL}open/welfare-mall/add-feedback`, params);
  }

  /**
   * 福利社
   * 获取购买优惠券个数
   */
  static async getUserBuyCouponNum(params) {
    return this.postRequest(`${this.BASE_URL}open/welfare-mall/user-buy-coupon-num`, params);
  }

  /**
   * 签到
   * 获取购买优惠券个数
   */
  static async getUserAwardCouponNum(params) {
    return this.postRequest(`${this.BASE_URL}open/sign-in/user-award-coupon-num`, params);
  }

  /**
   * 抽奖
   * 获取购买优惠券个数
   */
  static async getUserDrawCouponNum(params) {
    return this.postRequest(`${this.BASE_URL}open/luck-draw/user-draw-coupon-num`, params);
  }

  /**
   * 获取用户信息
   * @param {*} openId  
   */
  static async getUser(params) {
    const res = await this.postRequest(`${this.BASE_URL}open/activity/get-user`, params)
    return res.data
  }

   /**
   * 获取首页信息
   */
  static getIndexList(params ={}) {
    return this.postRequest(`${this.BASE_URL}open/welfare-mall/homepage-data`, params);
  }

     /**
   * 获取活动列表
   */
  static getActivityList(type,page,pageSize) {
    let params={
      type:type,
      page:page,
      pageSize:pageSize,
    }
    return this.postRequest(`${this.BASE_URL}open/welfare-mall/activity/list`, params);
  }

       /**
   * 获取活动详情
   */
  static getActivityDetail(activityId) {
    let params={
      activityId:activityId
    }
    return this.postRequest(`${this.BASE_URL}open/welfare-mall/activity/detail`, params);
  }

  static getPayStatus(orderSn) {
    let params={
      orderSn:orderSn
    }
    return this.postRequest(`${this.BASE_URL}open/call/getPayStatus`, params);
  }



       /**
   * 创建订单
   */
  static createOrder(mobile,activityId,num,shopId="", refStatisticsPostParam) {
    refStatisticsPostParam = refStatisticsPostParam || {}
    let params = {
      activityId:activityId,
      memberMobile:mobile,
      num:num,
      shopId:shopId,
      scene: refStatisticsPostParam.scene || "",
      channel: refStatisticsPostParam.channel || "0",
      department: refStatisticsPostParam.department || "0"
    };
    return this.postRequest(`${this.BASE_URL}open/activity/create-order`, params);
  }

  //获取支付参数
  static getOrderParams(orderSn,openId,isOrderPayment=false) {
    let params = {
      orderSn:orderSn,
      source: "FREE_MINI_APP",
      thirdPartyName: 'coupon-activity',
      payCode: "HSAY-SHARE",
      openId: openId
    };
    if(isOrderPayment){
      params.isOrderPayment =true;
      params.orderInfoPath = "pages/welfareMall/order/orderCompletion?ordersn="
      params.productDetailPath = "pages/welfareMall/activityInfo/activityInfo?activityId="
    }
    return this.postRequest(`${this.BASE_URL}open/activity/get-order-params`, params);
  }

  /**
   * 个人中心数据，包括导航
   */
  static getPersonalData(params) {
    return this.postRequest(`${this.BASE_URL}open/welfare-mall/personal-data`, params);
  }

  /**
   * 未使用的卡券个数
   */
  static async getUserCouponSnNum(params) {
    return this.postRequest(`${this.BASE_URL}open/coupon/user-coupon-sn-num`, params);
  }
  /**
   * 用户卡券列表
   */
  static getUserCouponSnList(params) {
    return this.postRequest(`${this.BASE_URL}open/coupon/user-coupon-sn-list`, params);
  }

    /**
   * 获取核销记录
   */
  static getHexiaoList(params) {
    return this.postRequest(`${this.BASE_URL}open/hexiao/list`, params);
  }

  /**
   * 根据手机识别职员信息
   */
  static discernStoreStaff(params) {
    return this.postRequest(`${this.BASE_URL}open/staff/discern-store-staff`, params);
  }

  /**
   * 根据职员获取门店列表
   */
  static getStoreListByStaff(params) {
    return this.postRequest(`${this.BASE_URL}open/staff/get-store-list-by-staff`, params);
  }

  /**
   * 根据登录手机号获取职员列表
   */
  static getStoreStaffList(params) {
    return this.postRequest(`${this.BASE_URL}open/staff/get-store-staff-list`, params);
  }

  /**
   * 添加门店职员
   */
  static addStoreStaff(params) {
    return this.postRequest(`${this.BASE_URL}open/staff/add-store-staff`, params);
  }

  /**
   * 删除门店职员
   */
  static delStoreStaff(params) {
    return this.postRequest(`${this.BASE_URL}open/staff/del-store-staff`, params);
  }
  
}

export default WelfareMall