实现多商户履约平台基础
This commit is contained in:
@@ -23,9 +23,10 @@ func (h *OrderHandler) List(c *gin.Context) {
|
||||
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
||||
size, _ := strconv.Atoi(c.DefaultQuery("size", "20"))
|
||||
q := service.OrderListQuery{
|
||||
Page: page,
|
||||
Size: size,
|
||||
Status: c.Query("status"),
|
||||
MerchantID: middleware.GetMerchantID(c),
|
||||
Page: page,
|
||||
Size: size,
|
||||
Status: c.Query("status"),
|
||||
}
|
||||
// 分销商只能看自己的订单
|
||||
if middleware.GetRole(c) == model.RoleDistributor {
|
||||
@@ -45,11 +46,11 @@ func (h *OrderHandler) List(c *gin.Context) {
|
||||
}
|
||||
|
||||
type createOrderReq struct {
|
||||
SkinID uint `json:"skin_id" binding:"required"`
|
||||
BuyerName string `json:"buyer_name"`
|
||||
Remark string `json:"remark"`
|
||||
Status string `json:"status"` // 管理员可指定初始状态(联调造异常单)
|
||||
DistributorID *uint `json:"distributor_id"` // 管理员可指定分销商
|
||||
SkinID uint `json:"skin_id" binding:"required"`
|
||||
BuyerName string `json:"buyer_name"`
|
||||
Remark string `json:"remark"`
|
||||
Status string `json:"status"` // 管理员可指定初始状态(联调造异常单)
|
||||
DistributorID *uint `json:"distributor_id"` // 管理员可指定分销商
|
||||
}
|
||||
|
||||
func (h *OrderHandler) Create(c *gin.Context) {
|
||||
@@ -75,6 +76,7 @@ func (h *OrderHandler) Create(c *gin.Context) {
|
||||
req.BuyerName = "测试买家"
|
||||
}
|
||||
order, err := h.svc.Create(service.CreateOrderInput{
|
||||
MerchantID: middleware.GetMerchantID(c),
|
||||
SkinID: req.SkinID,
|
||||
DistributorID: distributorID,
|
||||
BuyerName: req.BuyerName,
|
||||
@@ -99,7 +101,7 @@ func (h *OrderHandler) UpdateStatus(c *gin.Context) {
|
||||
response.BadRequest(c, "参数错误")
|
||||
return
|
||||
}
|
||||
if err := h.svc.UpdateStatus(uint(id), req.Status); err != nil {
|
||||
if err := h.svc.UpdateStatus(middleware.GetMerchantID(c), uint(id), req.Status); err != nil {
|
||||
response.BadRequest(c, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -107,7 +109,7 @@ func (h *OrderHandler) UpdateStatus(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *OrderHandler) Dashboard(c *gin.Context) {
|
||||
stats, err := h.svc.Dashboard()
|
||||
stats, err := h.svc.Dashboard(middleware.GetMerchantID(c))
|
||||
if err != nil {
|
||||
response.ServerError(c, err.Error())
|
||||
return
|
||||
@@ -120,6 +122,7 @@ func (h *OrderHandler) ListShipLogs(c *gin.Context) {
|
||||
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
||||
size, _ := strconv.Atoi(c.DefaultQuery("size", "20"))
|
||||
list, total, err := h.svc.ListShipLogs(service.ShipLogListQuery{
|
||||
MerchantID: middleware.GetMerchantID(c),
|
||||
Page: page,
|
||||
Size: size,
|
||||
OrderNo: c.Query("order_no"),
|
||||
|
||||
Reference in New Issue
Block a user