<?php

namespace App\Transformer\Account;

class AccountTransformer
{
    // 用户列表
    public function newBuildSupplierList($data): array
    {
        return [
            'meta' => getMeta($data),
            'list'  => $this->newEachSupplierList($data),
        ];
    }

    private function newEachSupplierList($list): array
    {
        $result = [];
        if (empty($list)) return $result;

        foreach ($list as $item) {
            $result[] = [
                'id'                        => getProp($item, 'id'),
                'company'                   => getProp($item, 'company'),
                'business_license'          => getProp($item, 'business_license'),
                'legal_person'              => getProp($item, 'legal_person'),
                'company_address'           => getProp($item, 'company_address'),
                'bank_card'                 => getProp($item, 'bank_card'),
                'bank_name'                 => getProp($item, 'bank_name'),
                'mobile'                    => getProp($item, 'mobile'),
                'USCC'                      => getProp($item, 'USCC'),
                'status'              => getProp($item, 'status'),
                'remark'                    => getProp($item, 'remark'),
                'created_at'                => transDate(getProp($item, 'created_at')),
                'enable_editable'           => getProp($item, 'status') == '待审核' ? 1 : 0,
            ];
        }

        return $result;
    }
}
