You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.0 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Service\v3\Implementations;
  3. use App\Model\v3\FinancialRecord;
  4. use App\Service\v3\Interfaces\RevenueListServiceInterface;
  5. class RevenueListService implements RevenueListServiceInterface
  6. {
  7. public function do()
  8. {
  9. // TODO: Implement do() method.
  10. }
  11. public function check($userId)
  12. {
  13. }
  14. public function undo()
  15. {
  16. // TODO: Implement undo() method.
  17. }
  18. public function getListByUser($userId, $page=1, $pagesize=10 ,$startTime = '',$endTime = '')
  19. {
  20. $financialRecord = new FinancialRecord();
  21. $mod = bcmod((string)$userId, '5', 0);
  22. $financialRecord->suffix($mod);
  23. $builder = $financialRecord->where('user_id',$userId)
  24. ->where('money_type','<',100);
  25. // if(!empty($startTime) && !empty($endTime)){
  26. // $builder->whereBetween('created_at',[strtotime($startTime.' 00:00:00'),strtotime($endTime.' 23:59:59')]);
  27. // }
  28. if (!empty($startTime)) {
  29. $builder->where('created_at', '>=', $startTime);
  30. }
  31. if (!empty($endTime)) {
  32. $builder->where('created_at', '<=', $endTime);
  33. }
  34. $paginate = $builder->orderBy('created_at', 'desc')->paginate($pagesize);
  35. $revenues = $paginate->toArray();
  36. return ['has_more_pages' => $paginate->hasMorePages(), 'revenue_list' => $revenues['data']];
  37. }
  38. public function getRevenueByUser($userId,$type = [],$startTime = '',$endTime = '')
  39. {
  40. $financialRecord = new FinancialRecord();
  41. $mod = bcmod((string)$userId, '5', 0);
  42. $financialRecord->suffix($mod);
  43. $builder = $financialRecord->where('user_id',$userId)
  44. ->whereIn('money_type',$type);
  45. if(!empty($startTime) && !empty($endTime)){
  46. $builder->whereBetween('created_at',[$startTime,$endTime]);
  47. }
  48. $revenue = $builder->select('money','money_type','created_at')->orderBy('created_at', 'desc')->get()->toArray();
  49. return $revenue;
  50. }
  51. }