MasterWorkerInfoLogic.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\workerapi\logic;
  3. use app\common\logic\BaseLogic;
  4. use app\common\model\bank_account\BankAccount;
  5. use app\common\model\master_worker\MasterWorkerInfo;
  6. /**
  7. * @author 林海涛
  8. * @date 2024/7/10 下午4:29
  9. */
  10. class MasterWorkerInfoLogic extends BaseLogic
  11. {
  12. public static function changeIdCard($params,$userId)
  13. {
  14. try{
  15. $where = [['worker_id', '=', $userId]];
  16. $userInfo = MasterWorkerInfo::where($where)->findOrEmpty();
  17. if ($userInfo->isEmpty()) {
  18. $userInfo = new MasterWorkerInfo();
  19. $userInfo->user_id = $userId;
  20. }
  21. $userInfo->real_name = $params['real_name'];
  22. $userInfo->id_card = $params['id_card'];
  23. $userInfo->id_card_front_img = $params['id_card_front_img'];
  24. $userInfo->id_card_opposite_img = $params['id_card_opposite_img'];
  25. $userInfo->mobile = $params['mobile'];
  26. $userInfo->address = $params['address'];
  27. $userInfo->save();
  28. return true;
  29. } catch(\Exception $e){
  30. self::setError($e->getMessage());
  31. return false;
  32. }
  33. }
  34. /**
  35. * 绑定银行卡
  36. * @param $params
  37. * @param $userId
  38. * @return bool
  39. * @author 林海涛
  40. * @date 2024/7/11 下午4:41
  41. */
  42. public static function bindBankAccount($params,$userId)
  43. {
  44. try{
  45. $where = [['worker_id', '=', $userId]];
  46. $bankAccount = BankAccount::where($where)->findOrEmpty();
  47. if ($bankAccount->isEmpty()) {
  48. $bankAccount = new BankAccount();
  49. $bankAccount->worker_id = $userId;
  50. }
  51. $bankAccount->account_holder = $params['account_holder'];
  52. $bankAccount->bank_name = $params['bank_name'];
  53. $bankAccount->province = $params['province'];
  54. $bankAccount->city = $params['city'];
  55. $bankAccount->opening_branch = $params['opening_branch'];
  56. $bankAccount->account = $params['account'];
  57. $bankAccount->mobile = $params['mobile'];
  58. $bankAccount->save();
  59. return true;
  60. } catch(\Exception $e){
  61. self::setError($e->getMessage());
  62. return false;
  63. }
  64. }
  65. public static function bankAccountInfo($userId)
  66. {
  67. $where = [['worker_id', '=', $userId]];
  68. return BankAccount::where($where)->withoutField(['user_id','worker_id'])->findOrEmpty()->toArray();
  69. }
  70. }