Skip to content

Commit

Permalink
fix reset dishes
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Jun 20, 2024
1 parent 0b2aa9a commit f8f44c1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion adapters/rms/RMSAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,13 @@ class RMSAdapter {
const promise = new Promise(async (resolve, reject) => {
try {
let outOfStocksDishes = await this.loadOutOfStocksDishes();
const outOfStocksDishesIds = outOfStocksDishes.map(d => d.rmsId);
await Dish.update({
rmsId: { nin: outOfStocksDishesIds },
balance: { '!=': -1 }
}, { balance: -1 }).fetch();
for (let item of outOfStocksDishes) {
emitter.emit("rms-sync:out-of-stocks-before-each-product-item", item);
await Dish.update({ rmsId: { "!=": item.rmsId } }, { balance: -1 }).fetch();
await Dish.update({ rmsId: item.rmsId }, { balance: item.balance }).fetch();
}
return resolve();
Expand Down
7 changes: 6 additions & 1 deletion adapters/rms/RMSAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,15 @@ export default abstract class RMSAdapter {
const promise = new Promise<void>(async (resolve, reject) => {
try {
let outOfStocksDishes = await this.loadOutOfStocksDishes();
const outOfStocksDishesIds = outOfStocksDishes.map(d => d.rmsId);

await Dish.update({
rmsId: { nin: outOfStocksDishesIds },
balance: { '!=': -1 }
}, { balance: -1 }).fetch()

for(let item of outOfStocksDishes) {
emitter.emit("rms-sync:out-of-stocks-before-each-product-item", item);
await Dish.update({rmsId: {"!=": item.rmsId}}, {balance: -1}).fetch()
await Dish.update({rmsId: item.rmsId}, {balance: item.balance}).fetch()
}
return resolve();
Expand Down

0 comments on commit f8f44c1

Please sign in to comment.