瀏覽代碼

Merge branch 'pro' of http://code.pacsonline.cn/zskk_bg/yuanchengpasc into pro

刘桂岩 5 年之前
父節點
當前提交
f32b5e9740
共有 1 個文件被更改,包括 46 次插入0 次删除
  1. 46 0
      application/inter/controller/Wechat.php

+ 46 - 0
application/inter/controller/Wechat.php

@@ -107,6 +107,52 @@ class Wechat extends Base {
         }
 
 
+        // $order_id = $param['order_id'];
+        // $remote_order = DB::table('remote_order')->where('id', $order_id)->find();
+        // if(!$remote_order) {
+        //     return json_encode(['status'=>'fail','code'=>'3001','msg'=> "没有找到该订单"]);
+        // }
+        // if($remote_order !== Application::ORDER_STATUS['CREATE']) {
+        //     return json_encode(['status'=>'fail','code'=>'3002','msg'=> "订单状态出错"]);
+        // }
+        // DB::table('remote_order')->where('id', $order_id)->update(["status" => Application::ORDER_STATUS['PAYCOMPLTET']]);
+        // return json_encode(['status'=>'ok','code'=>'0000','msg'=> "支付回调成功"]);
+    }
+
+    public function wechatStudyPayCallback() {
+        try {
+             // $param = $_REQUEST['param'];
+            Log::record('---电子胶片--微信支付回调----开始----');
+
+            Log::record('---电子胶片--微信支付返回----xml----');
+            $xml = file_get_contents("php://input");
+            Log::record($xml);
+            Log::record('-----xml转数组--------');
+            $data = (array)simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); //将微信返回的XML 转换成数组
+            Log::record($data);
+            $out_trade_no = $data['out_trade_no'];
+            $data['timestamp'] = time();
+            Log::record('---电子胶片--添加流水记录----');
+            Log::record($data);
+            Db::table("wechat_pay_log")->insert($data);
+            Log::record('-----获取订单信息-----');
+            $order = Db::table("exams")->where("id", $out_trade_no)->field("id, pay_status")->find();
+            Log::record($order);
+            if($order && $order['pay_status'] === '0') {
+                $order['pay_status'] = '1';
+                // todo 消息通知
+                Log::record('-----更新检查状态-----');
+                DB::table("exams")->where("id", $out_trade_no)->update($order);
+            }
+            Log::record('--电子胶片---微信支付回调---结束---');
+            return self::SUCCESS;
+        } catch (\Throwable $th) {
+            Log::record('支付回调异常');
+            Log::record($th->getMessage());
+            //throw $th;
+        }
+
+
         // $order_id = $param['order_id'];
         // $remote_order = DB::table('remote_order')->where('id', $order_id)->find();
         // if(!$remote_order) {