import request from '../request'

//福禄会员api
const fulu = {
	/**
	 * 获取福禄商品折扣
	 */
	getPriceKeyword() {
		return request({
			url: `/system/config/configKey/fulu_vip_discount`,
		})
	},
	/**
	 * @param {
		 buy_num: Number			购买数量
		 charge_account: string		充值账号
		 goodsPictureUrl: string	商品图片地址
		 product_id: Number 		商品编号
	 } data
	 * 微信支付福禄下单
	 */
	prepareOrder(data) {
		return request({
			url: `/student/wx/prepareOrderForFulu`,
			method: 'post',
			data
		})
	},
	/**
	 * @param {
		 customer_order_no:string  外部订单号
	 } data
	 */
	orderInfoGet(data) {
		return request({
			url: `student/fulu/fuluCommonApi`,
			method: 'post',
			data: {
				method: 'fulu.order.info.get',
				biz_content: JSON.stringify(data)
			}
		})
	},
	//商品api
	goods: {
		/**
		 * 获取福禄商品类型列表
		 * mock
		 */
		async getTypeList() {
			let res = await request({
				url: `student/applet/fulu/list`
			})

			res.data = res.data.map(val => {
				val.type_name = val.typeName
				val.list = val.list.map(val2 => {
					val2.icon = val2.iconUrl
					val2.product_ids = val2.productIds.split(',')
					val2.remark = val2.remark.split('|')
					return val2
				})
				return val
			})
			
			return res
		},
		/**
		 * 获取商品信息
		 * @param {
			 product_id: string '商品ID'
		 } data
		 */
		infoGet(data) {
			return request({
				url: `student/fulu/fuluCommonApi`,
				method: 'post',
				data: {
					method: 'fulu.goods.info.get',
					biz_content: JSON.stringify(data)
				}
			})
		},
		/**
		 * 获取商品模板
		 * @param {
			 template_id: string '商品模板编号'
		 } data
		 */
		templateGet(data) {
			return request({
				url: `student/fulu/fuluCommonApi`,
				method: 'post',
				data: {
					method: 'fulu.goods.template.get',
					biz_content: JSON.stringify(data)
				}
			})
		},
		/**
		 * 获取商品列表
		 * @param {
			 first_category_id?: int 	'商品分类Id（一级）'
			 second_category_id?: int 	'商品分类Id（二级）'
			 third_category_id?: int 	'商品分类Id（三级）'
			 product_id?: int 			'商品编号'
			 product_name?: string 		'商品名称'
			 product_type?: string 		'库存类型：卡密、直充'
			 face_value?: double 		'面值'
		 } data
		 */
		listGet(data) {
			return request({
				url: `student/fulu/fuluCommonApi`,
				method: 'post',
				data: {
					method: 'fulu.goods.list.get',
					biz_content: JSON.stringify(data)
				}
			})
		}
	}
}

export default fulu
