MasterWorkerController.php 7.6 KB

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