/**
 * Web唐明明
 * 匆匆数载恍如梦，岁月迢迢华发增。
 * 碌碌无为枉半生，一朝惊醒万事空。
 * moduleName: 商品
 */

import {
	request
} from '../index'


// 商品管理-商品列表
const managesGoodsIndex = data => {
	return request({
		url: 'manages/goods/index',
		data: data
	})
}

// 商品管理-商品增发
const managesGoodsMint = data => {
	return request({
		url: 'manages/goods/' + data.id + '/mint',
		data: data,
		method: 'POST'
	})
}

// 商品管理-商品燃烧
const managesGoodsBurn = data => {
	return request({
		url: 'manages/goods/' + data.id + '/burn',
		data: data,
		method: 'POST'
	})
}

// 发布商品前置
const managesGoodsCreateBefore = () => {
	return request({
		url: 'manages/goods/create'
	})
}

// 发布商品
const managesGoodsCreate = (data) => {
	return request({
		url: 'manages/goods',
		method: 'POST',
		data: data
	})
}

// 发布产品类目
const managesCategory = () => {
	return request({
		url: 'manages/goods/category'
	})
}

// 发布产品类目类型配置
const managesCreate = (data) => {
	return request({
		url: 'manages/goods/create',
		data
	})
}

// 商品认证
const managesGoodsAuth = (id, data) => {
	return request({
		url: 'manages/goods/' + id + '/extends',
		method: 'POST',
		data
	})
}

// 商品删除
const managesGoodsDelete = id => {
	return request({
		url: 'manages/goods/' + id,
		method: 'DELETE'
	})
}

// 产品信息
const managesGoodsEdit = id => {
	return request({
		url: 'manages/goods/' + id
	})
}

// 产品编辑
const managesGoodsPut = (id, data) => {
	return request({
		url: 'manages/goods/' + id,
		method: 'PUT',
		data
	})
}

// 产品附加信息
const managesGoodsExtends = id => {
	return request({
		url: 'manages/goods/' + id + '/extends',
	})
}

// 领取优惠券
const managesCoupons = (id) => {
	return request({
		url: 'coupons/' + id + '/grant',
		method: 'POST'
	})
}

// 商城首页
const mall = data => {
	return request({
		url: "mall"
	})
}

// 商品列表
const list = data => {
	return request({
		url: "mall/goods",
		data
	})
}
// 通证权益 搜索页面
const searchUrl = (apiUrl, data) => {
	return request({
		url: apiUrl,
		data: data
	})
}
// 企业行业分类
const companyCategory = () => {
	return request({
		url: 'companies/industry'
	})
}
// 商品分类搜索-默认关键字
const randgoodsUrl = (apiUrl, data) => {
	return request({
		url: apiUrl,
		data: data
	})
}
// 商品详情
const goods = id => {
	return request({
		url: 'mall/goods/' + id
	})
}
// 商品分类
const goodsCategory = () => {
	return request({
		url: 'mall/categories'
	})
}
// 商品确认商品信息页面get  下单页 post
const mallBuyGoods = (data, method) => {
	return request({
		url: 'mall/buy/goods',
		method: method,
		data: data
	})
}
// 区块链证书
const managesChain = (id) => {
	return request({
		url: 'mall/goods/' + id + '/chain'
	})
}

// 商品认证
const managesAttestation = (id) => {
	return request({
		url: 'mall/goods/' + id + '/message'
	})
}

// 商品溯源
const managesTracedTo = (id,page) => {
	return request({
		url: 'mall/goods/' + id + '/trace',
		data:{
			page: page
		}
	})
}
// 商品第一条溯源
const checkmessage = (id) => {
	return request({
		url: 'mall/goods/' + id + '/checkmessage'
	})
}

// 商品类型 0全1自营2合作
const shopself = () => {
	return request({
		url: 'mall/shopself'
	})
}

// 商品服务类型调整
const goodsExtendsCreate = (id) => {
	return request({
		url: 'manages/goods/' + id + '/extends/create'
	})
}

export {
	managesGoodsIndex,
	managesGoodsMint,
	managesGoodsBurn,
	managesGoodsCreateBefore,
	managesGoodsCreate,
	managesCategory,
	managesGoodsAuth,
	managesGoodsDelete,
	managesGoodsEdit,
	managesCreate,
	managesGoodsPut,
	managesGoodsExtends,
	managesCoupons,
	mall,
	list,
	searchUrl,
	companyCategory,
	randgoodsUrl,
	goods,
	goodsCategory,
	mallBuyGoods,
	managesChain,
	managesAttestation,
	managesTracedTo,
	checkmessage,
	shopself,
	goodsExtendsCreate
}
