ShopExtController.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. if (!empty($list)) {
  22. foreach ($list as $key => $val) {
  23. $shortCover = $val['cover'] ?? '';
  24. $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  25. $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  26. $list[$key]['cover'] = $cover;
  27. $list[$key]['bigCover'] = $bigCover;
  28. $list[$key]['shortCover'] = $shortCover;
  29. }
  30. }
  31. util::success(['list' => $list]);
  32. }
  33. //添加打印机 shish 20210712
  34. public function actionAddPrint()
  35. {
  36. $shopAdmin = $this->shopAdmin;
  37. $roleId = $shopAdmin['roleId'] ?? 0;
  38. $role = AdminRoleClass::getById($roleId);
  39. $roleName = $role['roleName'] ?? '';
  40. if ($roleName == '员工') {
  41. util::fail('没有权限操作哦');
  42. }
  43. $shopId = $this->shopId;
  44. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  45. $get = Yii::$app->request->get();
  46. $printSn = $get['printSn'] ?? '';
  47. $printKey = $get['printKey'] ?? '';
  48. $print = new printUtil($printSn);
  49. $shop = $this->shop;
  50. $default = $shop->default ?? 0;
  51. $shopName = $shop->shopName ?? '';
  52. $sj = $this->sj;
  53. $sjName = $sj->name ?? '';
  54. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  55. if (!empty($printSn) && !empty($printKey)) {
  56. $return = $print->addPrint($printKey, $name);
  57. if ($return) {
  58. $ext->printSn = $printSn;
  59. $ext->printKey = $printKey;
  60. $ext->save();
  61. util::complete('添加成功');
  62. }
  63. }
  64. if (empty($printSn) && empty($printKey)) {
  65. $ext->printSn = '';
  66. $ext->printKey = '';
  67. $ext->save();
  68. util::complete('修改成功');
  69. }
  70. util::fail('添加失败');
  71. }
  72. //获取打印机信息
  73. public function actionGetPrint()
  74. {
  75. $shopId = $this->shopId;
  76. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  77. util::success($ext);
  78. }
  79. }