支付方式

feat/task1-c-wallet
devil_gong 2018-12-24 16:45:18 +08:00
parent df885e75a3
commit 923d179ddb
23 changed files with 227 additions and 35 deletions

View File

@ -121,7 +121,7 @@
<form class="am-form form-validation" action="{{:url('admin/payment/upload')}}" method="POST" request-type="ajax-reload" enctype="multipart/form-data">
<input type="hidden" name="max_file_size" value="{{:MyC('home_max_limit_file', 51200000)}}" />
<div class="am-alert am-radius am-alert-tips m-t-0" data-am-alert>
<p class="m-t-1)}}1 .class.php Alipay.class.php Alipay <br />2 类必须定义三个方法<br />&nbsp;&nbsp;&nbsp; 2.1 Config 配置方法<br />&nbsp;&nbsp;&nbsp; 2.2 Pay 支付方法<br />&nbsp;&nbsp;&nbsp; 2.3 Respond 回调方法</p>
<p class="m-t-10">1 类名必须于文件名一致(去除 .php ),如 Alipay.php 则取 Alipay <br />2 类必须定义三个方法<br />&nbsp;&nbsp;&nbsp; 2.1 Config 配置方法<br />&nbsp;&nbsp;&nbsp; 2.2 Pay 支付方法<br />&nbsp;&nbsp;&nbsp; 2.3 Respond 回调方法</p>
<p class="cr-red">PS以上条件不满足则无法查看插件</p>
</div>
<div class="am-form-group am-form-file">

View File

@ -25,7 +25,7 @@
<span class="msg">{{$msg}}</span>
<div class="tips-nav">
<a href="{{$Think.__MY_URL__}}" class="am-btn am-btn-secondary am-radius">回到首页</a>
<a href="{{:U('index/order/index')}}" class="am-btn am-btn-primary am-radius">我的订单</a>
<a href="{{:HomeUrl('order', 'index')}}" class="am-btn am-btn-primary am-radius">我的订单</a>
</div>
</div>
</div>

View File

