cloudBuildEditionAjaxController.js 5.7 KB

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