MasterWorkerInfoLogic.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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\MasterWorker;
  6. use app\common\model\master_worker\MasterWorkerInfo;
  7. use think\Exception;
  8. /**
  9. * @author 林海涛
  10. * @date 2024/7/10 下午4:29
  11. */
  12. class MasterWorkerInfoLogic extends BaseLogic
  13. {
  14. public static function getIdCard($userId)
  15. {
  16. return MasterWorkerInfo::where([['worker_id', '=', $userId]])->findOrEmpty()->toArray();
  17. }
  18. public static function changeIdCard($params,$userId)
  19. {
  20. try{
  21. if($params['id_card_front_img']=='https://weixiu.kyjlkj.com/static/wxapp/master_image/zm.png' || $params['id_card_opposite_img'] == 'https://weixiu.zhongdunzhizhao.com/static/wxapp/master_image/fm.png'){
  22. throw new Exception('请上传身份证正反面照片');
  23. }
  24. $where = [['worker_id', '=', $userId]];
  25. $userInfo = MasterWorkerInfo::where($where)->findOrEmpty();
  26. if ($userInfo->isEmpty()) {
  27. $userInfo = new MasterWorkerInfo();
  28. $userInfo->worker_id = $userId;
  29. }
  30. $userInfo->real_name = $params['real_name'];
  31. $userInfo->id_card = $params['id_card'];
  32. $userInfo->id_card_front_img = $params['id_card_front_img'];
  33. $userInfo->id_card_opposite_img = $params['id_card_opposite_img'];
  34. $userInfo->mobile = $params['mobile'];
  35. $userInfo->address = $params['address'];
  36. $userInfo->audit_state = 0;
  37. $masterWorker = MasterWorker::findOrEmpty($userId);
  38. if (!$masterWorker->isEmpty()) {
  39. $masterWorker->real_name = $userInfo->real_name;
  40. $masterWorker->save();
  41. }
  42. $userInfo->save();
  43. return true;
  44. } catch(\Exception $e){
  45. self::setError($e->getMessage());
  46. return false;
  47. }
  48. }
  49. /**
  50. * 绑定银行卡
  51. * @param $params
  52. * @param $userId
  53. * @return bool
  54. * @author 林海涛
  55. * @date 2024/7/11 下午4:41
  56. */
  57. public static function bindBankAccount($params,$userId)
  58. {
  59. try{
  60. $where = [['worker_id', '=', $userId]];
  61. $bankAccount = BankAccount::where($where)->findOrEmpty();
  62. if ($bankAccount->isEmpty()) {
  63. $bankAccount = new BankAccount();
  64. $bankAccount->worker_id = $userId;
  65. }
  66. $bankAccount->account_holder = $params['account_holder'];
  67. $bankAccount->bank_name = $params['bank_name'];
  68. $bankAccount->province = $params['province'];
  69. $bankAccount->city = $params['city'];
  70. $bankAccount->opening_branch = $params['opening_branch'];
  71. $bankAccount->account = $params['account'];
  72. $bankAccount->mobile = $params['mobile'];
  73. $bankAccount->bank_image = !empty($params['bank_image'])?$params['bank_image']:'';
  74. $bankAccount->audit_state = 0;
  75. $bankAccount->save();
  76. return true;
  77. } catch(\Exception $e){
  78. self::setError($e->getMessage());
  79. return false;
  80. }
  81. }
  82. public static function bankAccountInfo($userId)
  83. {
  84. $where = [['worker_id', '=', $userId]];
  85. return BankAccount::where($where)->withoutField(['user_id','worker_id'])->findOrEmpty()->toArray();
  86. }
  87. }