@ -2,6 +2,7 @@
namespace app\service;
use think\Db;
use app\service\ResourcesService;
/**
* APP导航服务层

View File

@ -813,7 +813,7 @@ class BuyService
}
// 获取订单商品
$order_detail = Db::name('OrderDetail')->field('goods_id,buy_number')->where(['order_id'=>$params['order_id']])->select();
$order_detail = Db::name('OrderDetail')->field('goods_id,buy_number,spec')->where(['order_id'=>$params['order_id']])->select();
if(!empty($order_detail))
{
foreach($order_detail as $v)
@ -828,7 +828,21 @@ class BuyService
// 扣除操作
if(!Db::name('Goods')->where(['id'=>$v['goods_id']])->setDec('inventory', $v['buy_number']))
{
return DataReturn('库存扣减失败['.$params['order_id'].'-'.$v['goods_id'].']', -10);
return DataReturn('商品库存扣减失败['.$params['order_id'].'-'.$v['goods_id'].'('.$goods['inventory'].'-'.$v['buy_number'].')]', -10);
}
// 扣除规格库存
$spec = empty($v['spec']) ? '' : json_decode($v['spec'], true);
$base = GoodsService::GoodsSpecDetail(['id'=>$v['goods_id'], 'spec'=>$spec]);
if($base['code'] == 0)
{
// 扣除规格操作
if(!Db::name('GoodsSpecBase')->where(['id'=>$base['data']['id'], 'goods_id'=>$v['goods_id']])->setDec('inventory', $v['buy_number']))
{
return DataReturn('规格库存扣减失败['.$params['order_id'].'-'.$v['goods_id'].'('.$goods['inventory'].'-'.$v['buy_number'].')]', -10);
}
} else {
return $base;
}
// 扣除日志添加
@ -894,7 +908,7 @@ class BuyService
}
// 获取订单商品
$order_detail = Db::name('OrderDetail')->field('goods_id,buy_number')->where(['order_id'=>$params['order_id']])->select();
$order_detail = Db::name('OrderDetail')->field('goods_id,buy_number,spec')->where(['order_id'=>$params['order_id']])->select();
if(!empty($order_detail))
{
foreach($order_detail as $v)
@ -906,7 +920,21 @@ class BuyService
// 回滚操作
if(!Db::name('Goods')->where(['id'=>$v['goods_id']])->setInc('inventory', $v['buy_number']))
{
return DataReturn('库存回滚失败['.$params['order_id'].'-'.$v['goods_id'].']', -10);
return DataReturn('商品库存回滚失败['.$params['order_id'].'-'.$v['goods_id'].']', -10);
}
// 扣除规格库存
$spec = empty($v['spec']) ? '' : json_decode($v['spec'], true);
$base = GoodsService::GoodsSpecDetail(['id'=>$v['goods_id'], 'spec'=>$spec]);
if($base['code'] == 0)
{
// 扣除规格操作
if(!Db::name('GoodsSpecBase')->where(['id'=>$base['data']['id'], 'goods_id'=>$v['goods_id']])->setInc('inventory', $v['buy_number']))
{
return DataReturn('规格库存回滚失败['.$params['order_id'].'-'.$v['goods_id'].']', -10);
}
} else {
return $base;
}
// 回滚日志更新

View File

@ -2,6 +2,7 @@
namespace app\service;
use think\Db;
use app\service\ResourcesService;
/**
* 快递服务层

View File

@ -1661,7 +1661,7 @@ class GoodsService
// 获取基础值数据
if(!empty($base_id))
{
$base = Db::name('GoodsSpecBase')->field('goods_id,price,inventory,coding,barcode,original_price')->find($base_id);
$base = Db::name('GoodsSpecBase')->field('id,goods_id,price,inventory,coding,barcode,original_price')->find($base_id);
if(!empty($base))
{
return DataReturn('操作成功', 0, $base);
@ -1670,7 +1670,7 @@ class GoodsService
}
}
} else {
$base = Db::name('GoodsSpecBase')->field('goods_id,price,inventory,coding,barcode,original_price')->where($where)->find();
$base = Db::name('GoodsSpecBase')->field('id,goods_id,price,inventory,coding,barcode,original_price')->where($where)->find();
if(!empty($base))
{
return DataReturn('操作成功', 0, $base);

View File

@ -358,13 +358,13 @@ class OrderService
];
Db::name('PayLog')->insertGetId($pay_log_data);
// 开启事务
Db::startTrans();
// 消息通知
$detail = '订单支付成功,金额'.PriceBeautify($params['order']['total_price']).'元';
MessageService::MessageAdd($params['order']['user_id'], '订单支付', $detail, 1, $params['order']['id']);
// 开启事务
Db::startTrans();
// 更新订单状态
$upd_data = array(
'status' => 2,

View File

@ -542,6 +542,7 @@ class PaymentService
{
return DataReturn('资源不存在或已被删除', -2);
}
// 权限
if(!is_writable($file))
{
@ -612,6 +613,7 @@ class PaymentService
// 批量创建
foreach(self::$payment_business_type_all as $v)
{
$name = strtolower($v['name']);
// 异步
$notify=<<<php
<?php
@ -620,20 +622,24 @@ $notify=<<<php
* {$v['desc']}支付异步入口
*/
namespace think;
// 默认绑定模块
\$_GET['m'] = 'Api';
\$_GET['c'] = '{$v['name']}Notify';
\$_GET['a'] = 'Notify';
\$_GET['s'] = '/api/{$name}notify/notify';
// 支付模块标记
define('PAYMENT_TYPE', '{$payment}');
// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';
// 支持事先使用静态方法设置Request对象和Config对象
// 引入公共入口文件
require './core.php';
// 引入ThinkPHP入口文件
require './ThinkPHP/ThinkPHP.php';
// 执行应用并响应
Container::get('app')->run()->send();
?>
php;
@ -645,20 +651,24 @@ $respond=<<<php
* {$v['desc']}支付同步入口
*/
namespace think;
// 默认绑定模块
\$_GET['m'] = 'Home';
\$_GET['c'] = '{$v['name']}';
\$_GET['a'] = 'Respond';
\$_GET['s'] = '/index/{$name}/respond';
// 支付模块标记
define('PAYMENT_TYPE', '{$payment}');
// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';
// 支持事先使用静态方法设置Request对象和Config对象
// 引入公共入口文件
require './core.php';
// 引入ThinkPHP入口文件
require './ThinkPHP/ThinkPHP.php';
// 执行应用并响应
Container::get('app')->run()->send();
?>
php;
$name = strtolower($v['name']);

View File

