FinancialDao.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\common\dao\system\financial;
  3. use app\common\dao\BaseDao;
  4. use app\common\model\system\financial\Financial;
  5. class FinancialDao extends BaseDao
  6. {
  7. protected function getModel(): string
  8. {
  9. return Financial::class;
  10. }
  11. public function search(array $where)
  12. {
  13. $query = Financial::hasWhere('merchant',function($query) use ($where){
  14. $query->when(isset($where['is_trader']) && $where['is_trader'] !=='',function($query) use($where){
  15. $query->where('is_trader',$where['is_trader']);
  16. });
  17. $query->where('is_del',0);
  18. });
  19. $query->when(isset($where['status']) && $where['status'] !=='',function($query) use($where){
  20. $query->where('Financial.status',$where['status']);
  21. })
  22. ->when(isset($where['financial_type']) && $where['financial_type'] !=='',function($query) use($where){
  23. $query->where('Financial.financial_type',$where['financial_type']);
  24. })
  25. ->when(isset($where['mer_id']) && $where['mer_id'] !=='',function($query) use($where){
  26. $query->where('Financial.mer_id',$where['mer_id']);
  27. })
  28. ->when(isset($where['financial_status']) && $where['financial_status'] !=='',function($query) use($where){
  29. $query->where('Financial.financial_status',$where['financial_status']);
  30. })
  31. ->when(isset($where['keyword']) && $where['keyword'] !=='',function($query) use($where){
  32. $query->join('SystemAdmin A','Financial.admin_id = A.admin_id')->field('A.real_name,A.admin_id')->whereLike('A.real_name',"%{$where['keyword']}%");
  33. })
  34. ->when(isset($where['keywords_']) && $where['keywords_'] !=='',function($query) use($where){
  35. $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_']}%");
  36. })
  37. ->when(isset($where['financial_id']) && $where['financial_id'] !=='',function($query) use($where){
  38. $query->where('Financial.financial_id',$where['financial_id']);
  39. })
  40. ->when(isset($where['date']) && $where['date'] !=='',function($query) use($where){
  41. getModelTime($query,$where['date'],'Financial.create_time');
  42. })
  43. ->when(isset($where['is_del']) && $where['is_del'] !=='',function($query) use($where){
  44. $query->where('Financial.is_del',$where['is_del']);
  45. });
  46. $query->order('Financial.create_time DESC');
  47. return $query;
  48. }
  49. }