PayConfigLogic.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\logic\settings\pay;
  20. use app\common\enum\PayEnum;
  21. use app\common\logic\BaseLogic;
  22. use app\common\model\PayConfig;
  23. class PayConfigLogic extends BaseLogic
  24. {
  25. /**
  26. * @notes 设置支付配置
  27. * @param $params
  28. * @return bool
  29. * @throws \think\db\exception\DataNotFoundException
  30. * @throws \think\db\exception\DbException
  31. * @throws \think\db\exception\ModelNotFoundException
  32. * @author ljj
  33. * @date 2021/7/27 6:14 下午
  34. */
  35. public function setConfig($params)
  36. {
  37. $pay_config = PayConfig::find($params['id']);
  38. $config = '';
  39. if ($pay_config['pay_way'] == PayEnum::WECHAT_PAY) {
  40. $config = [
  41. 'interface_version' => $params['interface_version'],
  42. 'merchant_type' => $params['merchant_type'],
  43. 'mch_id' => $params['mch_id'],
  44. 'pay_sign_key' => $params['pay_sign_key'],
  45. 'apiclient_cert' => $params['apiclient_cert'],
  46. 'apiclient_key' => $params['apiclient_key'],
  47. 'wechat_public_serial' => $params['wechat_public_serial'] ?? '',
  48. 'wechat_public_cert' => $params['wechat_public_cert'] ?? '',
  49. ];
  50. }
  51. if ($pay_config['pay_way'] == PayEnum::ALI_PAY) {
  52. $config = [
  53. 'mode' => $params['mode'],
  54. 'merchant_type' => $params['merchant_type'],
  55. 'app_id' => $params['app_id'],
  56. 'private_key' => $params['private_key'],
  57. 'ali_public_key' => $params['ali_public_key'],
  58. ];
  59. }
  60. $pay_config->name = $params['name'];
  61. $pay_config->icon = $params['icon'];
  62. $pay_config->sort = $params['sort'];
  63. $pay_config->config = $config;
  64. $pay_config->remark = $params['remark'] ?? '';
  65. return $pay_config->save();
  66. }
  67. /**
  68. * @notes 查看支付配置
  69. * @param $params
  70. * @return array
  71. * @throws \think\db\exception\DataNotFoundException
  72. * @throws \think\db\exception\DbException
  73. * @throws \think\db\exception\ModelNotFoundException
  74. * @author ljj
  75. * @date 2021/7/28 2:24 下午
  76. */
  77. public function getConfig($params)
  78. {
  79. $payConfig = PayConfig::find($params['id'])->toArray();
  80. $payConfig['domain'] = request()->domain();
  81. return $payConfig;
  82. }
  83. }