|
@@ -1,20 +1,18 @@
|
|
|
<?php
|
|
|
namespace app\common\model;
|
|
|
-use think\Model;
|
|
|
-use think\Db;
|
|
|
-use app\common\model\Wallet;
|
|
|
+use \think\Db;
|
|
|
/*
|
|
|
*处理支付结果 接受服务器和服务器之间的通知
|
|
|
*/
|
|
|
-class Paymentdo extends Model
|
|
|
+class Paymentdo
|
|
|
{
|
|
|
|
|
|
|
|
|
//接受服务器的通知
|
|
|
- public function receive($orderId,$payamount)
|
|
|
+ public function receive($orderId,$payamount = 0)
|
|
|
{
|
|
|
|
|
|
- filePut('[payment][receive]异步回调开始17:'.$orderId);
|
|
|
+ filePut('[payment][receive]异步回调开始'.$orderId);
|
|
|
//$orderId = Pay::getOrderId();
|
|
|
if (!$orderId)
|
|
|
{
|
|
@@ -74,20 +72,17 @@ class Paymentdo extends Model
|
|
|
public function touchEvent($event, $orderId)
|
|
|
{
|
|
|
//检查该订单是否已绑定事件
|
|
|
- $pay_event = Db::name('pay_event');
|
|
|
- $pay_order = Db::name('pay_order');
|
|
|
-
|
|
|
$where = [];
|
|
|
$where['pay_no'] = $orderId;
|
|
|
$where['event'] = $event;
|
|
|
- $info = $pay_event->where($where)->find();
|
|
|
+ $info = Db::name('pay_event')->where($where)->find();
|
|
|
if(!$info||!isset($info['class']))
|
|
|
{return;}
|
|
|
|
|
|
$class = new $info['class'];
|
|
|
|
|
|
- db()->startTrans();
|
|
|
- $orderInfo = $pay_order->where(['pay_no' => $orderId])->lock(true)->find();
|
|
|
+ Db::startTrans();
|
|
|
+ $orderInfo = Db::name('pay_order')->where(['pay_no' => $orderId])->lock(true)->find();
|
|
|
filePut("[PAY][touchEvent] STRAT" . $orderId);
|
|
|
|
|
|
//如果找到了绑定的事件
|
|
@@ -97,8 +92,8 @@ class Paymentdo extends Model
|
|
|
if ($event === 'success') {
|
|
|
if($orderInfo['status'] === 0)//成功事件只触发1次
|
|
|
{
|
|
|
- $pay_order->where(['pay_no' => $orderId])->update(['status'=>2]);
|
|
|
- db()->commit();
|
|
|
+ Db::name('pay_order')->where(['pay_no' => $orderId])->update(['status'=>2]);
|
|
|
+ Db::commit();
|
|
|
filePut('[PAY][touchEvent] success start'.$orderId);//.$info['args']
|
|
|
call_user_func_array([$class, $info['method']], [$orderId, $args]);
|
|
|
//得到事件模型类
|