修改显示问题
This commit is contained in:
1 parent
07a90e860d
commit
88bffaa5d0
5 files changed
+22
-2
No files matched your search
@@ -23,6 +23,7 @@ const TABLES = {
|
||||
{ name: 'openid', type: 'VARCHAR(64)', notNull: true, comment: '用户 openid' },
|
||||
{ name: 'product_id', type: 'VARCHAR(32)', notNull: true, comment: '道具 ID' },
|
||||
{ name: 'env', type: 'TINYINT', notNull: true, default: '0', comment: '0 现网 1 沙箱' },
|
||||
{ name: 'channel', type: 'VARCHAR(16)', comment: '支付渠道:apple 表示 iOS 内购' },
|
||||
{ name: 'amount', type: 'INT', notNull: true, default: '0', comment: '下单金额(分)' },
|
||||
{ name: 'status', type: 'VARCHAR(16)', notNull: true, default: "'created'", comment: 'created 已下单 delivered 已发货' },
|
||||
{ name: 'wx_order_id', type: 'VARCHAR(64)', comment: '平台单号,唯一' },
|
||||
|
||||
@@ -79,6 +79,8 @@ async function isAdmin(openid) {
|
||||
|
||||
const sha1 = (text) => crypto.createHash('sha1').update(text).digest('hex')
|
||||
const isPaid = (status) => status >= 2 && status <= 4 // 2 已支付待发货 / 3 发货中 / 4 已发货
|
||||
// 订单渠道:7 / 8 是苹果 iOS(内购)订单,开发者不能主动退款
|
||||
const isAppleOrder = (order) => [7, 8].includes(Number(order && order.order_type))
|
||||
|
||||
// 从推送的 XML 里取字段,值可能在 CDATA 里
|
||||
function xmlTag(xml, name) {
|
||||
@@ -244,6 +246,7 @@ async function deliverRecord(record, order) {
|
||||
const delivered = await store.assignCode(record.outTradeNo, {
|
||||
wxOrderId: detail.wx_order_id || record.wxOrderId || '',
|
||||
paidFee: detail.paid_fee || 0,
|
||||
channel: isAppleOrder(detail) ? 'apple' : 'wxpay',
|
||||
})
|
||||
const notify = await tryNotify(delivered)
|
||||
return {
|
||||
@@ -343,6 +346,7 @@ async function myCodes(code) {
|
||||
productId: record.productId,
|
||||
productName: await nameOf(record.productId),
|
||||
env: record.env || 0,
|
||||
channel: record.channel || '',
|
||||
deliveredAt: record.deliveredAt,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ const ORDER_COLUMNS = [
|
||||
'openid',
|
||||
'product_id',
|
||||
'env',
|
||||
'channel',
|
||||
'amount',
|
||||
'status',
|
||||
'wx_order_id',
|
||||
@@ -34,6 +35,7 @@ function toRecord(row) {
|
||||
openid: row.openid,
|
||||
productId: row.product_id,
|
||||
env: row.env,
|
||||
channel: row.channel || '',
|
||||
amount: row.amount,
|
||||
status: row.status,
|
||||
code: row.code || '',
|
||||
@@ -55,6 +57,7 @@ async function saveOrder(record) {
|
||||
record.openid,
|
||||
String(record.productId),
|
||||
record.env || 0,
|
||||
record.channel || null,
|
||||
record.amount || 0,
|
||||
record.status || 'created',
|
||||
record.wxOrderId || null,
|
||||
|
||||
+13
-1
@@ -84,7 +84,14 @@ const fakeWx = http.createServer((req, res) => {
|
||||
return reply({
|
||||
errcode: 0,
|
||||
errmsg: 'ok',
|
||||
order: { order_id: orderId, status, paid_fee: 10, left_fee: 10, wx_order_id: `wx-${env}-${orderId}` },
|
||||
order: {
|
||||
order_id: orderId,
|
||||
status,
|
||||
order_type: 0, // 0 普通虚拟支付(7 才是苹果内购)
|
||||
paid_fee: 10,
|
||||
left_fee: 10,
|
||||
wx_order_id: `wx-${env}-${orderId}`,
|
||||
},
|
||||
})
|
||||
}
|
||||
if (urlPath === '/xpay/notify_provide_goods') {
|
||||
@@ -336,6 +343,11 @@ async function main() {
|
||||
[sandboxDelivered.code, '补单专用'],
|
||||
].sort()
|
||||
)
|
||||
// 退款按钮的显隐看订单渠道:普通虚拟支付记成 wxpay,苹果内购记成 apple
|
||||
assert.deepStrictEqual(
|
||||
Array.from(new Set(mine.list.map((item) => item.channel))),
|
||||
['wxpay']
|
||||
)
|
||||
const others = await fetchJson(port, '/pay/my', { code: 'code-other' })
|
||||
assert.deepStrictEqual(others.list, [])
|
||||
|
||||
|
||||
Reference in new issue
Block a user