Commit c593d6d9 authored by 陈家荣's avatar 陈家荣

update

parent 62287ecf
......@@ -3,6 +3,15 @@
var _ = require('lodash');
var loadUserLevel = require('./loadUserLevel');
var async=require('async');
var request = require('request');
var env = process.env.NODE_ENV;
var API_ADDRESS = 'http://rest.wxpai.cn';
if (env == 'sandbox') {
API_ADDRESS = 'http://rest.wxpai.cn';
} else if (env == 'production') {
API_ADDRESS = 'https://rest.wxpai.cn';
}
exports.loadLevel=function(ent_code,items,callback){
var openIds = [];
......@@ -27,7 +36,7 @@ exports.loadLevel=function(ent_code,items,callback){
var tasks = [];
_.forEach(openIds, function(open_id) {
tasks.push(function(cont){
loadUserLevel.loadLevelFromAPI(ent_code,open_id,cont);
loadLevelFromAPI(ent_code,open_id,cont);
});
});
async.parallel(tasks,function(err,results){
......@@ -111,4 +120,21 @@ exports.loadLevelByUser=function(ent_code,items,callback){
}
return callback && callback();
});
};
function loadLevelFromAPI(ent_code,open_id,callback){
if(!ent_code || !open_id){
return callback && callback(null,null);
}
var url = API_ADDRESS + '/v1.0/internal/member/exp/byopenid?openId='+open_id+'&entCode='+ent_code;
request.get({
url: url,
json: {}
}, function(e, r, body) {
if (e) {
console.log(e)
}
return callback && callback(null,(body && body.data) || null);
});
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment