BillTransformer.php 966 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace App\Http\Controllers\Manage\Finance\Transformers;
  3. /**
  4. * Created by PhpStorm.
  5. * User: tandunzhao
  6. * Date: 2017/11/17
  7. * Time: 下午4:26
  8. */
  9. class BillTransformer
  10. {
  11. public function transform($bill){
  12. return [
  13. 'channel_id' => isset($bill->distribution_channel_id) ? $bill->distribution_channel_id : "",
  14. 'channel_name' => isset($bill->distribution_channel_name) ? $bill->distribution_channel_name : "",
  15. 'date' => isset($bill->date) ? date('Y-m-d',strtotime($bill->date)) : "",
  16. 'recharge_amount' => (float)(isset($bill->recharge_amount) ? $bill->recharge_amount : 0),
  17. 'settlement_price' => (float)(isset($bill->settlement_price) ? $bill->settlement_price : 0),
  18. 'tallage' => (float)(isset($bill->tallage) ? ($bill->tallage) : 0),
  19. 'rate' => (100 * (float)(isset($bill->rate) ? ($bill->rate) : 0))."%",
  20. ];
  21. }
  22. }