chore: gitee sync script; subscription keyword search; order filter ui
This commit is contained in:
@@ -182,13 +182,29 @@ class SiteSubscriptionController extends Controller
|
||||
->where('ends_at', '<', now()->addDays(7));
|
||||
}
|
||||
})
|
||||
->when($filters['keyword'] !== '', function (Builder $builder) use ($filters) {
|
||||
$keyword = $filters['keyword'];
|
||||
->when($filters['keyword'] !== '', function (Builder $builder) use ($filters) {
|
||||
// 关键词搜索:订阅号 / 站点 / 套餐 / 计费周期
|
||||
$keyword = trim((string) ($filters['keyword'] ?? ''));
|
||||
if ($keyword === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$builder->where(function (Builder $subQuery) use ($keyword) {
|
||||
$subQuery->where('subscription_no', 'like', '%' . $keyword . '%')
|
||||
$builder->where(function (Builder $q) use ($keyword) {
|
||||
$q->where('subscription_no', 'like', '%' . $keyword . '%')
|
||||
->orWhere('plan_name', 'like', '%' . $keyword . '%')
|
||||
->orWhere('billing_cycle', 'like', '%' . $keyword . '%');
|
||||
->orWhere('billing_cycle', 'like', '%' . $keyword . '%')
|
||||
->orWhereHas('merchant', function (Builder $mq) use ($keyword) {
|
||||
$mq->where('name', 'like', '%' . $keyword . '%')
|
||||
->orWhere('slug', 'like', '%' . $keyword . '%');
|
||||
})
|
||||
->orWhereHas('plan', function (Builder $pq) use ($keyword) {
|
||||
$pq->where('name', 'like', '%' . $keyword . '%')
|
||||
->orWhere('code', 'like', '%' . $keyword . '%');
|
||||
});
|
||||
|
||||
if (ctype_digit($keyword)) {
|
||||
$q->orWhere('id', (int) $keyword);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,6 +24,18 @@
|
||||
<option value="{{ $value }}" @selected(($filters['payment_status'] ?? '') === $value)>{{ $label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<select name="merchant_id">
|
||||
<option value="">全部站点</option>
|
||||
@foreach(($merchants ?? []) as $m)
|
||||
<option value="{{ $m->id }}" @selected((string)($filters['merchant_id'] ?? '') === (string)$m->id)>{{ $m->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<select name="plan_id">
|
||||
<option value="">全部套餐</option>
|
||||
@foreach(($plans ?? []) as $p)
|
||||
<option value="{{ $p->id }}" @selected((string)($filters['plan_id'] ?? '') === (string)$p->id)>{{ $p->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<select name="sync_status">
|
||||
<option value="">全部同步状态</option>
|
||||
<option value="unsynced" @selected(($filters['sync_status'] ?? '') === 'unsynced')>未同步</option>
|
||||
@@ -102,6 +114,8 @@
|
||||
<form method="get" action="/admin/platform-orders/export" class="mb-10">
|
||||
<input type="hidden" name="status" value="{{ $filters['status'] ?? '' }}">
|
||||
<input type="hidden" name="payment_status" value="{{ $filters['payment_status'] ?? '' }}">
|
||||
<input type="hidden" name="merchant_id" value="{{ $filters['merchant_id'] ?? '' }}">
|
||||
<input type="hidden" name="plan_id" value="{{ $filters['plan_id'] ?? '' }}">
|
||||
<input type="hidden" name="fail_only" value="{{ $filters['fail_only'] ?? '' }}">
|
||||
<input type="hidden" name="synced_only" value="{{ $filters['synced_only'] ?? '' }}">
|
||||
<input type="hidden" name="sync_status" value="{{ $filters['sync_status'] ?? '' }}">
|
||||
@@ -122,6 +136,8 @@
|
||||
<input type="hidden" name="scope" value="filtered">
|
||||
<input type="hidden" name="status" value="{{ $filters['status'] ?? '' }}">
|
||||
<input type="hidden" name="payment_status" value="{{ $filters['payment_status'] ?? '' }}">
|
||||
<input type="hidden" name="merchant_id" value="{{ $filters['merchant_id'] ?? '' }}">
|
||||
<input type="hidden" name="plan_id" value="{{ $filters['plan_id'] ?? '' }}">
|
||||
<input type="hidden" name="fail_only" value="{{ $filters['fail_only'] ?? '' }}">
|
||||
<input type="hidden" name="synced_only" value="{{ $filters['synced_only'] ?? '' }}">
|
||||
<input type="hidden" name="sync_status" value="{{ $filters['sync_status'] ?? '' }}">
|
||||
@@ -142,6 +158,16 @@
|
||||
<form method="post" action="/admin/platform-orders/batch-activate-subscriptions" onsubmit="return confirm('确认对全部订单执行批量同步?该操作仍只处理“已支付+已生效+未同步”的订单,但范围可能很大。');" class="mb-10">
|
||||
@csrf
|
||||
<input type="hidden" name="scope" value="all">
|
||||
<input type="hidden" name="status" value="{{ $filters['status'] ?? '' }}">
|
||||
<input type="hidden" name="payment_status" value="{{ $filters['payment_status'] ?? '' }}">
|
||||
<input type="hidden" name="merchant_id" value="{{ $filters['merchant_id'] ?? '' }}">
|
||||
<input type="hidden" name="plan_id" value="{{ $filters['plan_id'] ?? '' }}">
|
||||
<input type="hidden" name="fail_only" value="{{ $filters['fail_only'] ?? '' }}">
|
||||
<input type="hidden" name="synced_only" value="{{ $filters['synced_only'] ?? '' }}">
|
||||
<input type="hidden" name="sync_status" value="{{ $filters['sync_status'] ?? '' }}">
|
||||
<input type="hidden" name="syncable_only" value="{{ $filters['syncable_only'] ?? '' }}">
|
||||
<input type="hidden" name="batch_synced_24h" value="{{ $filters['batch_synced_24h'] ?? '' }}">
|
||||
<input type="hidden" name="keyword" value="{{ $filters['keyword'] ?? '' }}">
|
||||
<label class="muted form-inline-row mb-8">
|
||||
<span>确认输入</span>
|
||||
<input type="text" name="confirm" placeholder="YES" class="w-140">
|
||||
@@ -160,6 +186,8 @@
|
||||
<input type="hidden" name="scope" value="filtered">
|
||||
<input type="hidden" name="status" value="{{ $filters['status'] ?? '' }}">
|
||||
<input type="hidden" name="payment_status" value="{{ $filters['payment_status'] ?? '' }}">
|
||||
<input type="hidden" name="merchant_id" value="{{ $filters['merchant_id'] ?? '' }}">
|
||||
<input type="hidden" name="plan_id" value="{{ $filters['plan_id'] ?? '' }}">
|
||||
<input type="hidden" name="fail_only" value="{{ $filters['fail_only'] ?? '' }}">
|
||||
<input type="hidden" name="synced_only" value="{{ $filters['synced_only'] ?? '' }}">
|
||||
<input type="hidden" name="sync_status" value="{{ $filters['sync_status'] ?? '' }}">
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<option value="{{ $plan->id }}" @selected(($filters['plan_id'] ?? '') == $plan->id)>{{ $plan->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<input name="keyword" placeholder="搜索订阅号 / 套餐快照 / 计费周期" value="{{ $filters['keyword'] ?? '' }}">
|
||||
<input name="keyword" placeholder="搜索订阅号 / 站点 / 套餐 / 计费周期" value="{{ $filters['keyword'] ?? '' }}">
|
||||
<div>
|
||||
<button type="submit">应用筛选</button>
|
||||
</div>
|
||||
|
||||
50
scripts/gitee_push.sh
Executable file
50
scripts/gitee_push.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# 安全推送到 Gitee:凭证从 /app/working.secret 读取,不写入仓库。
|
||||
# 用法:bash scripts/gitee_push.sh
|
||||
|
||||
REPO_DIR=$(cd "$(dirname "$0")/.." && pwd)
|
||||
cd "$REPO_DIR"
|
||||
|
||||
USER_FILE="/app/working.secret/gitee_user"
|
||||
TOKEN_FILE="/app/working.secret/gitee_token"
|
||||
|
||||
if [[ ! -f "$USER_FILE" || ! -f "$TOKEN_FILE" ]]; then
|
||||
echo "缺少凭证文件:"
|
||||
echo "- $USER_FILE(内容:你的 Gitee 用户名)"
|
||||
echo "- $TOKEN_FILE(内容:你的 Gitee 私人令牌)"
|
||||
echo "请你在服务器上手动创建这两个文件(不要提交到 git)。"
|
||||
exit 10
|
||||
fi
|
||||
|
||||
ASKPASS=$(mktemp)
|
||||
chmod 700 "$ASKPASS"
|
||||
cat > "$ASKPASS" <<'EOF'
|
||||
#!/usr/bin/env sh
|
||||
prompt="$1"
|
||||
if echo "$prompt" | grep -qi "username"; then
|
||||
cat /app/working.secret/gitee_user
|
||||
exit 0
|
||||
fi
|
||||
if echo "$prompt" | grep -qi "password"; then
|
||||
cat /app/working.secret/gitee_token
|
||||
exit 0
|
||||
fi
|
||||
exit 0
|
||||
EOF
|
||||
chmod 700 "$ASKPASS"
|
||||
|
||||
# 禁止交互式提示,强制走 askpass
|
||||
export GIT_TERMINAL_PROMPT=0
|
||||
export GIT_ASKPASS="$ASKPASS"
|
||||
|
||||
echo "Pushing to origin ..."
|
||||
# 只推送当前分支
|
||||
branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
git push -u origin "$branch"
|
||||
|
||||
rm -f "$ASKPASS"
|
||||
|
||||
echo "Push done."
|
||||
Reference in New Issue
Block a user