Pay.php 3.6 KB

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