students-handler.js
959 Bytes
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
/**
* 处理学生营销相关数据结构
* @date: 2016-08-06 18:20:52
* @author: sefon<809775195@qq.com>
*/
'use strict';
// const helpers = global.yoho.helpers;
const _ = require('lodash');
/**
* 优惠券
* @params data array
* @return Object
*/
const getCoupon = (data) => {
let dest = [];
_.forEach(data, (value) => {
dest.push(value);
});
return dest;
};
/**
* 处理学生营销资源位数据
* @params data array 资源位接口返回数据
* @return object
*/
exports.studentResource = (data) => {
let dest = {};
_.forEach(data, (value) => {
switch (value.template_name) {
case 'focus':
Object.assign(dest, {mainBanner: {list: value.data}});
break;
case 'getCoupon':
Object.assign(dest, getCoupon(value.data));
break;
default:
break;
}
});
return dest;
};