FinancialDao.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\dao\system\financial;
  12. use app\common\dao\BaseDao;
  13. use app\common\model\system\financial\Financial;
  14. class FinancialDao extends BaseDao
  15. {
  16. protected function getModel(): string
  17. {
  18. return Financial::class;
  19. }
  20. public function search(array $where)
  21. {
  22. $query = Financial::hasWhere('merchant',function($query) use ($where){
  23. $query->when(isset($where['is_trader']) && $where['is_trader'] !=='',function($query) use($where){
  24. $query->where('is_trader',$where['is_trader']);
  25. });
  26. $query->where('is_del',0);
  27. });
  28. $query->when(isset($where['status']) && $where['status'] !=='',function($query) use($where){
  29. $query->where('Financial.status',$where['status']);
  30. })
  31. ->when(isset($where['financial_type']) && $where['financial_type'] !=='',function($query) use($where){
  32. $query->where('Financial.financial_type',$where['financial_type']);
  33. })
  34. ->when(isset($where['mer_id']) && $where['mer_id'] !=='',function($query) use($where){
  35. $query->where('Financial.mer_id',$where['mer_id']);
  36. })
  37. ->when(isset($where['financial_status']) && $where['financial_status'] !=='',function($query) use($where){
  38. $query->where('Financial.financial_status',$where['financial_status']);
  39. })
  40. ->when(isset($where['keyword']) && $where['keyword'] !=='',function($query) use($where){
  41. $query->join('SystemAdmin A','Financial.admin_id = A.admin_id')->field('A.real_name,A.admin_id')->whereLike('A.real_name',"%{$where['keyword']}%");
  42. })
  43. ->when(isset($where['keywords_']) && $where['keywords_'] !=='',function($query) use($where){
  44. $query->join('MerchantAdmin M','Financial.mer_admin_id = M.merchant_admin_id')->field('M.real_name,M.merchant_admin_id')->whereLike('M.real_name',"%{$where['keywords_']}%");
  45. })
  46. ->when(isset($where['financial_id']) && $where['financial_id'] !=='',function($query) use($where){
  47. $query->where('Financial.financial_id',$where['financial_id']);
  48. })
  49. ->when(isset($where['date']) && $where['date'] !=='',function($query) use($where){
  50. getModelTime($query,$where['date'],'Financial.create_time');
  51. })
  52. ->when(isset($where['is_del']) && $where['is_del'] !=='',function($query) use($where){
  53. $query->where('Financial.is_del',$where['is_del']);
  54. });
  55. $query->order('Financial.create_time DESC');
  56. return $query;
  57. }
  58. }