var system=require("../../system")
const http=require("http")
const querystring = require('querystring');
var settings=require("../../../config/settings");
const AppletBase =require("../applet.base");
class friendsApplet extends AppletBase{
   constructor(){
     super();
     this.businesschanceService=system.getObject("service.businesschanceSve");
     this.orderService=system.getObject("service.orderSve");
     this.userService=system.getObject("service.userSve");
     this.accountService=system.getObject("service.accountSve");
   }
   async getMyFriends(obj,req){
     console.log("---------------------getMyFriends------------------------------");
     var openid = obj.openid;
     var nickName = obj.nickName;
     console.log(openid);
     var userInfo =await this.cacheManager["AppletUserinfoCache"].get(openid);
     console.log(userInfo);
     if(userInfo){
       userInfo=JSON.parse(userInfo);
       if(!nickName){
         var accounts = await this.accountService.dao.model.findAll({where:{referrerOnlyCode:userInfo.unionId},raw:true});
         return accounts
       }else{
         var accounts = await this.accountService.dao.model.findAll({where:{referrerOnlyCode:userInfo.unionId,nickName:nickName},raw:true});
         return accounts
       }
     }else{
       return system.getResult2(null,null);
     }

   }
}
module.exports=friendsApplet;
