shop-service.js
1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Created by TaoHuang on 2016/6/28.
*/
'use strict';
const Promise = require('bluebird');
const co = Promise.coroutine;
const _ = require('lodash');
const Api = require('./shop-api');
const DEFAULT_IMG = '01091c21f2317a64f123f1649fbbccf7ba';
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.api = new Api(ctx);
}
getShopBannerAsync(shopId) {
return this.api.shopBannerAsync(shopId).then((result) => {
if (result.code === 200) {
return _.includes(result.data.banner, DEFAULT_IMG) ? '' : result.data.banner;
} else {
return null;
}
});
}
queryShopByBrandIdAsync(sid, bid) {
return co(function * () {
let result = yield this.api.queryShopsByBrandId(sid, bid);
if (_.get(result, 'code') !== 200) {
return false;
}
return _.get(result, 'data[0]', {});
}).bind(this)();
}
};