ts_aimz/net/api/shop.js
2025-06-16 15:04:57 +08:00

199 lines
6.3 KiB
JavaScript

import {
request
} from "../http";
// 公共API
// 0b00884a-f7a2-425f-93e5-599fbaad4bde 软著分类
// ce3ded65-68ed-4f42-89da-de1b813b8f7e 证件类型
const proName = 'aiShop'
const apiPath = {
fileList: '/api/file/list', //根据ID获取文件详情
indexList: "/api/goodsonline/listpage", //上架的软著商品列表 GET
saveGoods: "/api/goods/save", //新增软著商品 POST
goodsDetail: "/api/goods/get/{goodsId}", //商品详情 GET
delGoods: "/api/goods/remove/{ids}", //删除商品 DELETE
updateGoods: "/api/goods/update/{goodsId}", //修改商品 PUT
doCheck: "/api/goods/sub-check/{goodsId}", //提交审核 PUT
onGoods: "/api/goods/{publish}/{goodsId}", //上架商品 PUT publish
offGoods: "/api/goods/{publish}/{goodsId}", //下架商品 no-publish
saleGoods: '/api/goods/{publish}/{goodsId}', //上架或下架商品
goodsDics: "/api/data/listbyparentid/{dId}", //商品数据字典
goodsDicDetail: '/api/data/get/{dId}', //字典详情
areaList: "/api/area/listbyparentid/{pId}", //省市区树结构
areaDetail: '/api/area/get/{areaId}', //地区详情
saveOrder: '/api/order/save/{goodsId}', //新增订单
orderDetail: '/api/order/get/{orderId}', //订单详情
confirmOrder: '/api/order/confirm-pay/{orderId}', //确定付款
cancelOrder: '/api/order/save-cancel/{orderId}', //取消订单
mineBuyOrder: '/api/order/listpage-buy', //我购买的订单
mineSellOrder: '/api/order/listpage-sell', //我已经销售的
mineSellGoods: '/api/goods/listpage', //我售卖的软著
replenishList: '/api/correction/{kind}', //补充资料列表
replenishDetail: '/api/correction/get/{correctionId}', //补充资料详情
replenishSave: '/api/correction/save', //保存补充材料
saveBuyPersonInfo: '/api/order/save-input/{orderId}', //保存购买人信息
}
class Shop {
// 通用路径参数替换方法
static #replacePathParams(path, params) {
return Object.entries(params).reduce(
(acc, [key, value]) => acc.replace(`{${key}}`, value),
path
)
}
// 通用请求方法
static requestHandler(endpoint, method, data = null, pathParams = {}) {
const path = Object.keys(pathParams).length ?
this.#replacePathParams(endpoint, pathParams) :
endpoint
return request(path, method, data, proName)
}
//根据ids获取文件信息
static doGetFileInfos(data) {
return this.requestHandler(apiPath.fileList, "GET", data)
}
// 获取上架的软著列表
static doGetIndexList(data) {
return this.requestHandler(apiPath.indexList, "GET", data)
}
// 软著类型
static doGetGoodsDic(id) {
return this.requestHandler(apiPath.goodsDics, "GET", null, {
dId: id
})
}
//字典详情
static doGetDicDetail(id) {
return this.requestHandler(apiPath.goodsDicDetail, "GET", null, {
dId: id
})
}
// 新增软件商品
static doSaveGoods(data) {
return this.requestHandler(apiPath.saveGoods, "POST", data)
}
// 商品详情
static doGetGoodsDetail(id) {
return this.requestHandler(apiPath.goodsDetail, "GET", null, {
goodsId: id
})
}
// 删除商品
static doDelGoods(id) {
return this.requestHandler(apiPath.delGoods, "DELETE", null, {
ids: id
})
}
// 更新商品
static doUpdateGoods(id, data) {
return this.requestHandler(apiPath.updateGoods, "PUT", data, {
goodsId: id
})
}
// 提交审核
static doSubCheck(id) {
return this.requestHandler(apiPath.doCheck, "PUT", null, {
goodsId: id
})
}
// 上架商品
static doOnGoods(id) {
return this.requestHandler(apiPath.onGoods, "PUT", null, {
goodsId: id
})
}
// 下架商品
static doOffGoods(id) {
return this.requestHandler(apiPath.offGoods, "PUT", null, {
goodsId: id
})
}
//上架或下架商品
static doSaleGoods(status, id) {
return this.requestHandler(apiPath.saleGoods, "PUT", null, {
publish: status,
goodsId: id
})
}
//获取地区
static doGetAreaList(id) {
return this.requestHandler(apiPath.areaList, "GET", null, {
pId: id
})
}
//地区详情
static doGetAreaDetail(id) {
return this.requestHandler(apiPath.areaDetail, "GET", null, {
areaId: id
})
}
//新增订单
static doSaveOrder(id) {
return this.requestHandler(apiPath.saveOrder, "POST", null, {
goodsId: id
})
}
//订单详情
static doGetOrderDetail(id) {
return this.requestHandler(apiPath.orderDetail, "GET", null, {
orderId: id
})
}
//确定付款
static doConfirmOrder(oId) {
return this.requestHandler(apiPath.confirmOrder, "PUT", null, {
orderId: oId
})
}
//取消订单
static doCancelOrder(oId) {
return this.requestHandler(apiPath.cancelOrder, "PUT", null, {
orderId: oId
})
}
//我购买的
static doGetMineOrders(data) {
return this.requestHandler(apiPath.mineBuyOrder, "GET", data)
}
//我已售卖的
static doGetMineSellOrder(data) {
return this.requestHandler(apiPath.mineSellOrder, "GET", data)
}
//我售卖的商品
static doGetMineSellGoods(data) {
return this.requestHandler(apiPath.mineSellGoods, "GET", data)
}
//获取补充资料列表
static doGetReplenishList(type, data) {
const typeStr = 'listpage-' + type
return this.requestHandler(apiPath.replenishList, "GET", data, {
kind: typeStr
})
}
//获取补充资料详情
static doGetReplenishDetail(id) {
return this.requestHandler(apiPath.replenishDetail, "GET", null, {
correctionId: id
})
}
//保存补充材料
static doSaveReplenish(data) {
return this.requestHandler(apiPath.replenishSave, "POST", data)
}
//保存受让人信息
static doSaveBuyPersonInfo(orderId, data) {
return this.requestHandler(apiPath.saveBuyPersonInfo, "POST", data, {
orderId: orderId
})
}
}
export default Shop;