magazine.js
1.59 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const _ = require('lodash');
class magazineModel extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getMagazinePayment(uid, { sku, buyNumber }) {
return this.get({data: {
method: 'app.Shopping.virtual.ebook.payment',
product_sku: sku,
uid: uid,
buy_number: buyNumber || 1
}}).then((data) => {
if (data.code === 200) {
data = data.data;
let totalPrice = '';
let prices = _.forEach(_.get(data, 'eBook.prices'), val => {
if (val.select === 'Y') {
val.className = 'active';
totalPrice = val.price;
}
});
return {
goodsList: data.goods_list || [],
maxBuyNumber: _.get(data, 'eBook.maxBuyNumber'),
prices,
totalPrice,
};
}
return {};
});
}
computeMagazineOrder(uid, { sku, buyNumber }) {
return this.post({data: {
method: 'app.Shopping.virtual.ebook.compute',
product_sku: sku,
uid: uid,
buy_number: buyNumber || 1
}});
}
submitMagazineOrder(uid, { sku, buyNumber }) {
return this.post({data: {
method: 'app.Shopping.virtual.ebook.submit',
product_sku: sku,
uid: uid,
help_uid: uid.toString(),
buy_number: buyNumber || 1
}});
}
}
module.exports = magazineModel;