✨ feat(gift): 增加查询保底进度接口
This commit is contained in:
@@ -14,6 +14,7 @@ import { GiftCodeDetailModel } from "../../../db/GiftCodeDetail";
|
|||||||
import { GiftCodeType, GiftCodeModel } from "../../../db/GiftCode";
|
import { GiftCodeType, GiftCodeModel } from "../../../db/GiftCode";
|
||||||
import { nowSeconds } from "../../../pubUtils/timeUtil";
|
import { nowSeconds } from "../../../pubUtils/timeUtil";
|
||||||
import { AP } from "../../../pubUtils/dicParam";
|
import { AP } from "../../../pubUtils/dicParam";
|
||||||
|
import { GiftPackageFloorModel } from "../../../db/GiftPackageFloor";
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -56,6 +57,31 @@ export class ItemHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取礼包保底情况
|
||||||
|
public async getGiftPackageFloor(msg: { id: number }, session: BackendSession) {
|
||||||
|
let { id } = msg;
|
||||||
|
const roleId = session.get('roleId');
|
||||||
|
let dicGoods = gameData.goods.get(id);
|
||||||
|
if (!dicGoods) {
|
||||||
|
return resResult(STATUS.ACTIVITY_DATA_ERROR);
|
||||||
|
}
|
||||||
|
let dicItid = ITID.get(dicGoods.itid);
|
||||||
|
if (!dicItid) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||||
|
if (dicItid.type != CONSUME_TYPE.GIFT_PACKAGE) {
|
||||||
|
return resResult(STATUS.NOT_CONSUME_GOODS);
|
||||||
|
}
|
||||||
|
let giftID = dicGoods.gift;
|
||||||
|
if (!giftID) {
|
||||||
|
return resResult(STATUS.NOT_GIFTPACKAGE);
|
||||||
|
}
|
||||||
|
let giftPackageData = gameData.giftPackage.get(giftID);
|
||||||
|
if (!giftPackageData) {
|
||||||
|
return resResult(STATUS.NOT_GIFTPACKAGE);
|
||||||
|
}
|
||||||
|
let result = await GiftPackageFloorModel.findByGiftPackageId(roleId, giftPackageData.id, 'floors giftPackageId');
|
||||||
|
return resResult(STATUS.SUCCESS, result);
|
||||||
|
}
|
||||||
|
|
||||||
// 使用体力道具
|
// 使用体力道具
|
||||||
public async useApItem(msg: { id: number, count: number }, session: BackendSession) {
|
public async useApItem(msg: { id: number, count: number }, session: BackendSession) {
|
||||||
let { id, count } = msg;
|
let { id, count } = msg;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ describe('测试英杰传宝箱', function () {
|
|||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function (done) {
|
after(function (done) {
|
||||||
pinusClient.disconnect();
|
pinusClient.disconnect();
|
||||||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -44,4 +44,14 @@ describe('测试英杰传宝箱', function () {
|
|||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('查看保底情况', function (done) {
|
||||||
|
pinusClient.request('role.itemHandler.getGiftPackageFloor', {
|
||||||
|
id: GOOD_ID_RED_RAND,
|
||||||
|
}, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
console.log(JSON.stringify(res));
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ export default class GiftPackageFloor extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 根据礼包 id 查找
|
// 根据礼包 id 查找
|
||||||
public static async findByGiftPackageId(roleId: string, giftPackageId: number, lean = true) {
|
public static async findByGiftPackageId(roleId: string, giftPackageId: number, select = '', lean = true) {
|
||||||
const result: GiftPackageFloorType = await GiftPackageFloorModel.findOneAndUpdate({ roleId, giftPackageId}, {}, {new: true, upsert: true}).lean(lean);
|
const result: GiftPackageFloorType = await await GiftPackageFloorModel.findOneAndUpdate({ roleId, giftPackageId}, {}, {new: true, upsert: true}).select(select).lean(lean);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user