PaymentService.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\api\service;
  3. use app\common\model\PaymentChannelModel;
  4. class PaymentService extends \app\BaseService
  5. {
  6. private $paymentChannel;
  7. public function __construct()
  8. {
  9. $this->paymentChannel = new PaymentChannelModel();
  10. }
  11. public function channels() {
  12. $channels = $this->paymentChannel->findAll()->toArray();
  13. return array_map(function ($channel) {
  14. $fmt = [
  15. "id" => $channel['id'],
  16. 'name' => $channel['name'],
  17. 'icon' => $channel['icon'],
  18. 'type' => $channel['type'],
  19. 'is_upload_code' => $channel['is_upload_code'],
  20. 'credit_card_config' => [],
  21. ];
  22. if($channel['type'] == 2) {
  23. $fmt['zue_coin_exchange_rate'] = $channel['zue_coin_exchange_rate'];
  24. $fmt['zue_coin_consume_rate'] = $channel['zue_coin_consume_rate'];
  25. } else if($channel['type'] == 3) {
  26. $disposables = [];
  27. $stages = [];
  28. foreach ($channel['relation'] as $item) {
  29. $credit_config = [
  30. 'id' => $item['id'],
  31. 'bank' => $item['bank'],
  32. ];
  33. if($item['is_stage'] == 1) {
  34. $credit_config['periods'] = [];
  35. if($item['stage_6'][0] == 1) {
  36. array_push($credit_config['periods'], ['nper' => 6, 'service_charge_rate' => (int)$item['stage_6'][1]]);
  37. }
  38. if($item['stage_9'][0] == 1) {
  39. array_push($credit_config['periods'], ['nper' => 9, 'service_charge_rate' => (int)$item['stage_9'][1]]);
  40. }
  41. if($item['stage_12'][0] == 1) {
  42. array_push($credit_config['periods'], ['nper' => 12, 'service_charge_rate' => (int)$item['stage_12'][1]]);
  43. }
  44. if($item['stage_24'][0] == 1) {
  45. array_push($credit_config['periods'], ['nper' => 24, 'service_charge_rate' => (int)$item['stage_24'][1]]);
  46. }
  47. if($item['stage_36'][0] == 1) {
  48. array_push($credit_config['periods'], ['nper' => 36, 'service_charge_rate' => (int)$item['stage_36'][1]]);
  49. }
  50. array_push($stages, $credit_config);
  51. } else {
  52. array_push($disposables, $credit_config);
  53. }
  54. }
  55. $fmt['relation'] = ['disposables' =>$disposables, "stages" => $stages ];
  56. }
  57. return $fmt;
  58. }, $channels);
  59. }
  60. }