1. 清理预充值SQL
2. 查日志的脚本
This commit is contained in:
@@ -2387,7 +2387,7 @@ components:
|
|||||||
DtoClientCreateOrderRequest:
|
DtoClientCreateOrderRequest:
|
||||||
properties:
|
properties:
|
||||||
app_type:
|
app_type:
|
||||||
description: 应用类型(强充必传)(official_account:公众号, miniapp:小程序)
|
description: 应用类型(微信强充必传)(official_account:公众号, miniapp:小程序)
|
||||||
type: string
|
type: string
|
||||||
identifier:
|
identifier:
|
||||||
description: 资产标识符(SN/IMEI/虚拟号/ICCID/MSISDN)
|
description: 资产标识符(SN/IMEI/虚拟号/ICCID/MSISDN)
|
||||||
@@ -2401,6 +2401,9 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
nullable: true
|
nullable: true
|
||||||
type: array
|
type: array
|
||||||
|
payment_method:
|
||||||
|
description: 支付方式(强充必传)(wechat:微信, alipay:支付宝)
|
||||||
|
type: string
|
||||||
required:
|
required:
|
||||||
- identifier
|
- identifier
|
||||||
- package_ids
|
- package_ids
|
||||||
@@ -2419,6 +2422,8 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
pay_config:
|
pay_config:
|
||||||
$ref: '#/components/schemas/DtoClientPayConfig'
|
$ref: '#/components/schemas/DtoClientPayConfig'
|
||||||
|
payment_link:
|
||||||
|
$ref: '#/components/schemas/DtoClientPaymentLink'
|
||||||
recharge:
|
recharge:
|
||||||
$ref: '#/components/schemas/DtoClientRechargeInfo'
|
$ref: '#/components/schemas/DtoClientRechargeInfo'
|
||||||
type: object
|
type: object
|
||||||
@@ -2427,10 +2432,10 @@ components:
|
|||||||
amount:
|
amount:
|
||||||
description: 充值金额(分)
|
description: 充值金额(分)
|
||||||
maximum: 1e+07
|
maximum: 1e+07
|
||||||
minimum: 100
|
minimum: 1
|
||||||
type: integer
|
type: integer
|
||||||
app_type:
|
app_type:
|
||||||
description: 应用类型 (official_account:公众号, miniapp:小程序)
|
description: 应用类型(微信支付必传)(official_account:公众号, miniapp:小程序)
|
||||||
type: string
|
type: string
|
||||||
identifier:
|
identifier:
|
||||||
description: 资产标识符(SN/IMEI/虚拟号/ICCID/MSISDN)
|
description: 资产标识符(SN/IMEI/虚拟号/ICCID/MSISDN)
|
||||||
@@ -2438,13 +2443,12 @@ components:
|
|||||||
minLength: 1
|
minLength: 1
|
||||||
type: string
|
type: string
|
||||||
payment_method:
|
payment_method:
|
||||||
description: 支付方式 (wechat:微信支付)
|
description: 支付方式 (wechat:微信支付, alipay:支付宝)
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- identifier
|
- identifier
|
||||||
- amount
|
- amount
|
||||||
- payment_method
|
- payment_method
|
||||||
- app_type
|
|
||||||
type: object
|
type: object
|
||||||
DtoClientExchangePendingResponse:
|
DtoClientExchangePendingResponse:
|
||||||
properties:
|
properties:
|
||||||
@@ -2656,7 +2660,7 @@ components:
|
|||||||
description: 应用类型(微信支付必传)(official_account:公众号, miniapp:小程序)
|
description: 应用类型(微信支付必传)(official_account:公众号, miniapp:小程序)
|
||||||
type: string
|
type: string
|
||||||
payment_method:
|
payment_method:
|
||||||
description: 支付方式 (wallet:钱包, wechat:微信)
|
description: 支付方式 (wallet:钱包, wechat:微信, alipay:支付宝)
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- payment_method
|
- payment_method
|
||||||
@@ -2665,10 +2669,27 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
pay_config:
|
pay_config:
|
||||||
$ref: '#/components/schemas/DtoClientPayConfig'
|
$ref: '#/components/schemas/DtoClientPayConfig'
|
||||||
|
payment_link:
|
||||||
|
$ref: '#/components/schemas/DtoClientPaymentLink'
|
||||||
payment_method:
|
payment_method:
|
||||||
description: 支付方式
|
description: 支付方式
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
DtoClientPaymentLink:
|
||||||
|
properties:
|
||||||
|
copy_link:
|
||||||
|
description: 复制到普通浏览器打开的支付链接(与 qr_link 相同)
|
||||||
|
type: string
|
||||||
|
pay_expire_at:
|
||||||
|
description: 支付链接过期时间(RFC3339 格式)
|
||||||
|
type: string
|
||||||
|
payment_no:
|
||||||
|
description: 支付单号
|
||||||
|
type: string
|
||||||
|
qr_link:
|
||||||
|
description: 二维码内容链接,前端用该链接生成二维码
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
DtoClientRechargeCheckResponse:
|
DtoClientRechargeCheckResponse:
|
||||||
properties:
|
properties:
|
||||||
force_recharge_amount:
|
force_recharge_amount:
|
||||||
@@ -2780,6 +2801,8 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
pay_config:
|
pay_config:
|
||||||
$ref: '#/components/schemas/DtoClientRechargePayConfig'
|
$ref: '#/components/schemas/DtoClientRechargePayConfig'
|
||||||
|
payment_link:
|
||||||
|
$ref: '#/components/schemas/DtoClientPaymentLink'
|
||||||
recharge:
|
recharge:
|
||||||
$ref: '#/components/schemas/DtoClientRechargeResult'
|
$ref: '#/components/schemas/DtoClientRechargeResult'
|
||||||
type: object
|
type: object
|
||||||
@@ -3602,6 +3625,32 @@ components:
|
|||||||
type: object
|
type: object
|
||||||
DtoCreateWechatConfigRequest:
|
DtoCreateWechatConfigRequest:
|
||||||
properties:
|
properties:
|
||||||
|
ali_app_id:
|
||||||
|
description: 支付宝应用ID
|
||||||
|
maxLength: 100
|
||||||
|
type: string
|
||||||
|
ali_notify_url:
|
||||||
|
description: 支付宝异步通知地址
|
||||||
|
maxLength: 500
|
||||||
|
type: string
|
||||||
|
ali_pay_expire_minutes:
|
||||||
|
description: 支付过期分钟数 (默认30分钟)
|
||||||
|
maximum: 1440
|
||||||
|
minimum: 1
|
||||||
|
type: integer
|
||||||
|
ali_private_key:
|
||||||
|
description: 支付宝应用私钥(PEM格式)
|
||||||
|
type: string
|
||||||
|
ali_production:
|
||||||
|
description: 是否生产环境 (true:生产, false:沙箱)
|
||||||
|
type: boolean
|
||||||
|
ali_public_key:
|
||||||
|
description: 支付宝公钥(PEM格式,用于验签)
|
||||||
|
type: string
|
||||||
|
ali_return_url:
|
||||||
|
description: 支付宝同步跳转地址
|
||||||
|
maxLength: 500
|
||||||
|
type: string
|
||||||
description:
|
description:
|
||||||
description: 配置描述
|
description: 配置描述
|
||||||
maxLength: 500
|
maxLength: 500
|
||||||
@@ -3666,7 +3715,7 @@ components:
|
|||||||
maxLength: 200
|
maxLength: 200
|
||||||
type: string
|
type: string
|
||||||
provider_type:
|
provider_type:
|
||||||
description: 支付渠道类型 (wechat:微信直连, fuiou:富友)
|
description: 支付渠道类型 (wechat:微信直连v3, wechat_v2:微信直连v2, fuiou:富友)
|
||||||
type: string
|
type: string
|
||||||
wx_api_v2_key:
|
wx_api_v2_key:
|
||||||
description: 微信APIv2密钥
|
description: 微信APIv2密钥
|
||||||
@@ -8626,6 +8675,39 @@ components:
|
|||||||
type: object
|
type: object
|
||||||
DtoUpdateWechatConfigParams:
|
DtoUpdateWechatConfigParams:
|
||||||
properties:
|
properties:
|
||||||
|
ali_app_id:
|
||||||
|
description: 支付宝应用ID
|
||||||
|
maxLength: 100
|
||||||
|
nullable: true
|
||||||
|
type: string
|
||||||
|
ali_notify_url:
|
||||||
|
description: 支付宝异步通知地址
|
||||||
|
maxLength: 500
|
||||||
|
nullable: true
|
||||||
|
type: string
|
||||||
|
ali_pay_expire_minutes:
|
||||||
|
description: 支付过期分钟数
|
||||||
|
maximum: 1440
|
||||||
|
minimum: 1
|
||||||
|
nullable: true
|
||||||
|
type: integer
|
||||||
|
ali_private_key:
|
||||||
|
description: 支付宝应用私钥(PEM格式)
|
||||||
|
nullable: true
|
||||||
|
type: string
|
||||||
|
ali_production:
|
||||||
|
description: 是否生产环境 (true:生产, false:沙箱)
|
||||||
|
nullable: true
|
||||||
|
type: boolean
|
||||||
|
ali_public_key:
|
||||||
|
description: 支付宝公钥(PEM格式,用于验签)
|
||||||
|
nullable: true
|
||||||
|
type: string
|
||||||
|
ali_return_url:
|
||||||
|
description: 支付宝同步跳转地址
|
||||||
|
maxLength: 500
|
||||||
|
nullable: true
|
||||||
|
type: string
|
||||||
description:
|
description:
|
||||||
description: 配置描述
|
description: 配置描述
|
||||||
maxLength: 500
|
maxLength: 500
|
||||||
@@ -8706,7 +8788,7 @@ components:
|
|||||||
nullable: true
|
nullable: true
|
||||||
type: string
|
type: string
|
||||||
provider_type:
|
provider_type:
|
||||||
description: 支付渠道类型 (wechat:微信直连, fuiou:富友)
|
description: 支付渠道类型 (wechat:微信直连v3, wechat_v2:微信直连v2, fuiou:富友)
|
||||||
nullable: true
|
nullable: true
|
||||||
type: string
|
type: string
|
||||||
wx_api_v2_key:
|
wx_api_v2_key:
|
||||||
@@ -8890,6 +8972,27 @@ components:
|
|||||||
type: object
|
type: object
|
||||||
DtoWechatConfigResponse:
|
DtoWechatConfigResponse:
|
||||||
properties:
|
properties:
|
||||||
|
ali_app_id:
|
||||||
|
description: 支付宝应用ID
|
||||||
|
type: string
|
||||||
|
ali_notify_url:
|
||||||
|
description: 支付宝异步通知地址
|
||||||
|
type: string
|
||||||
|
ali_pay_expire_minutes:
|
||||||
|
description: 支付过期分钟数
|
||||||
|
type: integer
|
||||||
|
ali_private_key:
|
||||||
|
description: 支付宝应用私钥(配置状态)
|
||||||
|
type: string
|
||||||
|
ali_production:
|
||||||
|
description: 是否生产环境
|
||||||
|
type: boolean
|
||||||
|
ali_public_key:
|
||||||
|
description: 支付宝公钥(配置状态)
|
||||||
|
type: string
|
||||||
|
ali_return_url:
|
||||||
|
description: 支付宝同步跳转地址
|
||||||
|
type: string
|
||||||
created_at:
|
created_at:
|
||||||
description: 创建时间
|
description: 创建时间
|
||||||
type: string
|
type: string
|
||||||
@@ -8949,7 +9052,7 @@ components:
|
|||||||
description: 公众号Token(已脱敏)
|
description: 公众号Token(已脱敏)
|
||||||
type: string
|
type: string
|
||||||
provider_type:
|
provider_type:
|
||||||
description: 支付渠道类型 (wechat:微信直连, fuiou:富友)
|
description: 支付渠道类型 (wechat:微信直连v3, wechat_v2:微信直连v2, fuiou:富友)
|
||||||
type: string
|
type: string
|
||||||
updated_at:
|
updated_at:
|
||||||
description: 更新时间
|
description: 更新时间
|
||||||
@@ -23253,11 +23356,11 @@ paths:
|
|||||||
maximum: 100
|
maximum: 100
|
||||||
minimum: 1
|
minimum: 1
|
||||||
type: integer
|
type: integer
|
||||||
- description: 支付渠道类型 (wechat:微信直连, fuiou:富友)
|
- description: 支付渠道类型 (wechat:微信直连v3, wechat_v2:微信直连v2, fuiou:富友)
|
||||||
in: query
|
in: query
|
||||||
name: provider_type
|
name: provider_type
|
||||||
schema:
|
schema:
|
||||||
description: 支付渠道类型 (wechat:微信直连, fuiou:富友)
|
description: 支付渠道类型 (wechat:微信直连v3, wechat_v2:微信直连v2, fuiou:富友)
|
||||||
nullable: true
|
nullable: true
|
||||||
type: string
|
type: string
|
||||||
- description: 是否激活 (true:已激活, false:未激活)
|
- description: 是否激活 (true:已激活, false:未激活)
|
||||||
|
|||||||
155
docs/alipay-integration/前端对接说明.md
Normal file
155
docs/alipay-integration/前端对接说明.md
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
# 支付宝支付链接前端对接说明
|
||||||
|
|
||||||
|
## 1. 对接范围
|
||||||
|
|
||||||
|
本次新增的是 **C 端支付宝支付链接能力**。前端无需接入支付宝 SDK,后端会返回已签名的支付宝 WAP 支付链接。
|
||||||
|
|
||||||
|
覆盖场景:
|
||||||
|
|
||||||
|
1. 套餐订单支付
|
||||||
|
2. 钱包充值
|
||||||
|
3. 强制充值购包场景
|
||||||
|
|
||||||
|
微信支付原逻辑保持不变:微信返回 `pay_config`,支付宝返回 `payment_link`。
|
||||||
|
|
||||||
|
具体接口路径、完整请求字段、响应结构、错误码请以前端接口文档 / OpenAPI 文档为准。
|
||||||
|
|
||||||
|
## 2. 支付方式取值
|
||||||
|
|
||||||
|
前端统一使用 `payment_method` 区分支付方式:
|
||||||
|
|
||||||
|
| 值 | 含义 | 前端处理 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `wallet` | 钱包支付 | 仅订单支付支持,无第三方跳转 |
|
||||||
|
| `wechat` | 微信支付 | 使用返回的 `pay_config` 调起微信支付 |
|
||||||
|
| `alipay` | 支付宝支付 | 使用返回的 `payment_link` 打开或展示支付链接 |
|
||||||
|
|
||||||
|
注意事项:
|
||||||
|
|
||||||
|
- `app_type` 只在微信支付时需要。
|
||||||
|
- 支付宝支付时不需要传 `app_type`。
|
||||||
|
- 支付宝支付返回的是支付链接,不是 JSAPI 参数。
|
||||||
|
|
||||||
|
## 3. 前端需要关注的响应字段
|
||||||
|
|
||||||
|
当选择支付宝支付时,接口响应中会返回 `payment_link`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"payment_link": {
|
||||||
|
"payment_no": "支付单号",
|
||||||
|
"qr_link": "支付宝支付链接,可用于生成二维码",
|
||||||
|
"copy_link": "支付宝支付链接,可复制或直接打开",
|
||||||
|
"pay_expire_at": "支付链接过期时间,RFC3339 格式"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
字段说明:
|
||||||
|
|
||||||
|
| 字段 | 用途 |
|
||||||
|
| --- | --- |
|
||||||
|
| `payment_no` | 支付单号,问题排查 / 客服查询使用 |
|
||||||
|
| `qr_link` | 前端可用该链接生成二维码 |
|
||||||
|
| `copy_link` | 用户复制或浏览器打开的支付链接,当前与 `qr_link` 一致 |
|
||||||
|
| `pay_expire_at` | 支付链接过期时间,前端可用于倒计时展示 |
|
||||||
|
|
||||||
|
## 4. 推荐交互流程
|
||||||
|
|
||||||
|
### 4.1 支付宝支付流程
|
||||||
|
|
||||||
|
前端拿到 `payment_link` 后:
|
||||||
|
|
||||||
|
1. H5 / 浏览器场景:直接跳转 `copy_link`。
|
||||||
|
2. PC 场景:使用 `qr_link` 生成二维码。
|
||||||
|
3. App / WebView 场景:在外部浏览器或支付宝可识别环境中打开 `copy_link`。
|
||||||
|
|
||||||
|
支付成功后:
|
||||||
|
|
||||||
|
- 不要只依赖支付宝返回页判断支付成功。
|
||||||
|
- 最终支付状态以服务端订单 / 充值记录状态为准。
|
||||||
|
- 用户返回页面后,前端应轮询订单详情、订单列表或充值记录接口。
|
||||||
|
|
||||||
|
## 5. 各业务场景说明
|
||||||
|
|
||||||
|
### 5.1 套餐订单支付
|
||||||
|
|
||||||
|
普通套餐下单后,如果需要支付,前端调用订单支付接口,并传:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"payment_method": "alipay"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
支付宝支付响应示例:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"payment_method": "alipay",
|
||||||
|
"payment_link": {
|
||||||
|
"payment_no": "...",
|
||||||
|
"qr_link": "...",
|
||||||
|
"copy_link": "...",
|
||||||
|
"pay_expire_at": "..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
前端根据 `payment_link` 发起支付宝支付。
|
||||||
|
|
||||||
|
### 5.2 钱包充值
|
||||||
|
|
||||||
|
创建钱包充值单时传:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"payment_method": "alipay"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
支付宝场景返回 `payment_link`;微信场景返回 `pay_config`。
|
||||||
|
|
||||||
|
### 5.3 强制充值购包
|
||||||
|
|
||||||
|
创建订单时,如果后端判断需要强制充值,前端可指定:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"payment_method": "alipay"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
如果是支付宝强充,响应中会返回:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"order_type": "recharge",
|
||||||
|
"recharge": {},
|
||||||
|
"payment_link": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
前端按支付宝支付链接流程处理。
|
||||||
|
|
||||||
|
## 6. 前端展示建议
|
||||||
|
|
||||||
|
支付宝支付页面建议展示:
|
||||||
|
|
||||||
|
- 支付金额
|
||||||
|
- 支付宝二维码或“去支付宝支付”按钮
|
||||||
|
- 支付链接过期倒计时
|
||||||
|
- “我已完成支付”按钮
|
||||||
|
- “重新获取支付链接”按钮
|
||||||
|
|
||||||
|
点击“我已完成支付”时,不直接判定成功,应查询服务端状态。
|
||||||
|
|
||||||
|
## 7. 注意事项
|
||||||
|
|
||||||
|
1. 金额单位仍然是 **分**。
|
||||||
|
2. 支付宝支付不需要 `app_type`。
|
||||||
|
3. `pay_config` 只用于微信支付。
|
||||||
|
4. `payment_link` 只用于支付宝支付。
|
||||||
|
5. 支付状态以服务端为准,不以前端跳转结果为准。
|
||||||
|
6. 支付链接过期后,前端应重新调用对应支付 / 充值接口获取新链接。
|
||||||
|
7. 具体接口路径、完整字段、错误码请以前端接口文档 / OpenAPI 文档为准。
|
||||||
@@ -56,6 +56,47 @@ redis-cli HGETALL polling:stats:package
|
|||||||
redis-cli HGETALL polling:init:progress
|
redis-cli HGETALL polling:init:progress
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 4. 跨 Worker 日志查询
|
||||||
|
|
||||||
|
线上多实例 Worker 日志分散时,使用仓库内 Rust 工具统一扫描普通日志和 `.gz` 轮转日志。工具默认只输出汇总、命中文件和少量样例,不会把窗口刷满。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rustc scripts/ops/search-worker-logs.rs -O -o /tmp/jh-logq
|
||||||
|
|
||||||
|
/tmp/jh-logq \
|
||||||
|
--roots "/data/worker-1/logs:/data/worker-2/logs:/data/worker-3/logs:/data/worker-4/logs" \
|
||||||
|
--iccid 8986000000000000000 \
|
||||||
|
--date 2026-05-24 \
|
||||||
|
--interface realname
|
||||||
|
```
|
||||||
|
|
||||||
|
常用接口别名:
|
||||||
|
|
||||||
|
| 别名 | 匹配内容 |
|
||||||
|
|------|----------|
|
||||||
|
| `realname` | 实名接口、`realStatus`、实名相关业务日志 |
|
||||||
|
| `flow` / `carddata` | 流量接口、`used`、流量相关业务日志 |
|
||||||
|
| `card_status` | 卡状态接口、`cardStatus`、卡状态业务日志 |
|
||||||
|
| `stop` | 停机接口或停机业务日志 |
|
||||||
|
| `start` / `resume` | 复机接口或复机业务日志 |
|
||||||
|
|
||||||
|
排查“23 号有实名同步,24 号没有”的建议顺序:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 对比两天命中数,先确认是不是所有 Worker 都没有
|
||||||
|
/tmp/jh-logq --roots "/data/worker-1/logs:/data/worker-2/logs:/data/worker-3/logs:/data/worker-4/logs" \
|
||||||
|
--iccid 8986000000000000000 --date 2026-05-23 --interface realname --count-only
|
||||||
|
|
||||||
|
/tmp/jh-logq --roots "/data/worker-1/logs:/data/worker-2/logs:/data/worker-3/logs:/data/worker-4/logs" \
|
||||||
|
--iccid 8986000000000000000 --date 2026-05-24 --interface realname --count-only
|
||||||
|
|
||||||
|
# 如果 24 号实名没有命中,再看这张卡当天是否仍在跑其他轮询
|
||||||
|
/tmp/jh-logq --roots "/data/worker-1/logs:/data/worker-2/logs:/data/worker-3/logs:/data/worker-4/logs" \
|
||||||
|
--iccid 8986000000000000000 --date 2026-05-24
|
||||||
|
```
|
||||||
|
|
||||||
|
注意:旧版本 Gateway 成功请求日志没有稳定输出接口 `path`,脚本对历史日志的 `realname` 匹配会同时使用 `realStatus` 和“实名”业务日志推断。若需要严格按 Gateway 路径查询,生产版本需要在 Gateway 请求/响应日志中输出 `path`。
|
||||||
|
|
||||||
## 告警配置
|
## 告警配置
|
||||||
|
|
||||||
### 1. 默认告警规则
|
### 1. 默认告警规则
|
||||||
|
|||||||
66
docs/脚本/清理代理预充值.sql
Normal file
66
docs/脚本/清理代理预充值.sql
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
-- 锁定代理主钱包,确认余额和冻结余额
|
||||||
|
SELECT *
|
||||||
|
FROM tb_agent_wallet
|
||||||
|
WHERE shop_id = :shop_id
|
||||||
|
AND wallet_type = 'main'
|
||||||
|
AND deleted_at IS NULL
|
||||||
|
FOR UPDATE;
|
||||||
|
|
||||||
|
-- 确认 frozen_balance = 0 且 balance > 0 后执行
|
||||||
|
INSERT INTO tb_agent_wallet_transaction (
|
||||||
|
agent_wallet_id,
|
||||||
|
shop_id,
|
||||||
|
user_id,
|
||||||
|
transaction_type,
|
||||||
|
amount,
|
||||||
|
balance_before,
|
||||||
|
balance_after,
|
||||||
|
status,
|
||||||
|
reference_type,
|
||||||
|
reference_id,
|
||||||
|
remark,
|
||||||
|
metadata,
|
||||||
|
creator,
|
||||||
|
shop_id_tag,
|
||||||
|
enterprise_id_tag,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
shop_id,
|
||||||
|
:operator_user_id,
|
||||||
|
'deduct',
|
||||||
|
-balance,
|
||||||
|
balance,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
'平台清理代理预充值剩余余额,历史消费流水保留',
|
||||||
|
jsonb_build_object('reason', 'clear_agent_main_wallet_balance'),
|
||||||
|
:operator_user_id,
|
||||||
|
shop_id_tag,
|
||||||
|
enterprise_id_tag,
|
||||||
|
NOW(),
|
||||||
|
NOW()
|
||||||
|
FROM tb_agent_wallet
|
||||||
|
WHERE shop_id = :shop_id
|
||||||
|
AND wallet_type = 'main'
|
||||||
|
AND deleted_at IS NULL
|
||||||
|
AND balance > 0
|
||||||
|
AND frozen_balance = 0;
|
||||||
|
|
||||||
|
UPDATE tb_agent_wallet
|
||||||
|
SET balance = 0,
|
||||||
|
version = version + 1,
|
||||||
|
updated_at = NOW()
|
||||||
|
WHERE shop_id = :shop_id
|
||||||
|
AND wallet_type = 'main'
|
||||||
|
AND deleted_at IS NULL
|
||||||
|
AND balance > 0
|
||||||
|
AND frozen_balance = 0;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
95
scripts/ops/README.md
Normal file
95
scripts/ops/README.md
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
# 线上日志查询工具
|
||||||
|
|
||||||
|
## 编译和打包
|
||||||
|
|
||||||
|
Rust 工具是单文件实现,不依赖 Cargo 包:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rustc scripts/ops/search-worker-logs.rs -O -o /tmp/jh-logq
|
||||||
|
```
|
||||||
|
|
||||||
|
上面命令只编译当前机器可运行的版本。本机是 macOS 时,不能把这个默认产物直接放到 Linux 服务器。
|
||||||
|
|
||||||
|
打 Linux x86_64 服务器包:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p dist
|
||||||
|
rustup target add x86_64-unknown-linux-musl
|
||||||
|
HOST_TRIPLE="$(rustc -vV | awk '/^host:/ {print $2}')"
|
||||||
|
RUST_LLD="$(rustc --print sysroot)/lib/rustlib/${HOST_TRIPLE}/bin/rust-lld"
|
||||||
|
rustc --target x86_64-unknown-linux-musl \
|
||||||
|
-C linker="$RUST_LLD" \
|
||||||
|
scripts/ops/search-worker-logs.rs \
|
||||||
|
-O \
|
||||||
|
-o dist/jh-logq-linux-amd64
|
||||||
|
tar -czf dist/jh-logq-linux-amd64.tar.gz -C dist jh-logq-linux-amd64
|
||||||
|
```
|
||||||
|
|
||||||
|
如果服务器是 ARM64:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p dist
|
||||||
|
rustup target add aarch64-unknown-linux-musl
|
||||||
|
HOST_TRIPLE="$(rustc -vV | awk '/^host:/ {print $2}')"
|
||||||
|
RUST_LLD="$(rustc --print sysroot)/lib/rustlib/${HOST_TRIPLE}/bin/rust-lld"
|
||||||
|
rustc --target aarch64-unknown-linux-musl \
|
||||||
|
-C linker="$RUST_LLD" \
|
||||||
|
scripts/ops/search-worker-logs.rs \
|
||||||
|
-O \
|
||||||
|
-o dist/jh-logq-linux-arm64
|
||||||
|
tar -czf dist/jh-logq-linux-arm64.tar.gz -C dist jh-logq-linux-arm64
|
||||||
|
```
|
||||||
|
|
||||||
|
上传并安装到服务器:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scp dist/jh-logq-linux-amd64.tar.gz user@server:/tmp/
|
||||||
|
ssh user@server
|
||||||
|
cd /tmp
|
||||||
|
tar -xzf jh-logq-linux-amd64.tar.gz
|
||||||
|
sudo install -m 0755 jh-logq-linux-amd64 /usr/local/bin/jh-logq
|
||||||
|
jh-logq --help
|
||||||
|
```
|
||||||
|
|
||||||
|
如果交叉编译仍报 linker 相关错误,用 Docker 编译 Linux 产物兜底:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p dist
|
||||||
|
docker run --rm -v "$PWD":/work -w /work rust:1-bookworm \
|
||||||
|
sh -lc 'rustc scripts/ops/search-worker-logs.rs -O -o dist/jh-logq-linux-amd64'
|
||||||
|
```
|
||||||
|
|
||||||
|
## 目录选择
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 推荐:直接打开交互向导,自动发现日志目录并按编号选择
|
||||||
|
/tmp/jh-logq
|
||||||
|
|
||||||
|
# 自动发现候选日志目录
|
||||||
|
/tmp/jh-logq --list-roots
|
||||||
|
|
||||||
|
# 已经知道 ICCID 时,也会先自动发现目录并让你按编号选择
|
||||||
|
/tmp/jh-logq --choose --iccid 8986000000000000000 --date 2026-05-24 --interface realname
|
||||||
|
```
|
||||||
|
|
||||||
|
目录选择支持:
|
||||||
|
|
||||||
|
- 回车或 `all`:扫描全部候选目录
|
||||||
|
- `1,3-4`:只扫描第 1、3、4 个目录
|
||||||
|
- `all,!2,!5-7`:扫描全部,但排除第 2、5、6、7 个目录
|
||||||
|
|
||||||
|
显式传目录仍然保留给自动化脚本使用:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/tmp/jh-logq \
|
||||||
|
--roots "/data/worker-1/logs:/data/worker-2/logs:/data/worker-3/logs:/data/worker-4/logs" \
|
||||||
|
--iccid 8986000000000000000 \
|
||||||
|
--date 2026-05-24 \
|
||||||
|
--interface realname
|
||||||
|
```
|
||||||
|
|
||||||
|
默认只输出汇总、命中文件和少量样例,不会把窗口刷满。需要原始行时再加:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/tmp/jh-logq ... --lines --limit 100
|
||||||
|
```
|
||||||
1308
scripts/ops/search-worker-logs.rs
Normal file
1308
scripts/ops/search-worker-logs.rs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user