OrdersController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <?php
  2. namespace App\Http\Controllers\QuickApp\Order;
  3. use App\Modules\Statistic\Services\AdVisitStatService;
  4. use App\Http\Controllers\QuickApp\BaseController;
  5. use Illuminate\Http\Request;
  6. use App\Modules\Subscribe\Services\BookOrderService;
  7. use App\Modules\Subscribe\Services\ChapterOrderService;
  8. use App\Modules\Subscribe\Services\OrderService;
  9. use App\Http\Controllers\QuickApp\Order\Transformers\BookOrderTransformer;
  10. use App\Http\Controllers\QuickApp\Order\Transformers\ChapterOrderTransformer;
  11. use App\Http\Controllers\QuickApp\Order\Transformers\ChargeListTransformer;
  12. use App\Libs\Pay\PayFactory;
  13. use App\Libs\Pay\WechatPay;
  14. use App\Modules\Subscribe\Services\YearOrderService;
  15. use App\Modules\User\Services\UserService;
  16. use DB;
  17. use Hashids;
  18. use EasyWeChat\Foundation\Application;
  19. use App\Modules\Product\Services\ProductService;
  20. use App\Modules\Book\Services\BookConfigService;
  21. use App\Modules\Book\Services\BookService;
  22. use App\Modules\Channel\Services\PayTemplateService;
  23. use App\Modules\Trade\Models\PayMerchant;
  24. use App\Modules\Trade\Pay\OrderArousePayFactory;
  25. use App\Modules\Trade\Pay\OrderPaySuccess;
  26. use App\Modules\Trade\Services\PayMerchantService;
  27. use EasyWeChat\Support\XML;
  28. use Exception;
  29. use Log;
  30. class OrdersController extends BaseController
  31. {
  32. /**
  33. * @apiDefine Order 订单
  34. */
  35. /**
  36. *
  37. */
  38. private $chargeList;
  39. public function exchangeList()
  40. {
  41. foreach ($this->chargeList as &$item) {
  42. if (!$item->switch_to) continue;
  43. $order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('product_id', $item->id)->first();
  44. if ($order) {
  45. $change = ProductService::getProductSingle($item->switch_to);
  46. $item->id = $change->id;
  47. $item->price = $change->price;
  48. $item->given = $change->given;
  49. }
  50. }
  51. }
  52. /**
  53. * @apiVersion 1.0.0
  54. * @apiDescription 充值列表
  55. * @api {get} order/chargeList 充值列表
  56. * @apiHeader {String} [Authorization] token
  57. * @apiGroup Order
  58. * @apiName chargeList
  59. * @apiSuccess {int} code 状态码
  60. * @apiSuccess {String} msg 信息
  61. * @apiSuccess {object} data 结果集
  62. * @apiSuccessExample {json} Success-Response:
  63. * HTTP/1.1 200 OK
  64. * {
  65. * code: 0,
  66. * msg: "",
  67. * data: [
  68. * {
  69. * product_id: 1,
  70. * price: "30.00元",
  71. * vip: 0,
  72. * intro: [
  73. * {
  74. * label: 3000,
  75. * important: false
  76. * },
  77. * {
  78. * label: "书币",
  79. * important: true
  80. * }
  81. * ]
  82. * },
  83. * {
  84. * product_id: 2,
  85. * price: "50.00元",
  86. * vip: 1,
  87. * intro: [
  88. * {
  89. * label: 5000,
  90. * important: false
  91. * },
  92. * {
  93. * label: "1000+",
  94. * important: true
  95. * },
  96. * {
  97. * label: "书币",
  98. * important: false
  99. * }
  100. * ]
  101. * },
  102. * {
  103. * product_id: 5,
  104. * price: "365.00元",
  105. * vip: 0,
  106. * intro: [
  107. * {
  108. * label: "年费VIP会员",
  109. * important: true
  110. * }
  111. * ]
  112. * }
  113. * ]
  114. * }
  115. */
  116. public function chargeList(Request $request)
  117. {
  118. $bid = $request->input('bid', '');
  119. $temp = $bid;
  120. $template_id = PayTemplateService::getPayTemplate($this->distribution_channel_id);
  121. $book_config = null;
  122. if ($bid) {
  123. $bid = Hashids::decode($bid)[0];
  124. $book_config = BookConfigService::getBookById($bid);
  125. }
  126. if ($template_id == 2) { //模板2只有在长篇小说过来的用户才显示
  127. //部分渠道需要2元模板不管哪个入口进来都展示
  128. $exclude_channels = explode(',', env('PRICE_TWO_SHOW_ALL_CHANNEL'));
  129. if (!in_array($this->distribution_channel_id, $exclude_channels)) {
  130. if ($book_config) {
  131. if ($book_config->charge_type == 'BOOK') $template_id = 1;
  132. }
  133. }
  134. }
  135. $res = ProductService::getChargeProduct($template_id);
  136. if (!$res) {
  137. return response()->error('WAP_SYS_ERROR');
  138. }
  139. $this->chargeList = $res;
  140. $this->exchangeList();
  141. //TODO 长篇小数才有模板2
  142. $uid = $this->uid;
  143. $is_first_recharge = OrderService::judgeUserFirstRecharge($uid);
  144. $data = [];
  145. $appad = 0;
  146. foreach ($res as $v) {
  147. if ($template_id == 7 && $book_config && $book_config->charge_type == 'BOOK' && $v->price == 2) {
  148. continue;
  149. }
  150. if ($template_id == 2 && $v->type == 'NEW_USER' && !$bid) {
  151. //2元模版,直接进充值,不出现
  152. continue;
  153. }
  154. if ($v->type == 'NEW_USER' && $is_first_recharge) {
  155. if (
  156. env('NO_NEW_USER_CHARGE') &&
  157. in_array(
  158. $this->distribution_channel_id,
  159. explode(',', env('NO_NEW_USER_CHARGE'))
  160. )
  161. ) {
  162. continue;
  163. }
  164. $temp = [
  165. 'price' => (float) $v->price . '元',
  166. 'is_year_order' => 0,
  167. 'is_month_order' => 0,
  168. 'text' => sprintf('%s+%s书币', $v->price * 100, $v->given),
  169. 'today_special' => $v->is_default,
  170. 'first_charge' => true,
  171. 'save_text' => round($v->given / 100, 1) . '元',
  172. 'product_id' => $v->id,
  173. ];
  174. $data[] = $temp;
  175. } elseif ($v->type == 'YEAR_ORDER') {
  176. if ($v->type == 'NEW_USER') {
  177. continue;
  178. }
  179. $save_text = '年费vip会员';
  180. $text = '每天1元,全年免费看';
  181. $temp = [
  182. 'price' => (int) $v->price . '元',
  183. 'is_year_order' => 1,
  184. 'is_month_order' => 0,
  185. 'text' => $text,
  186. 'today_special' => $v->is_default,
  187. 'first_charge' => false,
  188. 'save_text' => $save_text,
  189. 'product_id' => $v->id,
  190. ];
  191. $data[] = $temp;
  192. } else {
  193. if ($v->type == 'NEW_USER') {
  194. continue;
  195. }
  196. $save_text = '';
  197. if ($v->given) {
  198. $save_text = round($v->given / 100, 1) . '元';
  199. $text = sprintf('%s+%s书币', $v->price * 100, $v->given);
  200. } else {
  201. $text = sprintf('%s书币', $v->price * 100);
  202. }
  203. $temp = [
  204. 'price' => (float) $v->price . '元',
  205. 'is_year_order' => 0,
  206. 'is_month_order' => 0,
  207. 'text' => $text,
  208. 'today_special' => $v->is_default,
  209. 'first_charge' => false,
  210. 'save_text' => $save_text,
  211. 'product_id' => $v->id,
  212. ];
  213. $data[] = $temp;
  214. }
  215. }
  216. return response()->success($data);
  217. }
  218. /**
  219. * @apiVersion 1.0.0
  220. * @apiDescription 单本消费记录
  221. * @api {get} order/bookOrderList 单本消费记录
  222. * @apiHeader {String} [Authorization] token
  223. * @apiGroup Order
  224. * @apiName bookOrderList
  225. * @apiParam {String} [page_size] 分页大小
  226. * @apiParam {String} [page] 页码
  227. * @apiSuccess {int} code 状态码
  228. * @apiSuccess {String} msg 信息
  229. * @apiSuccess {object} data 结果集
  230. * @apiSuccess {Int} uid uid
  231. * @apiSuccess {Int} bid bid
  232. * @apiSuccess {Int} book_name 书名
  233. * @apiSuccess {Int} fee 钱
  234. * @apiSuccess {String} created_at 时间
  235. * @apiSuccessExample {json} Success-Response:
  236. * HTTP/1.1 200 OK
  237. * {
  238. * code: 0,
  239. * msg: "",
  240. * data: list:[
  241. * {
  242. * uid: 4,
  243. * bid: 1,
  244. * book_name: "dfsedfertrwet",
  245. * fee: 100,
  246. * created_at: "2017-12-02 16:24:54"
  247. * }
  248. * ]
  249. * meta: {
  250. * total: 1,
  251. * per_page: 15,
  252. * current_page: 1,
  253. * last_page: 1,
  254. * next_page_url: "",
  255. * prev_page_url: ""
  256. * }
  257. * }
  258. * }
  259. */
  260. public function bookOrderList(Request $request)
  261. {
  262. $page_size = $request->input('page_size', 15);
  263. $book_order = BookOrderService::getRecord($this->uid, $page_size);
  264. return response()->pagination(new BookOrderTransformer(), $book_order);
  265. }
  266. /**
  267. * @apiVersion 1.0.0
  268. * @apiDescription 章节消费记录
  269. * @api {get} order/chapterOrderList 章节消费记录
  270. * @apiHeader {String} [Authorization] token
  271. * @apiGroup Order
  272. * @apiName chapterOrderList
  273. * @apiParam {String} [page_size] 分页大小
  274. * @apiParam {String} [page] 页码
  275. * @apiSuccess {int} code 状态码
  276. * @apiSuccess {String} msg 信息
  277. * @apiSuccess {object} data 结果集
  278. * @apiSuccess {Int} uid uid
  279. * @apiSuccess {Int} bid bid
  280. * @apiSuccess {Int} cid cid
  281. * @apiSuccess {Int} chapter_name 章节名
  282. * @apiSuccess {Int} book_name 书名
  283. * @apiSuccess {Int} fee 钱
  284. * @apiSuccess {String} created_at 时间
  285. * @apiSuccessExample {json} Success-Response:
  286. * HTTP/1.1 200 OK
  287. * {
  288. * code: 0,
  289. * msg: "",
  290. * data: list:[
  291. * {
  292. * uid: 4,
  293. * bid: 1,
  294. * cid: 1,
  295. * chapter_name: "sdfsd",
  296. * book_name: "dfsedfertrwet",
  297. * fee: 100,
  298. * created_at: "2017-12-02 16:24:54"
  299. * }
  300. * ]
  301. * meta: {
  302. * total: 1,
  303. * per_page: 15,
  304. * current_page: 1,
  305. * last_page: 1,
  306. * next_page_url: "",
  307. * prev_page_url: ""
  308. * }
  309. * }
  310. */
  311. public function chapterOrderList(Request $request)
  312. {
  313. $chapter_model = new ChapterOrderService();
  314. $page_size = $request->input('page_size', 15);
  315. $chapter_order = $chapter_model->getByUid($this->uid, $page_size);
  316. foreach ($chapter_order as $item) {
  317. if ($item->fee == 0) {
  318. $result = AdVisitStatService::getInfoV2($this->uid, $item->cid, ['UNLOCK', 'UNLOCK_2']);
  319. $item->fee = '解锁';
  320. }
  321. }
  322. return response()->pagination(new ChapterOrderTransformer(), $chapter_order);
  323. }
  324. /**
  325. * @apiVersion 1.0.0
  326. * @apiDescription 充值记录
  327. * @api {get} order/chargeRecordLists 充值记录
  328. * @apiParam {String} [token] token
  329. * @apiHeader {String} [Authorization] token 两个token任选其一
  330. * @apiGroup Order
  331. * @apiName chargeRecordLists
  332. * @apiParam {String} [page_size] 分页大小
  333. * @apiParam {String} [page] 页码
  334. * @apiSuccess {int} code 状态码
  335. * @apiSuccess {String} msg 信息
  336. * @apiSuccess {object} data 结果集
  337. * @apiSuccess {String} data.price 价格
  338. * @apiSuccess {String} data.status 状态
  339. * @apiSuccess {String} data.trade_no 订单号
  340. * @apiSuccess {String} data.created_at 时间
  341. * @apiSuccessExample {json} Success-Response:
  342. * HTTP/1.1 200 OK
  343. * {
  344. * code: 0,
  345. * msg: "",
  346. * data: {
  347. * list: [
  348. * {
  349. * id: 134,
  350. * price: "1.00",
  351. * status: "PAID",
  352. * trade_no: "201712021915481585670623626232",
  353. * created_at: "2017-12-02 19:15:56"
  354. * }
  355. * ],
  356. * meta: {
  357. * total: 1,
  358. * per_page: 15,
  359. * current_page: 1,
  360. * last_page: 1,
  361. * next_page_url: "",
  362. * prev_page_url: ""
  363. * }
  364. * }
  365. * }
  366. */
  367. public function chargeRecordLists(Request $request)
  368. {
  369. $page_size = $request->input('page_size', 15);
  370. $res = OrderService::getOrderList($this->uid, $page_size);
  371. return response()->pagination(new ChargeListTransformer(), $res);
  372. }
  373. //订单是否成功
  374. public function isSuccess(Request $request)
  375. {
  376. $order = $request->input('order');
  377. $order_info = OrderService::getByTradeNo($order);
  378. if ($order_info && $order_info->status == 'PAID') {
  379. return response()->success();
  380. }
  381. return response()->error('QAPP_SYS_ERROR');
  382. }
  383. private function getPayParams(Request $request)
  384. {
  385. $product_id = $request->get('product_id', 0);
  386. $send_order_id = $request->get('send_order_id', 0);
  387. if (!$product_id) {
  388. return false;
  389. }
  390. $bid = $request->get('bid', 0);
  391. if ($bid) {
  392. $from_bid = BookService::decodeBidStatic($bid);
  393. }
  394. $trade_no = date("YmdHis") . hexdec(uniqid());
  395. $product_info = ProductService::getProductSingle($product_id);
  396. $uid = $this->uid;
  397. $distribution_channel_id = $this->distribution_channel_id;
  398. $price = $product_info->price * 100;
  399. if (in_array($uid, explode(',', env('TEST_UID')))) {
  400. $price = 1;
  401. }
  402. $from_type = 'QuickApp';
  403. if ($product_info->type == 'YEAR_ORDER') {
  404. $order_type = 'YEAR';
  405. } elseif ($product_info->type == 'BOOK_ORDER') {
  406. $order_type = 'BOOK';
  407. } elseif ($product_info->type == 'TICKET_RECHARGE') {
  408. $order_type = 'RECHARGE';
  409. } else {
  410. $order_type = '';
  411. }
  412. $create_ip = _getIp();
  413. return compact(
  414. 'distribution_channel_id',
  415. 'uid',
  416. 'product_id',
  417. 'price',
  418. 'trade_no',
  419. 'create_ip',
  420. 'send_order_id',
  421. 'from_bid',
  422. 'from_type',
  423. 'order_type'
  424. );
  425. }
  426. /**
  427. * @apiVersion 1.0.0
  428. * @apiDescription 支付
  429. * @api {get} goToPay 微信APP支付
  430. * @apiGroup pay
  431. * @apiName wxindex
  432. * @apiParam {Int} product_id product_id
  433. * @apiParam {Int} send_order_id send_order_id
  434. * @apiParam {String} bid bid
  435. * @apiHeader {String} [Authorization] token
  436. * @apiSuccess {int} code 状态码
  437. * @apiSuccess {String} msg 信息
  438. * @apiSuccess {Object} data 信息
  439. * @apiSuccess {Object} data.trade_no 订单号
  440. * @apiSuccess {Object} data.appId 唤起支付的appId
  441. * @apiSuccess {Object} data.mch_id 唤起支付的mch_id
  442. * @apiSuccess {Object} data.nonce_str 唤起支付的nonce_str
  443. * @apiSuccess {Object} data.prepay_id 唤起支付的prepay_id
  444. * @apiSuccess {Object} data.sign 唤起支付的sign
  445. * @apiSuccess {Object} data.trade_type 唤起支付trade_type
  446. * @apiSuccessExample {json} Success-Response:
  447. * HTTP/1.1 200 OK
  448. * {
  449. * code: 0,
  450. * msg: "",
  451. * data: {
  452. *
  453. * }
  454. */
  455. function wxIndex(Request $request)
  456. {
  457. if ($params = $this->getPayParams($request)) {
  458. $params['pay_merchant_source'] = 'OFFICIALPAY_QAPP_APP';
  459. } else {
  460. return response()->error('QAPP_PARAM_ERROR');
  461. }
  462. $app = OrderArousePayFactory::wx($this->uid);
  463. // 微信支付参数
  464. $params['trade_type'] = 'APP'; //交易类型
  465. $result = $app->handle($params);
  466. if ($result) {
  467. $result['trade_no'] = $params['trade_no'];
  468. return response()->success($result);
  469. } else {
  470. return response()->error('APP_CREATE_WECHAT_ORDER_FAIL');
  471. }
  472. }
  473. /**
  474. * @apiVersion 1.0.0
  475. * @apiDescription 微信H5支付
  476. * @api {get} goToH5Pay 微信H5支付
  477. * @apiGroup pay
  478. * @apiName wxH5Index
  479. * @apiParam {Int} product_id product_id
  480. * @apiParam {Int} send_order_id send_order_id
  481. * @apiParam {String} bid bid
  482. * @apiHeader {String} [Authorization] token
  483. * @apiSuccess {int} code 状态码
  484. * @apiSuccess {String} msg 信息
  485. * @apiSuccess {Object} data 信息
  486. * @apiSuccess {Object} data.trade_no 订单号
  487. * @apiSuccess {Object} data.appId 唤起支付的appId
  488. * @apiSuccess {Object} data.mch_id 唤起支付的mch_id
  489. * @apiSuccess {Object} data.nonce_str 唤起支付的nonce_str
  490. * @apiSuccess {Object} data.prepay_id 唤起支付的prepay_id
  491. * @apiSuccess {Object} data.sign 唤起支付的sign
  492. * @apiSuccess {Object} data.trade_type 唤起支付trade_type
  493. * @apiSuccess {Object} data.mweb_url 唤起支付mweb_url
  494. * @apiSuccessExample {json} Success-Response:
  495. * HTTP/1.1 200 OK
  496. * {
  497. * code: 0,
  498. * msg: "",
  499. * data: {
  500. *
  501. * }
  502. */
  503. function wxH5Index(Request $request)
  504. {
  505. if ($params = $this->getPayParams($request)) {
  506. $params['pay_merchant_source'] = 'OFFICIALPAY_QAPP_H5';
  507. } else {
  508. return response()->error('QAPP_PARAM_ERROR');
  509. }
  510. $app = OrderArousePayFactory::wx($this->uid);
  511. // 微信支付参数
  512. $params['trade_type'] = 'MWEB'; //交易类型
  513. $result = $app->handle($params);
  514. if ($result) {
  515. $result['trade_no'] = $params['trade_no'];
  516. return response()->success($result);
  517. } else {
  518. return response()->error('APP_CREATE_WECHAT_ORDER_FAIL');
  519. }
  520. }
  521. /**
  522. * @apiVersion 1.0.0
  523. * @apiDescription 支付宝APP支付
  524. * @api {get} goToAliPay 支付宝APP支付
  525. * @apiGroup pay
  526. * @apiName aliIndex
  527. * @apiParam {Int} product_id product_id
  528. * @apiParam {Int} send_order_id send_order_id
  529. * @apiParam {String} bid bid
  530. * @apiHeader {String} [Authorization] token
  531. * @apiSuccess {Object} data.order_info 唤起支付信息str
  532. * @apiSuccess {Object} data.trade_no 订单号
  533. * @apiSuccessExample {json} Success-Response:
  534. * HTTP/1.1 200 OK
  535. * {
  536. * code: 0,
  537. * msg: "",
  538. * data:""
  539. *
  540. */
  541. public function aliIndex(Request $request)
  542. {
  543. if ($params = $this->getPayParams($request)) {
  544. $params['pay_merchant_source'] = 'QuickAppALiPay';
  545. $params['type'] = 'App';
  546. } else {
  547. return response()->error('QAPP_PARAM_ERROR');
  548. }
  549. $app = OrderArousePayFactory::ali($this->uid);
  550. $order_info = $app->handle($params);
  551. return response()->success(['trade_no' => $params['trade_no'], 'order_info' => $order_info]);
  552. }
  553. /**
  554. * @apiVersion 1.0.0
  555. * @apiDescription 订单查询
  556. * @api {get} checkOrder 订单查询
  557. * @apiGroup pay
  558. * @apiName checkOrder
  559. * @apiParam {String} [token] token
  560. * @apiHeader {String} [Authorization] token 两个token任选其一
  561. * @apiParam {String} order order
  562. * @apiSuccess {int} code 状态码
  563. * @apiSuccess {String} msg 信息
  564. * @apiSuccess {Object} data 信息
  565. * @apiSuccessExample {json} Success-Response:
  566. * HTTP/1.1 200 OK
  567. * {
  568. * code: 0,
  569. * msg: "",
  570. * data: {
  571. *
  572. * }
  573. */
  574. public function checkOrder(Request $request)
  575. {
  576. $order = $request->input('order', '');
  577. $i = 0;
  578. $uid = $this->uid;
  579. while ($i <= 10) {
  580. $order_info = OrderService::getByTradeNo($order);
  581. if (!$order_info) {
  582. return response()->error('QAPP_SYS_ERROR');
  583. break;
  584. }
  585. if (isset($order_info->status) && $order_info->status == 'PAID') {
  586. $data['balance'] = 0;
  587. $user = UserService::getById($uid);
  588. if ($user) {
  589. $data['balance'] = $user->balance;
  590. }
  591. return response()->success($data);
  592. }
  593. sleep(1);
  594. $i++;
  595. }
  596. return response()->error('QAPP_SYS_ERROR');
  597. }
  598. /**
  599. * 官方微信回调
  600. */
  601. function wxback(Request $request)
  602. {
  603. $xml = XML::parse(strval($request->getContent()));
  604. myLog('wxpay')->info($xml);
  605. if (isset($xml['attach'])) {
  606. $pay_merchant_name = $xml['attach'];
  607. $config = PayMerchantService::getPayConfigByNameStatic($pay_merchant_name);
  608. $app = PayFactory::official($config);
  609. $response = $app->notify()->handleNotify(function ($notify, $successful) {
  610. if (!$successful) {
  611. return 'fail';
  612. }
  613. if (OrderPaySuccess::handle($notify->out_trade_no, $notify->transaction_id)) {
  614. return true;
  615. } else {
  616. return 'fail';
  617. }
  618. });
  619. return $response;
  620. } else {
  621. return 'fail';
  622. }
  623. }
  624. /**
  625. * 支付宝支付回调
  626. */
  627. function aliback(Request $request)
  628. {
  629. $param = $request->except('_url');
  630. $app = PayFactory::aliPay();
  631. myLog('alipay')->info($param);
  632. if ($app->notify($param)) {
  633. if (OrderPaySuccess::handle($param['out_trade_no'], $param['trade_no'])) {
  634. return response('success');
  635. } else {
  636. return response('fail');
  637. }
  638. return response('success');
  639. } else {
  640. return response('fail');
  641. }
  642. }
  643. function wait(Request $request)
  644. {
  645. $param = $request->except('_url');
  646. return view('pay.middleware')->with($param);
  647. }
  648. }