@ -2,6 +2,7 @@
namespace app\service;
use think\Db;
use app\service\ResourcesService;
/**
* 筛选价格服务层

View File

@ -2,8 +2,6 @@
namespace app\service;
use think\Db;
use app\service\ResourcesService;
use app\service\MessageService;
use app\service\RegionService;
/**

View File

@ -42,8 +42,8 @@ class Alipay
$base = [
'name' => '支付宝', // 插件名称
'version' => '0.0.1', // 插件版本
'apply_version' => '1.0~1.3', // 适用系统版本描述
'apply_terminal'=> ['pc','h5'], // 适用终端 ['pc', 'h5', 'app', 'alipay', 'wechat', 'baidu']
'apply_version' => '不限', // 适用系统版本描述
'apply_terminal'=> ['pc','h5'], // 适用终端 默认全部 ['pc', 'h5', 'app', 'alipay', 'wechat', 'baidu']
'desc' => '适用PC+H5即时到帐支付方式买家的交易资金直接打入卖家支付宝账户快速回笼交易资金。 <a href="http://www.alipay.com/" target="_blank">立即申请</a>', // 插件描述支持html
'author' => 'Devil', // 开发者
'author_url' => 'http://shopxo.net/', // 开发者主页
@ -58,7 +58,7 @@ class Alipay
'name' => 'account',
'placeholder' => '支付宝账号',
'title' => '支付宝账号',
'is_required' => 1,
'is_required' => 0,
'message' => '请填写支付宝账号',
],
[
@ -68,7 +68,7 @@ class Alipay
'name' => 'partner',
'placeholder' => '合作者身份 partner ID',
'title' => '合作者身份 partner ID',
'is_required' => 1,
'is_required' => 0,
'message' => '请填写合作者身份 partner ID',
],
[
@ -78,7 +78,7 @@ class Alipay
'name' => 'key',
'placeholder' => '交易安全校验码 key',
'title' => '交易安全校验码 key',
'is_required' => 1,
'is_required' => 0,
'message' => '请填写交易安全校验码 key',
],
// [

View File

@ -43,7 +43,7 @@ class AlipayMini
'name' => '支付宝', // 插件名称
'version' => '0.0.1', // 插件版本
'apply_version' => '不限', // 适用系统版本描述
'apply_terminal'=> ['alipay'], // 适用终端 ['pc', 'h5', 'app', 'alipay', 'wechat', 'baidu']
'apply_terminal'=> ['alipay'], // 适用终端 默认全部 ['pc', 'h5', 'app', 'alipay', 'wechat', 'baidu']
'desc' => '适用支付宝小程序,即时到帐支付方式,买家的交易资金直接打入卖家支付宝账户,快速回笼交易资金。 <a href="http://www.alipay.com/" target="_blank">立即申请</a>', // 插件描述支持html
'author' => 'Devil', // 开发者
'author_url' => 'http://shopxo.net/', // 开发者主页
@ -58,7 +58,7 @@ class AlipayMini
'name' => 'appid',
'placeholder' => 'appid',
'title' => 'appid',
'is_required' => 1,
'is_required' => 0,
'message' => '请填写小程序appid',
],
[
@ -66,24 +66,27 @@ class AlipayMini
'name' => 'rsa_public',
'placeholder' => '应用公钥',
'title' => '应用公钥',
'is_required' => 1,
'is_required' => 0,
'rows' => 6,
'message' => '请填写应用公钥',
],
[
'element' => 'textarea',
'name' => 'rsa_private',
'placeholder' => '应用私钥',
'title' => '应用私钥',
'is_required' => 1,
'is_required' => 0,
'rows' => 6,
'message' => '请填写应用私钥',
],
[
'element' => 'textarea',
'name' => 'out_rsa_public',
'placeholder' => '支付宝公钥',
'title' => '支付宝公钥',
'is_required' => 1,
'is_required' => 0,
'rows' => 6,
'message' => '请填写支付宝公钥',
],
];

0
public/install/shopxo_tp5.sql Normal file → Executable file
View File

View File

@ -0,0 +1,25 @@
<?php
/**
* 订单支付异步入口
*/
namespace think;
// 默认绑定模块
$_GET['s'] = '/api/ordernotify/notify';
// 支付模块标记
define('PAYMENT_TYPE', 'Alipay');
// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';
// 支持事先使用静态方法设置Request对象和Config对象
// 引入公共入口文件
require './core.php';
// 执行应用并响应
Container::get('app')->run()->send();
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* 订单支付同步入口
*/
namespace think;
// 默认绑定模块
$_GET['s'] = '/index/order/respond';
// 支付模块标记
define('PAYMENT_TYPE', 'Alipay');
// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';
// 支持事先使用静态方法设置Request对象和Config对象
// 引入公共入口文件
require './core.php';
// 执行应用并响应
Container::get('app')->run()->send();
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* 订单支付异步入口
*/
namespace think;
// 默认绑定模块
$_GET['s'] = '/api/ordernotify/notify';
// 支付模块标记
define('PAYMENT_TYPE', 'AlipayMini');
// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';
// 支持事先使用静态方法设置Request对象和Config对象
// 引入公共入口文件
require './core.php';
// 执行应用并响应
Container::get('app')->run()->send();
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* 订单支付同步入口
*/
namespace think;
// 默认绑定模块
$_GET['s'] = '/index/order/respond';
// 支付模块标记
define('PAYMENT_TYPE', 'AlipayMini');
// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';
// 支持事先使用静态方法设置Request对象和Config对象
// 引入公共入口文件
require './core.php';
// 执行应用并响应
Container::get('app')->run()->send();
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* 订单支付同步入口
*/
namespace think;
// 默认绑定模块
$_GET['s'] = '/index/order/respond';
// 支付模块标记
define('PAYMENT_TYPE', 'CashPayment');
// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';
// 支持事先使用静态方法设置Request对象和Config对象
// 引入公共入口文件
require './core.php';
// 执行应用并响应
Container::get('app')->run()->send();
?>

View File

@ -0,0 +1,25 @@
<?php
/**
* 订单支付同步入口
*/
namespace think;
// 默认绑定模块
$_GET['s'] = '/index/order/respond';
// 支付模块标记
define('PAYMENT_TYPE', 'DeliveryPayment');
// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';
// 支持事先使用静态方法设置Request对象和Config对象
// 引入公共入口文件
require './core.php';
// 执行应用并响应
Container::get('app')->run()->send();
?>

0
public/static/admin/default/css/express.css Normal file → Executable file
View File

View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

View File