cloudEditionAjaxController.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /**
  2. * Created by MyPC on 2019/11/5.
  3. */
  4. const hash=require('../class/hash');
  5. const cloudService=require('../service/cloudEditionService');
  6. const operateLogService=require('../service/operateLogService');
  7. const url=require("url");
  8. var models=require('../models');
  9. var cloudEditionAjaxController={
  10. //------------用户列表界面相关----------------
  11. /**
  12. * 用户列表刷新
  13. */
  14. refreshCuringPage: async function(req, res){
  15. var curingList= await cloudService.getCuringList(req, res);
  16. res.json({ 'status': 1,'curingList':curingList.curingList,'pageData':curingList.pageData });
  17. },
  18. //------------用户详情页界面相关----------------
  19. /**
  20. * 获得养护用户信息详情
  21. */
  22. getCuringBySsoid: async function(req, res){
  23. var params = url.parse(req.url, true).query;
  24. if(!hash.isExistence(params.ssoid)){
  25. res.json({ 'status': 0,'msg':'error ssoid' });
  26. return ;
  27. }
  28. var detail= await cloudService.getCuringBySsoid(params.ssoid,params.client_id);
  29. //console.log(detail);
  30. if(hash.isExistence(detail)) {
  31. res.json({ 'status': 1,'detail':detail });
  32. }else{
  33. res.json({ 'status': 3,'msg':'该号码未注册养护项目' });
  34. }
  35. },
  36. /**
  37. * 升级用户使用的养护 为专业版本--根据编办
  38. */
  39. upCuringDo: async function(req, res){
  40. //post数据获得
  41. var ssoid=req.body.ssoid;//通行证ID
  42. var compilationId=req.body.compilationId;//编办ID
  43. if(hash.isExistence(ssoid)&&hash.isExistence(compilationId)) {
  44. var flag= await cloudService.upCuringDo(req.body);
  45. if(flag){
  46. res.json({ 'status': 1,'msg':'升级成功' });
  47. }else{
  48. res.json({ 'status': 3,'msg':'升级失败' });
  49. }
  50. }else{
  51. res.json({ 'status': 3,'msg':'数据不正确' });
  52. }
  53. },
  54. /**
  55. * 用户关联CLD客户
  56. */
  57. relevanceClientDo: async function(req, res){
  58. //post数据获得
  59. var cidKey=req.body.cidKey;//客户ID
  60. var ssoId=req.body.ssoId;//养护用户ID
  61. if(hash.isExistence(cidKey)&&hash.isExistence(ssoId)) {
  62. var flag= await cloudService.relevanceClientDo(req.body);
  63. if(flag){
  64. res.json({ 'status': 1,'msg':'绑定CLD客户成功' });
  65. }else{
  66. res.json({ 'status': 2,'msg':'绑定失败' });
  67. }
  68. }else{
  69. res.json({ 'status': 3,'msg':'参数不正确' });
  70. }
  71. },
  72. /**
  73. * 用户取消关联CLD客户
  74. */
  75. relieveClientDo: async function(req, res){
  76. //post数据获得
  77. var ssoId=req.body.ssoId;//养护用户ID
  78. if(hash.isExistence(ssoId)) {
  79. var flag= await cloudService.relieveClientDo(req.body);
  80. if(flag){
  81. /*var operateLogList=await models.operate_log.findByCondition(1,hash.hashDecode(id));
  82. //获得绑定的CLD客户信息
  83. res.json({ 'status': 1,'operateLogList':operateLogList,'msg':'解绑CLD客户成功' });*/
  84. res.json({ 'status': 1,'msg':'解绑CLD客户成功' });
  85. }else{
  86. res.json({ 'status': 2,'msg':'解绑失败' });
  87. }
  88. }else{
  89. res.json({ 'status': 3,'msg':'参数不正确' });
  90. }
  91. },
  92. /**
  93. * 养护用户分页---废弃
  94. */
  95. /* getCuringPage: async function(req, res){
  96. var currentPage=req.params.currentPage;
  97. if(!hash.isNotANumber(currentPage)){
  98. res.json({ 'status': 2,'msg':'currentPage error' });return ;
  99. }
  100. //get获得方式
  101. var params = url.parse(req.url, true).query;
  102. var curingList= await cloudService.getCuringList(req, res);
  103. res.json({ 'status': 1,'curingList':curingList.curingList,'pageData':curingList.pageData });
  104. },
  105. //获得养护信息--废弃
  106. getCuringInfo: async function(req, res){
  107. if(!hash.isNotANumber(req.params.mobile)){
  108. res.json({ 'status': 0,'msg':'error mobile' });
  109. return ;
  110. }
  111. //获得本地绑定CLD客户用户
  112. var bcDetail= await cloudService.getBindCuringByMobile(req.params.mobile);
  113. var cDetail= await cloudService.getCuringByMobile(req.params.mobile);
  114. if(!hash.isExistence(bcDetail)){//没有绑定CLD客户
  115. if(!hash.isExistence(cDetail)){
  116. res.header("Content-Type", "application/json; charset=utf-8")
  117. res.json({ 'status': 3,'msg':'该号码未注册养护项目' });
  118. return ;
  119. }
  120. res.json({ 'status': 2,'msg':'已升级用户列表不存在' });//未绑定CLD客户
  121. }else{
  122. res.json({ 'status': 1,'detail':bcDetail });
  123. }
  124. },
  125. */
  126. //搜索手机号,防止由于改号码导致数据不全问题
  127. checkMobile: async function(req, res){
  128. if(!hash.isNotANumber(req.params.mobile)){
  129. res.json({ 'status': 0,'msg':'error mobile' });
  130. return ;
  131. }
  132. var data= await cloudService.getCuringByMobile(req.params.mobile);
  133. if(hash.isExistence(data)) {
  134. var curingDetail=await models.cloud_curing.getCuringBySsoid(data['userInfo']['ssoId']);
  135. var client_id='';
  136. if(hash.isExistence(curingDetail)&&hash.isExistence(curingDetail['client_id'])){
  137. client_id=curingDetail['client_id'];
  138. }
  139. res.json({ 'status': 1,'data':{'id':data['userInfo']['ssoId'],'client_id':client_id} });
  140. }else{
  141. res.json({ 'status': 3,'msg':'该号码未注册养护项目' });
  142. }
  143. },
  144. //养护详情页 数据---可能废弃
  145. getCuringById: async function(req, res){
  146. if(!hash.isExistence(req.params.id)){
  147. res.json({ 'status': 0,'msg':'error id' });
  148. return ;
  149. }
  150. var id=hash.hashDecode(req.params.id);
  151. if(!hash.isNotANumber(id)){
  152. res.json({ 'status': 0,'msg':'error id' });
  153. return ;
  154. }
  155. res.json({ 'status': 3,'msg':'数据不正确' });
  156. },
  157. }
  158. module.exports = cloudEditionAjaxController;