ShopExtController.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\shop\classes\ShopExtClass;
  4. use common\components\printUtil;
  5. use common\components\util;
  6. use Yii;
  7. class ShopExtController extends BaseController
  8. {
  9. public $guestAccess = [];
  10. //添加打印机 shish 20210712
  11. public function actionAddPrint()
  12. {
  13. $shopId = $this->shopId;
  14. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  15. $get = Yii::$app->request->get();
  16. $printSn = $get['printSn'] ?? '';
  17. $printKey = $get['printKey'] ?? '';
  18. $print = new printUtil($printSn);
  19. $shop = $this->shop;
  20. $shopName = $shop['shopName'] ?? '';
  21. $ext->printSn = $printSn;
  22. $ext->printKey = $printKey;
  23. $ext->save();
  24. $return = $print->addPrint($printKey, $shopName);
  25. if ($return) {
  26. util::complete();
  27. }
  28. util::fail();
  29. }
  30. //获取打印机信息
  31. public function actionGetPrint()
  32. {
  33. $shopId = $this->shopId;
  34. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  35. util::success($ext);
  36. }
  37. }