增加各种状态的新建测试单

This commit is contained in:
yml2213
2026-07-20 18:13:10 +08:00
parent ee78b80cd3
commit 24d4e76c7f
6 changed files with 47 additions and 18 deletions
+2 -2
View File
@@ -41,8 +41,8 @@ func loadDotEnv() {
if wd, err := os.Getwd(); err == nil { if wd, err := os.Getwd(); err == nil {
paths = append(paths, paths = append(paths,
filepath.Join(wd, ".env"), filepath.Join(wd, ".env"),
filepath.Join(wd, "..", ".env"), // 在 backend/ 下启动时读仓库根 .env filepath.Join(wd, "..", ".env"), // 在 backend/ 下启动时读仓库根 .env
filepath.Join(wd, "backend", ".env"), // 在仓库根启动时 filepath.Join(wd, "backend", ".env"), // 在仓库根启动时
) )
} }
paths = append(paths, ".env") paths = append(paths, ".env")
+3 -5
View File
@@ -48,7 +48,7 @@ type createOrderReq struct {
SkinID uint `json:"skin_id" binding:"required"` SkinID uint `json:"skin_id" binding:"required"`
BuyerName string `json:"buyer_name"` BuyerName string `json:"buyer_name"`
Remark string `json:"remark"` Remark string `json:"remark"`
Status string `json:"status"` // 管理员可传 paid 直接可发货 Status string `json:"status"` // 管理员可指定初始状态(联调造异常单)
DistributorID *uint `json:"distributor_id"` // 管理员可指定分销商 DistributorID *uint `json:"distributor_id"` // 管理员可指定分销商
} }
@@ -60,7 +60,7 @@ func (h *OrderHandler) Create(c *gin.Context) {
} }
distributorID := middleware.GetUserID(c) distributorID := middleware.GetUserID(c)
status := "" status := ""
// 管理员可指定分销商、创建已支付测试单 // 管理员可指定分销商、任意初始状态(方便联调)
if middleware.GetRole(c) == model.RoleAdmin { if middleware.GetRole(c) == model.RoleAdmin {
if req.DistributorID != nil && *req.DistributorID > 0 { if req.DistributorID != nil && *req.DistributorID > 0 {
distributorID = *req.DistributorID distributorID = *req.DistributorID
@@ -69,9 +69,7 @@ func (h *OrderHandler) Create(c *gin.Context) {
id, _ := strconv.ParseUint(d, 10, 64) id, _ := strconv.ParseUint(d, 10, 64)
distributorID = uint(id) distributorID = uint(id)
} }
if req.Status == model.OrderStatusPaid { status = req.Status
status = model.OrderStatusPaid
}
} }
if req.BuyerName == "" { if req.BuyerName == "" {
req.BuyerName = "测试买家" req.BuyerName = "测试买家"
+12 -2
View File
@@ -74,8 +74,18 @@ func (s *OrderService) Create(in CreateOrderInput) (*model.Order, error) {
} }
status := model.OrderStatusPending status := model.OrderStatusPending
if in.Status == model.OrderStatusPaid { switch in.Status {
status = model.OrderStatusPaid 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{ order := &model.Order{
+4
View File
@@ -0,0 +1,4 @@
启动代理到 8080
cloudflared tunnel run --url http://localhost:8080 mac-mini-tunnel
+1 -1
View File
@@ -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` | | **X-Api-Key** | 测试使用,如 `sk_source_dev_key_3ad3d1bbacda0e54` |
| **api_secret** | 测试使用,**只用于本地算签名,不要写在 URL/Header**, `sk_source_dev_secret_5a43ec55cd020d83` | | **api_secret** | 测试使用,**只用于本地算签名,不要写在 URL/Header**, `sk_source_dev_secret_5a43ec55cd020d83` |
| **时间偏差** | 默认允许 ±300 秒 | | **时间偏差** | 默认允许 ±300 秒 |
+25 -8
View File
@@ -1,7 +1,6 @@
import { useCallback, useEffect, useState } from 'react' import { useCallback, useEffect, useState } from 'react'
import { import {
Button, Button,
Checkbox,
Form, Form,
Input, Input,
Modal, Modal,
@@ -63,7 +62,7 @@ export default function Orders() {
form.resetFields() form.resetFields()
form.setFieldsValue({ form.setFieldsValue({
buyer_name: '测试买家', buyer_name: '测试买家',
mark_paid: true, status: 'paid',
remark: '联调测试订单', remark: '联调测试订单',
}) })
setCreatedOrder(null) setCreatedOrder(null)
@@ -84,7 +83,8 @@ export default function Orders() {
skin_id: values.skin_id, skin_id: values.skin_id,
buyer_name: values.buyer_name, buyer_name: values.buyer_name,
remark: values.remark, remark: values.remark,
status: isAdmin && values.mark_paid ? 'paid' : undefined, // 管理员可指定任意初始状态,方便造异常单
status: isAdmin ? values.status : undefined,
}) })
setCreatedOrder(order) setCreatedOrder(order)
message.success(`测试订单已创建:${order.order_no}`) message.success(`测试订单已创建:${order.order_no}`)
@@ -291,7 +291,7 @@ export default function Orders() {
type="primary" type="primary"
onClick={() => { onClick={() => {
setCreatedOrder(null) setCreatedOrder(null)
form.setFieldsValue({ mark_paid: true }) form.setFieldsValue({ status: 'paid' })
}} }}
> >
@@ -350,9 +350,12 @@ export default function Orders() {
<Tag color={statusMap[createdOrder.status]?.color}> <Tag color={statusMap[createdOrder.status]?.color}>
{statusMap[createdOrder.status]?.text || createdOrder.status} {statusMap[createdOrder.status]?.text || createdOrder.status}
</Tag> </Tag>
{createdOrder.status === 'paid' && ( {(createdOrder.status === 'paid' || createdOrder.status === 'ship_failed') && (
<Typography.Text type="success"> can_ship=true</Typography.Text> <Typography.Text type="success"> can_ship=true</Typography.Text>
)} )}
{createdOrder.status !== 'paid' && createdOrder.status !== 'ship_failed' && (
<Typography.Text type="secondary"> can_ship=false</Typography.Text>
)}
</div> </div>
<div>{createdOrder.buyer_name}</div> <div>{createdOrder.buyer_name}</div>
</div> </div>
@@ -387,12 +390,26 @@ export default function Orders() {
<Input.TextArea rows={2} placeholder="联调说明" /> <Input.TextArea rows={2} placeholder="联调说明" />
</Form.Item> </Form.Item>
{isAdmin && ( {isAdmin && (
<Form.Item name="mark_paid" valuePropName="checked"> <Form.Item
<Checkbox></Checkbox> name="status"
label="初始状态(联调造单)"
rules={[{ required: true, message: '请选择状态' }]}
extra="源头 can_ship=true 的只有:已支付、发货失败"
>
<Select
options={[
{ value: 'pending', label: '待支付 pending — can_ship=false' },
{ value: 'paid', label: '已支付 paid — can_ship=true(正常可发)' },
{ value: 'delivering', label: '发货中 delivering — can_ship=false' },
{ value: 'delivered', label: '已交付 delivered — can_ship=false' },
{ value: 'ship_failed', label: '发货失败 ship_failed — can_ship=true(可重试)' },
{ value: 'cancelled', label: '已取消 cancelled — can_ship=false' },
]}
/>
</Form.Item> </Form.Item>
)} )}
<Typography.Paragraph type="secondary" style={{ fontSize: 12, marginBottom: 0 }}> <Typography.Paragraph type="secondary" style={{ fontSize: 12, marginBottom: 0 }}>
O20260720 O20260720
</Typography.Paragraph> </Typography.Paragraph>
</Form> </Form>
)} )}