OrderDayStatTransformer.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: hp
  5. * Date: 2017/12/1
  6. * Time: 11:42
  7. */
  8. namespace App\Http\Controllers\Manage\Trade\Transformers;
  9. class OrderDayStatTransformer
  10. {
  11. public function transform($stat)
  12. {
  13. return [
  14. 'distribution_channel_id' => $stat->distribution_channel_id,
  15. 'distribution_channel_name' => isset($stat->company_name)?$stat->company_name:$stat->distribution_channel_name,
  16. 'date' => $stat->date,
  17. 'pay_success_user_num' => $stat->pay_success_user_num,
  18. 'total_recharge_amount' => $stat->total_recharge_amount,
  19. 'unpaid_num' => $stat->unpaid_num,
  20. 'paid_num' => $stat->paid_num,
  21. 'promotion_total_uv' => $stat->promotion_total_uv,
  22. 'promotion_total_pv' => $stat->promotion_total_pv,
  23. 'send_order_num' => $stat->send_order_num,
  24. 'real_send_order_num' => $stat->real_send_order_num,
  25. 'register_user_num' => $stat->register_user_num,
  26. 'real_register_user_num' => $stat->real_register_user_num,
  27. 'force_user_num' => $stat->force_user_num,
  28. 'ticket_recharge_user_num' => $stat->ticket_recharge_user_num,
  29. 'year_recharge_user_num' => $stat->year_recharge_user_num,
  30. 'created_at' => $stat->created_at->toDateTimeString(),
  31. 'updated_at' => $stat->updated_at->toDateTimeString(),
  32. 'sign_num' => isset($stat->sign_num)?$stat->sign_num:0,
  33. 'actual_send_order_num' => isset($stat->actual_send_order_num)?$stat->actual_send_order_num:0,
  34. 'first_pay_user_num' => (int)$stat->first_recharge_user_num,
  35. 'first_pay_amount' => (float)$stat->first_recharge_amount,
  36. 'not_first_pay_user_num' => (int)$stat->pay_success_user_num - (int)$stat->first_recharge_user_num,
  37. 'not_first_pay_amount' => round((float)$stat->total_recharge_amount - (float)$stat->first_recharge_amount,2),
  38. 'reg_user_first_recharge_user_num'=>(float)$stat->reg_user_first_recharge_user_num,
  39. 'reg_user_first_recharge_amount'=>(float)$stat->reg_user_first_recharge_amount,
  40. 'fans_gender'=>isset($stat->fans_gender)?$stat->fans_gender:''
  41. ];
  42. }
  43. public function transformDefault($stat)
  44. {
  45. return [
  46. 'distribution_channel_id' => $stat->distribution_channel_id,
  47. 'distribution_channel_name' => $stat->distribution_channel_name,
  48. 'date' =>'',
  49. 'pay_success_user_num' => 0,
  50. 'total_recharge_amount' => 0,
  51. 'unpaid_num' => 0,
  52. 'paid_num' => 0,
  53. 'promotion_total_uv' => 0,
  54. 'promotion_total_pv' => 0,
  55. 'send_order_num' => 0,
  56. 'real_send_order_num' => 0,
  57. 'register_user_num' => 0,
  58. 'real_register_user_num' => 0,
  59. 'force_user_num' => 0,
  60. 'ticket_recharge_user_num' => 0,
  61. 'year_recharge_user_num' => 0,
  62. 'created_at' =>0,
  63. 'updated_at' => 0,
  64. 'sign_num' => 00,
  65. 'actual_send_order_num' => 00,
  66. 'first_pay_user_num' => 0,
  67. 'first_pay_amount' => 0,
  68. 'not_first_pay_user_num' => 0,
  69. 'not_first_pay_amount' => 0,
  70. 'reg_user_first_recharge_user_num'=>0,
  71. 'reg_user_first_recharge_amount'=>0,
  72. 'fans_gender'=>isset($stat->fans_gender)?$stat->fans_gender:''
  73. ];
  74. }
  75. }