Compare commits
8
Commits
feat/coupons
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d8b307939 | ||
|
|
9154d5da03 | ||
|
|
d7dec43c62 | ||
|
|
8020a4eb20 | ||
|
|
a3efdcfe37 | ||
|
|
c41a0900a7 | ||
|
|
fab0aeb22e | ||
|
|
ae37085e25 |
@@ -45,24 +45,24 @@ type Order struct {
|
||||
// 商品上的 shipping_mode 后续可能被改,订单必须记住成交时用的是哪种口径。
|
||||
ShippingMode string `gorm:"size:20;default:'ems_tax_self'" json:"shipping_mode"`
|
||||
|
||||
RefundAmount *float64 `gorm:"type:decimal(10,2)" json:"refund_amount"`
|
||||
RefundStatus string `gorm:"size:20" json:"refund_status"`
|
||||
RefundReason string `json:"refund_reason"`
|
||||
RefundAmount *float64 `gorm:"type:decimal(10,2)" json:"refund_amount"`
|
||||
RefundStatus string `gorm:"size:20" json:"refund_status"`
|
||||
RefundReason string `json:"refund_reason"`
|
||||
// RefundRejectReason 驳回退款时管理员填写的理由(对客户可见)
|
||||
RefundRejectReason string `json:"refund_reject_reason"`
|
||||
Status string `gorm:"size:20;not null;default:'pending_payment'" json:"status"`
|
||||
ShippingAddressID *uint `json:"shipping_address_id"`
|
||||
TrackingNumber string `gorm:"size:100" json:"tracking_number"`
|
||||
RefundRejectReason string `json:"refund_reject_reason"`
|
||||
Status string `gorm:"size:20;not null;default:'pending_payment'" json:"status"`
|
||||
ShippingAddressID *uint `json:"shipping_address_id"`
|
||||
TrackingNumber string `gorm:"size:100" json:"tracking_number"`
|
||||
// ShippedAt 首次发货时间。发货后自动完成(auto_complete_days)靠它算「发货满 N 天」;
|
||||
// 不能用 updated_at —— 改备注、补凭证都会刷新它,会把计时反复重置。
|
||||
// 历史订单没有这个值,迁移时用 updated_at 回填(近似,但不影响新单计时)。
|
||||
ShippedAt *time.Time `json:"shipped_at,omitempty"`
|
||||
// ExpressCompany 快递公司编码(sf / yto / zto / ems / dhl ...)。
|
||||
// 原先只有单号没有承运商,无法对接任何查询接口。
|
||||
ExpressCompany string `gorm:"size:50" json:"express_company"`
|
||||
ShippingPhoto string `gorm:"type:text" json:"shipping_photo"`
|
||||
ExpressPhoto string `gorm:"type:text" json:"express_photo"`
|
||||
CustomsPhoto string `gorm:"type:text" json:"customs_photo"`
|
||||
ExpressCompany string `gorm:"size:50" json:"express_company"`
|
||||
ShippingPhoto string `gorm:"type:text" json:"shipping_photo"`
|
||||
ExpressPhoto string `gorm:"type:text" json:"express_photo"`
|
||||
CustomsPhoto string `gorm:"type:text" json:"customs_photo"`
|
||||
// Remark 订单备注:管理员或供货商填写,对客户可见(详情页 + 通知邮件都会展示)。
|
||||
// 用途是说明特殊情况,如「客户要求周六送货」「已电话确认尺寸」。
|
||||
Remark string `gorm:"type:text" json:"remark"`
|
||||
|
||||
@@ -4,13 +4,15 @@ import "sale/internal/models"
|
||||
|
||||
// SeedCurrencyDefaults 首次启动写入货币默认值。
|
||||
//
|
||||
// 站点面向日本客人,默认货币就是 JPY(符号 ¥、不带小数)。
|
||||
// 站点面向日本客人,价格按日元计。
|
||||
// 符号用「日元」而不是 ¥:界面是中文的,¥ 会被读成人民币,
|
||||
// 前端 money() 对文字单位会自动放到数字后面(1,040日元)。
|
||||
// 只在 key 不存在时插入,已有配置(含运营手改过的)一律不覆盖 ——
|
||||
// 与 SeedEmailTemplates 一样的口径:升级不覆盖用户数据。
|
||||
func SeedCurrencyDefaults() {
|
||||
defaults := map[string]string{
|
||||
"currency_code": "JPY",
|
||||
"currency_symbol": "¥",
|
||||
"currency_symbol": "日元",
|
||||
"currency_decimals": "0",
|
||||
}
|
||||
for k, v := range defaults {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<template>
|
||||
<el-dialog :model-value="modelValue" title="メールアドレスの確認" width="420px" @update:model-value="emit('update:modelValue', $event)">
|
||||
<el-dialog :model-value="modelValue" title="邮箱验证" width="420px" @update:model-value="emit('update:modelValue', $event)">
|
||||
<div class="ev-body">
|
||||
<p class="ev-tip">
|
||||
認証コードを <b>{{ email }}</b> 宛にお送りします(有効期限 30 分)。
|
||||
確認が完了すると、ログインとご注文が可能になります。
|
||||
验证码会发送到 <b>{{ email }}</b>,有效期 30 分钟。
|
||||
完成验证后即可登录并正常下单。
|
||||
</p>
|
||||
<el-input
|
||||
v-model="code"
|
||||
maxlength="6"
|
||||
placeholder="6桁の認証コードを入力"
|
||||
placeholder="请输入 6 位验证码"
|
||||
size="large"
|
||||
class="ev-input"
|
||||
@keyup.enter="submit"
|
||||
@@ -16,10 +16,10 @@
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button :disabled="countdown > 0" :loading="sending" @click="send">
|
||||
{{ countdown > 0 ? `再送信 (${countdown}s)` : '認証コードを送信' }}
|
||||
{{ countdown > 0 ? `重新发送 (${countdown}s)` : '发送验证码' }}
|
||||
</el-button>
|
||||
<el-button type="primary" :loading="submitting" :disabled="code.trim().length === 0" @click="submit">
|
||||
認証する
|
||||
提交验证
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@@ -67,13 +67,13 @@ async function send() {
|
||||
try {
|
||||
const res: any = await authApi.sendEmailCode({ email: props.email, scene: props.scene })
|
||||
if (res?.email_sent === false) {
|
||||
ElMessage.error('確認メールを送信できませんでした。お問い合わせください')
|
||||
ElMessage.error('验证邮件发送失败,请联系客服')
|
||||
} else {
|
||||
ElMessage.success('認証コードを送信しました。メール(迷惑メールフォルダを含む)をご確認ください')
|
||||
ElMessage.success('验证码已发送,请查收邮箱(含垃圾箱)')
|
||||
startCountdown(60)
|
||||
}
|
||||
} catch (err: any) {
|
||||
ElMessage.error(err.response?.data?.error || '送信できませんでした')
|
||||
ElMessage.error(err.response?.data?.error || '发送失败')
|
||||
} finally {
|
||||
sending.value = false
|
||||
}
|
||||
@@ -85,12 +85,12 @@ async function submit() {
|
||||
submitting.value = true
|
||||
try {
|
||||
await authApi.verifyEmail({ email: props.email, code: value })
|
||||
ElMessage.success('メールアドレスの確認が完了しました')
|
||||
ElMessage.success('邮箱验证完成')
|
||||
code.value = ''
|
||||
emit('verified')
|
||||
emit('update:modelValue', false)
|
||||
} catch (err: any) {
|
||||
ElMessage.error(err.response?.data?.error || '認証コードが正しくないか、有効期限が切れています')
|
||||
ElMessage.error(err.response?.data?.error || '验证码不正确或已过期')
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@ import zh from './locales/zh.json'
|
||||
import en from './locales/en.json'
|
||||
import ja from './locales/ja.json'
|
||||
|
||||
// 站点面向日本客人:默认与兜底语言都是日文(2026-12 全站日语化)。
|
||||
// 界面默认中文(后台、供应商端、用户端都一样)。
|
||||
// 只有商品标题与价格是日文/日元口径,属于数据层,不走 i18n。
|
||||
// 用户手动切过语言就尊重 localStorage 里的选择。
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: localStorage.getItem('locale') || 'ja',
|
||||
fallbackLocale: 'ja',
|
||||
locale: localStorage.getItem('locale') || 'zh',
|
||||
fallbackLocale: 'zh',
|
||||
messages: { zh, en, ja },
|
||||
})
|
||||
|
||||
|
||||
@@ -259,7 +259,12 @@
|
||||
"noPrize": "No prize this time",
|
||||
"nextCycle": "Try again next cycle",
|
||||
"myRecords": "My entries",
|
||||
"noPrizeShort": "No prize"
|
||||
"noPrizeShort": "No prize",
|
||||
"cycleDaily": "Once a day",
|
||||
"cycleWeekly": "Once a week",
|
||||
"cycleMonthly": "Once a month",
|
||||
"cycleOnce": "One-off event",
|
||||
"cycleNone": "Limited-time event"
|
||||
},
|
||||
"ticket": {
|
||||
"title": "Tickets",
|
||||
@@ -568,4 +573,4 @@
|
||||
"discount": "Coupon discount",
|
||||
"unusable": "Not applicable to this order"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +259,12 @@
|
||||
"noPrize": "今回ははずれです",
|
||||
"nextCycle": "次の周期にまたどうぞ",
|
||||
"myRecords": "参加履歴",
|
||||
"noPrizeShort": "はずれ"
|
||||
"noPrizeShort": "はずれ",
|
||||
"cycleDaily": "1日1回",
|
||||
"cycleWeekly": "週1回",
|
||||
"cycleMonthly": "月1回",
|
||||
"cycleOnce": "単発イベント",
|
||||
"cycleNone": "期間限定イベント"
|
||||
},
|
||||
"ticket": {
|
||||
"title": "チケット",
|
||||
@@ -568,4 +573,4 @@
|
||||
"discount": "クーポン割引",
|
||||
"unusable": "このご注文では利用できません"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +259,12 @@
|
||||
"noPrize": "本次未中奖",
|
||||
"nextCycle": "下个周期再来",
|
||||
"myRecords": "我的参与记录",
|
||||
"noPrizeShort": "未中奖"
|
||||
"noPrizeShort": "未中奖",
|
||||
"cycleDaily": "每天一次",
|
||||
"cycleWeekly": "每周一次",
|
||||
"cycleMonthly": "每月一次",
|
||||
"cycleOnce": "一次性活动",
|
||||
"cycleNone": "限时活动"
|
||||
},
|
||||
"ticket": {
|
||||
"title": "工单",
|
||||
@@ -568,4 +573,4 @@
|
||||
"discount": "优惠券抵扣",
|
||||
"unusable": "本单不可用"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,8 +232,13 @@ const currentPageTitle = computed(() => {
|
||||
})
|
||||
|
||||
function changeLocale(lang: string) {
|
||||
if (lang === locale.value) return
|
||||
locale.value = lang
|
||||
localStorage.setItem('locale', lang)
|
||||
// 公告/活动/资讯/分类/轮播是后端按语言返回的(库里中文源 + *_ja),
|
||||
// 不重新拉一次,页面上还是切换前那种语言的缓存内容。
|
||||
// 整页重载最省事,也避免每个列表页各写一遍监听。
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
function handleCommand(command: string) {
|
||||
|
||||
@@ -176,8 +176,13 @@ const hideSidebar = computed(() => route.meta.hideSidebar as boolean)
|
||||
watch(route, () => { mobileMenuOpen.value = false })
|
||||
|
||||
function changeLocale(lang: string) {
|
||||
if (lang === locale.value) return
|
||||
locale.value = lang
|
||||
localStorage.setItem('locale', lang)
|
||||
// 公告/活动/资讯/分类/轮播是后端按语言返回的(库里中文源 + *_ja),
|
||||
// 不重新拉一次,页面上还是切换前那种语言的缓存内容。
|
||||
// 整页重载最省事,也避免每个列表页各写一遍监听。
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
// ── 邀请好友 ──────────────────────────────────────────────
|
||||
|
||||
@@ -31,7 +31,12 @@ export function setCurrency(conf: Partial<CurrencyConfig>) {
|
||||
currency.value = next
|
||||
}
|
||||
|
||||
/** 金额 → "¥1,040" / "¥1,040.50";空值与非法值按 0 处理(列表里常见 null)。 */
|
||||
// 符号是文字单位(日元 / 円)时按日式习惯放在数字后面:"1,040日元";
|
||||
// 是货币记号(¥ / $)时仍前置。这样既不会把日元写成 ¥1,040 让人误认成人民币,
|
||||
// 也不用在前端各处判断货币。
|
||||
const CJK_UNIT = /[\u3400-\u9fff\u3040-\u30ff]/
|
||||
|
||||
/** 金额 → "1,040日元" / "¥1,040";空值与非法值按 0 处理(列表里常见 null)。 */
|
||||
export function money(v: number | string | null | undefined): string {
|
||||
const raw = typeof v === 'string' ? parseFloat(v) : v
|
||||
const n = typeof raw === 'number' && isFinite(raw) ? raw : 0
|
||||
@@ -39,13 +44,17 @@ export function money(v: number | string | null | undefined): string {
|
||||
const fixed = n.toFixed(d)
|
||||
const [intPart, fracPart] = fixed.split('.')
|
||||
const withSep = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
||||
return currency.value.symbol + withSep + (fracPart ? '.' + fracPart : '')
|
||||
const body = withSep + (fracPart ? '.' + fracPart : '')
|
||||
return CJK_UNIT.test(currency.value.symbol) ? body + currency.value.symbol : currency.value.symbol + body
|
||||
}
|
||||
|
||||
/** 不带符号的数字(表单项、输入框回填用)。 */
|
||||
export function moneyNumber(v: number | string | null | undefined): string {
|
||||
const s = money(v)
|
||||
return s.startsWith(currency.value.symbol) ? s.slice(currency.value.symbol.length) : s
|
||||
const sym = currency.value.symbol
|
||||
if (s.startsWith(sym)) return s.slice(sym.length)
|
||||
if (s.endsWith(sym)) return s.slice(0, -sym.length)
|
||||
return s
|
||||
}
|
||||
|
||||
/** 兼容旧调用点:仓库里原本散落着 fmtMoney(),统一指向 money()。 */
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input v-model="form.password" type="password" show-password placeholder="请输入密码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="パスワード(確認)" prop="confirmPassword">
|
||||
<el-form-item label="确认密码" prop="confirmPassword">
|
||||
<el-input v-model="form.confirmPassword" type="password" show-password placeholder="请再次输入密码" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
@@ -66,7 +66,7 @@ const rules = {
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '请输入密码', trigger: 'blur' },
|
||||
{ min: 6, message: 'パスワードは6文字以上にしてください', trigger: 'blur' },
|
||||
{ min: 6, message: '密码至少6位', trigger: 'blur' },
|
||||
],
|
||||
confirmPassword: [
|
||||
{ required: true, message: '请再次输入密码', trigger: 'blur' },
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<div class="not-found">
|
||||
<div class="error-code">404</div>
|
||||
<h2>ページが見つかりません</h2>
|
||||
<p>お探しのページは存在しないか、削除されました</p>
|
||||
<el-button type="primary" @click="$router.push('/')">トップページへ戻る</el-button>
|
||||
<h2>页面不存在</h2>
|
||||
<p>您访问的页面不存在或已被移除</p>
|
||||
<el-button type="primary" @click="$router.push('/')">返回首页</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
<el-form-item label="描述">
|
||||
<el-input v-model="form.desc" type="textarea" :rows="2" placeholder="请输入描述" />
|
||||
</el-form-item>
|
||||
<el-form-item label="按钮文字">
|
||||
<el-input v-model="form.button" placeholder="如: 立即选购" />
|
||||
</el-form-item>
|
||||
<el-form-item label="图片" required>
|
||||
<el-upload
|
||||
class="banner-uploader"
|
||||
@@ -83,9 +86,6 @@
|
||||
<el-option v-for="l in lotteries" :key="l.id" :label="l.name" :value="l.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="按钮文字">
|
||||
<el-input v-model="form.button" placeholder="如: 立即选购" />
|
||||
</el-form-item>
|
||||
<el-form-item label="背景颜色">
|
||||
<el-input v-model="form.bg_color" placeholder="如: linear-gradient(135deg, #c8a45c 0%, #a8894a 100%)" />
|
||||
</el-form-item>
|
||||
|
||||
@@ -24,12 +24,12 @@ const stats = ref<any>({
|
||||
const statusMap: Record<string, string> = {
|
||||
pending_payment: '待付款',
|
||||
pending_confirm: '待确认',
|
||||
pending_ship: '発送待ち',
|
||||
shipped: '発送済み',
|
||||
pending_ship: '待发货',
|
||||
shipped: '已发货',
|
||||
completed: '已收货',
|
||||
refunding: '退款中',
|
||||
refunded: '已退款',
|
||||
cancelled: 'キャンセル済み',
|
||||
cancelled: '已取消',
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -336,7 +336,7 @@ async function sendTest() {
|
||||
ElMessage.success(res.message || '已发送')
|
||||
showTest.value = false
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.error || '送信できませんでした')
|
||||
ElMessage.error(e?.response?.data?.error || '发送失败')
|
||||
} finally {
|
||||
testing.value = false
|
||||
}
|
||||
|
||||
@@ -49,10 +49,10 @@
|
||||
<el-dialog v-model="showAdd" :title="editing ? '编辑抽奖' : '创建抽奖'" width="600px">
|
||||
<el-form :model="form" label-width="120px">
|
||||
<el-form-item label="抽奖名称" required>
|
||||
<el-input v-model="form.name" placeholder="请输入抽奖名称" />
|
||||
<el-input v-model="form.name" placeholder="请输入抽奖名称(中文)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="抽奖描述">
|
||||
<el-input v-model="form.description" type="textarea" :rows="3" placeholder="请输入抽奖描述" />
|
||||
<el-input v-model="form.description" type="textarea" :rows="3" placeholder="请输入抽奖描述(中文)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="活动图片">
|
||||
<el-upload
|
||||
@@ -170,7 +170,7 @@
|
||||
<el-dialog v-model="showPrize" title="添加奖品" width="500px">
|
||||
<el-form :model="prizeForm" label-width="100px">
|
||||
<el-form-item label="奖品名称" required>
|
||||
<el-input v-model="prizeForm.name" placeholder="请输入奖品名称" />
|
||||
<el-input v-model="prizeForm.name" placeholder="请输入奖品名称(中文)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="奖品类型">
|
||||
<el-select v-model="prizeForm.type" popper-class="dark-select-dropdown" style="width: 100%">
|
||||
@@ -273,7 +273,7 @@ async function fetchCoupons() {
|
||||
}
|
||||
}
|
||||
function couponLabel(c: any) {
|
||||
if (c.type === 'free_service_fee') return 'サービス手数料無料'
|
||||
if (c.type === 'free_service_fee') return '免服务费'
|
||||
return c.min_amount > 0 ? `${money(c.value)} / 满${money(c.min_amount)}` : money(c.value)
|
||||
}
|
||||
|
||||
|
||||
@@ -172,11 +172,11 @@ function companyName(code: string) {
|
||||
}
|
||||
|
||||
const PRIZE_TYPE_TXT: Record<string, string> = {
|
||||
physical: '現物', virtual: 'デジタル', credit: '资格',
|
||||
physical: '实物', virtual: '数字', credit: '资格',
|
||||
}
|
||||
const AWARD_TXT: Record<string, string> = {
|
||||
pending_info: '待填信息', pending_ship: '発送待ち',
|
||||
shipped: '発送済み', delivered: 'お受け取り済み', cancelled: 'キャンセル済み',
|
||||
pending_info: '待填信息', pending_ship: '待发货',
|
||||
shipped: '已发货', delivered: '已发放', cancelled: '已取消',
|
||||
}
|
||||
function prizeTypeText(t: string) { return PRIZE_TYPE_TXT[t] || t || '-' }
|
||||
function awardText(s: string) { return AWARD_TXT[s] || s || '-' }
|
||||
|
||||
@@ -372,8 +372,8 @@ const EXPRESS_OPTIONS = [
|
||||
// 三类凭证:发货照片 / 快递回执 / 物品清单
|
||||
const PHOTO_FIELDS = [
|
||||
{ key: 'shipping_photo', label: '発送写真' },
|
||||
{ key: 'express_photo', label: '送り状' },
|
||||
{ key: 'customs_photo', label: '内容品リスト' },
|
||||
{ key: 'express_photo', label: '快递回执' },
|
||||
{ key: 'customs_photo', label: '物品清单' },
|
||||
] as const
|
||||
|
||||
const uploadUrl = computed(() => {
|
||||
@@ -463,8 +463,8 @@ const photoGroups = computed(() => {
|
||||
const o = currentOrder.value || {}
|
||||
const groups = [
|
||||
{ key: 'shipping', label: '発送写真', urls: splitPhotos(o.shipping_photo) },
|
||||
{ key: 'express', label: '送り状', urls: splitPhotos(o.express_photo) },
|
||||
{ key: 'customs', label: '内容品リスト', urls: splitPhotos(o.customs_photo) },
|
||||
{ key: 'express', label: '快递回执', urls: splitPhotos(o.express_photo) },
|
||||
{ key: 'customs', label: '物品清单', urls: splitPhotos(o.customs_photo) },
|
||||
]
|
||||
// previewOffset:让每格的缩略图点开后,预览器停在自己那张上,
|
||||
// 同时能左右翻看全部凭证
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="金额限制" width="160">
|
||||
<template #default="{ row }">
|
||||
{{ row.min_amount }} - {{ row.max_amount || '∞' }} 元
|
||||
{{ row.min_amount }} - {{ row.max_amount || '∞' }} 日元
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="80">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<el-form :model="settings" label-width="160px">
|
||||
<el-form-item label="渠道费率 (%)"><el-input-number v-model="settings.payment_channel_fee_rate" :precision="2" /></el-form-item>
|
||||
<el-form-item label="服务费率 (%)"><el-input-number v-model="settings.service_fee_rate" :precision="2" /></el-form-item>
|
||||
<el-form-item label="包装费 (元)"><el-input-number v-model="settings.packaging_fee" :precision="2" :min="0" /></el-form-item>
|
||||
<el-form-item label="包装费 (日元)"><el-input-number v-model="settings.packaging_fee" :precision="2" :min="0" /></el-form-item>
|
||||
<el-form-item label="国际计算手续费 (%)"><el-input-number v-model="settings.international_fee_rate" :precision="2" :min="0" /></el-form-item>
|
||||
<el-form-item label="邀请注册">
|
||||
<el-switch v-model="inviteEnabled" active-value="true" inactive-value="false" />
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="首费(元)" required>
|
||||
<el-form-item label="首费(日元)" required>
|
||||
<el-input-number v-model="form.first_fee" :min="0" :precision="2" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -86,7 +86,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="续费(元)" required>
|
||||
<el-form-item label="续费(日元)" required>
|
||||
<el-input-number v-model="form.additional_fee" :min="0" :precision="2" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
@@ -92,10 +92,10 @@ async function handleResetPassword() {
|
||||
loading.value = true
|
||||
try {
|
||||
await authApi.resetPassword({ email: emailForm.email, code: resetForm.code, new_password: resetForm.new_password })
|
||||
ElMessage.success('パスワードを再設定しました。ログインしてください')
|
||||
ElMessage.success('密码重置成功,请登录')
|
||||
router.push('/login')
|
||||
} catch (err: any) {
|
||||
ElMessage.error(err.response?.data?.error || '再設定できませんでした')
|
||||
ElMessage.error(err.response?.data?.error || '重置失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@@ -157,18 +157,18 @@ const pwdText = computed(() => {
|
||||
})
|
||||
|
||||
function validatePassword(_rule: any, value: string, callback: (e?: Error) => void) {
|
||||
if (!value) return callback(new Error('パスワードをご入力ください'))
|
||||
if (value.length < 8) return callback(new Error('パスワードは8文字以上にしてください'))
|
||||
if (!/[a-zA-Z]/.test(value)) return callback(new Error('パスワードには英字を含めてください'))
|
||||
if (!/[0-9]/.test(value)) return callback(new Error('パスワードには数字を含めてください'))
|
||||
if (!value) return callback(new Error('请输入密码'))
|
||||
if (value.length < 8) return callback(new Error('密码至少 8 位'))
|
||||
if (!/[a-zA-Z]/.test(value)) return callback(new Error('密码需要包含字母'))
|
||||
if (!/[0-9]/.test(value)) return callback(new Error('密码需要包含数字'))
|
||||
callback()
|
||||
}
|
||||
|
||||
const rules = {
|
||||
username: [{ required: true, message: 'ユーザー名をご入力ください', trigger: 'blur' }],
|
||||
email: [{ required: true, message: 'メールアドレスをご入力ください', trigger: 'blur' }],
|
||||
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
|
||||
email: [{ required: true, message: '请输入邮箱', trigger: 'blur' }],
|
||||
password: [{ required: true, validator: validatePassword, trigger: 'blur' }],
|
||||
code: [{ required: true, message: '認証コードをご入力ください', trigger: 'blur' }],
|
||||
code: [{ required: true, message: '请输入邮箱验证码', trigger: 'blur' }],
|
||||
}
|
||||
|
||||
async function handleRegister() {
|
||||
@@ -178,7 +178,7 @@ async function handleRegister() {
|
||||
const res: any = await userStore.register(form)
|
||||
ElMessage.success(t('auth.registerSuccess'))
|
||||
if (res?.user?.email_verified === false) {
|
||||
ElMessage.warning({ message: 'メールアドレスが未確認です。「マイページ → メール確認」で認証を完了してからご注文ください', duration: 6000 })
|
||||
ElMessage.warning({ message: '邮箱尚未验证,请到「个人中心 → 验证邮箱」完成验证后再下单', duration: 6000 })
|
||||
}
|
||||
router.push('/')
|
||||
} finally {
|
||||
|
||||
@@ -124,12 +124,12 @@ const alerts = ref<any[]>([])
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
pending_payment: '待支付',
|
||||
pending_confirm: '待确认',
|
||||
pending_ship: '発送待ち',
|
||||
shipped: '発送済み',
|
||||
pending_ship: '待发货',
|
||||
shipped: '已发货',
|
||||
completed: '已收货',
|
||||
refunding: '退款中',
|
||||
refunded: '已退款',
|
||||
cancelled: 'キャンセル済み',
|
||||
cancelled: '已取消',
|
||||
}
|
||||
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
|
||||
@@ -191,8 +191,8 @@ const newEv = reactive({ description: '', location: '' })
|
||||
|
||||
const PHOTO_FIELDS = [
|
||||
{ key: 'shipping_photo', label: '発送写真' },
|
||||
{ key: 'express_photo', label: '送り状' },
|
||||
{ key: 'customs_photo', label: '内容品リスト' },
|
||||
{ key: 'express_photo', label: '快递回执' },
|
||||
{ key: 'customs_photo', label: '物品清单' },
|
||||
] as const
|
||||
|
||||
function imgUrl(p: string) {
|
||||
@@ -212,8 +212,8 @@ const uploadHeaders = computed(() => {
|
||||
})
|
||||
|
||||
const statusMap: Record<string, string> = {
|
||||
pending_payment: 'お支払い待ち', pending_confirm: '確認待ち', pending_ship: '発送待ち',
|
||||
shipped: '発送済み', completed: 'お届け済み', refunding: '返金処理中', refunded: '返金済み', cancelled: 'キャンセル',
|
||||
pending_payment: '待支付', pending_confirm: '待确认', pending_ship: '待发货',
|
||||
shipped: '已发货', completed: '已收货', refunding: '退款中', refunded: '已退款', cancelled: '已取消',
|
||||
}
|
||||
const statusTypeMap: Record<string, string> = {
|
||||
pending_payment: 'warning', pending_confirm: 'info', pending_ship: 'info',
|
||||
@@ -238,7 +238,7 @@ async function fetchOrders() {
|
||||
const res: any = await supplierApi.getOrders()
|
||||
orders.value = res.data || []
|
||||
} catch {
|
||||
ElMessage.error('ご注文を取得できませんでした')
|
||||
ElMessage.error('获取订单失败')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
</el-form-item>
|
||||
</template>
|
||||
<el-form-item :label="$t('address.detail')"><el-input v-model="form.address" type="textarea" /></el-form-item>
|
||||
<el-form-item><el-switch v-model="form.is_default" active-text="既定の住所" /></el-form-item>
|
||||
<el-form-item><el-switch v-model="form.is_default" active-text="默认地址" /></el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="showAdd = false">{{ $t('common.cancel') }}</el-button>
|
||||
@@ -103,7 +103,7 @@ async function fetchAddresses() {
|
||||
|
||||
async function addAddress() {
|
||||
await addressApi.create(form)
|
||||
ElMessage.success('住所を登録しました')
|
||||
ElMessage.success('地址已添加')
|
||||
showAdd.value = false
|
||||
Object.assign(form, { name: '', phone: '', country: '日本', province: '', city: '', district: '', address: '', is_default: false })
|
||||
regionPath.value = []
|
||||
@@ -117,7 +117,7 @@ async function setDefault(id: number) {
|
||||
|
||||
async function deleteAddr(id: number) {
|
||||
await addressApi.delete(id)
|
||||
ElMessage.success('住所を削除しました')
|
||||
ElMessage.success('地址已删除')
|
||||
await fetchAddresses()
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<BackNav />
|
||||
|
||||
<!-- 购物车为空 -->
|
||||
<el-empty v-if="!items.length" description="カートは空です" :image-size="120">
|
||||
<el-empty v-if="!items.length" description="购物车是空的" :image-size="120">
|
||||
<template #image>
|
||||
<el-icon :size="80" color="rgba(255,255,255,0.2)"><ShoppingCart /></el-icon>
|
||||
</template>
|
||||
@@ -277,17 +277,17 @@
|
||||
|
||||
<el-dialog v-model="showAddAddress" :title="$t('cart.addAddressTitle')" width="500px">
|
||||
<el-form :model="addressForm" label-width="100px">
|
||||
<el-form-item label="お受取人" required>
|
||||
<el-input v-model="addressForm.name" placeholder="お受取人の氏名" />
|
||||
<el-form-item label="收货人" required>
|
||||
<el-input v-model="addressForm.name" placeholder="请输入收货人姓名" />
|
||||
<div class="name-id-hint">{{ $t('address.nameIdHint') }}</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="電話番号" required><el-input v-model="addressForm.phone" placeholder="電話番号をご入力ください" /></el-form-item>
|
||||
<el-form-item label="国・地域">
|
||||
<el-form-item label="電話番号" required><el-input v-model="addressForm.phone" placeholder="请输入手机号" /></el-form-item>
|
||||
<el-form-item label="国家/地区">
|
||||
<el-select v-model="addressForm.country" filterable style="width: 100%">
|
||||
<el-option v-for="c in COUNTRIES" :key="c" :label="c" :value="c" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="addressForm.country === '中国'" label="都道府県・市区町村" required>
|
||||
<el-form-item v-if="addressForm.country === '中国'" label="所在地区" required>
|
||||
<el-cascader
|
||||
v-model="addrRegionPath"
|
||||
:options="REGION_TREE"
|
||||
@@ -300,11 +300,11 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<template v-else>
|
||||
<el-form-item label="州・省"><el-input v-model="addressForm.province" placeholder="例:California" /></el-form-item>
|
||||
<el-form-item label="州 / 省"><el-input v-model="addressForm.province" placeholder="例:California" /></el-form-item>
|
||||
<el-form-item label="市区町村"><el-input v-model="addressForm.city" placeholder="例:Los Angeles" /></el-form-item>
|
||||
</template>
|
||||
<el-form-item label="番地・建物名" required><el-input v-model="addressForm.address" type="textarea" :rows="2" placeholder="町名・番地・建物名" /></el-form-item>
|
||||
<el-form-item><el-switch v-model="addressForm.is_default" active-text="既定の住所にする" /></el-form-item>
|
||||
<el-form-item label="详细地址" required><el-input v-model="addressForm.address" type="textarea" :rows="2" placeholder="街道、门牌号等" /></el-form-item>
|
||||
<el-form-item><el-switch v-model="addressForm.is_default" active-text="设为默认地址" /></el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="showAddAddress = false">{{ $t('cart.cancel') }}</el-button>
|
||||
|
||||
@@ -57,26 +57,30 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { lotteryApi } from '../../api'
|
||||
import BackNav from '../../components/BackNav.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
const lotteries = ref<any[]>([])
|
||||
const page = ref(1)
|
||||
const pageSize = 6
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
|
||||
const CYCLE_TEXT: Record<string, string> = {
|
||||
daily: '1日1回',
|
||||
weekly: '週1回',
|
||||
monthly: '月1回',
|
||||
once: '単発イベント',
|
||||
// 周期文案跟着界面语言走:日文/中文都不该硬编码在代码里,
|
||||
// 否则切到中文界面还会露出「週1回」。
|
||||
const CYCLE_KEY: Record<string, string> = {
|
||||
daily: 'lottery.cycleDaily',
|
||||
weekly: 'lottery.cycleWeekly',
|
||||
monthly: 'lottery.cycleMonthly',
|
||||
once: 'lottery.cycleOnce',
|
||||
}
|
||||
|
||||
function cycleText(cycle?: string) {
|
||||
if (!cycle) return '期間限定イベント'
|
||||
return CYCLE_TEXT[cycle] || cycle
|
||||
if (!cycle) return t('lottery.cycleNone')
|
||||
return CYCLE_KEY[cycle] ? t(CYCLE_KEY[cycle]) : cycle
|
||||
}
|
||||
|
||||
function formatDate(date: string) {
|
||||
|
||||
@@ -106,9 +106,11 @@
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus/es/components/message/index'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { lotteryApi } from '../../api'
|
||||
import BackNav from '../../components/BackNav.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const lottery = ref<any>(null)
|
||||
@@ -132,16 +134,17 @@ const cycleShort = computed(() => {
|
||||
return map[status.value.cycle] || '週'
|
||||
})
|
||||
const cycleText = computed(() => {
|
||||
const map: Record<string, string> = { daily: '1日1回', weekly: '週1回', monthly: '每月一次' }
|
||||
return map[status.value.cycle] || '週1回'
|
||||
const map: Record<string, string> = { daily: 'lottery.cycleDaily', weekly: 'lottery.cycleWeekly', monthly: 'lottery.cycleMonthly' }
|
||||
const key = map[status.value.cycle]
|
||||
return key ? t(key) : t('lottery.cycleWeekly')
|
||||
})
|
||||
|
||||
const prizeTypeMap: Record<string, string> = {
|
||||
physical: '現物',
|
||||
virtual: 'デジタル',
|
||||
virtual: '虚拟',
|
||||
// 类型标签写「购买资格」而不是「下单资格」,避免和奖品名重复显示成
|
||||
// 「下单资格 | 下单资格 | 10」
|
||||
credit: '購入資格', coupon: 'クーポン',
|
||||
credit: '购买资格', coupon: '优惠券',
|
||||
}
|
||||
function prizeTypeText(t: string) { return prizeTypeMap[t] || t }
|
||||
|
||||
@@ -156,7 +159,7 @@ function formatDate(date: string) {
|
||||
|
||||
function needLogin(): boolean {
|
||||
if (!localStorage.getItem('token')) {
|
||||
ElMessage.warning('ログインしてください')
|
||||
ElMessage.warning('请先登录')
|
||||
router.push('/login')
|
||||
return true
|
||||
}
|
||||
@@ -210,7 +213,7 @@ async function play() {
|
||||
await loadStatus()
|
||||
await loadDraws()
|
||||
} catch (err: any) {
|
||||
ElMessage.error(err.response?.data?.error || '抽選に失敗しました')
|
||||
ElMessage.error(err.response?.data?.error || '抽奖失败')
|
||||
} finally {
|
||||
playing.value = false
|
||||
}
|
||||
@@ -220,9 +223,9 @@ async function register() {
|
||||
if (needLogin()) return
|
||||
try {
|
||||
await lotteryApi.register(Number(route.params.id))
|
||||
ElMessage.success('参加登録が完了しました')
|
||||
ElMessage.success('报名成功')
|
||||
} catch (err: any) {
|
||||
ElMessage.error(err.response?.data?.error || '参加登録に失敗しました')
|
||||
ElMessage.error(err.response?.data?.error || '报名失败')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -106,7 +106,7 @@ const EXPRESS_NAMES: Record<string, string> = {
|
||||
sf: 'SF Express', yto: 'YTO Express', zto: 'ZTO Express', sto: 'STO Express',
|
||||
yd: 'Yunda Express', ems: 'EMS(日本郵便)', jd: 'JD Logistics', db: 'Deppon Express',
|
||||
dhl: 'DHL', ups: 'UPS', fedex: 'FedEx', usps: 'USPS',
|
||||
jp: '日本郵便', yamato: 'ヤマト運輸', sagawa: '佐川急便', jtexpress: 'J&T Express',
|
||||
jp: '日本郵便', yamato: '黑猫宅急便', sagawa: '佐川急便', jtexpress: 'J&T Express',
|
||||
}
|
||||
function companyName(code: string) {
|
||||
if (!code) return '配送業者'
|
||||
@@ -114,14 +114,14 @@ function companyName(code: string) {
|
||||
}
|
||||
|
||||
const PRIZE_TYPE_TXT: Record<string, string> = {
|
||||
physical: '現物賞品', virtual: 'デジタル賞品', credit: '購入資格', coupon: 'クーポン',
|
||||
physical: '实物奖品', virtual: '数字奖品', credit: '购买资格', coupon: '优惠券',
|
||||
}
|
||||
const AWARD_TXT: Record<string, string> = {
|
||||
pending_info: 'お届け先の入力待ち',
|
||||
pending_ship: '発送待ち',
|
||||
shipped: '発送済み',
|
||||
delivered: 'お受け取り済み',
|
||||
cancelled: 'キャンセル済み',
|
||||
pending_info: '待填收货信息',
|
||||
pending_ship: '待发货',
|
||||
shipped: '已发货',
|
||||
delivered: '已发放',
|
||||
cancelled: '已取消',
|
||||
}
|
||||
|
||||
// 奖品被删掉的中奖记录没法履约,就不要摆表单了
|
||||
@@ -165,7 +165,7 @@ async function load() {
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error('当選履歴を取得できませんでした')
|
||||
ElMessage.error('获取中奖记录失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -174,17 +174,17 @@ async function load() {
|
||||
async function submitInfo(w: any) {
|
||||
const f = forms[w.id]
|
||||
if (!f.receiver_name.trim() || !f.receiver_phone.trim() || !f.receiver_address.trim()) {
|
||||
ElMessage.warning('お届け先をご入力ください')
|
||||
ElMessage.warning('请填写完整的收货信息')
|
||||
return
|
||||
}
|
||||
savingId.value = w.id
|
||||
try {
|
||||
await lotteryApi.updateWinnerInfo(w.id, f)
|
||||
ElMessage.success('お届け先を登録しました')
|
||||
ElMessage.success('收货信息已提交')
|
||||
formVisible.value = false
|
||||
await load()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.error || '送信できませんでした')
|
||||
ElMessage.error(e?.response?.data?.error || '提交失败')
|
||||
} finally {
|
||||
savingId.value = 0
|
||||
}
|
||||
|
||||
@@ -150,8 +150,8 @@ const photoGroups = computed(() => {
|
||||
const o = order.value || {}
|
||||
return [
|
||||
{ key: 'shipping', label: '発送写真', urls: splitPhotos(o.shipping_photo) },
|
||||
{ key: 'express', label: '送り状', urls: splitPhotos(o.express_photo) },
|
||||
{ key: 'customs', label: '内容品リスト', urls: splitPhotos(o.customs_photo) },
|
||||
{ key: 'express', label: '快递回执', urls: splitPhotos(o.express_photo) },
|
||||
{ key: 'customs', label: '物品清单', urls: splitPhotos(o.customs_photo) },
|
||||
]
|
||||
})
|
||||
|
||||
@@ -161,7 +161,7 @@ const EXPRESS_NAMES: Record<string, string> = {
|
||||
sf: 'SF Express', yto: 'YTO Express', zto: 'ZTO Express', sto: 'STO Express',
|
||||
yd: 'Yunda Express', ems: 'EMS(日本郵便)', jd: 'JD Logistics', db: 'Deppon Express',
|
||||
dhl: 'DHL', ups: 'UPS', fedex: 'FedEx', usps: 'USPS',
|
||||
jp: '日本郵便', yamato: 'ヤマト運輸', sagawa: '佐川急便',
|
||||
jp: '日本郵便', yamato: '黑猫宅急便', sagawa: '佐川急便',
|
||||
}
|
||||
|
||||
function expressName(code: string) {
|
||||
@@ -185,18 +185,18 @@ async function loadTracking(id: number) {
|
||||
}
|
||||
|
||||
const statusMap: Record<string, string> = {
|
||||
pending_payment: 'お支払い待ち', pending_confirm: '確認待ち', pending_ship: '発送待ち',
|
||||
shipped: '発送済み', completed: 'お届け済み', refunding: '返金処理中', refunded: '返金済み', cancelled: 'キャンセル',
|
||||
pending_payment: '待支付', pending_confirm: '待确认', pending_ship: '待发货',
|
||||
shipped: '已发货', completed: '已收货', refunding: '返金処理中', refunded: '已退款', cancelled: '已取消',
|
||||
}
|
||||
const statusTypeMap: Record<string, string> = {
|
||||
pending_payment: 'warning', pending_confirm: 'info', pending_ship: 'info',
|
||||
shipped: 'primary', completed: 'success', refunding: 'danger', refunded: 'danger', cancelled: 'info',
|
||||
}
|
||||
const refundStatusMap: Record<string, string> = {
|
||||
refunding: '返金処理中', refunded: '返金済み', cancelled: 'キャンセル',
|
||||
refunding: '返金処理中', refunded: '已退款', cancelled: '已取消',
|
||||
}
|
||||
const paymentMethodMap: Record<string, string> = {
|
||||
balance: '残高払い', alipay: 'Alipay', wechat: 'WeChat Pay',
|
||||
balance: '余额支付', alipay: 'Alipay', wechat: 'WeChat Pay',
|
||||
}
|
||||
|
||||
function statusText(s: string) { return statusMap[s] || s }
|
||||
@@ -234,11 +234,11 @@ function goPay() {
|
||||
|
||||
async function applyRefund() {
|
||||
if (!refundReason.value.trim()) {
|
||||
ElMessage.warning('返金理由をご入力ください')
|
||||
ElMessage.warning('请填写退款原因')
|
||||
return
|
||||
}
|
||||
await orderApi.refund(order.value.id, { reason: refundReason.value })
|
||||
ElMessage.success('返金申請を受け付けました')
|
||||
ElMessage.success('退款申请已提交')
|
||||
showRefund.value = false
|
||||
const res: any = await orderApi.getById(order.value.id)
|
||||
order.value = res.data
|
||||
|
||||
@@ -73,7 +73,7 @@ async function fetchOrders() {
|
||||
const res: any = await orderApi.list()
|
||||
orders.value = res.data || []
|
||||
} catch {
|
||||
ElMessage.error('ご注文を取得できませんでした')
|
||||
ElMessage.error('获取订单失败')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ async function cancelOrder(id: number) {
|
||||
|
||||
async function confirmReceipt(id: number) {
|
||||
try {
|
||||
await ElMessageBox.confirm('商品のお受け取りを確認しますか?', t('order.tip'), { type: 'info' })
|
||||
await ElMessageBox.confirm('确认已收到商品?', t('order.tip'), { type: 'info' })
|
||||
await orderApi.confirmReceipt(id)
|
||||
ElMessage.success(t('order.receiptConfirmed'))
|
||||
fetchOrders()
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
</p>
|
||||
<p class="brand-line" v-if="product.brand">
|
||||
<span class="brand-name">{{ product.brand.name }}</span>
|
||||
<span v-if="product.shipping_mode === 'tax_included'" class="mode-badge">税込・送料込み</span>
|
||||
<span v-else class="mode-hint">送料別</span>
|
||||
<span v-if="product.shipping_mode === 'tax_included'" class="mode-badge">含税包邮</span>
|
||||
<span v-else class="mode-hint">运费另计</span>
|
||||
</p>
|
||||
<p class="description">{{ product.description }}</p>
|
||||
<div class="meta">
|
||||
@@ -45,8 +45,8 @@
|
||||
<span v-if="!hasEnoughCredit()">(資格不足)</span>
|
||||
</el-tag>
|
||||
<el-tag v-if="product.credit_reward > 0" type="success">+{{ product.credit_reward * quantity }} {{ $t('product.creditReward') }}</el-tag>
|
||||
<el-tag v-if="product.in_stock === false" type="info" effect="dark">在庫切れ</el-tag>
|
||||
<el-tag v-else type="success" effect="plain">在庫あり</el-tag>
|
||||
<el-tag v-if="product.in_stock === false" type="info" effect="dark">无货</el-tag>
|
||||
<el-tag v-else type="success" effect="plain">有货</el-tag>
|
||||
</div>
|
||||
<div class="user-credits" v-if="product.require_credit">
|
||||
<span class="credits-label">購入資格:</span>
|
||||
@@ -131,7 +131,7 @@ onMounted(async () => {
|
||||
async function addToCart() {
|
||||
// 检查购物资格
|
||||
if (!hasEnoughCredit()) {
|
||||
ElMessage.warning(`購入資格が不足しています。この商品は 1 回分の資格が必要です(現在 ${userCredits.value} 回)`)
|
||||
ElMessage.warning(`购买资格不足。该商品需要 1 次购买资格(当前 ${userCredits.value} 次)`)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ async function addToCart() {
|
||||
ElMessage.success(t('product.addToCart') + ' ✓')
|
||||
} catch (err: any) {
|
||||
// 处理后端返回的错误
|
||||
const errorMsg = err.response?.data?.error || 'カートに追加できませんでした'
|
||||
const errorMsg = err.response?.data?.error || '添加购物车失败'
|
||||
ElMessage.error(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<BackNav />
|
||||
<div class="filter-bar">
|
||||
<el-select v-model="categoryId" :placeholder="$t('product.filterByCategory')" popper-class="dark-select-dropdown" @change="fetchProducts">
|
||||
<el-option label="すべてのカテゴリ" :value="undefined" />
|
||||
<el-option label="全部分类" :value="undefined" />
|
||||
<el-option v-for="c in categories" :key="c.id" :label="c.name" :value="c.id" />
|
||||
</el-select>
|
||||
<el-select v-model="brandId" placeholder="ブランドで絞り込む" popper-class="dark-select-dropdown" @change="fetchProducts">
|
||||
<el-option label="すべてのブランド" :value="undefined" />
|
||||
<el-select v-model="brandId" placeholder="筛选品牌" popper-class="dark-select-dropdown" @change="fetchProducts">
|
||||
<el-option label="全部品牌" :value="undefined" />
|
||||
<el-option v-for="b in brands" :key="b.id" :label="b.name" :value="b.id" />
|
||||
</el-select>
|
||||
</div>
|
||||
@@ -37,12 +37,12 @@
|
||||
<div class="product-tags">
|
||||
<!-- 寄送模式:含税是卖点(总价确定、包清关),做成强调徽章;
|
||||
自缴税是默认口径,弱化成一行小字,避免每张卡都挂着无信息量的标签 -->
|
||||
<span v-if="p.shipping_mode === 'tax_included'" class="mode-badge">税込・送料込み</span>
|
||||
<span v-else class="mode-hint">送料別</span>
|
||||
<el-tag v-if="p.require_credit" size="small" type="warning">購入資格が必要</el-tag>
|
||||
<span v-if="p.shipping_mode === 'tax_included'" class="mode-badge">含税包邮</span>
|
||||
<span v-else class="mode-hint">运费另计</span>
|
||||
<el-tag v-if="p.require_credit" size="small" type="warning">需要资格</el-tag>
|
||||
<el-tag v-if="p.credit_reward > 0" size="small" type="success">+{{ p.credit_reward }} 付与</el-tag>
|
||||
<!-- 只在无货时打标:818 个商品全都有货时,满屏「有货」标签只是噪音 -->
|
||||
<el-tag v-if="p.in_stock === false" size="small" type="info" effect="dark">在庫切れ</el-tag>
|
||||
<el-tag v-if="p.in_stock === false" size="small" type="info" effect="dark">无货</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<el-form :model="passwordForm" label-width="80px">
|
||||
<el-form-item :label="$t('profile.oldPassword')"><el-input v-model="passwordForm.old_password" type="password" show-password /></el-form-item>
|
||||
<el-form-item :label="$t('profile.newPassword')"><el-input v-model="passwordForm.new_password" type="password" show-password /></el-form-item>
|
||||
<el-form-item label="パスワード(確認)"><el-input v-model="passwordForm.confirm_password" type="password" show-password /></el-form-item>
|
||||
<el-form-item label="确认密码"><el-input v-model="passwordForm.confirm_password" type="password" show-password /></el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="showChangePassword = false">{{ $t('profile.cancel') }}</el-button>
|
||||
@@ -85,11 +85,11 @@ async function saveProfile() {
|
||||
saving.value = true
|
||||
try {
|
||||
await userApi.updateProfile(profileForm)
|
||||
ElMessage.success('プロフィールを更新しました')
|
||||
ElMessage.success('资料已更新')
|
||||
showEditProfile.value = false
|
||||
await userStore.fetchProfile()
|
||||
} catch (err: any) {
|
||||
ElMessage.error(err.response?.data?.error || '更新できませんでした')
|
||||
ElMessage.error(err.response?.data?.error || '更新失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
@@ -97,21 +97,21 @@ async function saveProfile() {
|
||||
|
||||
async function changePassword() {
|
||||
if (passwordForm.new_password !== passwordForm.confirm_password) {
|
||||
ElMessage.warning('パスワードが一致しません')
|
||||
ElMessage.warning('两次密码不一致')
|
||||
return
|
||||
}
|
||||
if (passwordForm.new_password.length < 6) {
|
||||
ElMessage.warning('パスワードは6文字以上にしてください')
|
||||
ElMessage.warning('密码至少6位')
|
||||
return
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
await userApi.changePassword({ old_password: passwordForm.old_password, new_password: passwordForm.new_password })
|
||||
ElMessage.success('パスワードを変更しました')
|
||||
ElMessage.success('密码已修改')
|
||||
showChangePassword.value = false
|
||||
Object.assign(passwordForm, { old_password: '', new_password: '', confirm_password: '' })
|
||||
} catch (err: any) {
|
||||
ElMessage.error(err.response?.data?.error || '変更できませんでした')
|
||||
ElMessage.error(err.response?.data?.error || '修改失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
@@ -119,14 +119,14 @@ async function changePassword() {
|
||||
|
||||
const roleMap: Record<string, string> = {
|
||||
admin: '管理者',
|
||||
supplier: 'サプライヤー',
|
||||
user: 'お客様',
|
||||
supplier: '供应商',
|
||||
user: '用户',
|
||||
}
|
||||
function roleText(r: string) { return roleMap[r] || r }
|
||||
|
||||
async function onEmailVerified() {
|
||||
await userStore.fetchProfile()
|
||||
ElMessage.success('メールアドレスの確認が完了しました。ご注文いただけます')
|
||||
ElMessage.success('邮箱已验证,现在可以正常下单了')
|
||||
}
|
||||
|
||||
onMounted(() => userStore.fetchProfile())
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"categories": {
|
||||
"烟草套餐": "タバコセット",
|
||||
"日本香烟": "日本たばこ",
|
||||
"外国香烟": "海外たばこ",
|
||||
"加热烟草": "加熱式たばこ",
|
||||
"加热设备": "加熱式デバイス",
|
||||
"手卷烟丝": "手巻きタバコ",
|
||||
"卷烟耗材": "手巻き用品",
|
||||
"其他烟丝": "その他シャグ",
|
||||
"口含烟/尼古丁袋": "ニコチンポーチ",
|
||||
"雪茄": "シガー",
|
||||
"烟斗烟丝": "パイプたばこ"
|
||||
},
|
||||
"banners": {
|
||||
"1": {
|
||||
"title": "上質な一本を",
|
||||
"desc": "毎日の一本に、こだわりを。",
|
||||
"button": "商品を見る"
|
||||
},
|
||||
"2": {
|
||||
"title": "毎週の抽選",
|
||||
"desc": "当選すると現物賞品をプレゼント。発送は当店が手配します。",
|
||||
"button": "参加する"
|
||||
},
|
||||
"3": {
|
||||
"title": "期間限定セール",
|
||||
"desc": "毎日更新の目玉商品をお見逃しなく。",
|
||||
"button": "詳細を見る"
|
||||
}
|
||||
},
|
||||
"announcements": {
|
||||
"1": {
|
||||
"title": "2026-07-16 お知らせ",
|
||||
"content": "これはお知らせのテスト投稿です。"
|
||||
}
|
||||
},
|
||||
"lotteries": {
|
||||
"1": {
|
||||
"name": "毎日抽選",
|
||||
"description": "1日1回ご参加いただけます。締切後に管理者が抽選し、当選者には購入資格を付与します。"
|
||||
},
|
||||
"3": {
|
||||
"name": "毎週たばこ10パック抽選",
|
||||
"description": "週に1回ご参加いただけます。当選すると店舗内のいずれかのブランドから10パックお選びいただけます(発送は当店が手配します)。"
|
||||
}
|
||||
},
|
||||
"lottery_prizes": {
|
||||
"香烟 10 包": "たばこ10パック"
|
||||
},
|
||||
"articles": {
|
||||
"1": {
|
||||
"title": "オープン記念:全品20%OFF",
|
||||
"summary": "国際たばこショップのオープンを記念して、全品20%OFFでご提供します。",
|
||||
"content": "<p>国際たばこショップのオープンを記念して、全品20%OFFでご提供いたします。この機会にぜひご利用ください。</p>"
|
||||
},
|
||||
"2": {
|
||||
"title": "MEVIUS(メビウス)シリーズの選び方:1mg〜12mgの違い",
|
||||
"summary": "メビウスは日本たばこの中で最もラインアップが整ったシリーズです。1mgから12mgまで揃い、同じタール数でもレギュラー・スリム・メンソール・カプセルに分かれます。この記事ではタール値ごとに当店の40種類以上を整理します。",
|
||||
"content": "<h3>まずタール、次にフレーバー</h3>\n<p>メビウスの型番はとても分かりやすいです。<strong>数字がそのままタール量</strong>を表します。12mgは最も濃いクラシック、8mgは日本で標準的な「中間」、6mg・5mgは軽め、3mgと1mgは喫味重視のライトです。</p>\n<ul>\n<li><strong>12mg</strong>:吸い応えが強く煙が濃い。長く吸われている方はここから。代表は MEVIUS Original / RICH 12mg ソフト。</li>\n<li><strong>10mg</strong>:12mgより少し軽く、日常的に吸う方に人気。</li>\n<li><strong>8mg</strong>:日本の主流。多くの方にとっての「基準値」です。</li>\n<li><strong>5〜6mg</strong>:軽め。濃いものから落としたい方、もともと軽いものが好みの方に。</li>\n<li><strong>3mg / 1mg</strong>:とても軽く、吸い応えより習慣と手触りを楽しむ方向け。</li>\n</ul>\n\n<h3>レギュラー(ハード)とスリム(ロング)</h3>\n<p>同じタール数でも、スリムは細く燃焼が速いため1本あたりの吸引回数は少なめですが、口当たりはすっきりします。レギュラーは煙がより豊かです。当店の MEVIUS E Series やロング100's はスリム系で、ゆっくり吸いたい方・残留香を抑えたい方に向いています。</p>\n\n<h3>メンソールとカプセル:Premium Menthol シリーズ</h3>\n<p>グリーン系はメンソール、パープル系はブルーベリーやマスカット系のフレーバーカプセルです。カプセルは<strong>いつ潰すか</strong>がポイントで、潰さなければ普通のメンソール、中盤で潰すと後半だけフレーバーが広がります。パープルの5mg・8mgは当店で最もリピートされる2種類、1mgは「冷たさだけ欲しい」方に。</p>\n\n<h3>いちばん無駄のない試し方</h3>\n<p>いきなりカートン買いはおすすめしません。<strong>同じタール数で横並び比較</strong>が最も効率的です。まず8mgのレギュラー・スリム・メンソールを1パックずつ試し、「濃さ」と「冷たさ」のどちらが好みかを見極めてから、12mgに上げるか5mgに下げるかを決めましょう。</p>\n\n<p class=\"tip\">ヒント:当店では毎週の抽選でたばこ10パックをプレゼント。当選後は店内のブランド・規格からお選びいただけます。</p>"
|
||||
},
|
||||
"3": {
|
||||
"title": "TEREA と SENTIA の選び方:加熱式たばこ入門",
|
||||
"summary": "加熱式たばこで最も見落とされやすいのが、スティックとデバイスの対応関係です。TEREA は IQOS ILUMA 専用、SENTIA は lil シリーズ用。間違えると味の問題ではなく、そもそも差し込めません。",
|
||||
"content": "<h3>TEREA:IQOS ILUMA 専用</h3>\n<p>TEREA は IQOS ILUMA シリーズ(ILUMA ONE、ILUMA PRIME を含む)用のスティックです。ILUMA は<strong>誘導加熱</strong>方式で本体内部にヒーター刃がないため、TEREA は両端が閉じた構造になっています。使用後はそのまま取り出せて、掃除も汚れも残りません。これが前世代の HEETS との最大の違いです。</p>\n<p><strong>重要な注意</strong>:TEREA は IQOS 3 DUO / 3 MULTI では使えません。これらの機種は HEETS 用です。</p>\n\n<h3>SENTIA:lil シリーズ(KT&G)専用</h3>\n<p>SENTIA は韓国 KT&G の加熱式たばこ体系で、lil SOLID / lil AIBLE などのデバイスで使用します。フレーバーは日本系よりストレートで、メンソールやフルーツの主張が強めです。</p>\n\n<h3>フレーバーの入り方</h3>\n<ul>\n<li><strong>レギュラー(たばこ味)</strong>:最も受け入れられやすく、紙巻きからの移行に最適。</li>\n<li><strong>メンソール/冷感</strong>:低温で焦げ臭が少ないため、紙巻きよりメンソールが際立ちます。</li>\n<li><strong>フルーツ/ミックス</strong>:香り重視でたばこ感を抑えたい方に。</li>\n</ul>\n<p>最初は「レギュラー+メンソール」の2パックから始め、口に合うか確認してからまとめ買いするのがおすすめです。</p>\n\n<h3>デバイスとスティックで揃えるべき3点</h3>\n<ol>\n<li>デバイスの型番を確認する(ILUMA / lil SOLID / lil AIBLE)。「加熱式」という言葉だけで判断しない。</li>\n<li>スティックが閉じ式かどうかを見る(閉じ式は掃除不要だが、対応機種のみ)。</li>\n<li>バッテリー内蔵の加熱デバイスは日本郵便で特殊扱いです。当店では該当商品を「税込・送料込み」便のみでお取り扱いしています。ご注文時にご確認ください。</li>\n</ol>"
|
||||
},
|
||||
"4": {
|
||||
"title": "手巻き入門:シャグ・ペーパー・フィルターの揃え方",
|
||||
"summary": "手巻きは巻けばいいというものではありません。シャグの細かさ、ペーパーの燃焼速度、フィルター径の3つが噛み合わないと、吸い抵抗と味に直結します。この記事では組み合わせの考え方を整理します。",
|
||||
"content": "<h3>1. シャグ:種類を見てからグラム数</h3>\n<p>手巻き用シャグは大きく3種類に分かれます。</p>\n<ul>\n<li><strong>バージニア</strong>:甘くクリアで、入門に最適。7seas Regular Blend がこの系統です。</li>\n<li><strong>イングリッシュ</strong>:ラタキアの燻香があり、個性が強く重め。</li>\n<li><strong>アロマ(着香)</strong>:チェリーやバニラなどの香り付き。7seas Cherry がこれで、室内でも吸いやすい。</li>\n</ul>\n<p>グラム数は<strong>30g入が味見用、40〜50g入が日常使いのサイズ</strong>です。Amphora シリーズの50g入はまさにその位置づけ。開封後は空気に触れて乾くので、小分けの缶に移すのがおすすめです。</p>\n\n<h3>2. ペーパー:「薄さ」より燃焼速度</h3>\n<p>ペーパーは<strong>長さ・坪量・燃焼速度</strong>の3点で選びます。</p>\n<ul>\n<li>長さ:70mmはレギュラーフィルター用、78mmはスリム向けで長めの巻きにも。</li>\n<li>坪量:薄いほど燃えが速く紙の味が少ない。厚いと燃えにくいが紙っぽさが出ます。</li>\n<li>スローバーニング:燃焼抑制処理が施され、吸う間隔が空いても自然に燃え切らない。ゆっくり吸う方に。</li>\n</ul>\n\n<h3>3. フィルター:径が吸い抵抗を決める</h3>\n<p>一般的なのは6mmと8mmです。6mmは抵抗が大きく煙が集中、8mmは既製品に近い吸い心地。<strong>フィルター径はペーパー幅と合わせる</strong>必要があり、合わないと片側が太くなって漏れます。</p>\n<p>活性炭フィルターは雑味を吸着しますが味も薄くなるため着香シャグ向き。ピュアなアセテートは味を保つのでバージニア向きです。</p>\n\n<h3>初心者にいちばん無難な組み合わせ</h3>\n<p>バージニア40g+70mmスローバーニングペーパー+8mmアセテートフィルター。火が消えにくく、抵抗も適度で、味が素直です。慣れてきたらイングリッシュシャグやスリムペーパーに広げてください。</p>"
|
||||
},
|
||||
"5": {
|
||||
"title": "EMS 税金自己負担と 税込・送料込み:2つの発送方法の選び方",
|
||||
"summary": "同じ商品でも、お支払い総額が変わることがあります。違いは発送方法にあります。2つの計算方式を理解しておけば、「安いと思ったら関税を別払い」という事態を避けられます。",
|
||||
"content": "<h3>EMS 税金自己負担(送料別)</h3>\n<p>表示価格は<strong>商品代のみ</strong>です。国際送料とサービス手数料はお会計時に別途計算され、通関時の税金はお受取人様のご負担となります。</p>\n<ul>\n<li>メリット:商品単価が最も安く見える。複数点の購入で送料を薄められる。</li>\n<li>注意:税関は商品代のみを課税対象とし、送料・手数料は申告価額に含まれません。</li>\n<li>通関申告と納税はお客様ご自身で行っていただきます。</li>\n</ul>\n\n<h3>税込・送料込み</h3>\n<p>表示価格に<strong>中国税関の税金と送料が含まれます</strong>。お会計額がそのまま最終金額で、通関は当店が手続きします。</p>\n<ul>\n<li>メリット:総額が確定し、通関手続きが不要。</li>\n<li>向いている方:1点だけ購入、申告手続きを避けたい方。</li>\n<li>制限:<strong>バッテリー内蔵の加熱デバイスはこの便のみ</strong>です。日本郵便はリチウム電池入りの荷物に追加の制限を設けています。</li>\n</ul>\n\n<h3>どちらを選ぶかの目安</h3>\n<ol>\n<li>3点以上、かつ電池を使わない通常商品 → EMS 税金自己負担のほうが総額で有利なことが多い。</li>\n<li>1点だけ、または加熱デバイスを含む → 税込・送料込みが手間なし。</li>\n<li>重く大きい(カートン、ギフト箱など) → 税込価格を優先。国際送料は重量制で、自己手配が安いとは限りません。</li>\n</ol>\n\n<h3>つまずきやすい2点</h3>\n<p><strong>1つ目:</strong>「商品価格」だけで他店の「お届け総額」と比較しないこと。発送方法が違えば、差額は送料と税金に隠れています。</p>\n<p><strong>2つ目:</strong>電池入り商品を分割発送しようとしないこと。電池単独の発送も制限があり、返送されるリスクが上がります。</p>"
|
||||
},
|
||||
"6": {
|
||||
"title": "毎週抽選のルール:当選でたばこ10パック",
|
||||
"summary": "当店では毎週抽選を開催しています。当選するとたばこ10パック(店内ブランドから選択可)をプレゼント。参加方法・当選確率・発送の流れをまとめました。",
|
||||
"content": "<h3>参加方法</h3>\n<ol>\n<li>アカウントにログインし、「イベント」ページへ。</li>\n<li>「抽選する」を押すとその場で結果が出ます。締切待ちはありません。</li>\n<li>暦週ごとに1回まで。月曜 00:00 にリセットされます。</li>\n</ol>\n\n<h3>賞品</h3>\n<p><strong>たばこ10パック</strong>。当選後、店内のブランドと規格からお選びいただけます(在庫状況によります)。発送は当店が手配します。</p>\n<p>現物賞品は「当選履歴」からお届け先をご入力ください。入力後に発送待ちの列に並びます。発送前なら住所変更できますが、発送後は変更できません。</p>\n\n<h3>当選確率について</h3>\n<p>抽選は<strong>重み付きランダム</strong>です。賞品自体に重みがあり、「はずれ」も1つの重みを持ちます。現在は賞品の重み10、はずれの重み90のため、1回あたりの当選率は約10%です。</p>\n<p>さらに<strong>購入額による重み付け</strong>を有効にしています。累計¥100のご購入ごとに当選の重みが+1されます。購入が多いアカウントほど当たりやすくなりますが、100%にはなりません。</p>\n\n<h3>「抽選プール」が見えない理由</h3>\n<p>即時抽選はその場で抽選・その場で記録する方式で、参加者を貯める工程がありません。そのため参加人数は表示していません。抽選記録(はずれを含む)はすべて保存され、詳細ページの「参加履歴」で確認できます。</p>\n\n<h3>はずれても損はありません</h3>\n<p>何も消費しません。抽選に購入資格や残高を使うことはなく、参加は無料です。はずれた場合は次の周期にまたご参加ください。</p>"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
#!/usr/bin/env python3
|
||||
"""收尾两个内容字段:products.unit(计量单位)与 products.description(沿用旧中文名的行)。
|
||||
|
||||
背景:商品名与价格已经迁移过,但详情页还会露出两处中文——
|
||||
· unit:'包 / 个 / 盒 / 套 / 件' 直接拼在价格后(¥1,040/包)
|
||||
· description:多数行原本就是把旧中文名复制了一份,改完 name 后它还是中文
|
||||
|
||||
做法:
|
||||
unit 用固定对照表(5 个取值);
|
||||
description 用「旧中文名 → 日文名」的同一份映射(数据集 + 人工表)反查,
|
||||
映射不到的行只列出来、不改库。
|
||||
|
||||
用法
|
||||
python3 fix_product_desc_unit.py --db /path/sale.db --dry-run
|
||||
python3 fix_product_desc_unit.py --db /path/sale.db --yes
|
||||
"""
|
||||
import argparse
|
||||
import datetime as dt
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sqlite3
|
||||
import sys
|
||||
import unicodedata
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
DATASET = Path('/root/ribenyan_products.json')
|
||||
if not DATASET.exists():
|
||||
DATASET = HERE.parent / "ribenyan_products.json"
|
||||
MANUAL = HERE / "product_name_ja.json"
|
||||
|
||||
UNIT_MAP = {
|
||||
"包": "パック",
|
||||
"个": "個",
|
||||
"盒": "箱",
|
||||
"套": "セット",
|
||||
"件": "点",
|
||||
"支": "本",
|
||||
"条": "カートン",
|
||||
"罐": "缶",
|
||||
"袋": "袋",
|
||||
"瓶": "本",
|
||||
"颗": "個",
|
||||
"张": "枚",
|
||||
}
|
||||
|
||||
|
||||
def norm(s: str) -> str:
|
||||
s = unicodedata.normalize("NFKC", s or "").lower()
|
||||
return re.sub(r"[\s\-_//·,,.。()()\[\]【】]+", "", s)
|
||||
|
||||
|
||||
def build_map() -> dict[str, str]:
|
||||
m = {}
|
||||
if DATASET.exists():
|
||||
for d in json.loads(DATASET.read_text(encoding="utf-8")):
|
||||
cn, jp = d.get("name_cn"), d.get("name_jp")
|
||||
if cn and jp:
|
||||
m[norm(cn)] = jp
|
||||
if MANUAL.exists():
|
||||
for cn, jp in json.loads(MANUAL.read_text(encoding="utf-8")).items():
|
||||
m[norm(cn)] = jp
|
||||
return m
|
||||
|
||||
|
||||
def backup(db_path):
|
||||
stamp = dt.datetime.now().strftime("%Y%m%d-%H%M%S")
|
||||
made = []
|
||||
for suffix in ("", "-wal", "-shm"):
|
||||
src = db_path + suffix
|
||||
if os.path.exists(src):
|
||||
dst = f"{db_path}.bak-descunit-{stamp}{suffix}"
|
||||
shutil.copy2(src, dst)
|
||||
made.append(dst)
|
||||
return made
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--db", required=True)
|
||||
ap.add_argument("--dry-run", action="store_true")
|
||||
ap.add_argument("--yes", action="store_true")
|
||||
args = ap.parse_args()
|
||||
if not args.dry_run and not args.yes:
|
||||
sys.exit("写库需要 --yes")
|
||||
|
||||
con = sqlite3.connect(args.db, isolation_level=None)
|
||||
con.execute("PRAGMA busy_timeout = 30000")
|
||||
mapping = build_map()
|
||||
|
||||
unit_plan = []
|
||||
for u, n in con.execute(
|
||||
"SELECT unit, COUNT(*) FROM products WHERE deleted_at IS NULL AND unit <> '' GROUP BY unit"
|
||||
).fetchall():
|
||||
if u in UNIT_MAP and UNIT_MAP[u] != u:
|
||||
unit_plan.append((u, UNIT_MAP[u], n))
|
||||
|
||||
desc_plan, desc_missing = [], []
|
||||
for pid, name, desc in con.execute(
|
||||
"SELECT id, name, description FROM products WHERE deleted_at IS NULL"
|
||||
).fetchall():
|
||||
if not desc or not re.search(r"[\u4e00-\u9fa5]", desc):
|
||||
continue
|
||||
ja = mapping.get(norm(desc))
|
||||
if ja and ja != desc:
|
||||
desc_plan.append((pid, desc, ja))
|
||||
else:
|
||||
desc_missing.append((pid, name, desc))
|
||||
|
||||
print(f"unit 需替换 {sum(n for _, _, n in unit_plan)} 行:")
|
||||
for old, new, n in unit_plan:
|
||||
print(f" {old} → {new} ({n} 行)")
|
||||
print(f"\ndescription 可映射 {len(desc_plan)} 行,未覆盖 {len(desc_missing)} 行")
|
||||
for pid, old, new in desc_plan[:6]:
|
||||
print(f" #{pid} {old[:34]} → {new[:40]}")
|
||||
if desc_missing:
|
||||
print("\n未覆盖的 description(不改):")
|
||||
for pid, name, desc in desc_missing[:8]:
|
||||
print(f" #{pid} name={name[:24]} desc={desc[:40]}")
|
||||
|
||||
if args.dry_run:
|
||||
print("\n[dry-run] 未写库")
|
||||
return
|
||||
|
||||
backups = backup(args.db)
|
||||
print("\n已备份:" + ", ".join(os.path.basename(b) for b in backups))
|
||||
con.execute("BEGIN IMMEDIATE")
|
||||
try:
|
||||
for old, new, _ in unit_plan:
|
||||
con.execute('UPDATE products SET unit = ? WHERE unit = ? AND deleted_at IS NULL', (new, old))
|
||||
for pid, old, new in desc_plan:
|
||||
con.execute('UPDATE products SET description = ? WHERE id = ?', (new, pid))
|
||||
con.execute("COMMIT")
|
||||
except Exception as exc: # noqa: BLE001
|
||||
con.execute("ROLLBACK")
|
||||
print("失败已回滚:", exc)
|
||||
raise
|
||||
print(f"已更新 unit {sum(n for _, _, n in unit_plan)} 行、description {len(desc_plan)} 行")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -107,8 +107,11 @@ def main():
|
||||
con.execute("PRAGMA busy_timeout = 30000")
|
||||
|
||||
settings = dict(con.execute("SELECT `key`, value FROM system_settings").fetchall())
|
||||
if settings.get("currency_code", "").upper() == "JPY" and not args.force:
|
||||
sys.exit("库里 currency_code 已是 JPY —— 已经迁移过,不做第二次(要重跑加 --force)")
|
||||
# 幂等判据用 currency_migrated_at(本脚本自己写的时间戳),不要用 currency_code:
|
||||
# 应用启动时的 SeedCurrencyDefaults 也会写 currency_code=JPY,
|
||||
# 拿它当「已迁移」标志会让脚本在真正迁移之前就自我拒绝。
|
||||
if settings.get("currency_migrated_at") and not args.force:
|
||||
sys.exit(f"已迁移过(currency_migrated_at={settings['currency_migrated_at']}),不做第二次(重跑加 --force)")
|
||||
|
||||
plan = []
|
||||
for table, col in MONEY_COLUMNS:
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env python3
|
||||
"""把内容表的「中文原文」放回原列,把日文搬进 *_ja 列。
|
||||
|
||||
分工:
|
||||
中文列(name/title/content/description/summary/button) = 运营用中文写的源内容
|
||||
*_ja 列 = 日文版本
|
||||
公开接口按请求语言挑一列输出,后台两列都能编辑。
|
||||
|
||||
中文原文从**内容日文化之前的库备份**里读(默认自动挑最新的 sale.db.bak-contentja-*),
|
||||
所以不需要手工重录。已有 *_ja 值且非空的行跳过,可重复执行。
|
||||
|
||||
用法
|
||||
python3 restore_content_zh.py --db /mnt/data/sale/data/sale.db --backup /mnt/data/sale/data/sale.db.bak-contentja-xxx --dry-run
|
||||
python3 restore_content_zh.py --db ... --backup ... --yes
|
||||
"""
|
||||
import argparse
|
||||
import datetime as dt
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
import sqlite3
|
||||
import sys
|
||||
|
||||
# (表, 中文列, 日文列)
|
||||
FIELDS = [
|
||||
("categories", "name", "name_ja"),
|
||||
("categories", "description", "description_ja"),
|
||||
("banners", "title", "title_ja"),
|
||||
("banners", "desc", "desc_ja"),
|
||||
("banners", "button", "button_ja"),
|
||||
("announcements", "title", "title_ja"),
|
||||
("announcements", "content", "content_ja"),
|
||||
("lotteries", "name", "name_ja"),
|
||||
("lotteries", "description", "description_ja"),
|
||||
("lottery_prizes", "name", "name_ja"),
|
||||
("articles", "title", "title_ja"),
|
||||
("articles", "summary", "summary_ja"),
|
||||
("articles", "content", "content_ja"),
|
||||
]
|
||||
|
||||
|
||||
def pick_backup(db_path):
|
||||
cands = sorted(glob.glob(db_path + ".bak-contentja-*"))
|
||||
cands = [c for c in cands if not c.endswith(("-wal", "-shm"))]
|
||||
return cands[-1] if cands else None
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--db", required=True)
|
||||
ap.add_argument("--backup", default=None)
|
||||
ap.add_argument("--dry-run", action="store_true")
|
||||
ap.add_argument("--yes", action="store_true")
|
||||
args = ap.parse_args()
|
||||
if not args.dry_run and not args.yes:
|
||||
sys.exit("写库需要 --yes")
|
||||
|
||||
backup_path = args.backup or pick_backup(args.db)
|
||||
if not backup_path or not os.path.exists(backup_path):
|
||||
sys.exit("找不到内容日文化之前的备份,请用 --backup 指定")
|
||||
|
||||
old = sqlite3.connect(backup_path)
|
||||
old.execute("PRAGMA busy_timeout = 20000")
|
||||
new = sqlite3.connect(args.db, isolation_level=None)
|
||||
new.execute("PRAGMA busy_timeout = 30000")
|
||||
|
||||
plan = [] # (表, 列, id, 原中文, 当前值)
|
||||
for table, zh_col, ja_col in FIELDS:
|
||||
have = {r[1] for r in new.execute(f'PRAGMA table_info("{table}")')}
|
||||
if ja_col not in have:
|
||||
print(f"!! {table}.{ja_col} 不存在 —— 先让应用跑一次 AutoMigrate")
|
||||
continue
|
||||
cols = {r[1] for r in old.execute(f'PRAGMA table_info("{table}")')}
|
||||
if zh_col not in cols:
|
||||
print(f"!! 备份里没有 {table}.{zh_col}")
|
||||
continue
|
||||
origin = dict(old.execute(f'SELECT id, "{zh_col}" FROM "{table}"').fetchall())
|
||||
for rid, cur_zh, cur_ja in new.execute(
|
||||
f'SELECT id, "{zh_col}", "{ja_col}" FROM "{table}"'
|
||||
).fetchall():
|
||||
if rid not in origin:
|
||||
continue
|
||||
zh = origin[rid] or ""
|
||||
if (cur_ja or "").strip():
|
||||
continue # 已经有日文,别覆盖
|
||||
if zh == (cur_zh or ""):
|
||||
continue # 本来就是中文
|
||||
plan.append((table, zh_col, ja_col, rid, zh, cur_zh))
|
||||
|
||||
print(f"备份:{os.path.basename(backup_path)}")
|
||||
print(f"需要搬动的字段:{len(plan)} 处")
|
||||
for table, zh_col, ja_col, rid, zh, cur in plan[:12]:
|
||||
print(f" {table}#{rid}.{zh_col}: 中文←{str(zh)[:26]!r} 日文→{str(cur)[:26]!r}")
|
||||
|
||||
if args.dry_run:
|
||||
print("\n[dry-run] 未写库")
|
||||
return
|
||||
|
||||
stamp = dt.datetime.now().strftime("%Y%m%d-%H%M%S")
|
||||
for suffix in ("", "-wal", "-shm"):
|
||||
src = args.db + suffix
|
||||
if os.path.exists(src):
|
||||
shutil.copy2(src, f"{args.db}.bak-langcol-{stamp}{suffix}")
|
||||
print(f"\n已备份:sale.db.bak-langcol-{stamp}")
|
||||
|
||||
new.execute("BEGIN IMMEDIATE")
|
||||
try:
|
||||
for table, zh_col, ja_col, rid, zh, cur in plan:
|
||||
new.execute(
|
||||
f'UPDATE "{table}" SET "{ja_col}" = ?, "{zh_col}" = ? WHERE id = ?',
|
||||
(cur, zh, rid),
|
||||
)
|
||||
new.execute("COMMIT")
|
||||
except Exception as exc: # noqa: BLE001
|
||||
new.execute("ROLLBACK")
|
||||
print("失败已回滚:", exc)
|
||||
raise
|
||||
print(f"已搬动 {len(plan)} 处:中文回原列,日文进 *_ja")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,176 @@
|
||||
#!/usr/bin/env python3
|
||||
"""把数据库里的「运营内容」改成日文:分类、轮播、公告、活动、奖品、资讯正文。
|
||||
|
||||
为什么需要这一步:代码里的界面文案已经 i18n/日文化,但首页 banner、活动标题、
|
||||
资讯文章这些是**运营数据**,存在库里,改代码不会跟。
|
||||
|
||||
用法
|
||||
python3 translate_content_ja.py --db /path/sale.db --dry-run
|
||||
python3 translate_content_ja.py --db /path/sale.db --yes
|
||||
|
||||
翻译表在 content_ja.json(键为原文,值是日文)。品牌名单独处理:
|
||||
「AmericanSpirit/美国精神」→ 保留拉丁部分;两边都是拉丁就原样保留。
|
||||
没有翻译条目的行只列出来、不改库。
|
||||
"""
|
||||
import argparse
|
||||
import datetime as dt
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sqlite3
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
TABLE = HERE / "content_ja.json"
|
||||
|
||||
# 简单字段:(表, id 是否按原文匹配, [(列, 是否用 id 索引)])
|
||||
SIMPLE = [
|
||||
("categories", "name"),
|
||||
("announcements", "title"),
|
||||
("announcements", "content"),
|
||||
("purchase_groups", "name"),
|
||||
]
|
||||
|
||||
|
||||
def load_map():
|
||||
return json.loads(TABLE.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def backup(db_path):
|
||||
stamp = dt.datetime.now().strftime("%Y%m%d-%H%M%S")
|
||||
made = []
|
||||
for suffix in ("", "-wal", "-shm"):
|
||||
src = db_path + suffix
|
||||
if os.path.exists(src):
|
||||
dst = f"{db_path}.bak-contentja-{stamp}{suffix}"
|
||||
shutil.copy2(src, dst)
|
||||
made.append(dst)
|
||||
return made
|
||||
|
||||
|
||||
def strip_brand(name: str) -> str:
|
||||
"""品牌名去掉中文段:'AmericanSpirit/美国精神' → 'AmericanSpirit'。"""
|
||||
if not name or "/" not in name:
|
||||
return name
|
||||
parts = [p.strip() for p in name.split("/") if p.strip()]
|
||||
if not parts:
|
||||
return name
|
||||
latin = [p for p in parts if re.fullmatch(r"[A-Za-z0-9 .&'\-]+", p)]
|
||||
return latin[0] if latin else parts[-1]
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--db", required=True)
|
||||
ap.add_argument("--dry-run", action="store_true")
|
||||
ap.add_argument("--yes", action="store_true")
|
||||
args = ap.parse_args()
|
||||
|
||||
if not args.dry_run and not args.yes:
|
||||
sys.exit("写库需要 --yes")
|
||||
|
||||
m = load_map()
|
||||
con = sqlite3.connect(args.db, isolation_level=None)
|
||||
con.execute("PRAGMA busy_timeout = 30000")
|
||||
|
||||
plan = [] # (table, id, col, old, new)
|
||||
missing = []
|
||||
|
||||
# 1) 分类 / 公告 / 购买分组:按原文映射
|
||||
cat_map = m.get("categories", {})
|
||||
for t, col in SIMPLE:
|
||||
for rid, val in con.execute(f"SELECT id, {col} FROM {t}").fetchall():
|
||||
if val is None:
|
||||
continue
|
||||
new = cat_map.get(val) if t == "categories" else m.get(t, {}).get(str(rid), {}).get(col)
|
||||
if new and new != val:
|
||||
plan.append((t, rid, col, val, new))
|
||||
elif t == "categories" and val not in cat_map:
|
||||
missing.append(f"categories#{rid} {val}")
|
||||
|
||||
# 2) 轮播:按 id 映射
|
||||
for rid, title, desc, button in con.execute("SELECT id, title, desc, button FROM banners").fetchall():
|
||||
tr = m.get("banners", {}).get(str(rid))
|
||||
if not tr:
|
||||
missing.append(f"banners#{rid} {title}")
|
||||
continue
|
||||
for col, old in (("title", title), ("desc", desc), ("button", button)):
|
||||
new = tr.get(col)
|
||||
if new and new != old:
|
||||
plan.append(("banners", rid, col, old, new))
|
||||
|
||||
# 3) 活动:按 id 映射("__冒烟测试_可删__" 这类测试行不在表里,会被列为待处理)
|
||||
for rid, name, desc in con.execute("SELECT id, name, description FROM lotteries").fetchall():
|
||||
tr = m.get("lotteries", {}).get(str(rid))
|
||||
if not tr:
|
||||
missing.append(f"lotteries#{rid} {name}")
|
||||
continue
|
||||
for col, old in (("name", name), ("description", desc)):
|
||||
new = tr.get(col)
|
||||
if new and new != old:
|
||||
plan.append(("lotteries", rid, col, old, new))
|
||||
|
||||
# 4) 奖品名:按原文映射
|
||||
prize_map = m.get("lottery_prizes", {})
|
||||
for rid, name in con.execute("SELECT id, name FROM lottery_prizes").fetchall():
|
||||
new = prize_map.get(name)
|
||||
if new and new != name:
|
||||
plan.append(("lottery_prizes", rid, "name", name, new))
|
||||
elif name not in prize_map and re.search(r"[\u4e00-\u9fa5]", name or ""):
|
||||
missing.append(f"lottery_prizes#{rid} {name}")
|
||||
|
||||
# 5) 资讯:标题/摘要/正文
|
||||
for rid, title, summary, content in con.execute("SELECT id, title, summary, content FROM articles").fetchall():
|
||||
tr = m.get("articles", {}).get(str(rid))
|
||||
if not tr:
|
||||
missing.append(f"articles#{rid} {title}")
|
||||
continue
|
||||
for col, old in (("title", title), ("summary", summary), ("content", content)):
|
||||
new = tr.get(col)
|
||||
if new and new != old:
|
||||
plan.append(("articles", rid, col, old, new))
|
||||
|
||||
# 6) 品牌名去中文段
|
||||
brand_changes = []
|
||||
for rid, name in con.execute("SELECT id, name FROM brands").fetchall():
|
||||
new = strip_brand(name)
|
||||
if new and new != name:
|
||||
brand_changes.append((rid, name, new))
|
||||
|
||||
print(f"内容改动 {len(plan)} 处,品牌名去中文 {len(brand_changes)} 条")
|
||||
for t, rid, col, old, new in plan[:14]:
|
||||
print(f" {t}#{rid}.{col}: {str(old)[:40]} → {str(new)[:44]}")
|
||||
if brand_changes:
|
||||
for rid, old, new in brand_changes[:6]:
|
||||
print(f" brands#{rid}: {old} → {new}")
|
||||
if missing:
|
||||
print(f"\n未覆盖 {len(missing)} 行(不改):")
|
||||
for x in missing[:10]:
|
||||
print(" " + x)
|
||||
|
||||
if args.dry_run:
|
||||
print("\n[dry-run] 未写库")
|
||||
return
|
||||
|
||||
backups = backup(args.db)
|
||||
print("\n已备份:" + ", ".join(os.path.basename(b) for b in backups))
|
||||
|
||||
con.execute("BEGIN IMMEDIATE")
|
||||
try:
|
||||
now = dt.datetime.now().isoformat(" ", "seconds")
|
||||
for t, rid, col, old, new in plan:
|
||||
con.execute(f'UPDATE "{t}" SET "{col}" = ? WHERE id = ?', (new, rid))
|
||||
for rid, old, new in brand_changes:
|
||||
con.execute('UPDATE "brands" SET name = ? WHERE id = ?', (new, rid))
|
||||
con.execute("COMMIT")
|
||||
except Exception as exc: # noqa: BLE001
|
||||
con.execute("ROLLBACK")
|
||||
print("失败已回滚:", exc)
|
||||
raise
|
||||
print(f"已更新内容 {len(plan)} 处 + 品牌名 {len(brand_changes)} 条")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user