Pay.php 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\wechatpay\shop\controller;
  11. use addon\wechatpay\model\Config as ConfigModel;
  12. use app\model\upload\Upload;
  13. use app\shop\controller\BaseShop;
  14. use think\facade\Config;
  15. /**
  16. * 支付 控制器
  17. */
  18. class Pay extends BaseShop
  19. {
  20. public function config()
  21. {
  22. $config_model = new ConfigModel();
  23. if (request()->isAjax()) {
  24. $appid = input("appid", "");//公众账号ID
  25. $mch_id = input("mch_id", "");//商户号
  26. $app_secrect = input("app_secrect", "");//应用密钥
  27. $pay_signkey = input("pay_signkey", "");//支付签名串API密钥
  28. $apiclient_cert = input("apiclient_cert", "");//支付证书cert
  29. $apiclient_key = input("apiclient_key", "");//支付证书key
  30. $app_type = input("app_type", "");//支持端口 如web app
  31. $pay_status = input("pay_status", 0);//支付启用状态
  32. $refund_status = input("refund_status", 0);//退款启用状态
  33. $transfer_status = input("transfer_status", 0);//转账启用状态
  34. $transfer_type = input("transfer_type", 'v2');
  35. $api_type = input("api_type", 'v2');
  36. $plateform_cert = input("plateform_cert", '');
  37. $v3_pay_signkey = input('v3_pay_signkey', '');
  38. $data = array(
  39. "appid" => $appid,
  40. "mch_id" => $mch_id,
  41. "app_secrect" => $app_secrect,
  42. "pay_signkey" => $pay_signkey,
  43. "apiclient_cert" => $apiclient_cert,
  44. "apiclient_key" => $apiclient_key,
  45. "refund_status" => $refund_status,
  46. "pay_status" => $pay_status,
  47. "transfer_status" => $transfer_status,
  48. "app_type" => $app_type,
  49. 'transfer_type' => $transfer_type,
  50. 'plateform_cert' => $plateform_cert,
  51. 'api_type' => $api_type,
  52. 'v3_pay_signkey' => $v3_pay_signkey
  53. );
  54. $result = $config_model->setPayConfig($data, $this->site_id, $this->app_module);
  55. return $result;
  56. } else {
  57. $info_result = $config_model->getPayConfig($this->site_id, $this->app_module);
  58. $info = $info_result["data"];
  59. if (!empty($info['value'])) {
  60. $app_type_arr = [];
  61. if (!empty($info['value']['app_type'])) {
  62. $app_type_arr = explode(',', $info['value']['app_type']);
  63. }
  64. $info['value']['app_type_arr'] = $app_type_arr;
  65. }
  66. $this->assign("info", $info);
  67. $this->assign("app_type", Config::get("app_type"));
  68. return $this->fetch("pay/config");
  69. }
  70. }
  71. /**
  72. * 上传微信支付证书
  73. */
  74. public function uploadWechatCert()
  75. {
  76. $upload_model = new Upload();
  77. $site_id = request()->siteid();
  78. $name = input("name", "");
  79. $extend_type = ['pem'];
  80. $param = array(
  81. "name" => "file",
  82. "extend_type" => $extend_type
  83. );
  84. $site_id = $site_id > 0 ? $site_id : 0;
  85. $result = $upload_model->setPath("common/wechat/cert/" . $site_id . "/")->file($param);
  86. return $result;
  87. }
  88. }