refactor(shop): inline B product config in existing payment functions
This commit is contained in:
parent
81dac3b154
commit
7886bbfef5
|
|
@ -1,18 +0,0 @@
|
|||
// layer_3 B 商城新商品;旧商品 ID 和订单继续沿用原流程。
|
||||
export const NEW_SHOP_PRODUCTS: Record<string, { price: number; name: string }> = {
|
||||
new_gold_1: { price: 600, name: "新版金币包1" },
|
||||
new_gold_2: { price: 3000, name: "新版金币包2" },
|
||||
new_gold_3: { price: 6800, name: "新版金币包3" },
|
||||
new_gold_4: { price: 12800, name: "新版金币包4" },
|
||||
new_gold_5: { price: 32800, name: "新版金币包5" },
|
||||
new_gold_6: { price: 64800, name: "新版金币包6" },
|
||||
new_unlimited_health_bundle_8: { price: 800, name: "新版组合礼包8元" },
|
||||
new_unlimited_health_bundle_18: { price: 1800, name: "新版组合礼包18元" },
|
||||
new_unlimited_health_bundle_36: { price: 3600, name: "新版组合礼包36元" },
|
||||
new_unlimited_health_bundle_68: { price: 6800, name: "新版组合礼包68元" },
|
||||
new_unlimited_health_bundle_98: { price: 9800, name: "新版组合礼包98元" },
|
||||
};
|
||||
|
||||
export function getNewShopProduct(id: string) {
|
||||
return Object.prototype.hasOwnProperty.call(NEW_SHOP_PRODUCTS, id) ? NEW_SHOP_PRODUCTS[id] : null;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
name: shopConfig
|
||||
desc: "layer_3 B商城商品价格和客服名称"
|
||||
methods:
|
||||
- POST
|
||||
tags: []
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
import * as StarterPackModule from "@/limitedTimeEvent";
|
||||
const StarterPack: any = StarterPackModule as any;
|
||||
import cloud from '@lafjs/cloud'
|
||||
import { getNewShopProduct } from '@/shopConfig';
|
||||
import { passOrderFields, PASS_PRICES } from '@/passCheckUpgrade';
|
||||
// const token = "nika123";
|
||||
// const EncodingAESKey = "XcdOFaZOQjmyBqYHxWAITtrmq11YaZQ63DeEZAAgYJt";
|
||||
|
|
@ -103,6 +102,11 @@ async function frontsign(data) {
|
|||
return signature
|
||||
}
|
||||
const propName = {
|
||||
new_gold_1: "新版金币包1", new_gold_2: "新版金币包2", new_gold_3: "新版金币包3",
|
||||
new_gold_4: "新版金币包4", new_gold_5: "新版金币包5", new_gold_6: "新版金币包6",
|
||||
new_unlimited_health_bundle_8: "新版组合礼包8元", new_unlimited_health_bundle_18: "新版组合礼包18元",
|
||||
new_unlimited_health_bundle_36: "新版组合礼包36元", new_unlimited_health_bundle_68: "新版组合礼包68元",
|
||||
new_unlimited_health_bundle_98: "新版组合礼包98元",
|
||||
reborn_Gift: "复活礼包6元", reborn_Gift_2: "复活礼包8元", reborn_Gift_3: "复活礼包10元",
|
||||
reborn_Gift_4: "复活礼包12元", reborn_Gift_5: "复活礼包15元",
|
||||
battlepass: '基础战令', battlepass_30: '高级战令', battlepass_12: '战令升级',
|
||||
|
|
@ -154,8 +158,17 @@ async function PostMsg(OpenId, msg) {
|
|||
return "ok"
|
||||
}
|
||||
async function PostImg(OpenId, outTradeNo, name, count, price, passInput: any = {}) {
|
||||
const shopProduct = getNewShopProduct(name);
|
||||
if (shopProduct) { count = 1; price = shopProduct.price; }
|
||||
// B 商城商品价格(分);旧商品继续沿用原流程。
|
||||
const shopPrices = {
|
||||
new_gold_1: 600, new_gold_2: 3000, new_gold_3: 6800,
|
||||
new_gold_4: 12800, new_gold_5: 32800, new_gold_6: 64800,
|
||||
new_unlimited_health_bundle_8: 800, new_unlimited_health_bundle_18: 1800,
|
||||
new_unlimited_health_bundle_36: 3600, new_unlimited_health_bundle_68: 6800,
|
||||
new_unlimited_health_bundle_98: 9800,
|
||||
};
|
||||
if (Object.prototype.hasOwnProperty.call(shopPrices, name)) {
|
||||
count = 1; price = shopPrices[name];
|
||||
}
|
||||
const rebornPrice = { reborn_Gift: 600, reborn_Gift_2: 800, reborn_Gift_3: 1000, reborn_Gift_4: 1200, reborn_Gift_5: 1500 };
|
||||
if (/^reborn_Gift(?:_[2-5])?$/.test(name)) {
|
||||
count = 1;
|
||||
|
|
@ -190,7 +203,7 @@ async function PostImg(OpenId, outTradeNo, name, count, price, passInput: any =
|
|||
|
||||
let user = await db.collection("users").where({ openid: OpenId }).update({ iosTime: frontBody.timeStamp });
|
||||
let param = {
|
||||
name: shopProduct ? shopProduct.name : propName[name],
|
||||
name: propName[name],
|
||||
openid: OpenId,
|
||||
outTradeNo: outTradeNo,
|
||||
time: timestamp,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import * as StarterPackModule from "@/limitedTimeEvent";
|
||||
const StarterPack: any = StarterPackModule as any;
|
||||
import cloud from '@lafjs/cloud'
|
||||
import { getNewShopProduct } from '@/shopConfig';
|
||||
import { passOrderFields, PASS_PRICES } from '@/passCheckUpgrade';
|
||||
import * as crypto from 'crypto';
|
||||
import * as JungleConfigModule from "@/jungleConfig";
|
||||
|
|
@ -18,8 +17,17 @@ export default async function (ctx: FunctionContext) {
|
|||
let itemid = ctx.body.itemid;
|
||||
let itemCount = ctx.body.itemCount;
|
||||
let itemPrice = ctx.body.itemPrice;
|
||||
const shopProduct = getNewShopProduct(itemid);
|
||||
if (shopProduct) { itemCount = 1; itemPrice = shopProduct.price; }
|
||||
// B 商城商品价格(分);旧商品继续沿用原流程。
|
||||
const shopPrices = {
|
||||
new_gold_1: 600, new_gold_2: 3000, new_gold_3: 6800,
|
||||
new_gold_4: 12800, new_gold_5: 32800, new_gold_6: 64800,
|
||||
new_unlimited_health_bundle_8: 800, new_unlimited_health_bundle_18: 1800,
|
||||
new_unlimited_health_bundle_36: 3600, new_unlimited_health_bundle_68: 6800,
|
||||
new_unlimited_health_bundle_98: 9800,
|
||||
};
|
||||
if (Object.prototype.hasOwnProperty.call(shopPrices, itemid)) {
|
||||
itemCount = 1; itemPrice = shopPrices[itemid];
|
||||
}
|
||||
const rebornPrice = { reborn_Gift: 600, reborn_Gift_2: 800, reborn_Gift_3: 1000, reborn_Gift_4: 1200, reborn_Gift_5: 1500 };
|
||||
if (/^reborn_Gift(?:_[2-5])?$/.test(itemid)) {
|
||||
itemCount = 1;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import * as StarterPackModule from "@/limitedTimeEvent";
|
||||
const StarterPack: any = StarterPackModule as any;
|
||||
import cloud from '@lafjs/cloud'
|
||||
import { getNewShopProduct } from '@/shopConfig';
|
||||
import { passOrderFields, PASS_PRICES } from '@/passCheckUpgrade';
|
||||
import * as crypto from 'crypto';
|
||||
import * as JungleConfigModule from "@/jungleConfig";
|
||||
|
|
@ -18,8 +17,17 @@ export default async function (ctx: FunctionContext) {
|
|||
let itemid = ctx.body.itemid;
|
||||
let itemCount = ctx.body.itemCount;
|
||||
let itemPrice = ctx.body.itemPrice;
|
||||
const shopProduct = getNewShopProduct(itemid);
|
||||
if (shopProduct) { itemCount = 1; itemPrice = shopProduct.price; }
|
||||
// B 商城商品价格(分);旧商品继续沿用原流程。
|
||||
const shopPrices = {
|
||||
new_gold_1: 600, new_gold_2: 3000, new_gold_3: 6800,
|
||||
new_gold_4: 12800, new_gold_5: 32800, new_gold_6: 64800,
|
||||
new_unlimited_health_bundle_8: 800, new_unlimited_health_bundle_18: 1800,
|
||||
new_unlimited_health_bundle_36: 3600, new_unlimited_health_bundle_68: 6800,
|
||||
new_unlimited_health_bundle_98: 9800,
|
||||
};
|
||||
if (Object.prototype.hasOwnProperty.call(shopPrices, itemid)) {
|
||||
itemCount = 1; itemPrice = shopPrices[itemid];
|
||||
}
|
||||
const rebornPrice = { reborn_Gift: 600, reborn_Gift_2: 800, reborn_Gift_3: 1000, reborn_Gift_4: 1200, reborn_Gift_5: 1500 };
|
||||
if (/^reborn_Gift(?:_[2-5])?$/.test(itemid)) {
|
||||
itemCount = 1;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ new_gold_1~6 共用原 gold_1~6 的首充记录,不重置资格。礼包
|
|||
|
||||
本次只修改本地文件,未部署、未修改微信商品后台。
|
||||
|
||||
1. 先发布公共函数模块 `shopConfig`(包含 YAML),再发布引用它的 `wx/orderPaySig`、`wx/iosorderPaySig`、`wx/KeFuInfo`。
|
||||
1. 发布现有的 `wx/orderPaySig`、`wx/iosorderPaySig`、`wx/KeFuInfo` 三个函数。新商品价格和客服名称已直接写入这些函数,无需新增公共云函数。
|
||||
2. 核对微信商品后台是否已配置上述 11 个新 ID 及对应价格。旧商品保留以支持 A 组和旧订单。
|
||||
3. 发布包含 ShopCatalog、shop2 和 A/B 加载修改的客户端。不要先给仍不识别新商品的旧客户端开放新商城订单。
|
||||
4. 微信真机分别验证 A/B 首页与关卡入口、首充已用/未用、8 元无无限体力、98 元加 12 小时、支付返回与重登补单。真机支付本次未执行。
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ registerHooks({
|
|||
const aliases = {
|
||||
"@/Utils": "data:text/javascript,export default globalThis.__jungleUtilsMock",
|
||||
"@/jungleConfig": configUrl.href,
|
||||
"@/shopConfig": new URL("../functions/shopConfig.ts", import.meta.url).href,
|
||||
"@/limitedTimeEvent": new URL("../functions/limitedTimeEvent.ts", import.meta.url).href,
|
||||
"@/passCheckUpgrade": new URL("../functions/passCheckUpgrade.ts", import.meta.url).href,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ registerHooks({
|
|||
if (specifier === '@/limitedTimeEvent') return { url: new URL('../functions/limitedTimeEvent.ts', import.meta.url).href, shortCircuit: true };
|
||||
if (specifier === '@/passCheckUpgrade') return { url: new URL('../functions/passCheckUpgrade.ts', import.meta.url).href, shortCircuit: true };
|
||||
if (specifier === '@/Utils') return { url: new URL('../functions/Utils.ts', import.meta.url).href, shortCircuit: true };
|
||||
if (specifier === '@/shopConfig') return { url: new URL('../functions/shopConfig.ts', import.meta.url).href, shortCircuit: true };
|
||||
if (specifier === '@/jungleConfig') return { url: new URL('../functions/jungleConfig.ts', import.meta.url).href, shortCircuit: true };
|
||||
return next(specifier, context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ function load(file, deps = {}, globals = {}) {
|
|||
}, Date, ...globals });
|
||||
return exports;
|
||||
}
|
||||
const catalog = load('shopConfig.ts');
|
||||
const ids = [1,2,3,4,5,6].map(i=>'new_gold_'+i).concat([8,18,36,68,98].map(i=>'new_unlimited_health_bundle_'+i));
|
||||
const prices = [600,3000,6800,12800,32800,64800,800,1800,3600,6800,9800];
|
||||
function fixture() {
|
||||
|
|
@ -24,7 +23,7 @@ function fixture() {
|
|||
const db={collection:()=>({add:async row=>{state.orders.push(row);return {};},where:()=>({getOne:async()=>({data:state.user}),update:async()=>({})})})};
|
||||
const cloud={database:()=>db,shared:{get:()=> 'token'},storage:{bucket:()=>({readFile:async()=>({Body:{transformToString:async()=> 'synthetic-key'}})})}};
|
||||
const deps={
|
||||
'@lafjs/cloud':{default:cloud}, '@/shopConfig':catalog,
|
||||
'@lafjs/cloud':{default:cloud},
|
||||
'@/limitedTimeEvent':{starterPackOrderSnapshot:()=>({})},
|
||||
'@/passCheckUpgrade':{passOrderFields:()=>({}),PASS_PRICES:{}},
|
||||
'@/jungleConfig':{getJunglePaidTierByProductId:()=>null},
|
||||
|
|
@ -61,6 +60,6 @@ test('legacy iOS cashier uses all B prices, display names and order IDs',async()
|
|||
assert.equal(payments[i].body.amount.total,prices[i]);
|
||||
const link=f.state.requests.filter(r=>r.body.msgtype==='link')[i].body.link;
|
||||
const data=JSON.parse(decodeURIComponent(link.url.split('#data=')[1]));
|
||||
assert.equal(data.name,catalog.getNewShopProduct(id).name);assert.equal(data.price,prices[i]);assert.equal(data.outTradeNo,'ios-'+i);
|
||||
assert.equal(data.name,i < 6 ? '新版金币包'+(i+1) : '新版组合礼包'+[8,18,36,68,98][i-6]+'元');assert.equal(data.price,prices[i]);assert.equal(data.outTradeNo,'ios-'+i);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user