浏览代码

苹果异步回调,金币充值

lizhen_gitee 1 年之前
父节点
当前提交
f4e24820a7
共有 1 个文件被更改,包括 8 次插入3 次删除
  1. 8 3
      application/api/controller/Payios.php

+ 8 - 3
application/api/controller/Payios.php

@@ -202,14 +202,14 @@ class Payios extends Api
         $this->success('success',$data['out_trade_no']);
     }
 
-    //vip,苹果内购支付回调
+    //vip,苹果内购支付回调,app请求的接口
     public function gold_notify_ios(){
-        $notify_file = $this->notify_log_start('ios');
 
         //苹果内购的验证收据
+
         $receipt_data = input('apple_receipt', '', 'trim');
         $order_no = input('order_no', '', 'trim');
-
+        filePut('金币 ios充值:参数apple_receipt='.$receipt_data.',order_no='.$order_no);
         if (!$receipt_data || !$order_no) {
             $this->error('缺少参数');
         }
@@ -219,6 +219,7 @@ class Payios extends Api
         $order_info = Db::name('pay_order')->where(['out_trade_no' => $order_no])->lock(true)->find();
         if (!$order_info) {
             Db::rollback();
+            filePut('金币 ios充值:订单丢失out_trade_no='.$order_no);
             $this->error('订单丢失');
         }
         if ($order_info['order_status'] == 1) {
@@ -230,6 +231,7 @@ class Payios extends Api
         $result = $this->validate_apple_pay($receipt_data);
         if (!$result['status']) {// 验证不通过
             Db::rollback();
+            filePut('金币 ios充值:验证out_trade_no='.$order_no.','.$result['message']);
             $this->error($result['message']);
         }
 
@@ -238,6 +240,7 @@ class Payios extends Api
         $args = json_decode($order_info['args'],true);
         if ($result['data']['receipt']['in_app'][$use_count]['product_id'] != $args['bundle_id']) {
             Db::rollback();
+            filePut('金币 ios充值:非法请求,请立刻停止out_trade_no='.$order_no.','.$result['message'].','.$result['data']['receipt']['in_app'][$use_count]['product_id'].'!='.$args['bundle_id']);
             $this->error('非法请求,请立刻停止');
         }
 
@@ -246,6 +249,7 @@ class Payios extends Api
         $result = model('Wallet')->lockChangeAccountRemain($order_info['user_id'],'gold',$args['gold'],10, '金币充值','pay_order',$order_info['id']);
         if($result['status']===false)
         {
+            filePut('金币 ios充值:验证out_trade_no='.$order_no.',逻辑添加金币失败');
             Db::rollback();
             return false;
         }
@@ -253,6 +257,7 @@ class Payios extends Api
         // 修改订单状态
         $ros = Db::name('pay_order')->where(['out_trade_no' => $order_no])->update(['order_status'=>1,'notifytime'=>time()]);
         if($ros === false) {
+            filePut('金币 ios充值:充值失败out_trade_no='.$order_no.','.$result['message'].','.'修改订单状态失败');
             Db::rollback();
             $this->error('充值失败');
         }