🎈 perf(活动): 活动通用商店添加count字段
This commit is contained in:
@@ -42,8 +42,8 @@ export class RefreshShopHandler {
|
|||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof RefreshShopHandler
|
* @memberof RefreshShopHandler
|
||||||
*/
|
*/
|
||||||
async buyGood(msg: { activityId: number, roundIndex: number, id: number, pageIndex: number }, session: BackendSession) {
|
async buyGood(msg: { activityId: number, roundIndex: number, id: number, pageIndex: number, count: number }, session: BackendSession) {
|
||||||
const { activityId, roundIndex, id, pageIndex } = msg;
|
const { activityId, roundIndex, id, pageIndex, count = 1 } = msg;
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
@@ -63,7 +63,7 @@ export class RefreshShopHandler {
|
|||||||
if (!item) {
|
if (!item) {
|
||||||
return resResult(STATUS.ACTIVITY_ID_ERROR);
|
return resResult(STATUS.ACTIVITY_ID_ERROR);
|
||||||
}
|
}
|
||||||
if (item.countMax > 0 && item.buyCount >= item.countMax) {
|
if (item.countMax > 0 && item.buyCount + count > item.countMax) {
|
||||||
return resResult(STATUS.ACTIVITY_MAX_COUNT);
|
return resResult(STATUS.ACTIVITY_MAX_COUNT);
|
||||||
}
|
}
|
||||||
if (item.price > 0) {
|
if (item.price > 0) {
|
||||||
@@ -71,16 +71,17 @@ export class RefreshShopHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//检查资源
|
//检查资源
|
||||||
let consume = stringToConsumeParam(item.consume)
|
let consumeArr = new Array<string>(count).fill(item.consume);
|
||||||
|
let consume = stringToConsumeParam(...consumeArr);
|
||||||
let consumeResult = await handleCost(roleId, sid, consume, ITEM_CHANGE_REASON.BUY_REFRESH_SHOP);
|
let consumeResult = await handleCost(roleId, sid, consume, ITEM_CHANGE_REASON.BUY_REFRESH_SHOP);
|
||||||
if (!consumeResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
if (!consumeResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||||
|
|
||||||
let rewardArray = stringToRewardParam(item.reward)
|
let rewardArray = stringToRewardParam(item.reward).map(cur => ({...cur, count: cur.count * count }));
|
||||||
let result = await addReward(roleId, roleName, sid, serverId, rewardArray, ITEM_CHANGE_REASON.BUY_REFRESH_SHOP);
|
let result = await addReward(roleId, roleName, sid, serverId, rewardArray, ITEM_CHANGE_REASON.BUY_REFRESH_SHOP);
|
||||||
|
|
||||||
await ActivityRefreshShopModel.addRecord(activityId, roleId, roundIndex, pageIndex, id);
|
await ActivityRefreshShopModel.addRecord(activityId, roleId, roundIndex, pageIndex, id);
|
||||||
|
|
||||||
item.buyCount += 1;
|
item.buyCount += count;
|
||||||
return resResult(STATUS.SUCCESS, Object.assign(result, {
|
return resResult(STATUS.SUCCESS, Object.assign(result, {
|
||||||
param: { activityId, roundIndex, id },
|
param: { activityId, roundIndex, id },
|
||||||
item: item
|
item: item
|
||||||
|
|||||||
@@ -303,8 +303,8 @@ export function checkRouteParam(route: string, msg: any) {
|
|||||||
}
|
}
|
||||||
case 'activity.refreshShopHandler.buyGood':
|
case 'activity.refreshShopHandler.buyGood':
|
||||||
{
|
{
|
||||||
let { activityId, roundIndex, id, pageIndex } = msg;
|
let { activityId, roundIndex, id, pageIndex, count } = msg;
|
||||||
if(!checkNaturalNumbers(activityId, roundIndex, id, pageIndex)) return false;
|
if(!checkNaturalNumbers(activityId, roundIndex, id, pageIndex, count)) return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'activity.refreshTaskHandler.getReward':
|
case 'activity.refreshTaskHandler.getReward':
|
||||||
|
|||||||
Reference in New Issue
Block a user