TestController.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace mall\controllers;
  3. use bizMall\shop\classes\ShopClass;
  4. use common\components\util;
  5. use Yii;
  6. use common\components\lakala\Lakala;
  7. class TestController extends BaseController
  8. {
  9. public $guestAccess = ['trade-query'];
  10. //收银台订单查询 ssh 20231026
  11. public function actionTradeQuery()
  12. {
  13. $shopId = 1;
  14. $shop = ShopClass::getById($shopId, true);
  15. if (empty($shop)) {
  16. util::fail('没有找到订单');
  17. }
  18. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  19. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  20. $params = [
  21. 'appid' => 'OP00002119',
  22. 'serial_no' => '018b08cfddbd',
  23. 'merchant_no' => $shop->lklSjNo,
  24. 'term_no' => $shop->lklScanTermNo,
  25. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  26. 'lklCertificatePath' => $lklCertificatePath,
  27. ];
  28. $laResource = new Lakala($params);
  29. $orderSn = 'KD26449727';
  30. $cashParams = [
  31. 'out_order_no' => $orderSn,
  32. ];
  33. $response = $laResource->cashierQuery($cashParams);
  34. if (isset($response['code']) == false || $response['code'] != '000000') {
  35. util::fail('支付失败了');
  36. }
  37. print_r($response);
  38. }
  39. }