1
0

MasterWorkerController.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?php
  2. namespace app\workerapi\controller;
  3. use app\common\logic\MasterWorkerExamineLogic;
  4. use app\common\model\dict\DictData;
  5. use app\workerapi\logic\LoginLogic;
  6. use app\workerapi\logic\MasterWorkerInfoLogic;
  7. use app\workerapi\logic\MasterWorkerLogic;
  8. use app\workerapi\logic\MasterWorkerRegisterLogic;
  9. use app\workerapi\validate\BankAccountValidate;
  10. use app\workerapi\validate\MasterWokerInfoValidate;
  11. use app\workerapi\validate\MasterWokerValidate;
  12. class MasterWorkerController extends BaseApiController
  13. {
  14. public array $notNeedLogin = ['customerPhone','interview','getQuestion','getInterview','getRegInfo'];
  15. /**
  16. * @notes 修改密码
  17. * @return \think\response\Json
  18. * @author 段誉
  19. * @date 2022/9/20 19:16
  20. */
  21. public function changePassword()
  22. {
  23. $params = (new MasterWokerValidate())->post()->goCheck('changePassword');
  24. $result = MasterWorkerLogic::changePassword($params, $this->userId);
  25. if (true === $result) {
  26. return $this->success('操作成功', [], 1, 1);
  27. }
  28. return $this->fail(MasterWorkerLogic::getError());
  29. }
  30. /**
  31. * 更改手机号
  32. * @return \think\response\Json
  33. * @author 林海涛
  34. * @date 2024/7/10 下午2:23
  35. */
  36. public function changeMobile()
  37. {
  38. $params = (new MasterWokerValidate())->post()->goCheck('changeMobile');
  39. $result = MasterWorkerLogic::changeMobile($params, $this->userId);
  40. if (true === $result) {
  41. return $this->success('操作成功', [], 1, 1);
  42. }
  43. return $this->fail(MasterWorkerLogic::getError());
  44. }
  45. /**
  46. * 更改身份证信息
  47. * @return \think\response\Json
  48. * @author 林海涛
  49. * @date 2024/7/10 下午4:46
  50. */
  51. public function changeIdCard()
  52. {
  53. $params = (new MasterWokerInfoValidate())->post()->goCheck('changeIdCard');
  54. $result = MasterWorkerInfoLogic::changeIdCard($params, $this->userId);
  55. if (true === $result) {
  56. \app\common\logic\MasterWorkerExamineLogic::updateEngineerInformation($this->userId);
  57. return $this->success('操作成功', [], 1, 1);
  58. }
  59. return $this->fail(MasterWorkerInfoLogic::getError());
  60. }
  61. public function getIdCard()
  62. {
  63. $result = MasterWorkerInfoLogic::getIdCard($this->userId);
  64. return $this->data($result);
  65. }
  66. public function approvalStopWork()
  67. {
  68. $result = MasterWorkerLogic::stopWork($this->userId);
  69. if (true === $result) {
  70. return $this->success('操作成功', [], 1, 1);
  71. }
  72. return $this->fail(MasterWorkerLogic::getError());
  73. }
  74. /**
  75. * 注销账号
  76. * @return \think\response\Json
  77. * @author 林海涛
  78. * @date 2024/7/10 下午4:46
  79. */
  80. public function logOff()
  81. {
  82. $result = MasterWorkerLogic::logOff($this->userId);
  83. if (true === $result) {
  84. LoginLogic::logout($this->userInfo);
  85. return $this->success('操作成功', [], 1, 1);
  86. }
  87. return $this->fail(MasterWorkerInfoLogic::getError());
  88. }
  89. /**
  90. * 绑定银行卡
  91. * @return \think\response\Json
  92. * @author 林海涛
  93. * @date 2024/7/11 下午4:27
  94. */
  95. public function bindBankAccount()
  96. {
  97. $params = (new BankAccountValidate())->post()->goCheck('bindBankAccount');
  98. $result = MasterWorkerInfoLogic::bindBankAccount($params, $this->userId);
  99. if (true === $result) {
  100. \app\common\logic\MasterWorkerExamineLogic::updateEngineerInformation($this->userId);
  101. return $this->success('操作成功', [], 1, 1);
  102. }
  103. return $this->fail(MasterWorkerInfoLogic::getError());
  104. }
  105. public function myInfo()
  106. {
  107. $result = MasterWorkerLogic::detail($this->userId);
  108. return $this->data($result);
  109. }
  110. public function bankAccountInfo()
  111. {
  112. $result = MasterWorkerInfoLogic::bankAccountInfo($this->userId);
  113. return $this->data($result);
  114. }
  115. /**
  116. * 客服电话
  117. * @return \think\response\Json
  118. */
  119. public function customerPhone()
  120. {
  121. $result = DictData::where(['type_value' => 'customer_support'])->column('value', 'name');
  122. return $this->data($result);
  123. }
  124. public function setInfo()
  125. {
  126. $params = (new MasterWokerValidate())->post()->goCheck('setInfo');
  127. $result = MasterWorkerLogic::setInfo($this->userId, $params);
  128. if (false === $result) {
  129. return $this->fail(MasterWorkerLogic::getError());
  130. }
  131. return $this->success('操作成功', $result, 1, 1);
  132. }
  133. public function interview()
  134. {
  135. $params = (new MasterWokerValidate())->post()->goCheck('interview');
  136. $result = MasterWorkerLogic::setInterview($params);
  137. if (false === $result) {
  138. return $this->fail(MasterWorkerLogic::getError());
  139. }
  140. return $this->success('操作成功', $result, 1, 1);
  141. }
  142. public function getInterview()
  143. {
  144. $params = (new MasterWokerValidate())->get()->goCheck('getInterview');
  145. $result = MasterWorkerLogic::getInterview($params);
  146. return $this->data($result);
  147. }
  148. public function getQuestion()
  149. {
  150. $params = (new MasterWokerValidate())->post()->goCheck('question');
  151. $result = MasterWorkerLogic::getQuestion($params);
  152. return json(['code' => 1, 'data' => $result['list'],'text'=> $result['text'], 'msg' => 'success']);
  153. }
  154. public function getRegInfo()
  155. {
  156. $params = (new MasterWokerValidate())->post()->goCheck('getRegInfo');
  157. $result = MasterWorkerLogic::getRegInfo($params);
  158. echo $result;
  159. die;
  160. }
  161. public function getCredential()
  162. {
  163. $params = request()->get();
  164. $result = MasterWorkerRegisterLogic::credential($this->userId,$params['image_name']??'');
  165. return $this->data($result);
  166. }
  167. public function setCredential()
  168. {
  169. $params = request()->post();
  170. $result = MasterWorkerRegisterLogic::setCredential($params,$this->userId);
  171. if (false === $result) {
  172. return $this->fail(MasterWorkerRegisterLogic::getError());
  173. }
  174. return $this->success('操作成功', [], 1, 1);
  175. }
  176. public function getAltitudeCredential()
  177. {
  178. $params = request()->get();
  179. if(in_array($params['credential_type'],[52,109])){
  180. $result = MasterWorkerRegisterLogic::credential($this->userId,'高处作业',1);
  181. if($result){
  182. return $this->success('', ['isAltitude'=>$result?1:0], 1, 1);
  183. }else{
  184. return $this->fail('尊敬的工程师,你好,因相关法律法规要求,空调加氟涉高作业,需要持有高处作业证书,如您想开启相关类目,请前往上传证书配置。谢谢合作!');
  185. }
  186. }
  187. return $this->success('', [], 1, 1);
  188. }
  189. }