123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- namespace App\Transformer\Settlement;
- class SettlementTransformer
- {
- /**
- * 结算列表
- *
- * @param $data
- * @return array
- */
- public function buildBills($data): array
- {
- return [
- 'meta' => getMeta($data),
- 'list' => $this->eachBills($data->items())
- ];
- }
- /**
- * @param $data
- * @return array
- */
- public function buildBillOrders($data): array
- {
- if (empty($data)) {
- return [];
- }
- $result = [];
- foreach ($data as $item) {
- $result[] = [
- 'id' => getProp($item, 'id'),
- 'price' => getProp($item, 'price'),
- 'send_order_id' => getProp($item, 'send_order_id'),
- 'send_order_name' => (string)getProp($item, 'send_order_name'),
- 'created_at' => $item->created_at->format('Y-m-d H:i:s'),
- ];
- }
- return $result;
- }
- /**
- * 提现列表
- *
- * @param $data
- * @return array
- */
- public function buildWithdrawCashes($data): array
- {
- return [
- 'meta' => getMeta($data),
- 'list' => $this->eachWithdrawCashes($data->items())
- ];
- }
- /**
- * @param $bills
- * @return array
- */
- private function eachBills($bills): array
- {
- if (empty($bills)) {
- return [];
- }
- $result = [];
- foreach ($bills as $bill) {
- $result[] = [
- 'date' => getProp($bill, 'date'),
- 'recharge_amount' => getProp($bill, 'recharge_amount'),
- 'rate' => getProp($bill, 'rate'),
- 'service_amount' => getProp($bill, 'service_amount'),
- 'settlement_price' => getProp($bill, 'settlement_price'),
- ];
- }
- return $result;
- }
- /**
- * @param $bills
- * @return array
- */
- private function eachWithdrawCashes($bills): array
- {
- if (empty($bills)) {
- return [];
- }
- $result = [];
- foreach ($bills as $bill) {
- $result[] = [
- 'amount' => getProp($bill, 'amount'),
- 'status' => getProp($bill, 'status'),
- 'created_at' => $bill->created_at->format('Y-m-d H:i:s'),
- 'bank_account' => getProp($bill, 'bank_account'),
- 'account_name' => getProp($bill, 'account_name'),
- 'pay_time' => getProp($bill, 'pay_time'),
- ];
- }
- return $result;
- }
- }
|