ShopExtController.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. if (!empty($printSn) && !empty($printKey)) {
  22. $return = $print->addPrint($printKey, $shopName);
  23. if ($return) {
  24. $ext->printSn = $printSn;
  25. $ext->printKey = $printKey;
  26. $ext->save();
  27. util::complete('添加成功');
  28. }
  29. }
  30. if (empty($printSn) && empty($printKey)) {
  31. $ext->printSn = '';
  32. $ext->printKey = '';
  33. $ext->save();
  34. util::complete('修改成功');
  35. }
  36. util::fail('添加失败');
  37. }
  38. //获取打印机信息
  39. public function actionGetPrint()
  40. {
  41. $shopId = $this->shopId;
  42. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  43. util::success($ext);
  44. }
  45. }