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.

76 lines
2.5 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,$tab ,$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('user_type','=',UserType::STORE);
  26. switch ($tab) {
  27. case 'all':
  28. break;
  29. case 'online':
  30. $builder->whereIn('money_type', $financialRecord::MONEY_TYPE_STORE_ORDER_ONLINE);
  31. break;
  32. case 'offline':
  33. $builder->where('money_type', $financialRecord::MONEY_TYPE_STORE_OFL_ORDER_COMP);
  34. break;
  35. case 'withdraw':
  36. $builder->where('money_type', $financialRecord::MONEY_TYPE_STORE_WITHDRAW);
  37. break;
  38. case 'reward':
  39. $builder->whereIn('money_type', $financialRecord::MONEY_TYPE_STORE_REWARD);
  40. break;
  41. }
  42. if (!empty($startTime)) {
  43. $builder->where('created_at', '>=', $startTime);
  44. }
  45. if (!empty($endTime)) {
  46. $builder->where('created_at', '<=', $endTime);
  47. }
  48. $paginate = $builder->orderBy('created_at', 'desc')->paginate($pagesize);
  49. $revenues = $paginate->toArray();
  50. return ['has_more_pages' => $paginate->hasMorePages(), 'revenue_list' => $revenues['data']];
  51. }
  52. public function getRevenueByUser($userId,$type = [],$startTime = '',$endTime = '')
  53. {
  54. $financialRecord = new FinancialRecord();
  55. $mod = bcmod((string)$userId, '5', 0);
  56. $financialRecord->suffix($mod);
  57. $builder = $financialRecord->where('user_id',$userId)
  58. ->whereIn('money_type',$type);
  59. if(!empty($startTime) && !empty($endTime)){
  60. $builder->whereBetween('created_at',[$startTime,$endTime]);
  61. }
  62. $revenue = $builder->select('money','money_type','created_at')->orderBy('created_at', 'desc')->get()->toArray();
  63. return $revenue;
  64. }
  65. }