MemberCashOutAccountService.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\service\api\member;
  12. use app\model\member\MemberCashOutAccount;
  13. use core\base\BaseApiService;
  14. /**
  15. * 会员提现账户服务层
  16. */
  17. class MemberCashOutAccountService extends BaseApiService
  18. {
  19. public function __construct()
  20. {
  21. parent::__construct();
  22. $this->model = new MemberCashOutAccount();
  23. }
  24. /**
  25. * 会员提现账户列表
  26. * @param array $where
  27. * @return array
  28. */
  29. public function getPage(array $where = [])
  30. {
  31. $where['member_id'] = $this->member_id;
  32. $field = 'account_id,member_id,account_type,bank_name,realname,account_no';
  33. $search_model = $this->model->where($where)->field($field)->order('create_time desc');
  34. return $this->pageQuery($search_model);
  35. }
  36. /**
  37. * 提现账户详情
  38. * @param int $account_id
  39. * @return array
  40. */
  41. public function getInfo(int $account_id)
  42. {
  43. $field = 'account_id,member_id,account_type,bank_name,realname,account_no, transfer_payment_code';
  44. return $this->model->where([['account_id', '=', $account_id], ['member_id', '=', $this->member_id]])->field($field)->findOrEmpty()->toArray();
  45. }
  46. /**
  47. * 获取首条信息
  48. * @param array $where
  49. * @param string $order_field
  50. * @param string $order
  51. * @return array
  52. */
  53. public function getFirstInfo(array $where, $order_field = 'create_time', string $order = 'desc'){
  54. $where[] = ['member_id', '=', $this->member_id];
  55. $field = 'account_id,member_id,account_type,bank_name,realname,account_no';
  56. return $this->model->where($where)->order($order_field, $order)->field($field)->findOrEmpty()->toArray();
  57. }
  58. /**
  59. * 添加提现账号
  60. * @param array $data
  61. * @return int
  62. */
  63. public function add(array $data)
  64. {
  65. $data['member_id'] = $this->member_id;
  66. $data['create_time'] = time();
  67. $res = $this->model->create($data);
  68. return $res->account_id;
  69. }
  70. /**
  71. * 修改提现账户
  72. * @param int $account_id
  73. * @param array $data
  74. * @return true
  75. */
  76. public function edit(int $account_id, array $data)
  77. {
  78. $data['update_time'] = time();
  79. $this->model->update($data, [ [ 'member_id', '=', $this->member_id ], ['account_id', '=', $account_id] ]);
  80. return true;
  81. }
  82. /**
  83. * 删除
  84. * @param int $account_id
  85. * @return true
  86. */
  87. public function del(int $account_id)
  88. {
  89. $where = [
  90. ['member_id', '=', $this->member_id],
  91. ['account_id', '=', $account_id]
  92. ];
  93. $this->model->where($where)->delete();
  94. return true;
  95. }
  96. }