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.

64 lines
2.0 KiB

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