ShopExtController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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\imgUtil;
  7. use common\components\util;
  8. use biz\admin\classes\AdminRoleClass;
  9. use common\components\printUtil;
  10. use Yii;
  11. class ShopExtController extends BaseController
  12. {
  13. public $guestAccess = [];
  14. //取出供应商的小菊颜色 ssh 20210907
  15. public function actionGetGhsXj()
  16. {
  17. $id = Yii::$app->request->get('ghsId', 0);
  18. $ghs = GhsClass::getById($id, true);
  19. GhsClass::valid($ghs, $this->shopId);
  20. $shopId = $ghs->shopId ?? 0;
  21. $list = XjClass::getAllByCondition(['shopId' => $shopId, 'delStatus' => 0, 'status' => 1], null, '*');
  22. if (!empty($list)) {
  23. foreach ($list as $key => $val) {
  24. $shortCover = $val['cover'] ?? '';
  25. $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  26. $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  27. $list[$key]['cover'] = $cover;
  28. $list[$key]['bigCover'] = $bigCover;
  29. $list[$key]['shortCover'] = $shortCover;
  30. }
  31. }
  32. util::success(['list' => $list]);
  33. }
  34. //添加打印机 ssh 20210712
  35. public function actionAddPrint()
  36. {
  37. $shopAdmin = $this->shopAdmin;
  38. $roleId = $shopAdmin['roleId'] ?? 0;
  39. $role = AdminRoleClass::getById($roleId);
  40. $roleName = $role['roleName'] ?? '';
  41. if ($roleName == '员工') {
  42. util::fail('没有权限操作哦');
  43. }
  44. $shopId = $this->shopId;
  45. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  46. $get = Yii::$app->request->get();
  47. $printSn = $get['printSn'] ?? '';
  48. $printKey = $get['printKey'] ?? '';
  49. $print = new printUtil($printSn);
  50. $shop = $this->shop;
  51. $default = $shop->default ?? 0;
  52. $shopName = $shop->shopName ?? '';
  53. $sj = $this->sj;
  54. $sjName = $sj->name ?? '';
  55. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  56. if (!empty($printSn) && !empty($printKey)) {
  57. $return = $print->addPrint($printKey, $name);
  58. if ($return) {
  59. $ext->printSn = $printSn;
  60. $ext->printKey = $printKey;
  61. $ext->save();
  62. util::complete('添加成功');
  63. }
  64. }
  65. if (empty($printSn) && empty($printKey)) {
  66. $ext->printSn = '';
  67. $ext->printKey = '';
  68. $ext->save();
  69. util::complete('修改成功');
  70. }
  71. util::fail('添加失败');
  72. }
  73. //获取打印机信息
  74. public function actionGetPrint()
  75. {
  76. $shopId = $this->shopId;
  77. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  78. util::success($ext);
  79. }
  80. //获取云喇叭信息 ssh 20220105
  81. public function actionGetLb()
  82. {
  83. $shopId = $this->shopId;
  84. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  85. util::success($ext);
  86. }
  87. //添加喇叭 ssh 20220105
  88. public function actionAddLb()
  89. {
  90. $shopAdmin = $this->shopAdmin;
  91. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  92. util::fail('超管才能修改');
  93. }
  94. $shopId = $this->shopId;
  95. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  96. $get = Yii::$app->request->get();
  97. $lbSn = $get['lbSn'] ?? '';
  98. $ext->lbSn = $lbSn;
  99. $ext->save();
  100. util::complete('设置成功');
  101. }
  102. }