ShopExtController.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace hd\controllers;
  3. use biz\ghs\classes\GhsClass;
  4. use biz\product\classes\XjClass;
  5. use biz\shop\classes\ShopExtClass;
  6. use common\components\util;
  7. use biz\admin\classes\AdminRoleClass;
  8. use common\components\printUtil;
  9. use Yii;
  10. class ShopExtController extends BaseController
  11. {
  12. public $guestAccess = [];
  13. //取出供应商的小菊颜色 shish 20210907
  14. public function actionGetGhsXj()
  15. {
  16. $id = Yii::$app->request->get('ghsId', 0);
  17. $ghs = GhsClass::getById($id, true);
  18. GhsClass::valid($ghs, $this->shopId);
  19. $shopId = $ghs->shopId ?? 0;
  20. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  21. $list = XjClass::getSjXj($ext);
  22. util::success(['list' => $list]);
  23. }
  24. //添加打印机 shish 20210712
  25. public function actionAddPrint()
  26. {
  27. $shopAdmin = $this->shopAdmin;
  28. $roleId = $shopAdmin['roleId'] ?? 0;
  29. $role = AdminRoleClass::getById($roleId);
  30. $roleName = $role['roleName'] ?? '';
  31. if ($roleName == '员工') {
  32. util::fail('没有权限操作哦');
  33. }
  34. $shopId = $this->shopId;
  35. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  36. $get = Yii::$app->request->get();
  37. $printSn = $get['printSn'] ?? '';
  38. $printKey = $get['printKey'] ?? '';
  39. $print = new printUtil($printSn);
  40. $shop = $this->shop;
  41. $default = $shop->default ?? 0;
  42. $shopName = $shop->shopName ?? '';
  43. $sj = $this->sj;
  44. $sjName = $sj->name ?? '';
  45. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  46. if (!empty($printSn) && !empty($printKey)) {
  47. $return = $print->addPrint($printKey, $name);
  48. if ($return) {
  49. $ext->printSn = $printSn;
  50. $ext->printKey = $printKey;
  51. $ext->save();
  52. util::complete('添加成功');
  53. }
  54. }
  55. if (empty($printSn) && empty($printKey)) {
  56. $ext->printSn = '';
  57. $ext->printKey = '';
  58. $ext->save();
  59. util::complete('修改成功');
  60. }
  61. util::fail('添加失败');
  62. }
  63. //获取打印机信息
  64. public function actionGetPrint()
  65. {
  66. $shopId = $this->shopId;
  67. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  68. util::success($ext);
  69. }
  70. }