feat: 七日签到及新手礼包上线前的代码检查
This commit is contained in:
parent
d73060c54b
commit
82273090ad
|
|
@ -10,6 +10,10 @@ export default async function (ctx: FunctionContext) {
|
|||
// if (gameName == "iaa") {
|
||||
// dbname = "usersAd";
|
||||
// }
|
||||
// const gameName = ctx.body.gameName;
|
||||
// if (gameName == "iaa") {
|
||||
// dbname = "usersAd";
|
||||
// }
|
||||
if (!action) {
|
||||
return { code: 0, data: null, msg: "未获取到action" };
|
||||
}
|
||||
|
|
@ -156,6 +160,7 @@ export async function reportRookieGift(order: any, user: any, paidAt: number) {
|
|||
const saved = fresh.data;
|
||||
if (!saved?.rookieGiftPaidAt) throw new Error('rookie_gift snapshot not persisted');
|
||||
const ThinkingData = require('thinkingdata-node');
|
||||
// e5e0为正式服
|
||||
const appId = user.isDebug === 'true' ? '95993f9ab6f1402a87abe5147827e5e0' : '40e3d5c5f2af49a4a074205564ce5dbb';
|
||||
const sdk = ThinkingData.initWithBatchMode(appId, 'https://data.nika4fun.com/sync_data', { dryRun: false, deviceId: '123456789' });
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ export default async function (ctx: FunctionContext) {
|
|||
const from = body.from;
|
||||
const supportsWucaiMigration = Number(body.wucai_capability) >= 1;
|
||||
let dbname = "users";
|
||||
const gameName = body.gameName;
|
||||
if (gameName == "iaa") {
|
||||
dbname = "usersAd";
|
||||
}
|
||||
// const gameName = body.gameName;
|
||||
// if (gameName == "iaa") {
|
||||
// dbname = "usersAd";
|
||||
// }
|
||||
if (from === "wucai" && dbname !== "users") {
|
||||
return wucaiLoginFail("WUCAI_UNSUPPORTED_GAME", "五彩账号迁移仅支持主用户库");
|
||||
}
|
||||
|
|
@ -379,29 +379,6 @@ const getClientIp = (req) => {
|
|||
);
|
||||
};
|
||||
|
||||
const propName = {
|
||||
"金币包1": "gold_1",
|
||||
"金币包2": "gold_2",
|
||||
"金币包3": "gold_3",
|
||||
"金币包4": "gold_4",
|
||||
"金币包5": "gold_5",
|
||||
"金币包6": "gold_6",
|
||||
"无限体力组合包1": "unlimited_health_bundle_1",
|
||||
"无限体力组合包2": "unlimited_health_bundle_2",
|
||||
"无限体力组合包3": "unlimited_health_bundle_3",
|
||||
"局内购买冻结": "freeze_in_game",
|
||||
"局内购买锤子": "hammer_in_game",
|
||||
"局内购买魔棒": "wand_in_gamerefill",
|
||||
"补满体力": "health",
|
||||
"宝藏1": "jungle_treasure_1",
|
||||
"宝藏2": "jungle_treasure_2",
|
||||
"宝藏3": "jungle_treasure_3",
|
||||
"宝藏4": "jungle_treasure_4",
|
||||
"宝藏5": "jungle_treasure_5",
|
||||
"宝藏6": "jungle_treasure_6",
|
||||
"宝藏7": "jungle_treasure_7",
|
||||
"宝藏8": "jungle_treasure_8"
|
||||
};
|
||||
|
||||
async function getWXOpenId(code, dbname) {
|
||||
let appid = process.env.WX_MINIGAME_APP_ID;
|
||||
|
|
@ -584,7 +561,7 @@ async function sign(outTradeNo, nonceStr, timestamp) {
|
|||
// 更新签名内容
|
||||
sign.update(data);
|
||||
// 获取存储桶
|
||||
const bucket = cloud.storage.bucket('j3k323ol-colorblock-oss');
|
||||
const bucket = cloud.storage.bucket(process.env.WX_PAY_PRIVATE_KEY_BUCKET);
|
||||
// 获取文件列表
|
||||
const res = await bucket.readFile('apiclient_key.pem');
|
||||
const privateKeyPem = await res.Body.transformToString();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import cloud from '@lafjs/cloud'
|
||||
import Utils from "@/Utils";
|
||||
export default async function (ctx: FunctionContext) {
|
||||
const mjsonUrl = 'j3k323ol-colorblock-oss';
|
||||
const mjsonUrl = process.env.WX_PAY_PRIVATE_KEY_BUCKET;
|
||||
// 获取存储桶
|
||||
const bucket = cloud.storage.bucket(mjsonUrl);
|
||||
// 获取文件列表
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ async function sign(outTradeNo, nonceStr, timestamp) {
|
|||
// 更新签名内容
|
||||
sign.update(data);
|
||||
// 获取存储桶
|
||||
const bucket = cloud.storage.bucket('j3k323ol-colorblock-oss');
|
||||
const bucket = cloud.storage.bucket(process.env.WX_PAY_PRIVATE_KEY_BUCKET);
|
||||
// 获取文件列表
|
||||
const res = await bucket.readFile('apiclient_key.pem');
|
||||
const privateKeyPem = await res.Body.transformToString();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import * as StarterPackModule from "@/limitedTimeEvent";
|
||||
const StarterPack: any = StarterPackModule as any;
|
||||
import * as StarterPackModule from "@/limitedTimeEvent";
|
||||
const StarterPack: any = StarterPackModule as any;
|
||||
import cloud from '@lafjs/cloud'
|
||||
import { passOrderFields, PASS_PRICES } from '@/passCheckUpgrade';
|
||||
// const token = "nika123";
|
||||
|
|
@ -68,7 +70,7 @@ async function sign(nonceStr, timestamp, body) {
|
|||
// 更新签名内容
|
||||
sign.update(data);
|
||||
// 获取存储桶
|
||||
const bucket = cloud.storage.bucket('j3k323ol-colorblock-oss');
|
||||
const bucket = cloud.storage.bucket(process.env.WX_PAY_PRIVATE_KEY_BUCKET);
|
||||
// 获取文件列表
|
||||
const res = await bucket.readFile('apiclient_key.pem');
|
||||
const privateKeyPem = await res.Body.transformToString();
|
||||
|
|
@ -88,7 +90,7 @@ async function frontsign(data) {
|
|||
// 更新签名内容
|
||||
sign.update(data);
|
||||
// 获取存储桶
|
||||
const bucket = cloud.storage.bucket('j3k323ol-colorblock-oss');
|
||||
const bucket = cloud.storage.bucket(process.env.WX_PAY_PRIVATE_KEY_BUCKET);
|
||||
// 获取文件列表
|
||||
const res = await bucket.readFile('apiclient_key.pem');
|
||||
const privateKeyPem = await res.Body.transformToString();
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ async function sead(order, userInfo, ip) {
|
|||
console.log("未找到distinctId无法上传数数")
|
||||
return;
|
||||
}
|
||||
let id = '95993f9ab6f1402a87abe5147827e5e0';
|
||||
let id = '95993f9ab6f1402a87abe5147827e5e0'; // 正式
|
||||
if (userInfo.isDebug != "true") {
|
||||
id = '40e3d5c5f2af49a4a074205564ce5dbb';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ globalThis.__jungleUtilsMock = {
|
|||
|
||||
globalThis.require = () => ({
|
||||
initWithBatchMode() {
|
||||
return { track() {}, close() {} };
|
||||
return { track() { }, close() { } };
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -10,38 +10,46 @@ const realNow = Date.now, realFetch = globalThis.fetch;
|
|||
Date.now = () => now;
|
||||
test.after(() => { Date.now = realNow; globalThis.fetch = realFetch; });
|
||||
const clone = value => value == null ? value : structuredClone(value);
|
||||
const matches = (row, query) => Object.entries(query).every(([k,v]) => v === null ? row[k] == null : row[k] === v);
|
||||
const matches = (row, query) => Object.entries(query).every(([k, v]) => v === null ? row[k] == null : row[k] === v);
|
||||
const { privateKey } = generateKeyPairSync('rsa', { modulusLength: 2048, privateKeyEncoding: { type: 'pkcs8', format: 'pem' }, publicKeyEncoding: { type: 'spki', format: 'pem' } });
|
||||
globalThis.__rookieCloud = {
|
||||
database: () => ({ collection: name => ({
|
||||
async add(data) { tables[name].push(clone(data)); return { id: 'mock' }; },
|
||||
where(query) { return {
|
||||
async getOne() { return { data: clone(tables[name].find(r => matches(r, query))) }; },
|
||||
async update(data) {
|
||||
if (dbError && data.rookieGiftPaidAt) throw new Error('synthetic snapshot error');
|
||||
const rows = tables[name].filter(r => matches(r, query));
|
||||
rows.forEach(r => Object.assign(r, clone(data))); return { updated: rows.length };
|
||||
database: () => ({
|
||||
collection: name => ({
|
||||
async add(data) { tables[name].push(clone(data)); return { id: 'mock' }; },
|
||||
where(query) {
|
||||
return {
|
||||
async getOne() { return { data: clone(tables[name].find(r => matches(r, query))) }; },
|
||||
async update(data) {
|
||||
if (dbError && data.rookieGiftPaidAt) throw new Error('synthetic snapshot error');
|
||||
const rows = tables[name].filter(r => matches(r, query));
|
||||
rows.forEach(r => Object.assign(r, clone(data))); return { updated: rows.length };
|
||||
},
|
||||
async remove() { tables[name] = tables[name].filter(r => !matches(r, query)); },
|
||||
};
|
||||
},
|
||||
async remove() { tables[name] = tables[name].filter(r => !matches(r, query)); },
|
||||
}; },
|
||||
}) }),
|
||||
shared: { get: k => shared.get(k), set: (k,v) => shared.set(k,v) },
|
||||
})
|
||||
}),
|
||||
shared: { get: k => shared.get(k), set: (k, v) => shared.set(k, v) },
|
||||
storage: { bucket: () => ({ readFile: async () => ({ Body: { transformToString: async () => privateKey } }) }) },
|
||||
};
|
||||
globalThis.fetch = async () => ({ ok: true, json: async () => provider });
|
||||
globalThis.require = () => ({ initWithBatchMode: appId => ({
|
||||
track() {},
|
||||
trackFirst(event) {
|
||||
if (sdkError) throw new Error('synthetic analytics error');
|
||||
events.push({ appId, ...event });
|
||||
},
|
||||
close() {},
|
||||
}) });
|
||||
registerHooks({ resolve(specifier, context, next) {
|
||||
if (specifier === '@lafjs/cloud') return { url: 'data:text/javascript,export default globalThis.__rookieCloud', shortCircuit: true };
|
||||
if (specifier.startsWith('@/')) return { url: new URL('../functions/' + specifier.slice(2) + '.ts', import.meta.url).href, shortCircuit: true };
|
||||
return next(specifier, context);
|
||||
} });
|
||||
globalThis.require = () => ({
|
||||
initWithBatchMode: appId => ({
|
||||
track() { },
|
||||
trackFirst(event) {
|
||||
if (sdkError) throw new Error('synthetic analytics error');
|
||||
events.push({ appId, ...event });
|
||||
},
|
||||
close() { },
|
||||
})
|
||||
});
|
||||
registerHooks({
|
||||
resolve(specifier, context, next) {
|
||||
if (specifier === '@lafjs/cloud') return { url: 'data:text/javascript,export default globalThis.__rookieCloud', shortCircuit: true };
|
||||
if (specifier.startsWith('@/')) return { url: new URL('../functions/' + specifier.slice(2) + '.ts', import.meta.url).href, shortCircuit: true };
|
||||
return next(specifier, context);
|
||||
}
|
||||
});
|
||||
const { reportRookieGift, starterPackOrderSnapshot } = await import('../functions/limitedTimeEvent.ts');
|
||||
const { default: callback } = await import('../functions/wx/payCallBack.ts');
|
||||
const { default: query } = await import('../functions/wx/getPayInfo.ts');
|
||||
|
|
@ -197,9 +205,11 @@ test('merged legacy iOS creation and transfer retain battle pass metadata', asyn
|
|||
const user = reset(), passEnd = String(NOW + DAY);
|
||||
user.passCheck = JSON.stringify({ 2: { time: passEnd, activate: false } });
|
||||
shared.set('wxaccess_token', 'synthetic'); provider = { prepay_id: 'mock-prepay' };
|
||||
await customerService(ctx({ FromUserName: 'o', SessionFrom: JSON.stringify({
|
||||
tpye: 'ios', outTradeNo: 'pass-ios', propName: 'battlepass_30', count: 9, price: 1, passVersion: 2, passEnd,
|
||||
}) }));
|
||||
await customerService(ctx({
|
||||
FromUserName: 'o', SessionFrom: JSON.stringify({
|
||||
tpye: 'ios', outTradeNo: 'pass-ios', propName: 'battlepass_30', count: 9, price: 1, passVersion: 2, passEnd,
|
||||
})
|
||||
}));
|
||||
assert.equal(tables.iosOrder[0].passVersion, 2);
|
||||
assert.equal(tables.iosOrder[0].passEnd, passEnd);
|
||||
assert.equal(tables.iosOrder[0].goodsPrice, 3000);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user