ShopExtController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. $list = XjClass::getAllByCondition(['shopId' => $shopId, 'delStatus' => 0, 'status' => 1], null, '*');
  21. util::success(['list' => $list]);
  22. }
  23. //添加打印机 shish 20210712
  24. public function actionAddPrint()
  25. {
  26. $shopAdmin = $this->shopAdmin;
  27. $roleId = $shopAdmin['roleId'] ?? 0;
  28. $role = AdminRoleClass::getById($roleId);
  29. $roleName = $role['roleName'] ?? '';
  30. if ($roleName == '员工') {
  31. util::fail('没有权限操作哦');
  32. }
  33. $shopId = $this->shopId;
  34. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  35. $get = Yii::$app->request->get();
  36. $printSn = $get['printSn'] ?? '';
  37. $printKey = $get['printKey'] ?? '';
  38. $print = new printUtil($printSn);
  39. $shop = $this->shop;
  40. $default = $shop->default ?? 0;
  41. $shopName = $shop->shopName ?? '';
  42. $sj = $this->sj;
  43. $sjName = $sj->name ?? '';
  44. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  45. if (!empty($printSn) && !empty($printKey)) {
  46. $return = $print->addPrint($printKey, $name);
  47. if ($return) {
  48. $ext->printSn = $printSn;
  49. $ext->printKey = $printKey;
  50. $ext->save();
  51. util::complete('添加成功');
  52. }
  53. }
  54. if (empty($printSn) && empty($printKey)) {
  55. $ext->printSn = '';
  56. $ext->printKey = '';
  57. $ext->save();
  58. util::complete('修改成功');
  59. }
  60. util::fail('添加失败');
  61. }
  62. //获取打印机信息
  63. public function actionGetPrint()
  64. {
  65. $shopId = $this->shopId;
  66. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  67. util::success($ext);
  68. }
  69. }