|
@@ -16,10 +16,10 @@ class CouponService extends CrudService {
|
|
|
async userView(filter, { skip = 0, limit, sort, desc, projection } = {}) {
|
|
|
const customer = _.get(this.ctx, 'user._id');
|
|
|
if (!customer) throw new BusinessError(ErrorCode.NOT_LOGIN, '未找到用户登陆信息');
|
|
|
- let list = await this.query({ ...filter, status: '0' }, { skip, limit, sort, desc, projection });
|
|
|
- list = await this.makeShowData(list);
|
|
|
+ let data = await this.query({ ...filter, status: '0' }, { skip, limit, sort, desc, projection });
|
|
|
+ data = await this.makeShowData(data);
|
|
|
// 还需要判断用户是否领取过了
|
|
|
- for (const coupon of list) {
|
|
|
+ for (const coupon of data) {
|
|
|
const { get_limit, get_limit_config } = coupon;
|
|
|
if (get_limit === 'nolimit') coupon.canGet = true;
|
|
|
else {
|
|
@@ -29,7 +29,8 @@ class CouponService extends CrudService {
|
|
|
else coupon.canGet = true;
|
|
|
}
|
|
|
}
|
|
|
- return list;
|
|
|
+ const total = await this.model.count({ ...filter, status: '0' });
|
|
|
+ return { data, total };
|
|
|
}
|
|
|
|
|
|
|