diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go
index 2105993..4ea83ad 100644
--- a/backend/internal/config/config.go
+++ b/backend/internal/config/config.go
@@ -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")
diff --git a/backend/internal/handler/order.go b/backend/internal/handler/order.go
index e1995fa..18b4262 100644
--- a/backend/internal/handler/order.go
+++ b/backend/internal/handler/order.go
@@ -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 = "测试买家"
diff --git a/backend/internal/service/order.go b/backend/internal/service/order.go
index 0bd591c..c8c3ab7 100644
--- a/backend/internal/service/order.go
+++ b/backend/internal/service/order.go
@@ -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{
diff --git a/docs/cf 隧道代理.md b/docs/cf 隧道代理.md
new file mode 100644
index 0000000..75272de
--- /dev/null
+++ b/docs/cf 隧道代理.md
@@ -0,0 +1,4 @@
+启动代理到 8080
+
+cloudflared tunnel run --url http://localhost:8080 mac-mini-tunnel
+
diff --git a/docs/开放接口-皮肤源头对接.md b/docs/开放接口-皮肤源头对接.md
index 029244f..c3fb846 100644
--- a/docs/开放接口-皮肤源头对接.md
+++ b/docs/开放接口-皮肤源头对接.md
@@ -20,7 +20,7 @@
| 项 | 值(示例 / 请替换) |
|----|---------------------|
-| **API 根地址 Base URL** | `https://http://221329.cc.cd` 开发临时地址 |
+| **API 根地址 Base URL** | `https://221329.cc.cd` 开发临时地址 |
| **X-Api-Key** | 测试使用,如 `sk_source_dev_key_3ad3d1bbacda0e54` |
| **api_secret** | 测试使用,**只用于本地算签名,不要写在 URL/Header**, `sk_source_dev_secret_5a43ec55cd020d83` |
| **时间偏差** | 默认允许 ±300 秒 |
diff --git a/frontend/src/pages/Orders.tsx b/frontend/src/pages/Orders.tsx
index 0b32ad1..502e478 100644
--- a/frontend/src/pages/Orders.tsx
+++ b/frontend/src/pages/Orders.tsx
@@ -1,7 +1,6 @@
import { useCallback, useEffect, useState } from 'react'
import {
Button,
- Checkbox,
Form,
Input,
Modal,
@@ -63,7 +62,7 @@ export default function Orders() {
form.resetFields()
form.setFieldsValue({
buyer_name: '测试买家',
- mark_paid: true,
+ status: 'paid',
remark: '联调测试订单',
})
setCreatedOrder(null)
@@ -84,7 +83,8 @@ export default function Orders() {
skin_id: values.skin_id,
buyer_name: values.buyer_name,
remark: values.remark,
- status: isAdmin && values.mark_paid ? 'paid' : undefined,
+ // 管理员可指定任意初始状态,方便造异常单
+ status: isAdmin ? values.status : undefined,
})
setCreatedOrder(order)
message.success(`测试订单已创建:${order.order_no}`)
@@ -291,7 +291,7 @@ export default function Orders() {
type="primary"
onClick={() => {
setCreatedOrder(null)
- form.setFieldsValue({ mark_paid: true })
+ form.setFieldsValue({ status: 'paid' })
}}
>
再下一单
@@ -350,9 +350,12 @@ export default function Orders() {