增加各种状态的新建测试单
This commit is contained in:
@@ -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")
|
||||||
|
|||||||
@@ -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 = "测试买家"
|
||||||
|
|||||||
@@ -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{
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
启动代理到 8080
|
||||||
|
|
||||||
|
cloudflared tunnel run --url http://localhost:8080 mac-mini-tunnel
|
||||||
|
|
||||||
+1
-1
@@ -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 秒 |
|
||||||
|
|||||||
@@ -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>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user