123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- /**
- * Created by PhpStorm.
- * User: hp
- * Date: 2017/12/1
- * Time: 11:42
- */
- namespace App\Http\Controllers\Manage\Trade\Transformers;
- class OrderDayStatTransformer
- {
- public function transform($stat)
- {
- return [
- 'distribution_channel_id' => $stat->distribution_channel_id,
- 'distribution_channel_name' => isset($stat->company_name)?$stat->company_name:$stat->distribution_channel_name,
- 'date' => $stat->date,
- 'pay_success_user_num' => $stat->pay_success_user_num,
- 'total_recharge_amount' => $stat->total_recharge_amount,
- 'unpaid_num' => $stat->unpaid_num,
- 'paid_num' => $stat->paid_num,
- 'promotion_total_uv' => $stat->promotion_total_uv,
- 'promotion_total_pv' => $stat->promotion_total_pv,
- 'send_order_num' => $stat->send_order_num,
- 'real_send_order_num' => $stat->real_send_order_num,
- 'register_user_num' => $stat->register_user_num,
- 'real_register_user_num' => $stat->real_register_user_num,
- 'force_user_num' => $stat->force_user_num,
- 'ticket_recharge_user_num' => $stat->ticket_recharge_user_num,
- 'year_recharge_user_num' => $stat->year_recharge_user_num,
- 'created_at' => $stat->created_at->toDateTimeString(),
- 'updated_at' => $stat->updated_at->toDateTimeString(),
- 'sign_num' => isset($stat->sign_num)?$stat->sign_num:0,
- 'actual_send_order_num' => isset($stat->actual_send_order_num)?$stat->actual_send_order_num:0,
- 'first_pay_user_num' => (int)$stat->first_recharge_user_num,
- 'first_pay_amount' => (float)$stat->first_recharge_amount,
- 'not_first_pay_user_num' => (int)$stat->pay_success_user_num - (int)$stat->first_recharge_user_num,
- 'not_first_pay_amount' => round((float)$stat->total_recharge_amount - (float)$stat->first_recharge_amount,2),
- 'reg_user_first_recharge_user_num'=>(float)$stat->reg_user_first_recharge_user_num,
- 'reg_user_first_recharge_amount'=>(float)$stat->reg_user_first_recharge_amount,
- 'fans_gender'=>isset($stat->fans_gender)?$stat->fans_gender:''
- ];
- }
- public function transformDefault($stat)
- {
- return [
- 'distribution_channel_id' => $stat->distribution_channel_id,
- 'distribution_channel_name' => $stat->distribution_channel_name,
- 'date' =>'',
- 'pay_success_user_num' => 0,
- 'total_recharge_amount' => 0,
- 'unpaid_num' => 0,
- 'paid_num' => 0,
- 'promotion_total_uv' => 0,
- 'promotion_total_pv' => 0,
- 'send_order_num' => 0,
- 'real_send_order_num' => 0,
- 'register_user_num' => 0,
- 'real_register_user_num' => 0,
- 'force_user_num' => 0,
- 'ticket_recharge_user_num' => 0,
- 'year_recharge_user_num' => 0,
- 'created_at' =>0,
- 'updated_at' => 0,
- 'sign_num' => 00,
- 'actual_send_order_num' => 00,
- 'first_pay_user_num' => 0,
- 'first_pay_amount' => 0,
- 'not_first_pay_user_num' => 0,
- 'not_first_pay_amount' => 0,
- 'reg_user_first_recharge_user_num'=>0,
- 'reg_user_first_recharge_amount'=>0,
- 'fans_gender'=>isset($stat->fans_gender)?$stat->fans_gender:''
- ];
- }
- }
|