/**
 *@des 订单模块接口
 *@author zhengjinyi
 *@date 2020/03/19 14:56:57
 *@param registerByPass
 */
import request from '@/common/config/caimeiApi.js'
import $reg from '@/common/config/common.js'
/**
 *@获取订单列表
 *@param orderState 订单状态 1 2 3 4
 *@param pageNum	页码
 *@param pageSize	条数
 */
export function queryOrderList(params) {
	return new Promise(function(resolve,reject) {
		request.lodingGet('/order/list',params, res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *查询订单详情
 *@param orderID 订单ID
 */
export function queryOrderDetails(params) {
	return new Promise(function(resolve,reject) {
		request.get('/order/detail',params, res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *取消订单
 * @param orderID
 */
export function cancelOrder(params) {
	return new Promise(function(resolve,reject) {
		request.get('/order/cancel',params, res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *删除订单
 * @param orderID
 */
export function deleteOrder(params) {
	return new Promise(function(resolve,reject) {
		request.get('/order/delete',params, res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *确认订单
 * @param orderID
 */
export function affirmOrder(params) {
	return new Promise(function(resolve,reject) {
		request.post('/order/affirmOrder',params,true,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *确认收货
 * @param orderID
 */
export function confirmReceipt(params) {
	return new Promise(function(resolve,reject) {
		request.get('/order/affirm',params, res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *查询物流信息
 * @param orderID
 */
export function queryLogistics(params) {
	return new Promise(function(resolve,reject) {
		request.get('/order/logistics',params, res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *获取订单分享码
 * @param orderID
 */
export function queryOrderShareCode(params) {
	return new Promise(function(resolve,reject) {
		request.get('/order/share',params, res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *分享订单登录
 * @param orderID
 */
export function orderShareCode(params) {
	return new Promise(function(resolve,reject) {
		request.get('/order/shareCode',params, res => {
			resolve(res)
		})
	})
}
/**
 *机构搜索订单
 *@param searchWord 关键词
 *@param userId		用户ID
 *@param pageNum	页码
 *@param pageSize	条数
 */
export function searchOrderInfo(params) {
	return new Promise(function(resolve,reject) {
		request.lodingGet('/order/search',params, res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *搜索订单历史记录
 *@param userId
 */
export function searchOrderHistory(params) {
	return new Promise(function(resolve,reject) {
		request.get('/order/searchHistory',params, res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *清楚订单历史记录
 *@param
 */
export function clearOrderHistory(params) {
	return new Promise(function(resolve,reject) {
		request.lodingGet('/order/searchHistory/delete',params, res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *初始化收银台
 *@param  orderId 订单ID
 */
export function PayOrderCheckoutCounter(params) {
	return new Promise(function(resolve,reject) {
		request.lodingGet('/PayOrder/checkoutCounter',params, res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}

/**
 *微信支付
 *@param  amount支付金额，单位分，必须大于2
 *@param  payWay银联：UNIONPAY，微信：WEIXIN，支付宝：ALIPAY
 *@param  payType 微信小程序支付: MINIAPP_WEIXIN ,微信公众号支付: JSAPI_WEIXIN
 *@param  code  微信小程序code,微信小程序支付使用
 *@param  orderId  主订单ID
 */
export function WeChatMiniWxPay(params) {
	return new Promise(function(resolve,reject) {
		request.post('/PayOrder/miniWxPay',params,true,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *生成支付链接
 *@param  unpaidAmount 本次待付款金额
 *@param  orderId  主订单ID
 */
export function PayOrderPayLink(params) {
	return new Promise(function(resolve,reject) {
		request.post('/PayOrder/payLink',params,true,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}

