diff --git a/game-server/app/servers/role/handler/itemHandler.ts b/game-server/app/servers/role/handler/itemHandler.ts index 8a21a89a7..a3ce72368 100644 --- a/game-server/app/servers/role/handler/itemHandler.ts +++ b/game-server/app/servers/role/handler/itemHandler.ts @@ -1,5 +1,5 @@ import { Application, BackendSession, HandlerService, } from "pinus"; -import { STATUS, CONSUME_TYPE, DEBUG_MAGIC_WORD, GIFT_GENERATE_TYPE, ITEM_CHANGE_REASON } from "../../../consts"; +import { STATUS, CONSUME_TYPE, DEBUG_MAGIC_WORD, GIFT_GENERATE_TYPE, ITEM_CHANGE_REASON, GIFT_TYPE } from "../../../consts"; import { RewardInter } from "../../../pubUtils/interface"; import { resResult } from "../../../pubUtils/util"; @@ -177,6 +177,7 @@ export class ItemHandler { if(!giftCode) { return resResult(STATUS.GIFT_CODE_NOT_FOUND); } + if(giftCode.type != GIFT_TYPE.GAME) return resResult(STATUS.GIFT_TYPE_ERR); if(giftCode.generateType == GIFT_GENERATE_TYPE.ONE_TO_ONE) { // 一人一条,单条不能被多人使用 if(giftCodeDetail.usedNum > 0) return resResult(STATUS.GIFT_CODE_USED_NUM_MAX); } diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index d61df8ecd..76fe92ab0 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -975,6 +975,11 @@ export enum GIFT_GENERATE_TYPE { ONE_TO_MANY = 2, // 通码,一条码能被多人使用,每个人只能用一次 } +export enum GIFT_TYPE { + GAME = 1, // 游戏内码 + WEB = 2, // 外链发送 +} + export enum ITEM_CHANGE_REASON { DEBUG = 0, // debug接口、后台 RENAME = 1, // 重命名 diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index f10d98bfa..a64cfa7d4 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -599,6 +599,7 @@ export const STATUS = { GIFT_CODE_HAS_EXPIRED: { code: 31204, simStr: '礼包码已失效' }, GIFT_CODE_NOT_FOUND: { code: 31205, simStr: '未找到该礼包码' }, GIFT_CODE_CHANNEL_ERR: { code: 31206, simStr: '礼包码在您的渠道不生效' }, + GIFT_TYPE_ERR: { code: 31207, simStr: '该礼包码不可在此界面使用' }, // 邮件相关 31301-31400 MAIL_HAS_RECEIVE: { code: 31301, simStr: '邮件已领取'}, EQUIP_IS_OVER: { code: 31302, simStr: '装备已超过上限,无法领取' }, @@ -816,4 +817,5 @@ export const SDK_37_ACTIVITY_CODE = { TIME_IS_EXPIRED: { code: 20008, simStr: '时间戳已过期' }, SERVER_NOT_FOUND: { code: 20009, simStr: '服务器未找到' }, GIFT_CODE_CANNOT_USE: { code: 20010, simStr: '该礼包码不可使用' }, + GIFT_TYPE_ERR: { code: 20011, simStr: '该礼包码类型错误' }, } \ No newline at end of file diff --git a/shared/db/GiftCode.ts b/shared/db/GiftCode.ts index 2a6d3b598..96dd57348 100644 --- a/shared/db/GiftCode.ts +++ b/shared/db/GiftCode.ts @@ -53,7 +53,7 @@ export default class GiftCode extends BaseModel { usedNum: number; // 使用次数 @prop({ required: true, default: 0 }) - type: number; // 0-游戏内领取 1-公众号口令活动领取 2-邮件领取 + type: number; // 0-游戏内领取 1-邮件领取 @prop({ required: true, default: true }) isEnable: boolean; // 是否可以使用 @@ -76,7 +76,6 @@ export default class GiftCode extends BaseModel { } public static async updateData(id: number, values: GiftCodeParam, uid = 1) { - let rec: GiftCodeType = await GiftCodeModel.findOneAndUpdate({ id }, { $set: {...values, updatedBy: uid} }, { new: true }).lean(true); return rec; diff --git a/shared/domain/backEndField/params.ts b/shared/domain/backEndField/params.ts index 71c4a3128..2fe912ad5 100644 --- a/shared/domain/backEndField/params.ts +++ b/shared/domain/backEndField/params.ts @@ -275,6 +275,7 @@ export class UpdateGiftCode { endTime: number; // 结束时间 codeLen: number; // 礼包码位数 remark: string = ''; // 备注 + type: number; // 类型 0-游戏内 1-外链调用 constructor(id: number, obj: any) { this.id = id; @@ -284,6 +285,7 @@ export class UpdateGiftCode { this.endTime = obj.endTime; this.codeLen = obj.codeLen; this.remark = obj.remark; + this.type = obj.type; } checkParams() { @@ -295,6 +297,7 @@ export class UpdateGiftCode { } if(!isTimestamp(this.beginTime) || !isTimestamp(this.endTime)) return false; if(!isNumber(this.codeLen) || this.codeLen <= 0) return false; + if(this.type != 0 && this.type != 1) return false; return true; } } diff --git a/web-server/app/service/Sdk.ts b/web-server/app/service/Sdk.ts index 26de94430..18ff7bc47 100644 --- a/web-server/app/service/Sdk.ts +++ b/web-server/app/service/Sdk.ts @@ -1,6 +1,6 @@ import { Service } from 'egg'; -import { REDIS_KEY, PAY_37_CALLBACK_CODE, SDK_37_CONST, ORDER_STATE, SDK_37_TREAT_CODE, SERVER_STATUS, SDK_37_REFUND_CODE, SDK_37_ACTIVITY_CODE, PUBLIC_ACCOUNT_GIFT, GIFT_GENERATE_TYPE } from '@consts'; +import { REDIS_KEY, PAY_37_CALLBACK_CODE, SDK_37_CONST, ORDER_STATE, SDK_37_TREAT_CODE, SERVER_STATUS, SDK_37_REFUND_CODE, SDK_37_ACTIVITY_CODE, PUBLIC_ACCOUNT_GIFT, GIFT_GENERATE_TYPE, GIFT_TYPE } from '@consts'; import { GetGuildInfoByUserParam, GetRoleByServerParam, GetRoleByUidParam, GetServerAndUidParam, GetServerListParam, GetServerParam, GuildNameCallBackParam, IOSRefundParam, PayCallback37Data, RoleNameCallBackParam, SendGiftCodeParam } from '../domain/sdk'; import { RedisClient } from 'redis'; import { checkParamPrice, get37GetServerMd5Sign, get37Md5SignA, get37Md5SignB, getChannelId, getRedisSubChannel, md5 } from '../pubUtils/sdkUtil'; @@ -455,6 +455,7 @@ export default class Sdk extends Service { if(!giftCode) { return resResult(SDK_37_ACTIVITY_CODE.GIFT_NOT_FOUND); } + if(giftCode.type != GIFT_TYPE.WEB) return resResult(SDK_37_ACTIVITY_CODE.GIFT_TYPE_ERR); if(giftCode.generateType == GIFT_GENERATE_TYPE.ONE_TO_ONE) { // 一人一条,单条不能被多人使用 if(giftCodeDetail.usedNum > 0) return resResult(SDK_37_ACTIVITY_CODE.GIFT_CODE_CANNOT_USE); }