orderService.js 2.17 KB
/**
 * orderService.js
 *@author dennis
 *@createtime 2018/10/29
 *@description 订单相关网络请求
 */

import BaseService from '../../libs/services/baseService'

const CREATE_PAYMENTINFO = 'ufo.order.payment'
const BUYER_GETADDRESS = 'app.address.gethidden'
const BUYER_SUBMIT = 'ufo.order.submit'
const BUYER_PREPAY = 'ufo.order.pay'
const COMPUTE_COMPENSATE = 'ufo.buyer.computeCompensate'
const PRODUCT_RECOMMEND = 'ufo.product.data.search.recommend'
const CREATE_OFFLINE_PAYMENTINFO = 'ufo.order.offlinePayment';
const STORE_BUYER_SUBMIT = 'ufo.order.offlineSubmit'
export default class orderService extends BaseService {
  constructor(options) {
    super(options)
  }

  async createPaymentInfo(params, complete) {
    return await this.GET(
      {
        ...params,
        method: CREATE_PAYMENTINFO,
      },
      {
        path: '/shopping',
        complete
      }
    )
  }

  async createOfflinePayment(params, complete) {
    return await this.GET({
      ...params,
      method: CREATE_OFFLINE_PAYMENTINFO
    }, {
      path: '/shopping',
      complete
    })
  }

  async buyerGetAddress(params, complete) {

    return await this.GET({
      ...params,
      method: BUYER_GETADDRESS
    }, {
      complete
    })
  }

  async buyerSubmit(skup, channelNo = '2919', addressId, complete) {

    return await this.GET({
      method: BUYER_SUBMIT,
      skup,
      channelNo,
      addressId,
    }, {
      path: '/shopping',
      complete
    })
  }

  async storeBuyerSubmit(params,complete){
    return await this.GET({
      method: STORE_BUYER_SUBMIT,
      ...params
    }, {
      path: '/shopping',
      complete
    })
  }

  async prePay(orderCode, openId, complete) {

    return await this.GET({
      orderCode,
      openid: openId,
      payment: 3,
      method: BUYER_PREPAY,
    }, {
      path: '/payment',
      complete
    })
  }

  async getComputeCompensate(orderCode, complete) {

    return await this.GET({
      orderCode,
      method: COMPUTE_COMPENSATE,
    }, {
      complete
    })
  }

  async getRecommendList(product_id, complete) {

    return await this.GET({
      product_id,
      method: PRODUCT_RECOMMEND,
    }, {
      complete
    })
  }


}