军团:修改拍卖行价格
This commit is contained in:
@@ -73,25 +73,26 @@ export class AuctionHandler {
|
|||||||
return resResult(STATUS.AUCTION_GUILD_MEMBER_ONLY);
|
return resResult(STATUS.AUCTION_GUILD_MEMBER_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { curBuyer, curPrice, maxPrice, gid, count, bidRoles, watchingRoles } = lot;
|
let { curBuyer, curPrice, prePrice, maxPrice, gid, count, bidRoles, watchingRoles } = lot;
|
||||||
if (curBuyer === roleId && !max) {
|
if (curBuyer === roleId && !max) {
|
||||||
res.releaseCallback();
|
res.releaseCallback();
|
||||||
return resResult(STATUS.LOT_OFFER_SERIAL);
|
return resResult(STATUS.LOT_OFFER_SERIAL);
|
||||||
}
|
}
|
||||||
let newPrice = Math.floor(curPrice * dicParam.GUILD_AUCTION.AUCTION_PRICE_RISE);
|
let newPrice = Math.floor(curPrice * dicParam.GUILD_AUCTION.AUCTION_PRICE_RISE);
|
||||||
let maxFlag = max;
|
let maxFlag = max;
|
||||||
if (newPrice >= maxPrice) {
|
if (curPrice >= maxPrice) {
|
||||||
|
curPrice = maxPrice;
|
||||||
newPrice = maxPrice;
|
newPrice = maxPrice;
|
||||||
maxFlag = true;
|
maxFlag = true;
|
||||||
}
|
}
|
||||||
const costRes = await handleCost(roleId, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count: newPrice }], ITEM_CHANGE_REASON.AUCTION_OFFER);
|
const costRes = await handleCost(roleId, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count: curPrice }], ITEM_CHANGE_REASON.AUCTION_OFFER);
|
||||||
if (!costRes) {
|
if (!costRes) {
|
||||||
res.releaseCallback();
|
res.releaseCallback();
|
||||||
return resResult(STATUS.ROLE_COIN_NOT_ENOUGH);
|
return resResult(STATUS.ROLE_COIN_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curBuyer) {
|
if (curBuyer && prePrice > 0) {
|
||||||
await sendMailByContent(MAIL_TYPE.AUCTION_OVER, curBuyer, { goods: [getGoldObject(curPrice)] });
|
await sendMailByContent(MAIL_TYPE.AUCTION_OVER, curBuyer, { goods: [getGoldObject(prePrice)] });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxFlag) {
|
if (maxFlag) {
|
||||||
@@ -101,7 +102,7 @@ export class AuctionHandler {
|
|||||||
reportTAEvent(roleId, TA_EVENT.AUCTION_ITEM_GET, { item_name: dicGoods?.name, item_count: count, deel_price: newPrice }, ip);
|
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() });
|
||||||
const newLot = await LotModel.updateLot({ code, curBuyer: roleId, curPrice: newPrice, bidRoles, status: max ? LOT_STATUS.MAX : (maxFlag ? LOT_STATUS.SOLD : LOT_STATUS.ING), watchingRoles: Array.from(new Set([...watchingRoles, roleId])) });
|
const newLot = await LotModel.updateLot({ code, curBuyer: roleId, curPrice: newPrice, prePrice: curPrice, bidRoles, status: max ? LOT_STATUS.MAX : (maxFlag ? LOT_STATUS.SOLD : LOT_STATUS.ING), watchingRoles: Array.from(new Set([...watchingRoles, roleId])) });
|
||||||
await pushAuctionOver(newLot); // 推送竞价超过标志
|
await pushAuctionOver(newLot); // 推送竞价超过标志
|
||||||
res.releaseCallback();
|
res.releaseCallback();
|
||||||
|
|
||||||
@@ -194,9 +195,9 @@ export class AuctionHandler {
|
|||||||
});
|
});
|
||||||
const lotRecs = lotsData.map(lot => {
|
const lotRecs = lotsData.map(lot => {
|
||||||
const { gid, count, price: lotPrice } = lot;
|
const { gid, count, price: lotPrice } = lot;
|
||||||
const price = lotPrice === 0 ? getBasePrice(gid, count) : lotPrice;
|
// const price = lotPrice === 0 ? getBasePrice(gid, count) : lotPrice;
|
||||||
const sold = guildBidStatus(lot);
|
const sold = guildBidStatus(lot);
|
||||||
return { ...lot, price, sold };
|
return { ...lot, price: lotPrice, sold };
|
||||||
});
|
});
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { lotRecs });
|
return resResult(STATUS.SUCCESS, { lotRecs });
|
||||||
|
|||||||
@@ -210,15 +210,15 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
|||||||
return {
|
return {
|
||||||
auctionStage: AUCTION_STAGE.DEFAULT, sourceType,
|
auctionStage: AUCTION_STAGE.DEFAULT, sourceType,
|
||||||
sourceCode, serverId, guildCode, code, gid: id, count, begin, end, status: LOT_STATUS.DEFAULT,
|
sourceCode, serverId, guildCode, code, gid: id, count, begin, end, status: LOT_STATUS.DEFAULT,
|
||||||
maxPrice, curPrice: basePrice, sort
|
maxPrice, curPrice: basePrice, prePrice: 0, sort
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const lots = await LotModel.createRecs(lotsData);
|
const lots = await LotModel.createRecs(lotsData);
|
||||||
const dividendCode = genCode(DIVIDEND_CODE_LEN);
|
const dividendCode = genCode(DIVIDEND_CODE_LEN);
|
||||||
const dividendData: DividendParam = {
|
const dividendData: DividendParam = {
|
||||||
guildCode, sourceType, sourceCode, serverId, code: dividendCode, dividends: [], totalPrice: 0, begin, lots: lots.map(lot => {
|
guildCode, sourceType, sourceCode, serverId, code: dividendCode, dividends: [], totalPrice: 0, begin, lots: lots.map(lot => {
|
||||||
const { code, gid } = lot;
|
const { code, gid, curPrice } = lot;
|
||||||
return { code, gid, price: 0, time: guildEnd, max: false, count: lot.count }
|
return { code, gid, price: curPrice, time: guildEnd, max: false, count: lot.count }
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
const dividend = await DividendModel.createDividend(dividendData);
|
const dividend = await DividendModel.createDividend(dividendData);
|
||||||
@@ -402,7 +402,7 @@ export function auctionBidStatus(roleId: string, lot: LotParam) {
|
|||||||
|
|
||||||
export function guildBidStatus(lot: { max: boolean, gid: number, count: number, price: number, dividendStatus: number }) {
|
export function guildBidStatus(lot: { max: boolean, gid: number, count: number, price: number, dividendStatus: number }) {
|
||||||
const { max, gid, count, price: lotPrice, dividendStatus } = lot;
|
const { max, gid, count, price: lotPrice, dividendStatus } = lot;
|
||||||
return max || lotPrice === getMaxPrice(gid, count) || ((dividendStatus == DIVIDEND_STATUS.END || dividendStatus == DIVIDEND_STATUS.SENT) && lotPrice !== 0)
|
return max || ((dividendStatus == DIVIDEND_STATUS.END || dividendStatus == DIVIDEND_STATUS.SENT) && lotPrice !== 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function sendUngotDividend(debug = false) {
|
export async function sendUngotDividend(debug = false) {
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ export default class Lot extends BaseModel {
|
|||||||
@prop({ required: true, default: 1 })
|
@prop({ required: true, default: 1 })
|
||||||
count: number; // 物品数量
|
count: number; // 物品数量
|
||||||
@prop({ required: true, default: 0 })
|
@prop({ required: true, default: 0 })
|
||||||
|
prePrice: number; // 当前出价
|
||||||
|
@prop({ required: true, default: 0 })
|
||||||
curPrice: number; // 当前出价
|
curPrice: number; // 当前出价
|
||||||
@prop({ required: false, default: '' })
|
@prop({ required: false, default: '' })
|
||||||
curBuyer: string; // 当前出价最高者 RoleId
|
curBuyer: string; // 当前出价最高者 RoleId
|
||||||
|
|||||||
Reference in New Issue
Block a user