Wechat.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\inter\controller;
  3. use think\Controller;
  4. use think\Db;
  5. use think\Session;
  6. use app\common\library\UUIDs;
  7. use think\Cache;
  8. use think\Log;
  9. use app\common\library\Verify;
  10. use think\File;
  11. use app\common\library\send_message;
  12. use app\common\library\Message;
  13. class Wechat extends Base {
  14. public function _initialize() {
  15. }
  16. public function wechatCallback() {
  17. // $param = $_REQUEST['param'];
  18. Log::record('微信支付回调');
  19. Log::record('xml');
  20. $xml = file_get_contents("php://input");
  21. Log::record($xml);
  22. Log::record('objectxml');
  23. $objectxml = simplexml_load_string($xml);//将文件转换成 对象
  24. Log::record($objectxml);
  25. Log::record('xmljson');
  26. $xmljson= json_encode($objectxml );//将对象转换个JSON
  27. Log::record($xmljson);
  28. Log::record('xmlarray');
  29. $xmlarray=json_decode($xmljson,true);//将json转换成数组
  30. Log::record($xmlarray);
  31. Log::record('微信支付回调');
  32. // $order_id = $param['order_id'];
  33. // $remote_order = DB::table('remote_order')->where('id', $order_id)->find();
  34. // if(!$remote_order) {
  35. // return json_encode(['status'=>'fail','code'=>'3001','msg'=> "没有找到该订单"]);
  36. // }
  37. // if($remote_order !== Application::ORDER_STATUS['CREATE']) {
  38. // return json_encode(['status'=>'fail','code'=>'3002','msg'=> "订单状态出错"]);
  39. // }
  40. // DB::table('remote_order')->where('id', $order_id)->update(["status" => Application::ORDER_STATUS['PAYCOMPLTET']]);
  41. // return json_encode(['status'=>'ok','code'=>'0000','msg'=> "支付回调成功"]);
  42. }
  43. }