ShopExtController.php 1.6 KB

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