🐞 fix(拍卖行): 修复拍卖行发生的很多问题
This commit is contained in:
@@ -106,21 +106,30 @@ export class AuctionHandler {
|
|||||||
return resResult(STATUS.ROLE_COIN_NOT_ENOUGH);
|
return resResult(STATUS.ROLE_COIN_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curBuyer && prePrice > 0) {
|
|
||||||
await sendMailByContent(MAIL_TYPE.AUCTION_OVER, curBuyer, { goods: [getGoldObject(prePrice)] });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxFlag) {
|
|
||||||
newPrice = maxPrice;
|
|
||||||
await sendMailByContent(MAIL_TYPE.AUTION_REWARD, roleId, { goods: [{ id: gid, count }] });
|
|
||||||
let dicGoods = gameData.goods.get(gid);
|
|
||||||
reportTAEvent(roleId, TA_EVENT.AUCTION_ITEM_GET, { item_name: dicGoods?.name, item_count: count, deel_price: newPrice }, ip);
|
|
||||||
}
|
|
||||||
bidRoles.push({ roleId, price: newPrice, time: new Date() });
|
bidRoles.push({ roleId, price: newPrice, time: new Date() });
|
||||||
let lotStatus = await getLotStatus(auctionStage, max, maxFlag)
|
let lotStatus = await getLotStatus(auctionStage, max, maxFlag)
|
||||||
let update: LotParam = { code, curBuyer: roleId, curPrice: newPrice, auctionStage, prePrice: curPrice, bidRoles, status: lotStatus, watchingRoles: Array.from(new Set([...watchingRoles, roleId])), seq: 0 };
|
let update: LotParam = { code, curBuyer: roleId, curPrice: newPrice, auctionStage, prePrice: curPrice, bidRoles, status: lotStatus, watchingRoles: Array.from(new Set([...watchingRoles, roleId])), seq: 0 };
|
||||||
if(lotStatus == LOT_STATUS.BIDDING) update.end = new Date(Date.now() + AUCTION_BID_EXTEND_TIME * 1000);
|
if(lotStatus == LOT_STATUS.BIDDING) update.end = new Date(Date.now() + AUCTION_BID_EXTEND_TIME * 1000);
|
||||||
const newLot = await LotModel.updateLot(update);
|
const newLot = await LotModel.updateLot(update);
|
||||||
|
if(!newLot) {
|
||||||
|
// 如果拍卖行状态不对,那回退handleCost
|
||||||
|
if (curBuyer && prePrice > 0) {
|
||||||
|
await sendMailByContent(MAIL_TYPE.AUCTION_OVER, roleId, { goods: [getGoldObject(curPrice)] });
|
||||||
|
}
|
||||||
|
res.releaseCallback();
|
||||||
|
return resResult(STATUS.GUILD_LOT_HAS_SOLD);
|
||||||
|
} else {
|
||||||
|
if (curBuyer && prePrice > 0) {
|
||||||
|
await sendMailByContent(MAIL_TYPE.AUCTION_OVER, curBuyer, { goods: [getGoldObject(prePrice)] });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxFlag) {
|
||||||
|
newPrice = maxPrice;
|
||||||
|
await sendMailByContent(MAIL_TYPE.AUTION_REWARD, roleId, { goods: [{ id: gid, count }] });
|
||||||
|
let dicGoods = gameData.goods.get(gid);
|
||||||
|
reportTAEvent(roleId, TA_EVENT.AUCTION_ITEM_GET, { item_name: dicGoods?.name, item_count: count, deel_price: newPrice }, ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
await extendLotTime(newLot);
|
await extendLotTime(newLot);
|
||||||
if(seq <= LOTS_KEEP_TO_WORLD_CNT && seq > 0) await LotModel.updateOne({ begin, gid, count, status: LOT_STATUS.DEFAULT, serverId, seq: { $gt: LOTS_KEEP_TO_WORLD_CNT } }, { $set: { seq }});
|
if(seq <= LOTS_KEEP_TO_WORLD_CNT && seq > 0) await LotModel.updateOne({ begin, gid, count, status: LOT_STATUS.DEFAULT, serverId, seq: { $gt: LOTS_KEEP_TO_WORLD_CNT } }, { $set: { seq }});
|
||||||
await pushAuctionOver(newLot); // 推送竞价超过标志
|
await pushAuctionOver(newLot); // 推送竞价超过标志
|
||||||
|
|||||||
@@ -569,9 +569,8 @@ export async function getLotStatus(auctionStage: number, max: boolean, maxFlag:
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function extendLotTime(lot: LotType) {
|
export async function extendLotTime(lot: LotType) {
|
||||||
if(lot.status != LOT_STATUS.BIDDING) {
|
clearLotTimer(lot.code);
|
||||||
clearLotTimer(lot.code);
|
if(lot.status == LOT_STATUS.BIDDING) {
|
||||||
} else {
|
|
||||||
let timer = setTimeout(async () => {
|
let timer = setTimeout(async () => {
|
||||||
await sendSingleLot(lot.code);
|
await sendSingleLot(lot.code);
|
||||||
}, lot.end.getTime() - Date.now());
|
}, lot.end.getTime() - Date.now());
|
||||||
@@ -582,6 +581,7 @@ export async function extendLotTime(lot: LotType) {
|
|||||||
export async function sendSingleLot(code: string) {
|
export async function sendSingleLot(code: string) {
|
||||||
console.log('schedule sendSingleLot called:', new Date());
|
console.log('schedule sendSingleLot called:', new Date());
|
||||||
let lot = await LotModel.setLotSold(code, AUCTION_STAGE.GUILD); // 正在竞拍的拍品
|
let lot = await LotModel.setLotSold(code, AUCTION_STAGE.GUILD); // 正在竞拍的拍品
|
||||||
|
if(!lot) return;
|
||||||
await sendLotsRewardToMlail([lot]);
|
await sendLotsRewardToMlail([lot]);
|
||||||
await pushAuctionOver(lot);
|
await pushAuctionOver(lot);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -321,5 +321,5 @@ export enum WISH_POOL_TYPE {
|
|||||||
SOUL = 1, // 将魂
|
SOUL = 1, // 将魂
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AUCTION_BID_TIME = 30; // 倒计时10s前需要向后延长结算
|
export const AUCTION_BID_TIME = 10; // 倒计时10s前需要向后延长结算
|
||||||
export const AUCTION_BID_EXTEND_TIME = 40; // 向后延长15s
|
export const AUCTION_BID_EXTEND_TIME = 15; // 向后延长15s
|
||||||
@@ -105,7 +105,7 @@ export default class Lot extends BaseModel {
|
|||||||
if(data.status == LOT_STATUS.SOLD|| data.status == LOT_STATUS.MAX) {
|
if(data.status == LOT_STATUS.SOLD|| data.status == LOT_STATUS.MAX) {
|
||||||
data.saveAuctionStage = data.auctionStage;
|
data.saveAuctionStage = data.auctionStage;
|
||||||
}
|
}
|
||||||
const result: LotType = await LotModel.findOneAndUpdate({ code }, { ...data }, { new: true }).select('-_id -__v').lean();
|
const result: LotType = await LotModel.findOneAndUpdate({ code, status: { $in: [LOT_STATUS.DEFAULT, LOT_STATUS.BIDDING, LOT_STATUS.ING]} }, { ...data }, { new: true }).select('-_id -__v').lean();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user