Commit 7511a09c authored by 汪忙忙's avatar 汪忙忙

fix: 修改返回值

parent 1af1d053
......@@ -14,7 +14,7 @@ class AwardsService extends UserService{
this.activityprizedao = new BaseDao(context, PRIZE_CONFIG_DB_NAME);
}
// 根据奖品Id扣库存
// 根据奖品Id扣库存, 扣库存成功返回为1
async reduceStock(_id) {
let result = await this.activityprizedao.findOne({_id, deleteStatus: ACTIVITY_STATUS.NORMAL});
// 奖品不存在
......@@ -24,15 +24,15 @@ class AwardsService extends UserService{
let {switchStock, stock, useStock} = result;
// 若不限制库存
if (switchStock === 2) {
return true;
return 1;
}
// 若库存不足
if (useStock >= stock) {
return CODE_TYPES.ERROR_NO_STOCK;
}
try{
await this.activityprizedao.update(
{
return await this.activityprizedao.update(
{
_id ,
$where: "this.useStock < this.stock"
},
......@@ -42,9 +42,8 @@ class AwardsService extends UserService{
}
}
);
return true;
}catch(e) {
console.log(`扣库存(实物)失败:`, e);
console.log(`扣库存失败:`, e);
return CODE_TYPES.SYSTEM_ERROR;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment