|
@@ -40,16 +40,16 @@ class Dock_userService extends CrudService {
|
|
|
/**
|
|
|
* 申请参展的产品审核
|
|
|
* @param {Object} {id} 申请参展的产品的_id
|
|
|
- * @param {Object} {status} 要改变的状态
|
|
|
+ * @param {Object} {good_id, status} 要改变的状态
|
|
|
* 只要有一个产品通过审核,该用户就更变为可通过状态=>need_pass_user
|
|
|
*/
|
|
|
- async goodsCheck({ id }, { status }) {
|
|
|
- const object = await this.model.findOne({ goodsList: { $elemMatch: { _id: ObjectId(id) } } });
|
|
|
+ async goodsCheck({ id }, { good_id, status }) {
|
|
|
+ const object = await this.model.findOne({ _id: ObjectId(id), goodsList: { $elemMatch: { id: good_id } } });
|
|
|
if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到需要审核的产品信息');
|
|
|
- const product = object.goodsList.find(f => ObjectId(id).equals(f._id));
|
|
|
+ const product = object.goodsList.find(f => ObjectId(good_id).equals(f.id));
|
|
|
if (!product) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未在需要审核的产品中找到指定的产品');
|
|
|
product.status = status;
|
|
|
- await this.model.updateOne({ goodsList: { $elemMatch: { _id: ObjectId(id) } } }, object);
|
|
|
+ await this.model.updateOne({ _id: ObjectId(id), goodsList: { $elemMatch: { id: good_id } } }, object);
|
|
|
const need_pass_user = object.goodsList.some(e => e.status === '1');
|
|
|
if (need_pass_user) this.userCheck({ id: object._id }, { status: '1' });
|
|
|
}
|