Revert "✨ feat(db): 修改对item表的数据库操作方式"

This reverts commit 97a36fda70fc1ccbb7f310b04d149f46f997a614.
This commit is contained in:
luying
2023-05-22 19:41:04 +08:00
parent 7700ed438a
commit 024f1e2776
7 changed files with 23 additions and 23 deletions
@@ -1,6 +1,6 @@
import { CURRENCY_TYPE, HANDLE_REWARD_TYPE, CURRENCY_BY_TYPE } from '../../consts';
import Role, { RoleType } from '../../db/Role';
import Item, { ItemType } from '../../db/Item';
import { ItemModel, ItemType } from '../../db/Item';
import { ItemInter, RewardInter, } from '../../pubUtils/interface';
import { gameData } from '../../pubUtils/data';
import { sortItems } from './util';
@@ -81,7 +81,7 @@ export class CheckMeterial {
private async decreaseItem(id: number, count: number) {
console.log('#### decreaseItem 1', id, count);
if(!this.itemsIndb.has(id)) {
let item = await Item.findbyRoleAndGid(this.roleId, id);
let item = await ItemModel.findbyRoleAndGid(this.roleId, id);
console.log('#### decreaseItem', item);
if(!item) {
this.pushToNotEnoughItems(id, count);
@@ -2,7 +2,7 @@ import { ITID, CONSUME_TYPE, ITEM_TABLE, CURRENCY_TYPE, MAIL_TYPE, HANDLE_REWARD
import { getDecimalCnt, getRandEelm, getRandEelmWithWeight, getRandValueByMinMax, } from '../../pubUtils/util';
import Role, { RoleType } from '../../db/Role';
import { setAp } from '../actionPointService';
import Item from '../../db/Item';
import { ItemModel, } from '../../db/Item';
import { ItemInter, } from '../../pubUtils/interface';
import { gameData, getDefArtifactByGid } from '../../pubUtils/data';
import { uniq } from 'underscore';
@@ -59,7 +59,7 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
}
//检查并修改道具
if (items.length > 0) {
let { hasError, result } = await Item.decreaseItems(roleId, items);
let { hasError, result } = await ItemModel.decreaseItems(roleId, items);
if (hasError) return false;
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.ITEM_UPDATE, { goods: result.map(cur => ({...cur, reason })) }, sid);
saveItemChangeLog(roleId, result, reason);
@@ -340,7 +340,7 @@ export async function checkGoods(roleId: string, goodIds: Array<number>) {
}
//检查并修改道具
if (itemIds.length > 0) {
let items = await Item.findbyRoleAndIds(roleId, itemIds);
let items = await ItemModel.findbyRoleAndIds(roleId, itemIds);
if (items.length < itemIds.length)
return false;
}
@@ -460,7 +460,7 @@ export async function addBag(roleId: string, roleName: string, data: { id: numbe
let { name: itemName, itid, hid } = gameData.goods.get(id);
let { type } = ITID.get(itid);
let item = await Item.increaseItem(roleId, id, count, { roleId, roleName, itemName, id, type, hid });
let item = await ItemModel.increaseItem(roleId, id, count, { roleId, roleName, itemName, id, type, hid });
return { id: item.id, count: item.count, inc: count, reason };
}