feat(活动): 微信公众号口令

This commit is contained in:
luying
2023-04-04 10:11:05 +08:00
parent 94b6dca4cc
commit cecd959c00
22 changed files with 441 additions and 43 deletions

View File

@@ -5,6 +5,7 @@ import { ActivityBindPhoneRewardType } from '../../db/ActivityBindPhoneReward';
import { LinkType } from '../../db/Link';
import { UserType } from '../../db/User';
import { ActivityBase } from './activityField';
import { ActivityPublicAccountCodeType } from '../../db/ActivityPublicAccountCode';
// 数据库
interface PageDataInDb {
@@ -12,7 +13,6 @@ interface PageDataInDb {
pageName: string;
type: number;
rewards: string;
giftCode: string;
}
interface BindPhoneDataInDb {
@@ -49,18 +49,21 @@ class BindPhonePage extends PageData {
super(pageData);
this.rewards = pageData.rewards;
}
public setBindPhoneStatus(user: UserType, data: ActivityBindPhoneRewardType) {
if(user && user.channelInfo && user.channelInfo.is_phone_bind == 1) this.status = BIND_PHONE_STATUS.HAS_BIND;
if(data) this.status = data.status;
}
}
class WXPublicAccountPage extends PageData {
qrCodeLink: string; // 公众号二维码
rewards: string; // 口令能有的奖励
originGiftCode: string; // 加密后的口令
giftCode: string; // 加密后的口令
status: number = BIND_PHONE_STATUS.WAIT_BIND; // 状态 0-未使用 1-可领取 2-已领取
constructor(pageData: PageDataInDb) {
super(pageData);
this.originGiftCode = pageData.giftCode;
this.rewards = pageData.rewards;
}
@@ -72,6 +75,11 @@ class WXPublicAccountPage extends PageData {
this.giftCode = giftCode;
}
public setPlayerRecord(playerRecord: ActivityPublicAccountCodeType) {
if(!playerRecord) return;
this.status = playerRecord.hasReceived? BIND_PHONE_STATUS.HAS_BIND: BIND_PHONE_STATUS.RECEIVED;
}
public getShowResult() {
return pick(this, ['pageIndex', 'pageName', 'type', 'qrCodeLink', 'rewards', 'giftCode', 'status']);
}
@@ -133,15 +141,8 @@ export class BindPhoneData extends ActivityBase {
}
}
public setBindPhoneStatus(user: UserType, data: ActivityBindPhoneRewardType) {
if(this.bindPhone) {
if(user && user.channelInfo && user.channelInfo.is_phone_bind == 1) this.bindPhone.status = BIND_PHONE_STATUS.HAS_BIND;
if(data) this.bindPhone.status = data.status;
}
}
public getShowResult() {
let pages: (WXGroupPage|BindPhonePage|WXPublicAccountPage|BBSPage)[] = [];
let pages: any[] = [];
if(this.wxGroup) pages.push(this.wxGroup);
if(this.bindPhone) pages.push(this.bindPhone);
if(this.wxPublicAccount) pages.push(this.wxPublicAccount.getShowResult());

View File

@@ -419,4 +419,33 @@ export class PushMsg37Param {
public setSign(sign: string) {
this.sign = sign;
}
}
export class SendGiftCodeParam {
user_id: number; // 用户id
server_id: number; // 区服id
role_id: string; // 角色id
gift_id: string; // 礼包id
order_id: string; // 订单号
time: number; // 时间戳
sign: string; // 37给的签名
constructor(data: any) {
this.user_id = data.user_id;
this.server_id = data.server_id;
this.role_id = data.role_id;
this.gift_id = data.gift_id;
this.order_id = data.order_id;
this.time = data.time;
this.sign = data.sign;
}
checkParams() {
return this.user_id != undefined && this.server_id != undefined && this.gift_id != undefined && this.order_id != undefined && this.time != undefined && this.sign != undefined
}
getBody() {
let { user_id, server_id, role_id, gift_id, order_id, time } = this;
return { user_id, server_id, role_id, gift_id, order_id, time }
}
}