NotifyController.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. namespace App\Http\Controllers\Wap;
  3. use App\Http\Controllers\FrontController;
  4. use App\Models\Comment;
  5. use App\Models\GoodsCollect;
  6. use App\Models\Member;
  7. use App\Models\MemberAddress;
  8. use App\Models\MemberClan;
  9. use App\Models\MemberOpenId;
  10. use App\Models\Members;
  11. use App\Models\Order;
  12. use App\Models\Shop;
  13. use App\Models\ShopCollect;
  14. use App\Servers\AddressServer;
  15. use App\Servers\AlbumServer;
  16. use App\Servers\CommonServer;
  17. use App\Servers\MemberLogsServer;
  18. use App\Servers\MemberServer;
  19. use App\Servers\PassServer;
  20. use App\Servers\PayServer;
  21. use App\Servers\RedisDataServer;
  22. use App\Servers\ShopFileServer;
  23. use App\Servers\ShopOrderServer;
  24. use App\Servers\SmsServer;
  25. use App\Servers\WeixinServer;
  26. use App\Servers\ZfbServer;
  27. use SimpleSoftwareIO\QrCode\Facades\QrCode;
  28. class NotifyController extends FrontController
  29. {
  30. public function __construct()
  31. {
  32. parent::__construct();
  33. }
  34. /**
  35. * 线下支付微信支付回调
  36. * @throws \Exception
  37. */
  38. function shopOrderPayWx()
  39. {
  40. //回调类型
  41. $xml = file_get_contents('php://input');
  42. $data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
  43. // file_put_contents('wx_pay.txt', json_encode($data));
  44. // file_put_contents('asdas.txt', json_encode($data));
  45. // $data=file_get_contents('wx_pay.txt');
  46. // $data=json_decode($data,true);
  47. $type = 1;
  48. if (isset($data['type'])) {
  49. $type = $data['type'];
  50. unset($data['type']);
  51. }
  52. $sign = WeixinServer::creatServer()->verifyCer($data);
  53. if ($sign != $data['sign']) {
  54. $xml = '<xml>
  55. <return_code><![CDATA[SUCCESS]]></return_code>
  56. <return_msg><![CDATA[OK]]></return_msg>
  57. </xml>';
  58. exit($xml);
  59. }
  60. if ($data['result_code'] == 'SUCCESS' && $data['return_code'] == 'SUCCESS') {
  61. if ($type == 2) {
  62. ShopOrderServer::creatServer()->OrderNotify($data['out_trade_no'], $data['transaction_id'], $data['total_fee'] / 100, 1, $data, $data['openid']);
  63. } elseif ($type == 1 || $type == 3) {
  64. PayServer::creatServer()->NotifyPay($data['out_trade_no'], $data['transaction_id'], $data['total_fee'] / 100, $data);
  65. } else {
  66. }
  67. }
  68. $xml = '<xml>
  69. <return_code><![CDATA[SUCCESS]]></return_code>
  70. <return_msg><![CDATA[OK]]></return_msg>
  71. </xml>';
  72. exit($xml);
  73. }
  74. /**
  75. * buyer_id 对应会员唯一ID
  76. * 支付宝支付回调
  77. */
  78. function shopOrderPayZfb()
  79. {
  80. $data = request()->input();
  81. file_put_contents('al_pay.txt', json_encode($data));
  82. // file_put_contents('al_pay2.txt', serialize($data));
  83. // $data=file_get_contents('al_pay.txt');
  84. // $data=json_decode($data,true);
  85. $is_verify = ZfbServer::creatServer()->verifyData($data);
  86. if ($is_verify) {
  87. if ((!empty($data['trade_status']) && $data['trade_status'] == 'TRADE_SUCCESS') || (!empty($data['trade_status']) && $data['trade_status'] == 'TRADE_FINISHED')) {
  88. ShopOrderServer::creatServer()->OrderNotify($data['out_trade_no'], $data['notify_id'], $data['total_amount'], 2, $data, $data['buyer_id']);
  89. }
  90. }
  91. echo 'success';
  92. exit;
  93. }
  94. /**
  95. * 线上订单支付回调
  96. * @throws \Exception
  97. */
  98. function orderPayWx()
  99. {
  100. $xml = file_get_contents('php://input');
  101. $data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
  102. // file_put_contents('o_wx_pay.txt', json_encode($data));
  103. // $data=file_get_contents('wx_pay.txt');
  104. // $data=json_decode($data,true);
  105. $sign = WeixinServer::creatServer()->verifyCer($data);
  106. if ($sign != $data['sign']) {
  107. $xml = '<xml>
  108. <return_code><![CDATA[SUCCESS]]></return_code>
  109. <return_msg><![CDATA[OK]]></return_msg>
  110. </xml>';
  111. exit($xml);
  112. }
  113. if ($data['result_code'] == 'SUCCESS' && $data['return_code'] == 'SUCCESS') {
  114. // ShopOrderServer::creatServer()->OrderNotify($data['out_trade_no'], $data['transaction_id'],$data['total_fee']/100,1, $data,$data['openid']);
  115. PayServer::creatServer()->NotifyPay($data['out_trade_no'], $data['transaction_id'], $data['total_fee'] / 100, $data);
  116. }
  117. $xml = '<xml>
  118. <return_code><![CDATA[SUCCESS]]></return_code>
  119. <return_msg><![CDATA[OK]]></return_msg>
  120. </xml>';
  121. exit($xml);
  122. }
  123. /**
  124. * 线上订单支付宝支付
  125. * @throws \Exception
  126. */
  127. function orderPayZfb()
  128. {
  129. $data = request()->input();
  130. // file_put_contents('o_al_pay.txt', json_encode($data));
  131. // file_put_contents('al_pay2.txt', serialize($data));
  132. // $data=file_get_contents('al_pay.txt');
  133. // $data=json_decode($data,true);
  134. $is_verify = ZfbServer::creatServer()->verifyData($data);
  135. if ($is_verify) {
  136. if ((!empty($data['trade_status']) && $data['trade_status'] == 'TRADE_SUCCESS') || (!empty($data['trade_status']) && $data['trade_status'] == 'TRADE_FINISHED')) {
  137. // ShopOrderServer::creatServer()->OrderNotify($data['out_trade_no'], $data['notify_id'],$data['total_amount'],2, $data,$data['buyer_id']);
  138. PayServer::creatServer()->NotifyPay($data['out_trade_no'], $data['notify_id'], $data['total_amount'], $data);
  139. }
  140. }
  141. echo 'success';
  142. exit;
  143. }
  144. }