Withdraw.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. *
  5. * User: king/QQ:995265288
  6. * Date: 2018/7/27 下午4:11
  7. * Email: livsyitian@163.com
  8. */
  9. namespace app\backend\models;
  10. use app\common\scopes\UniacidScope;
  11. class Withdraw extends \app\common\models\Withdraw
  12. {
  13. public static function boot()
  14. {
  15. parent::boot();
  16. self::addGlobalScope(new UniacidScope);
  17. }
  18. public function scopeRecords($query)
  19. {
  20. $query->with(['hasOneMember' => function ($query) {
  21. return $query->select('uid', 'mobile', 'realname', 'nickname', 'avatar');
  22. }]);
  23. return parent::scopeRecords($query);
  24. }
  25. public function scopeSearch($query, $search)
  26. {
  27. if ($search['member_id']) {
  28. $query->where('member_id', $search['member_id']);
  29. }
  30. if (isset($search['status']) && $search['status'] != "") {
  31. $query->ofStatus($search['status']);
  32. }
  33. if ($search['withdraw_sn']) {
  34. $query->ofWithdrawSn($search['withdraw_sn']);
  35. }
  36. if ($search['type']) {
  37. $query->whereType($search['type']);
  38. }
  39. if ($search['pay_way']) {
  40. $query->where('pay_way', $search['pay_way']);
  41. }
  42. if ($search['searchtime']) {
  43. $range = [strtotime($search['time']['start']), strtotime($search['time']['end'])];
  44. $query->whereBetween('created_at', $range);
  45. }
  46. if ($search['member']) {
  47. $query->whereHas('hasOneMember', function ($query) use ($search) {
  48. return $query->searchLike($search['member']);
  49. });
  50. }
  51. return $query;
  52. }
  53. public static function getTypes()
  54. {
  55. $configs = \app\backend\modules\income\Income::current()->getItems();
  56. return $configs;
  57. }
  58. }