Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jamesyang1999
ShopXO
提交
8d6109d8
ShopXO
项目概览
jamesyang1999
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8d6109d8
编写于
5月 07, 2019
作者:
D
devil_gong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
账户充值
上级
ed301c05
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
475 addition
and
211 deletion
+475
-211
application/lang/zh-cn.php
application/lang/zh-cn.php
+1
-0
application/plugins/wallet/Recharge.php
application/plugins/wallet/Recharge.php
+13
-19
application/plugins/wallet/Rechargenotify.php
application/plugins/wallet/Rechargenotify.php
+42
-0
application/plugins/wallet/service/BaseService.php
application/plugins/wallet/service/BaseService.php
+2
-172
application/plugins/wallet/service/PayService.php
application/plugins/wallet/service/PayService.php
+357
-0
application/service/MessageService.php
application/service/MessageService.php
+1
-1
application/service/OrderService.php
application/service/OrderService.php
+2
-2
application/service/PayLogService.php
application/service/PayLogService.php
+37
-0
config/shopxo.sql
config/shopxo.sql
+20
-17
未找到文件。
application/lang/zh-cn.php
浏览文件 @
8d6109d8
...
@@ -154,6 +154,7 @@ return array(
...
@@ -154,6 +154,7 @@ return array(
'common_business_type_list'
=>
array
(
'common_business_type_list'
=>
array
(
0
=>
array
(
'id'
=>
0
,
'name'
=>
'默认'
,
'checked'
=>
true
),
0
=>
array
(
'id'
=>
0
,
'name'
=>
'默认'
,
'checked'
=>
true
),
1
=>
array
(
'id'
=>
1
,
'name'
=>
'订单'
),
1
=>
array
(
'id'
=>
1
,
'name'
=>
'订单'
),
2
=>
array
(
'id'
=>
2
,
'name'
=>
'充值'
),
),
),
// 用户积分 - 操作类型
// 用户积分 - 操作类型
...
...
application/plugins/wallet/Recharge.php
浏览文件 @
8d6109d8
...
@@ -12,6 +12,7 @@ namespace app\plugins\wallet;
...
@@ -12,6 +12,7 @@ namespace app\plugins\wallet;
use
app\plugins\wallet\Common
;
use
app\plugins\wallet\Common
;
use
app\plugins\wallet\service\BaseService
;
use
app\plugins\wallet\service\BaseService
;
use
app\plugins\wallet\service\PayService
;
/**
/**
* 钱包 - 充值
* 钱包 - 充值
...
@@ -115,7 +116,7 @@ class Recharge extends Common
...
@@ -115,7 +116,7 @@ class Recharge extends Common
{
{
// 用户
// 用户
$params
[
'user'
]
=
$this
->
user
;
$params
[
'user'
]
=
$this
->
user
;
return
Base
Service
::
Pay
(
$params
);
return
Pay
Service
::
Pay
(
$params
);
}
}
/**
/**
...
@@ -131,7 +132,7 @@ class Recharge extends Common
...
@@ -131,7 +132,7 @@ class Recharge extends Common
if
(
input
(
'post.'
))
if
(
input
(
'post.'
))
{
{
$params
[
'user'
]
=
$this
->
user
;
$params
[
'user'
]
=
$this
->
user
;
return
Base
Service
::
RechargePayCheck
(
$params
);
return
Pay
Service
::
RechargePayCheck
(
$params
);
}
else
{
}
else
{
$this
->
assign
(
'msg'
,
'非法访问'
);
$this
->
assign
(
'msg'
,
'非法访问'
);
return
$this
->
fetch
(
'public/tips_error'
);
return
$this
->
fetch
(
'public/tips_error'
);
...
@@ -149,23 +150,16 @@ class Recharge extends Common
...
@@ -149,23 +150,16 @@ class Recharge extends Common
*/
*/
public
function
respond
(
$params
=
[])
public
function
respond
(
$params
=
[])
{
{
$this
->
assign
(
'msg'
,
'支付失败'
);
$params
[
'user'
]
=
$this
->
user
;
return
$this
->
fetch
(
'public/pay_error'
);
$ret
=
PayService
::
Respond
(
$params
);
}
if
(
$ret
[
'code'
]
==
0
)
{
/**
$this
->
assign
(
'msg'
,
'支付成功'
);
* 支付异步通知
return
$this
->
fetch
(
'public/pay_success'
);
* @author Devil
}
else
{
* @blog http://gong.gg/
$this
->
assign
(
'msg'
,
$ret
[
'msg'
]);
* @version 1.0.0
return
$this
->
fetch
(
'public/pay_error'
);
* @date 2019-04-29
}
* @desc description
* @param [array] $params [输入参数]
*/
public
function
notify
(
$params
=
[])
{
$this
->
assign
(
'msg'
,
'支付成功'
);
return
$this
->
fetch
(
'public/pay_success'
);
}
}
/**
/**
...
...
application/plugins/wallet/Rechargenotify.php
0 → 100644
浏览文件 @
8d6109d8
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace
app\plugins\wallet
;
use
app\plugins\wallet\service\PayService
;
/**
* 钱包 - 充值异步处理
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class
Rechargenotify
{
/**
* 支付异步处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-03-04T14:35:38+0800
* @param [array] $params [输入参数]
*/
public
function
notify
(
$params
=
[])
{
$ret
=
PayService
::
Notify
(
$params
);
if
(
$ret
[
'code'
]
==
0
)
{
exit
(
'success'
);
}
exit
(
'error'
);
}
}
?>
\ No newline at end of file
application/plugins/wallet/service/BaseService.php
浏览文件 @
8d6109d8
...
@@ -15,6 +15,7 @@ use app\service\PluginsService;
...
@@ -15,6 +15,7 @@ use app\service\PluginsService;
use
app\service\ResourcesService
;
use
app\service\ResourcesService
;
use
app\service\PaymentService
;
use
app\service\PaymentService
;
use
app\plugins\wallet\service\WalletService
;
use
app\plugins\wallet\service\WalletService
;
use
app\plugins\wallet\service\PayService
;
/**
/**
* 基础服务层
* 基础服务层
...
@@ -25,17 +26,6 @@ use app\plugins\wallet\service\WalletService;
...
@@ -25,17 +26,6 @@ use app\plugins\wallet\service\WalletService;
*/
*/
class
BaseService
class
BaseService
{
{
// 基础数据附件字段
public
static
$base_config_attachment_field
=
[
'default_level_images'
];
// 充值支付状态
public
static
$recharge_status_list
=
[
0
=>
[
'value'
=>
0
,
'name'
=>
'未支付'
,
'checked'
=>
true
],
1
=>
[
'value'
=>
1
,
'name'
=>
'已支付'
],
];
/**
/**
* 充值列表
* 充值列表
* @author Devil
* @author Devil
...
@@ -71,7 +61,7 @@ class BaseService
...
@@ -71,7 +61,7 @@ class BaseService
}
}
// 支付状态
// 支付状态
$v
[
'status_text'
]
=
isset
(
$v
[
'status'
])
?
self
::
$recharge_status_list
[
$v
[
'status'
]][
'name'
]
:
''
;
$v
[
'status_text'
]
=
isset
(
$v
[
'status'
])
?
PayService
::
$recharge_status_list
[
$v
[
'status'
]][
'name'
]
:
''
;
// 支付时间
// 支付时间
$v
[
'pay_time_text'
]
=
empty
(
$v
[
'pay_time'
])
?
''
:
date
(
'Y-m-d H:i:s'
,
$v
[
'pay_time'
]);
$v
[
'pay_time_text'
]
=
empty
(
$v
[
'pay_time'
])
?
''
:
date
(
'Y-m-d H:i:s'
,
$v
[
'pay_time'
]);
...
@@ -183,166 +173,6 @@ class BaseService
...
@@ -183,166 +173,6 @@ class BaseService
return
DataReturn
(
'添加失败'
,
-
100
);
return
DataReturn
(
'添加失败'
,
-
100
);
}
}
/**
* 支付
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-04-29
* @desc description
* @param array $params [description]
*/
public
static
function
Pay
(
$params
=
[])
{
// 请求参数
$p
=
[
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'user'
,
'error_msg'
=>
'用户信息有误'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'recharge_id'
,
'error_msg'
=>
'充值日志id不能为空'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'payment_id'
,
'error_msg'
=>
'请选择支付方式'
,
],
];
$ret
=
ParamsChecked
(
$params
,
$p
);
if
(
$ret
!==
true
)
{
return
DataReturn
(
$ret
,
-
1
);
}
// 支付方式;
$payment
=
PaymentService
::
PaymentList
([
'where'
=>
[
'id'
=>
intval
(
$params
[
'payment_id'
]),
'is_enable'
=>
1
,
'is_open_user'
=>
1
]]);
if
(
empty
(
$payment
[
0
]))
{
return
DataReturn
(
'支付方式有误'
,
-
1
);
}
// 支付入口文件检查
$pay_checked
=
PaymentService
::
EntranceFileChecked
(
$payment
[
0
][
'payment'
],
'wallet'
);
if
(
$pay_checked
[
'code'
]
!=
0
)
{
// 入口文件不存在则创建
$payment_params
=
[
'payment'
=>
$payment
[
0
][
'payment'
],
'business'
=>
[
[
'name'
=>
'Wallet'
,
'desc'
=>
'钱包'
],
],
'respond'
=>
'/index/plugins/index/pluginsname/wallet/pluginscontrol/wallet/pluginsaction/respond'
,
'notify'
=>
'/index/plugins/index/pluginsname/wallet/pluginscontrol/wallet/pluginsaction/notify'
,
];
$ret
=
PaymentService
::
PaymentEntranceCreated
(
$payment_params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
}
// 非线上支付方式不可用
if
(
in_array
(
$payment
[
0
][
'payment'
],
config
(
'shopxo.under_line_list'
)))
{
return
DataReturn
(
'不能使用非线上支付方式进行充值'
,
-
10
);
}
// 获取充值数据
$recharge
=
Db
::
name
(
'PluginsWalletRecharge'
)
->
where
([
'id'
=>
intval
(
$params
[
'recharge_id'
])])
->
find
();
if
(
empty
(
$recharge
))
{
return
DataReturn
(
'充值数据不存在'
,
-
1
);
}
if
(
$recharge
[
'status'
]
==
1
)
{
return
DataReturn
(
'该数据已充值,请重新创建充值订单'
,
-
2
);
}
// 回调地址
$url
=
__MY_URL__
.
'payment_wallet_'
.
strtolower
(
$payment
[
0
][
'payment'
]);
// url模式, pathinfo模式下采用自带url生成url, 避免非index.php多余
if
(
MyC
(
'home_seo_url_model'
,
0
)
==
0
)
{
$call_back_url
=
$url
.
'_respond.php'
;
}
else
{
$call_back_url
=
PluginsHomeUrl
(
'wallet'
,
'recharge'
,
'respond'
,
[
'paymentname'
=>
$payment
[
0
][
'payment'
]]);
if
(
stripos
(
$call_back_url
,
'?'
)
!==
false
)
{
$call_back_url
=
$url
.
'_respond.php'
;
}
}
// 发起支付
$pay_data
=
array
(
'user'
=>
$params
[
'user'
],
'out_user'
=>
md5
(
$params
[
'user'
][
'id'
]),
'order_id'
=>
$recharge
[
'id'
],
'order_no'
=>
$recharge
[
'recharge_no'
],
'name'
=>
'钱包充值'
,
'total_price'
=>
$recharge
[
'money'
],
'notify_url'
=>
$url
.
'_notify.php'
,
'call_back_url'
=>
$call_back_url
,
'site_name'
=>
MyC
(
'home_site_name'
,
'ShopXO'
,
true
),
'ajax_url'
=>
PluginsHomeUrl
(
'wallet'
,
'recharge'
,
'paycheck'
)
);
$pay_name
=
'payment\\'
.
$payment
[
0
][
'payment'
];
$ret
=
(
new
$pay_name
(
$payment
[
0
][
'config'
]))
->
Pay
(
$pay_data
);
if
(
isset
(
$ret
[
'code'
])
&&
$ret
[
'code'
]
==
0
)
{
return
$ret
;
}
return
DataReturn
(
empty
(
$ret
[
'msg'
])
?
'支付接口异常'
:
$ret
[
'msg'
],
-
1
);
}
/**
* 支付状态校验
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-01-08
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
RechargePayCheck
(
$params
=
[])
{
// 请求参数
$p
=
[
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'order_no'
,
'error_msg'
=>
'充值单号有误'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'user'
,
'error_msg'
=>
'用户信息有误'
,
],
];
$ret
=
ParamsChecked
(
$params
,
$p
);
if
(
$ret
!==
true
)
{
return
DataReturn
(
$ret
,
-
1
);
}
// 获取订单状态
$where
=
[
'recharge_no'
=>
$params
[
'order_no'
],
'user_id'
=>
$params
[
'user'
][
'id'
]];
$recharge
=
Db
::
name
(
'PluginsWalletRecharge'
)
->
where
(
$where
)
->
field
(
'id,status'
)
->
find
();
if
(
empty
(
$recharge
))
{
return
DataReturn
(
'充值数据不存在'
,
-
400
,
[
'url'
=>
__MY_URL__
]);
}
if
(
$recharge
[
'status'
]
==
1
)
{
return
DataReturn
(
'支付成功'
,
0
,
[
'url'
=>
PluginsHomeUrl
(
'wallet'
,
'recharge'
,
'index'
)]);
}
return
DataReturn
(
'支付中'
,
-
300
);
}
/**
/**
* 充值纪录删除
* 充值纪录删除
* @author Devil
* @author Devil
...
...
application/plugins/wallet/service/PayService.php
0 → 100644
浏览文件 @
8d6109d8
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace
app\plugins\wallet\service
;
use
think\Db
;
use
app\service\PaymentService
;
use
app\service\PayLogService
;
use
app\service\MessageService
;
/**
* 支付服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class
PayService
{
// 充值支付状态
public
static
$recharge_status_list
=
[
0
=>
[
'value'
=>
0
,
'name'
=>
'未支付'
,
'checked'
=>
true
],
1
=>
[
'value'
=>
1
,
'name'
=>
'已支付'
],
];
/**
* 支付
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-04-29
* @desc description
* @param array $params [description]
*/
public
static
function
Pay
(
$params
=
[])
{
// 请求参数
$p
=
[
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'user'
,
'error_msg'
=>
'用户信息有误'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'recharge_id'
,
'error_msg'
=>
'充值日志id不能为空'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'payment_id'
,
'error_msg'
=>
'请选择支付方式'
,
],
];
$ret
=
ParamsChecked
(
$params
,
$p
);
if
(
$ret
!==
true
)
{
return
DataReturn
(
$ret
,
-
1
);
}
// 支付方式;
$payment
=
PaymentService
::
PaymentList
([
'where'
=>
[
'id'
=>
intval
(
$params
[
'payment_id'
]),
'is_enable'
=>
1
,
'is_open_user'
=>
1
]]);
if
(
empty
(
$payment
[
0
]))
{
return
DataReturn
(
'支付方式有误'
,
-
1
);
}
// 支付入口文件检查
$pay_checked
=
PaymentService
::
EntranceFileChecked
(
$payment
[
0
][
'payment'
],
'wallet'
);
if
(
$pay_checked
[
'code'
]
!=
0
)
{
// 入口文件不存在则创建
$payment_params
=
[
'payment'
=>
$payment
[
0
][
'payment'
],
'business'
=>
[
[
'name'
=>
'Wallet'
,
'desc'
=>
'钱包'
],
],
'respond'
=>
'/index/plugins/index/pluginsname/wallet/pluginscontrol/recharge/pluginsaction/respond'
,
'notify'
=>
'/index/plugins/index/pluginsname/wallet/pluginscontrol/rechargenotify/pluginsaction/notify'
,
];
$ret
=
PaymentService
::
PaymentEntranceCreated
(
$payment_params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
}
// 非线上支付方式不可用
if
(
in_array
(
$payment
[
0
][
'payment'
],
config
(
'shopxo.under_line_list'
)))
{
return
DataReturn
(
'不能使用非线上支付方式进行充值'
,
-
10
);
}
// 获取充值数据
$recharge
=
Db
::
name
(
'PluginsWalletRecharge'
)
->
where
([
'id'
=>
intval
(
$params
[
'recharge_id'
])])
->
find
();
if
(
empty
(
$recharge
))
{
return
DataReturn
(
'充值数据不存在'
,
-
1
);
}
if
(
$recharge
[
'status'
]
==
1
)
{
return
DataReturn
(
'该数据已充值,请重新创建充值订单'
,
-
2
);
}
// 回调地址
$url
=
__MY_URL__
.
'payment_wallet_'
.
strtolower
(
$payment
[
0
][
'payment'
]);
// url模式, pathinfo模式下采用自带url生成url, 避免非index.php多余
if
(
MyC
(
'home_seo_url_model'
,
0
)
==
0
)
{
$call_back_url
=
$url
.
'_respond.php'
;
}
else
{
$call_back_url
=
PluginsHomeUrl
(
'wallet'
,
'recharge'
,
'respond'
,
[
'paymentname'
=>
$payment
[
0
][
'payment'
]]);
if
(
stripos
(
$call_back_url
,
'?'
)
!==
false
)
{
$call_back_url
=
$url
.
'_respond.php'
;
}
}
// 发起支付
$pay_data
=
array
(
'user'
=>
$params
[
'user'
],
'out_user'
=>
md5
(
$params
[
'user'
][
'id'
]),
'order_id'
=>
$recharge
[
'id'
],
'order_no'
=>
$recharge
[
'recharge_no'
],
'name'
=>
'账户充值'
,
'total_price'
=>
$recharge
[
'money'
],
'notify_url'
=>
$url
.
'_notify.php'
,
'call_back_url'
=>
$call_back_url
,
'site_name'
=>
MyC
(
'home_site_name'
,
'ShopXO'
,
true
),
'ajax_url'
=>
PluginsHomeUrl
(
'wallet'
,
'recharge'
,
'paycheck'
)
);
$pay_name
=
'payment\\'
.
$payment
[
0
][
'payment'
];
$ret
=
(
new
$pay_name
(
$payment
[
0
][
'config'
]))
->
Pay
(
$pay_data
);
if
(
isset
(
$ret
[
'code'
])
&&
$ret
[
'code'
]
==
0
)
{
return
$ret
;
}
return
DataReturn
(
empty
(
$ret
[
'msg'
])
?
'支付接口异常'
:
$ret
[
'msg'
],
-
1
);
}
/**
* 支付状态校验
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-01-08
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
RechargePayCheck
(
$params
=
[])
{
// 请求参数
$p
=
[
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'order_no'
,
'error_msg'
=>
'充值单号有误'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'user'
,
'error_msg'
=>
'用户信息有误'
,
],
];
$ret
=
ParamsChecked
(
$params
,
$p
);
if
(
$ret
!==
true
)
{
return
DataReturn
(
$ret
,
-
1
);
}
// 获取订单状态
$where
=
[
'recharge_no'
=>
$params
[
'order_no'
],
'user_id'
=>
$params
[
'user'
][
'id'
]];
$recharge
=
Db
::
name
(
'PluginsWalletRecharge'
)
->
where
(
$where
)
->
field
(
'id,status'
)
->
find
();
if
(
empty
(
$recharge
))
{
return
DataReturn
(
'充值数据不存在'
,
-
400
,
[
'url'
=>
__MY_URL__
]);
}
if
(
$recharge
[
'status'
]
==
1
)
{
return
DataReturn
(
'支付成功'
,
0
,
[
'url'
=>
PluginsHomeUrl
(
'wallet'
,
'recharge'
,
'index'
)]);
}
return
DataReturn
(
'支付中'
,
-
300
);
}
/**
* 支付同步处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-28
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
Respond
(
$params
=
[])
{
// 请求参数
$p
=
[
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'user'
,
'error_msg'
=>
'用户信息有误'
,
],
];
$ret
=
ParamsChecked
(
$params
,
$p
);
if
(
$ret
!==
true
)
{
return
DataReturn
(
$ret
,
-
1
);
}
// 支付方式
$payment_name
=
defined
(
'PAYMENT_TYPE'
)
?
PAYMENT_TYPE
:
(
isset
(
$params
[
'paymentname'
])
?
$params
[
'paymentname'
]
:
''
);
if
(
empty
(
$payment_name
))
{
return
DataReturn
(
'支付方式标记异常'
,
-
1
);
}
$payment
=
PaymentService
::
PaymentList
([
'where'
=>
[
'payment'
=>
$payment_name
]]);
if
(
empty
(
$payment
[
0
]))
{
return
DataReturn
(
'支付方式有误'
,
-
1
);
}
// 支付数据校验
$pay_name
=
'payment\\'
.
$payment_name
;
$ret
=
(
new
$pay_name
(
$payment
[
0
][
'config'
]))
->
Respond
(
array_merge
(
$_GET
,
$_POST
));
if
(
isset
(
$ret
[
'code'
])
&&
$ret
[
'code'
]
==
0
)
{
return
DataReturn
(
'支付成功'
,
0
);
}
return
DataReturn
(
empty
(
$ret
[
'msg'
])
?
'支付失败'
:
$ret
[
'msg'
],
-
100
);
}
/**
* 支付异步处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-28
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
Notify
(
$params
=
[])
{
// 支付方式
$payment
=
PaymentService
::
PaymentList
([
'where'
=>
[
'payment'
=>
PAYMENT_TYPE
]]);
if
(
empty
(
$payment
[
0
]))
{
return
DataReturn
(
'支付方式有误'
,
-
1
);
}
// 支付数据校验
$pay_name
=
'payment\\'
.
PAYMENT_TYPE
;
$ret
=
(
new
$pay_name
(
$payment
[
0
][
'config'
]))
->
Respond
(
array_merge
(
$_GET
,
$_POST
));
if
(
!
isset
(
$ret
[
'code'
])
||
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
// 获取充值信息
$recharge
=
Db
::
name
(
'PluginsWalletRecharge'
)
->
where
([
'recharge_no'
=>
$ret
[
'data'
][
'out_trade_no'
]])
->
find
();
// 支付处理
$pay_params
=
[
'recharge'
=>
$recharge
,
'payment'
=>
$payment
[
0
],
'pay'
=>
[
'trade_no'
=>
$ret
[
'data'
][
'trade_no'
],
'subject'
=>
$ret
[
'data'
][
'subject'
],
'buyer_user'
=>
$ret
[
'data'
][
'buyer_user'
],
'pay_price'
=>
$ret
[
'data'
][
'pay_price'
],
],
];
return
self
::
RechargePayHandle
(
$pay_params
);
}
/**
* 充值支付处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-10-05T23:02:14+0800
* @param [array] $params [输入参数]
*/
private
static
function
RechargePayHandle
(
$params
=
[])
{
// 订单信息
if
(
empty
(
$params
[
'recharge'
]))
{
return
DataReturn
(
'资源不存在或已被删除'
,
-
1
);
}
if
(
$params
[
'recharge'
][
'status'
]
>
0
)
{
$status_text
=
self
::
$recharge_status_list
[
$params
[
'recharge'
][
'status'
]][
'name'
];
return
DataReturn
(
'状态不可操作['
.
$status_text
.
']'
,
0
);
}
// 支付方式
if
(
empty
(
$params
[
'payment'
]))
{
return
DataReturn
(
'支付方式有误'
,
-
1
);
}
// 支付参数
$pay_price
=
isset
(
$params
[
'pay'
][
'pay_price'
])
?
$params
[
'pay'
][
'pay_price'
]
:
0
;
// 写入支付日志
$pay_log_data
=
[
'user_id'
=>
$params
[
'recharge'
][
'user_id'
],
'order_id'
=>
$params
[
'recharge'
][
'id'
],
'total_price'
=>
$params
[
'recharge'
][
'money'
],
'trade_no'
=>
isset
(
$params
[
'pay'
][
'trade_no'
])
?
$params
[
'pay'
][
'trade_no'
]
:
''
,
'buyer_user'
=>
isset
(
$params
[
'pay'
][
'buyer_user'
])
?
$params
[
'pay'
][
'buyer_user'
]
:
''
,
'pay_price'
=>
$pay_price
,
'subject'
=>
isset
(
$params
[
'pay'
][
'subject'
])
?
$params
[
'pay'
][
'subject'
]
:
'账户充值'
,
'payment'
=>
$params
[
'payment'
][
'payment'
],
'payment_name'
=>
$params
[
'payment'
][
'name'
],
'business_type'
=>
2
,
];
PayLogService
::
PayLogInsert
(
$pay_log_data
);
// 开启事务
Db
::
startTrans
();
// 消息通知
$detail
=
'账户充值成功,金额'
.
PriceBeautify
(
$params
[
'recharge'
][
'money'
])
.
'元'
;
MessageService
::
MessageAdd
(
$params
[
'recharge'
][
'user_id'
],
'账户充值'
,
$detail
,
2
,
$params
[
'recharge'
][
'id'
]);
// 更新充值状态
$upd_data
=
array
(
'status'
=>
1
,
'pay_price'
=>
$pay_price
,
'payment_id'
=>
$params
[
'payment'
][
'id'
],
'payment'
=>
$params
[
'payment'
][
'payment'
],
'payment_name'
=>
$params
[
'payment'
][
'name'
],
'pay_time'
=>
time
(),
'upd_time'
=>
time
(),
);
if
(
Db
::
name
(
'PluginsWalletRecharge'
)
->
where
([
'id'
=>
$params
[
'recharge'
][
'id'
]])
->
update
(
$upd_data
))
{
// 提交事务
Db
::
commit
();
return
DataReturn
(
'支付成功'
,
0
);
}
// 处理失败
Db
::
rollback
();
return
DataReturn
(
'处理失败'
,
-
100
);
}
}
?>
\ No newline at end of file
application/service/MessageService.php
浏览文件 @
8d6109d8
...
@@ -31,7 +31,7 @@ class MessageService
...
@@ -31,7 +31,7 @@ class MessageService
* @param [int] $user_id [用户id]
* @param [int] $user_id [用户id]
* @param [string] $title [标题]
* @param [string] $title [标题]
* @param [string] $detail [内容]
* @param [string] $detail [内容]
* @param [int] $business_type [业务类型(0默认, 1订单, ...)]
* @param [int] $business_type [业务类型(0默认, 1订单,
2充值,
...)]
* @param [int] $business_id [业务id]
* @param [int] $business_id [业务id]
* @param [int] $type [类型(默认0 普通消息)]
* @param [int] $type [类型(默认0 普通消息)]
* @return [boolean] [成功true, 失败false]
* @return [boolean] [成功true, 失败false]
...
...
application/service/OrderService.php
浏览文件 @
8d6109d8
...
@@ -18,6 +18,7 @@ use app\service\IntegralService;
...
@@ -18,6 +18,7 @@ use app\service\IntegralService;
use
app\service\RegionService
;
use
app\service\RegionService
;
use
app\service\ExpressService
;
use
app\service\ExpressService
;
use
app\service\ResourcesService
;
use
app\service\ResourcesService
;
use
app\service\PayLogService
;
/**
/**
* 订单服务层
* 订单服务层
...
@@ -412,9 +413,8 @@ class OrderService
...
@@ -412,9 +413,8 @@ class OrderService
'payment'
=>
$params
[
'payment'
][
'payment'
],
'payment'
=>
$params
[
'payment'
][
'payment'
],
'payment_name'
=>
$params
[
'payment'
][
'name'
],
'payment_name'
=>
$params
[
'payment'
][
'name'
],
'business_type'
=>
1
,
'business_type'
=>
1
,
'add_time'
=>
time
(),
];
];
Db
::
name
(
'PayLog'
)
->
insertGetId
(
$pay_log_data
);
PayLogService
::
PayLogInsert
(
$pay_log_data
);
// 开启事务
// 开启事务
Db
::
startTrans
();
Db
::
startTrans
();
...
...
application/service/PayLogService.php
浏览文件 @
8d6109d8
...
@@ -21,6 +21,43 @@ use think\Db;
...
@@ -21,6 +21,43 @@ use think\Db;
*/
*/
class
PayLogService
class
PayLogService
{
{
/**
* 支付日志添加
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-05-07T00:57:36+0800
* @param [array] $params [输入参数]
* @param [int] $user_id [用户id]
* @param [int] $order_id [业务订单id]
* @param [float] $total_price [业务订单实际金额]
* @param [string] $trade_no [支付平台交易号]
* @param [string] $buyer_user [支付平台用户帐号]
* @param [float] $pay_price [支付金额]
* @param [string] $subject [业务订单名称]
* @param [string] $payment [支付方式标记]
* @param [string] $payment_name [支付方式名称]
* @param [int] $business_type [业务类型(0默认, 1订单, 2充值, ...)]
* @return [boolean] [成功true, 失败false]
*/
public
static
function
PayLogInsert
(
$params
=
[])
{
$data
=
[
'user_id'
=>
isset
(
$params
[
'user_id'
])
?
intval
(
$params
[
'user_id'
])
:
0
,
'order_id'
=>
isset
(
$params
[
'order_id'
])
?
intval
(
$params
[
'order_id'
])
:
0
,
'total_price'
=>
isset
(
$params
[
'total_price'
])
?
intval
(
$params
[
'total_price'
])
:
0
,
'trade_no'
=>
isset
(
$params
[
'trade_no'
])
?
$params
[
'trade_no'
]
:
''
,
'buyer_user'
=>
isset
(
$params
[
'buyer_user'
])
?
intval
(
$params
[
'buyer_user'
])
:
''
,
'pay_price'
=>
isset
(
$params
[
'pay_price'
])
?
PriceNumberFormat
(
$params
[
'pay_price'
])
:
0.00
,
'subject'
=>
isset
(
$params
[
'subject'
])
?
intval
(
$params
[
'subject'
])
:
''
,
'payment'
=>
isset
(
$params
[
'payment'
])
?
intval
(
$params
[
'payment'
])
:
''
,
'payment_name'
=>
isset
(
$params
[
'payment_name'
])
?
intval
(
$params
[
'payment_name'
])
:
''
,
'business_type'
=>
isset
(
$params
[
'business_type'
])
?
intval
(
$params
[
'business_type'
])
:
0
,
'add_time'
=>
time
(),
];
return
Db
::
name
(
'PayLog'
)
->
insertGetId
(
$data
)
>
0
;
}
/**
/**
* 获取支付日志类型
* 获取支付日志类型
* @author Devil
* @author Devil
...
...
config/shopxo.sql
浏览文件 @
8d6109d8
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录