| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\api\service;
- use app\common\model\PaymentChannelModel;
- class PaymentService extends \app\BaseService
- {
- private $paymentChannel;
- public function __construct()
- {
- $this->paymentChannel = new PaymentChannelModel();
- }
- public function channels() {
- $channels = $this->paymentChannel->findAll()->toArray();
- return array_map(function ($channel) {
- $fmt = [
- "id" => $channel['id'],
- 'name' => $channel['name'],
- 'icon' => $channel['icon'],
- 'type' => $channel['type'],
- 'is_upload_code' => $channel['is_upload_code'],
- 'credit_card_config' => [],
- ];
- if($channel['type'] == 2) {
- $fmt['zue_coin_exchange_rate'] = $channel['zue_coin_exchange_rate'];
- $fmt['zue_coin_consume_rate'] = $channel['zue_coin_consume_rate'];
- } else if($channel['type'] == 3) {
- $disposables = [];
- $stages = [];
- foreach ($channel['relation'] as $item) {
- $credit_config = [
- 'id' => $item['id'],
- 'bank' => $item['bank'],
- ];
- if($item['is_stage'] == 1) {
- $credit_config['periods'] = [];
- if($item['stage_6'][0] == 1) {
- array_push($credit_config['periods'], ['nper' => 6, 'service_charge_rate' => (int)$item['stage_6'][1]]);
- }
- if($item['stage_9'][0] == 1) {
- array_push($credit_config['periods'], ['nper' => 9, 'service_charge_rate' => (int)$item['stage_9'][1]]);
- }
- if($item['stage_12'][0] == 1) {
- array_push($credit_config['periods'], ['nper' => 12, 'service_charge_rate' => (int)$item['stage_12'][1]]);
- }
- if($item['stage_24'][0] == 1) {
- array_push($credit_config['periods'], ['nper' => 24, 'service_charge_rate' => (int)$item['stage_24'][1]]);
- }
- if($item['stage_36'][0] == 1) {
- array_push($credit_config['periods'], ['nper' => 36, 'service_charge_rate' => (int)$item['stage_36'][1]]);
- }
- array_push($stages, $credit_config);
- } else {
- array_push($disposables, $credit_config);
- }
- }
- $fmt['relation'] = ['disposables' =>$disposables, "stages" => $stages ];
- }
- return $fmt;
- }, $channels);
- }
- }
|