人人商城

refund.ctrl.php 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->model('payment');
  8. load()->classs('uploadedfile');
  9. $dos = array('save_setting', 'display');
  10. $do = in_array($do, $dos) ? $do : 'display';
  11. permission_check_account_user('profile_payment_refund', true, 'wxapp');
  12. $_W['page']['title'] = '退款参数 - 小程序选项';
  13. if ($do == 'display') {
  14. $setting = uni_setting_load('payment', $_W['uniacid']);
  15. $setting = $setting['payment'];
  16. if (empty($setting['wechat_refund'])) {
  17. $setting['wechat_refund'] = array('switch' => 0, 'key' => '', 'cert' => '');
  18. }
  19. $has_cert = !empty($setting['wechat_refund']['cert']); $has_key = !empty($setting['wechat_refund']['key']); $open_or_close = !empty($setting['wechat_refund']['switch']);
  20. }
  21. if ($do == 'save_setting') {
  22. $type = $_GPC['type'];
  23. $is_open = $_GPC['switch'] == '1' ? 1 : 0;
  24. $setting = uni_setting_load('payment', $_W['uniacid']);
  25. $pay_setting = $setting['payment'];
  26. $files = UploadedFile::createFromGlobal();
  27. $cert = isset($files['cert']) ? $files['cert'] : null; $private_key = isset($files['key']) ? $files['key'] : null; $cert_content = $pay_setting['wechat_refund']['cert']; $private_key_content = $pay_setting['wechat_refund']['key']; $open_or_close = !empty($pay_setting['wechat_refund']['switch']);
  28. if($cert && $cert->isOk()) { $cert_content = $cert->getContent();
  29. $cert_content = authcode($cert_content, 'ENCODE');
  30. }
  31. if($private_key && $private_key->isOk()) { $key_content = $private_key->getContent();
  32. $private_key_content = authcode($key_content, 'ENCODE');
  33. }
  34. if($is_open) {
  35. if(! $cert_content) {
  36. itoast('请上传apiclient_cert.pem证书', '', 'info');
  37. }
  38. if(! $private_key_content) {
  39. itoast ('请上传apiclient_key.pem证书', '', 'info');
  40. }
  41. }
  42. $pay_setting['wechat_refund'] = array('cert'=>$cert_content,
  43. 'key'=>$private_key_content, 'switch'=>$is_open, 'version'=>1);
  44. uni_setting_save('payment', $pay_setting);
  45. itoast('设置成功', '', 'success');
  46. }
  47. template('wxapp/refund');