94 lines
3.3 KiB
PHP
94 lines
3.3 KiB
PHP
<?php
|
||
/**
|
||
* SaaSMall商城系统 - 团队十年电商经验汇集巨献!
|
||
* =========================================================
|
||
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
|
||
* ----------------------------------------------
|
||
* 官方网址: https://www.gobuysaas.com
|
||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||
* =========================================================
|
||
*/
|
||
|
||
namespace addon\store\shopapi\controller;
|
||
|
||
|
||
use app\model\system\Pay as PayModel;
|
||
use app\model\web\Config as WebConfig;
|
||
|
||
|
||
/**
|
||
* 支付配置
|
||
* Class Pay
|
||
* @package app\shop\controller
|
||
*/
|
||
class Pay extends BaseStoreApi
|
||
{
|
||
/**
|
||
* 交易设置详情
|
||
*/
|
||
public function configInfo()
|
||
{
|
||
$config_model = new WebConfig();
|
||
$info = $config_model->getOrderConfig($this->site_id);
|
||
$pay_config = $config_model->getPayConfig($this->site_id);
|
||
$pay_config = $pay_config[ 'data' ][ 'value' ];
|
||
$info = array_merge($info[ 'data' ][ 'value' ], $pay_config);
|
||
return $this->response($this->success($info));
|
||
}
|
||
|
||
/**
|
||
* 交易设置编辑
|
||
*/
|
||
public function config()
|
||
{
|
||
$config_model = new WebConfig();
|
||
$site_id = $this->site_id;
|
||
$member_withdrawal_audit_switch = isset($this->params[ 'member_withdrawal_audit_switch' ]) ? $this->params[ 'member_withdrawal_audit_switch' ] : 0;// 会员提现审核开关,1:开启,0:关闭
|
||
$member_withdrawal_rate = isset($this->params[ 'member_withdrawal_rate' ]) ? $this->params[ 'member_withdrawal_rate' ] : 0;
|
||
$data = [
|
||
'member_withdrawal_audit_switch' => $member_withdrawal_audit_switch,
|
||
'member_withdrawal_rate' => $member_withdrawal_rate
|
||
];
|
||
$res = $config_model->setPayConfig($data, $site_id);
|
||
$auto_close = isset($this->params[ 'auto_close' ]) ? $this->params[ 'auto_close' ] : 0;//订单未付款自动关闭时间
|
||
$auto_take_delivery = isset($this->params[ 'auto_take_delivery' ]) ? $this->params[ 'auto_take_delivery' ] : 14;//订单发货后自动收货时间
|
||
$result = $config_model->setOrderConfig([
|
||
'auto_close' => $auto_close,
|
||
'auto_take_delivery' => $auto_take_delivery,
|
||
], $this->site_id);
|
||
return $this->response($res);
|
||
}
|
||
|
||
/**
|
||
* 在线支付
|
||
* @return mixed|void
|
||
*/
|
||
public function pay()
|
||
{
|
||
$out_trade_no = $this->params[ 'out_trade_no' ] ?? '';
|
||
|
||
$pay_model = new PayModel();
|
||
$pay_type = $this->params[ 'pay_type' ] ?? '';
|
||
$return_url = url('shop/pay/payresult?out_trade_no=' . $out_trade_no);
|
||
|
||
$res = $pay_model->pay($pay_type, $out_trade_no, 'h5', '', '', $return_url, 0);
|
||
return $this->response($res);
|
||
}
|
||
|
||
/**
|
||
* 支付结果
|
||
* @return mixed|void
|
||
*/
|
||
public function payresult()
|
||
{
|
||
$out_trade_no = $this->params[ 'out_trade_no' ] ?? '';
|
||
|
||
$pay_model = new PayModel();
|
||
$pay_info = $pay_model->getPayInfo($out_trade_no)[ 'data' ];
|
||
if (empty($pay_info)) return $this->error('未获取到支付信息');
|
||
|
||
return $this->response($pay_info);
|
||
}
|
||
|
||
} |