MasterWorkerInfoLogic.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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->save();
  26. return true;
  27. } catch(\Exception $e){
  28. self::setError($e->getMessage());
  29. return false;
  30. }
  31. }
  32. /**
  33. * 绑定银行卡
  34. * @param $params
  35. * @param $userId
  36. * @return bool
  37. * @author 林海涛
  38. * @date 2024/7/11 下午4:41
  39. */
  40. public static function bindBankAccount($params,$userId)
  41. {
  42. try{
  43. $where = [['worker_id', '=', $userId]];
  44. $bankAccount = BankAccount::where($where)->findOrEmpty();
  45. if ($bankAccount->isEmpty()) {
  46. $bankAccount = new BankAccount();
  47. $bankAccount->worker_id = $userId;
  48. }
  49. $bankAccount->account_holder = $params['account_holder'];
  50. $bankAccount->bank_name = $params['bank_name'];
  51. $bankAccount->province = $params['province'];
  52. $bankAccount->city = $params['city'];
  53. $bankAccount->opening_branch = $params['opening_branch'];
  54. $bankAccount->account = $params['account'];
  55. $bankAccount->mobile = $params['mobile'];
  56. $bankAccount->save();
  57. return true;
  58. } catch(\Exception $e){
  59. self::setError($e->getMessage());
  60. return false;
  61. }
  62. }
  63. public static function bankAccountInfo($userId)
  64. {
  65. $where = [['worker_id', '=', $userId]];
  66. return BankAccount::where($where)->withoutField(['user_id','worker_id'])->findOrEmpty()->toArray();
  67. }
  68. }