...
|
...
|
@@ -8,39 +8,7 @@ const api = require('./coupon-api'); |
|
|
const _ = require('lodash');
|
|
|
const decrypt = _.partial(global.yoho.crypto.decrypt, null);
|
|
|
|
|
|
const _acquireAsync = _.overArgs(api.acquireAsync, [decrypt, _ => _]);
|
|
|
|
|
|
const acquireAsync = (cid, uid) => {
|
|
|
return _acquireAsync(cid, uid).then(result => {
|
|
|
switch (result.code) {
|
|
|
case 200:
|
|
|
return {
|
|
|
code: 200,
|
|
|
message: '恭喜您,成功领取优惠券'
|
|
|
};
|
|
|
case 401:
|
|
|
return {
|
|
|
code: 401,
|
|
|
message: '您已领取过优惠券'
|
|
|
};
|
|
|
case 315:
|
|
|
return {
|
|
|
code: 315,
|
|
|
message: '优惠券已过期'
|
|
|
};
|
|
|
case 300:
|
|
|
return {
|
|
|
code: 300,
|
|
|
message: '请求参数错误'
|
|
|
};
|
|
|
default:
|
|
|
return {
|
|
|
code: 500,
|
|
|
message: '领券失败!'
|
|
|
};
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
const acquireAsync = _.overArgs(api.acquireAsync, [decrypt, _1 => _1]);
|
|
|
|
|
|
module.exports = {
|
|
|
acquireAsync,
|
...
|
...
|
|