增加各种状态的新建测试单
This commit is contained in:
@@ -41,8 +41,8 @@ func loadDotEnv() {
|
||||
if wd, err := os.Getwd(); err == nil {
|
||||
paths = append(paths,
|
||||
filepath.Join(wd, ".env"),
|
||||
filepath.Join(wd, "..", ".env"), // 在 backend/ 下启动时读仓库根 .env
|
||||
filepath.Join(wd, "backend", ".env"), // 在仓库根启动时
|
||||
filepath.Join(wd, "..", ".env"), // 在 backend/ 下启动时读仓库根 .env
|
||||
filepath.Join(wd, "backend", ".env"), // 在仓库根启动时
|
||||
)
|
||||
}
|
||||
paths = append(paths, ".env")
|
||||
|
||||
@@ -48,7 +48,7 @@ type createOrderReq struct {
|
||||
SkinID uint `json:"skin_id" binding:"required"`
|
||||
BuyerName string `json:"buyer_name"`
|
||||
Remark string `json:"remark"`
|
||||
Status string `json:"status"` // 管理员可传 paid 直接可发货
|
||||
Status string `json:"status"` // 管理员可指定初始状态(联调造异常单)
|
||||
DistributorID *uint `json:"distributor_id"` // 管理员可指定分销商
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func (h *OrderHandler) Create(c *gin.Context) {
|
||||
}
|
||||
distributorID := middleware.GetUserID(c)
|
||||
status := ""
|
||||
// 管理员可指定分销商、创建已支付测试单
|
||||
// 管理员可指定分销商、任意初始状态(方便联调)
|
||||
if middleware.GetRole(c) == model.RoleAdmin {
|
||||
if req.DistributorID != nil && *req.DistributorID > 0 {
|
||||
distributorID = *req.DistributorID
|
||||
@@ -69,9 +69,7 @@ func (h *OrderHandler) Create(c *gin.Context) {
|
||||
id, _ := strconv.ParseUint(d, 10, 64)
|
||||
distributorID = uint(id)
|
||||
}
|
||||
if req.Status == model.OrderStatusPaid {
|
||||
status = model.OrderStatusPaid
|
||||
}
|
||||
status = req.Status
|
||||
}
|
||||
if req.BuyerName == "" {
|
||||
req.BuyerName = "测试买家"
|
||||
|
||||
@@ -74,8 +74,18 @@ func (s *OrderService) Create(in CreateOrderInput) (*model.Order, error) {
|
||||
}
|
||||
|
||||
status := model.OrderStatusPending
|
||||
if in.Status == model.OrderStatusPaid {
|
||||
status = model.OrderStatusPaid
|
||||
switch in.Status {
|
||||
case model.OrderStatusPending,
|
||||
model.OrderStatusPaid,
|
||||
model.OrderStatusDelivering,
|
||||
model.OrderStatusDelivered,
|
||||
model.OrderStatusShipFailed,
|
||||
model.OrderStatusCancelled:
|
||||
status = in.Status
|
||||
case "":
|
||||
// default pending
|
||||
default:
|
||||
return nil, errors.New("无效的订单状态")
|
||||
}
|
||||
|
||||
order := &model.Order{
|
||||
|
||||
Reference in New Issue
Block a user