Help.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\{Category, Help as HelpModel, HelpApply};
  5. use liuniu\UtilService;
  6. use think\Request;
  7. class Help extends Api
  8. {
  9. protected $noNeedLogin = [];
  10. protected $noNeedRight = ['*'];
  11. public function index(Request $request)
  12. {
  13. $where = UtilService::getMore(
  14. [
  15. ['category_id',0],
  16. ['page',1],
  17. ['limit',10],
  18. ['status',-2],
  19. ['isrec',-1],
  20. ['user_id_1',$this->auth->getUserinfo()['id']],
  21. ]
  22. );
  23. return $this->success('获取成功',HelpModel::lst($where));
  24. }
  25. public function ify()
  26. {
  27. $this->success('获取成功',Category::getCategoryArray('help'));
  28. }
  29. public function apply(Request $request)
  30. {
  31. $where = UtilService::postMore(
  32. [
  33. ['category_id',0],
  34. ['full_name',''],
  35. ['contact',''],
  36. ['id_card',''],
  37. ['title',''],
  38. ['info',''],
  39. ['userimage',''],
  40. ['userimages',''],
  41. ['sex',0],
  42. ['politics',0],
  43. ['birthday',''],
  44. ['address',''],
  45. ['company',''],
  46. ['unit_nature',''],
  47. ['monthly_income',0],
  48. ['annual_household_income',0],
  49. ['annual_household_income_average',0],
  50. ['identity',''],
  51. ['marriage',0],
  52. ['medical_insurance',0],
  53. ['object_features',0],
  54. ['reason',0],
  55. ['family',[]],
  56. ],$request
  57. );
  58. $where['cid'] = $this->cid;
  59. $where['user_id'] = $this->auth->getUserinfo()['id'];
  60. $rs = HelpModel::help_create($where);
  61. if(!$rs) $this->error(HelpModel::getErrorInfo());
  62. $this->success('申请成功',$rs);
  63. }
  64. public function help_user_apply(Request $request)
  65. {
  66. $where = UtilService::postMore(
  67. [
  68. ['help_id',0],
  69. ['full_name',''],
  70. ['phone',''],
  71. ['user_id',$this->auth->getUserinfo()['id']],
  72. ['cid',$this->cid],
  73. ],$request
  74. );
  75. if($where['help_id']==0) $this->error('项目编号不能为0!');
  76. if($where['full_name']=='') $this->error('姓名不能为空!');
  77. if($where['phone']=='') $this->error('手机号不能为空!');
  78. if(HelpApply::where('user_id',$this->auth->getUserinfo()['id'])->where('help_id',$where['help_id'])->find()) $this->error('项目不能重复申请!');
  79. HelpApply::create($where);
  80. $this->success('申请成功');
  81. }
  82. public function user_apply_lst(Request $request)
  83. {
  84. $where = UtilService::getMore(
  85. [
  86. ['status',-2],
  87. ['page',''],
  88. ['limit',''],
  89. ['user_id',$this->auth->getUserinfo()['id']],
  90. ],$request
  91. );
  92. $this->success('获取成功',HelpApply::lst($where));
  93. }
  94. public function lst(Request $request)
  95. {
  96. $where = UtilService::getMore(
  97. [
  98. ['user_id',$this->auth->getUserinfo()['id']],
  99. ['user_id_1',$this->auth->getUserinfo()['id']],
  100. ['page',1],
  101. ['limit',10],
  102. ['status',-2],
  103. ]
  104. );
  105. return $this->success('获取成功',HelpModel::lst($where));
  106. }
  107. public function view()
  108. {
  109. $id = input('id',0);
  110. if($id==0) $this->error('参数错误!');
  111. $rs = HelpModel::info($this->cid,$id,$this->auth->getUserinfo()['id']);
  112. if(!$rs)$this->error(HelpModel::getErrorInfo());
  113. return $this->success('获取成功',$rs);
  114. }
  115. }