123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- /**
- * Created by MyPC on 2019/11/5.
- */
- const hash=require('../class/hash');
- const cloudService=require('../service/cloudEditionService');
- const operateLogService=require('../service/operateLogService');
- const url=require("url");
- var models=require('../models');
- var cloudEditionAjaxController={
- //获得养护信息
- getCuringInfo: async function(req, res){
- if(!hash.isNotANumber(req.params.mobile)){
- res.json({ 'status': 0,'msg':'error mobile' });
- return ;
- }
- //获得本地绑定CLD客户用户
- var bcDetail= await cloudService.getBindCuringByMobile(req.params.mobile);
- var cDetail= await cloudService.getCuringByMobile(req.params.mobile);
- //数据组合
- /*var detail={};
- if(hash.isExistence(bcDetail)){
- detail=bcDetail;
- }
- if(hash.isExistence(cDetail)){
- detail['mobile']=cDetail['userInfo']['mobile'];
- detail['email']=cDetail['userInfo']['email'];
- detail['username']=cDetail['userInfo']['username'];
- detail['create_time']=cDetail['userInfo']['create_time'];
- detail['company']=cDetail['userInfo']['company'];
- detail['province']=cDetail['userInfo']['province'];
- detail['upgrade_list']=cDetail['userInfo']['upgrade_list'];
- detail['curing']=cDetail;
- }*/
- //console.log(detail);
- if(!hash.isExistence(bcDetail)){//没有绑定CLD客户
- if(!hash.isExistence(cDetail)){
- res.header("Content-Type", "application/json; charset=utf-8")
- res.json({ 'status': 3,'msg':'该号码未注册养护项目' });
- return ;
- }
- res.json({ 'status': 2,'msg':'已升级用户列表不存在' });//未绑定CLD客户
- }else{
- res.json({ 'status': 1,'detail':bcDetail });
- }
- },
- //根据编办ID获得养护升级用户
- getCuringByCompilationId: async function(req, res){
- var compilation_id=req.params.compilation_id;
- var curingList= await cloudService.getCuringList(compilation_id);
- res.json({ 'status': 1,'curingList':curingList.curingList,'pageData':curingList.pageData });
- },
- //养护激活用户分页
- getCuringPage: async function(req, res){
- var currentPage=req.params.currentPage;
- if(!hash.isNotANumber(currentPage)){
- res.json({ 'status': 2,'msg':'currentPage error' });return ;
- }
- //get获得方式
- var params = url.parse(req.url, true).query;
- var curingList= await cloudService.getCuringList(params.compilation_id,currentPage);
- res.json({ 'status': 1,'curingList':curingList.curingList,'pageData':curingList.pageData });
- },
- //搜索手机号,防止由于改号码导致数据不全问题
- checkMobile: async function(req, res){
- if(!hash.isNotANumber(req.params.mobile)){
- res.json({ 'status': 0,'msg':'error mobile' });
- return ;
- }
- var data= await cloudService.getCuringByMobile(req.params.mobile);
- if(hash.isExistence(data)) {
- var curingDetail=await models.cloud_curing.getCuringBySsoid(data['userInfo']['ssoId']);
- var client_id='';
- if(hash.isExistence(curingDetail)&&hash.isExistence(curingDetail['client_id'])){
- client_id=curingDetail['client_id'];
- }
- res.json({ 'status': 1,'data':{'id':data['userInfo']['ssoId'],'client_id':client_id} });
- }else{
- res.json({ 'status': 3,'msg':'该号码未注册养护项目' });
- }
- },
- /**
- * 异步获得养护用户信息详情
- */
- getCuringBySsoid: async function(req, res){
- var params = url.parse(req.url, true).query;
- if(!hash.isExistence(params.ssoid)){
- res.json({ 'status': 0,'msg':'error ssoid' });
- return ;
- }
- var detail= await cloudService.getCuringBySsoid(params.ssoid,params.client_id);
- //console.log(detail);
- if(hash.isExistence(detail)) {
- res.json({ 'status': 1,'detail':detail });
- }else{
- res.json({ 'status': 3,'msg':'该号码未注册养护项目' });
- }
- },
- upCuringDo: async function(req, res){
- //post数据获得
- var ssoid=req.body.ssoid;//通行证ID
- var compilationId=req.body.compilationId;//编办ID
- if(hash.isExistence(ssoid)&&hash.isExistence(compilationId)) {
- var flag= await cloudService.upCuringDo(req.body);
- if(flag){
- res.json({ 'status': 1,'msg':'升级成功' });
- }else{
- res.json({ 'status': 3,'msg':'升级失败' });
- }
- }else{
- res.json({ 'status': 3,'msg':'数据不正确' });
- }
- },
- //养护绑定CLD客户
- relevanceClientDo: async function(req, res){
- //post数据获得
- var cidKey=req.body.cidKey;//客户ID
- var id=req.body.id;//养护用户ID
- if(hash.isExistence(cidKey)&&hash.isExistence(id)) {
- var flag= await cloudService.relevanceClientDo(req.body);
- if(flag){
- //获得绑定的CLD客户信息
- var detail= await models.CLD_client.findById(cidKey);
- var operateLogList=await models.operate_log.findByCondition(1,hash.hashDecode(id));
- res.json({ 'status': 1,'detail':detail,'operateLogList':operateLogList,'msg':'绑定CLD客户成功' });
- }else{
- res.json({ 'status': 2,'msg':'绑定失败' });
- }
- }else{
- res.json({ 'status': 3,'msg':'参数不正确' });
- }
- },
- //养护移除CLD客户
- relieveClientDo: async function(req, res){
- //post数据获得
- var id=req.body.id;//养护用户ID
- if(hash.isExistence(id)) {
- var flag= await cloudService.relieveClientDo(req.body);
- if(flag){
- var operateLogList=await models.operate_log.findByCondition(1,hash.hashDecode(id));
- //获得绑定的CLD客户信息
- res.json({ 'status': 1,'operateLogList':operateLogList,'msg':'解绑CLD客户成功' });
- }else{
- res.json({ 'status': 2,'msg':'解绑失败' });
- }
- }else{
- res.json({ 'status': 3,'msg':'参数不正确' });
- }
- },
- //养护详情页 数据
- getCuringById: async function(req, res){
- if(!hash.isExistence(req.params.id)){
- res.json({ 'status': 0,'msg':'error id' });
- return ;
- }
- var id=hash.hashDecode(req.params.id);
- if(!hash.isNotANumber(id)){
- res.json({ 'status': 0,'msg':'error id' });
- return ;
- }
- res.json({ 'status': 3,'msg':'数据不正确' });
- },
- }
- module.exports = cloudEditionAjaxController;
|