orderService.js 2.9 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'
const ORDER_SELECT_COUPON = 'ufo.order.selectCoupon'
const ORDER_COMPUTE = 'ufo.order.compute'
const ORDER_OFFLINE_COMPUTE = 'ufo.order.offlineCompute'
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, couponCode, complete) {

    return await this.GET({
      method: BUYER_SUBMIT,
      skup,
      channelNo,
      addressId,
      coupon_code: couponCode || ''
    }, {
      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
    })
  }

  async orderSelectCoupon(skup, complete) {
    return await this.GET({
      skup,
      method: ORDER_SELECT_COUPON,
    }, {
      path: '/shopping',
      complete
    })
  }

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

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


}