mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-11-30 02:49:03 +08:00
pay
This commit is contained in:
parent
076a83bb7d
commit
dc9512ac1c
@ -2,6 +2,8 @@
|
||||
|
||||
namespace Admin\Controller;
|
||||
|
||||
use Service\ResourcesService;
|
||||
|
||||
/**
|
||||
* 支付方式管理
|
||||
* @author Devil
|
||||
@ -62,8 +64,6 @@ class PaymentController extends CommonController
|
||||
$data = [];
|
||||
if(is_dir($this->payment_dir))
|
||||
{
|
||||
$image_host = C('IMAGE_HOST');
|
||||
$db = M('Payment');
|
||||
if($dh = opendir($this->payment_dir))
|
||||
{
|
||||
while(($temp_file = readdir($dh)) !== false)
|
||||
@ -81,18 +81,17 @@ class PaymentController extends CommonController
|
||||
$temp['payment'] = $payment;
|
||||
|
||||
// 获取数据库配置信息
|
||||
$db_config = $db->where(['payment'=>$payment])->find();
|
||||
if(!empty($db_config))
|
||||
$db_config = ResourcesService::PaymentList(['where'=>['payment'=>$payment]]);
|
||||
if(!empty($db_config[0]))
|
||||
{
|
||||
$temp['is_install'] = 1;
|
||||
$temp['id'] = $db_config['id'];
|
||||
$temp['name'] = $db_config['name'];
|
||||
$temp['logo'] = empty($db_config['logo']) ? '' : $image_host.$db_config['logo'];
|
||||
$temp['apply_terminal'] = empty($db_config['apply_terminal']) ? '' : json_decode($db_config['apply_terminal'], true);
|
||||
$temp['is_enable'] = $db_config['is_enable'];
|
||||
$temp['config'] = empty($db_config['config']) ? '' : json_decode($db_config['config'], true);
|
||||
$temp['id'] = $db_config[0]['id'];
|
||||
$temp['name'] = $db_config[0]['name'];
|
||||
$temp['logo'] = $db_config[0]['logo'];
|
||||
$temp['apply_terminal'] = $db_config[0]['apply_terminal'];
|
||||
$temp['is_enable'] = $db_config[0]['is_enable'];
|
||||
$temp['config'] = $db_config[0]['config'];
|
||||
}
|
||||
|
||||
$data[] = $temp;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Home\Controller;
|
||||
|
||||
use Service\OrderService;
|
||||
|
||||
/**
|
||||
* 订单管理
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class OrderController extends CommonController
|
||||
{
|
||||
/**
|
||||
* [_initialize 前置操作-继承公共前置方法]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-03T12:39:08+0800
|
||||
*/
|
||||
public function _initialize()
|
||||
{
|
||||
// 调用父类前置方法
|
||||
parent::_initialize();
|
||||
|
||||
// 是否登录
|
||||
$this->Is_Login();
|
||||
}
|
||||
|
||||
/**
|
||||
* [Index 首页]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2017-02-25T15:30:36+0800
|
||||
*/
|
||||
public function Pay()
|
||||
{
|
||||
$params = $_REQUEST;
|
||||
$params['user'] = $this->user;
|
||||
|
||||
echo '<pre>';
|
||||
$ret = OrderService::Pay($params);
|
||||
|
||||
|
||||
print_r($ret);
|
||||
}
|
||||
}
|
||||
?>
|
@ -275,7 +275,7 @@ function BuySubmitBack(e)
|
||||
}
|
||||
setTimeout(function()
|
||||
{
|
||||
alert(e.data.id);
|
||||
window.location.href = e.data.pay_url;
|
||||
}, 1500);
|
||||
} else {
|
||||
$('form.form-validation').find('button[type="submit"]').button('reset');
|
||||
|
@ -186,6 +186,8 @@ class Alipay
|
||||
public function Pay($params = [])
|
||||
{
|
||||
// 编写代码
|
||||
|
||||
return 'Pay success';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -200,6 +202,8 @@ class Alipay
|
||||
public function Respond($params = [])
|
||||
{
|
||||
// 编写代码
|
||||
|
||||
return 'Respond success';
|
||||
}
|
||||
}
|
||||
?>
|
@ -641,7 +641,12 @@ class BuyService
|
||||
default :
|
||||
$msg = L('common_operation_success');
|
||||
}
|
||||
return DataReturn($msg, 0, $m->find($order_id));
|
||||
|
||||
$result = [
|
||||
'order' => $m->find($order_id),
|
||||
'pay_url' => U('Home/Order/Pay', ['id'=>$order_id]),
|
||||
];
|
||||
return DataReturn($msg, 0, $result);
|
||||
}
|
||||
}
|
||||
?>
|
@ -3,6 +3,7 @@
|
||||
namespace Service;
|
||||
|
||||
use Service\GoodsService;
|
||||
use Service\ResourcesService;
|
||||
|
||||
/**
|
||||
* 订单服务层
|
||||
@ -26,11 +27,11 @@ class OrderService
|
||||
{
|
||||
if(empty($params['id']))
|
||||
{
|
||||
return DataReturn('请选择订单', -1);
|
||||
return DataReturn('订单id有误', -1);
|
||||
}
|
||||
|
||||
$m = M('Order');
|
||||
$where = ['id'=>intval($params['id']), 'user_id' => $this->user['id']];
|
||||
$where = ['id'=>intval($params['id']), 'user_id' => $params['user']['id']];
|
||||
$data = $m->where($where)->field('id,status,total_price,payment_id')->find();
|
||||
if(empty($data))
|
||||
{
|
||||
@ -46,6 +47,13 @@ class OrderService
|
||||
return DataReturn('状态不可操作['.$status_text.']', -1);
|
||||
}
|
||||
|
||||
// 支付方式
|
||||
$payment = ResourcesService::PaymentList(['where'=>['id'=>$data['payment_id']]]);
|
||||
if(empty($payment[0]))
|
||||
{
|
||||
return DataReturn('支付方式有误', -1);
|
||||
}
|
||||
|
||||
// 发起支付
|
||||
$notify_url = __MY_URL__.'Notify/order.php';
|
||||
$pay_data = array(
|
||||
@ -55,7 +63,8 @@ class OrderService
|
||||
'total_price' => $data['total_price'],
|
||||
'notify_url' => $notify_url,
|
||||
);
|
||||
$pay = (new \Library\Payment\Alipay())->Pay($pay_data);
|
||||
$pay_name = '\Library\Payment\\'.$payment[0]['payment'];
|
||||
$pay = (new $pay_name($payment[0]['config']))->Pay($pay_data);
|
||||
if(empty($pay))
|
||||
{
|
||||
return DataReturn('支付接口异常', -1);
|
||||
|
@ -61,8 +61,8 @@ class ResourcesService
|
||||
*/
|
||||
public static function PaymentList($params = [])
|
||||
{
|
||||
$where = ['is_enable'=>1];
|
||||
$data = M('Payment')->where($where)->field('id,logo,name,sort,payment')->order('sort asc')->select();
|
||||
$where = empty($params['where']) ? ['is_enable'=>1] : $params['where'];
|
||||
$data = M('Payment')->where($where)->field('id,logo,name,sort,payment,config,apply_terminal,apply_terminal,element,is_enable')->order('sort asc')->select();
|
||||
if(!empty($data) && is_array($data))
|
||||
{
|
||||
$images_host = C('IMAGE_HOST');
|
||||
@ -70,6 +70,9 @@ class ResourcesService
|
||||
{
|
||||
$v['logo_old'] = $v['logo'];
|
||||
$v['logo'] = empty($v['logo']) ? null : $images_host.$v['logo'];
|
||||
$v['element'] = empty($v['element']) ? '' : json_decode($v['element'], true);
|
||||
$v['config'] = empty($v['config']) ? '' : json_decode($v['config'], true);
|
||||
$v['apply_terminal'] = empty($v['apply_terminal']) ? '' : json_decode($v['apply_terminal'], true);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
|
40
shopxo.sql
40
shopxo.sql
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user