XjController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\product\classes\XjClass;
  4. use bizGhs\item\classes\ItemClass;
  5. use common\components\imgUtil;
  6. use common\components\util;
  7. use Yii;
  8. class XjController extends BaseController
  9. {
  10. //取出所有小菊 ssh 20210904
  11. public function actionGetAllXj()
  12. {
  13. $where = [];
  14. $where['shopId'] = $this->shopId;
  15. $where['status'] = 1;
  16. $list = XjClass::getShopXj($this->shopId);
  17. util::success(['list' => $list]);
  18. }
  19. //取出商家上架的小菊 ssh 20210904
  20. public function actionGetSjXj()
  21. {
  22. $get = Yii::$app->request->get();
  23. $itemId = $get['itemId'] ?? 0;
  24. $product = ItemClass::getById($itemId, true);
  25. if ($product->mainId != $this->mainId) {
  26. util::fail('不是您的花材');
  27. }
  28. $list = XjClass::getAllByCondition(['itemId' => $itemId, 'delStatus' => 0, 'status' => 1], null, '*');
  29. if (!empty($list)) {
  30. foreach ($list as $key => $val) {
  31. $shortCover = $val['cover'] ?? '';
  32. $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  33. $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  34. $list[$key]['cover'] = $cover;
  35. $list[$key]['bigCover'] = $bigCover;
  36. $list[$key]['shortCover'] = $shortCover;
  37. }
  38. }
  39. util::success(['list' => $list]);
  40. }
  41. //取出商家所有小菊 ssh 20210904
  42. public function actionGetFilterXj()
  43. {
  44. $get = Yii::$app->request->get();
  45. $itemId = $get['itemId'] ?? 0;
  46. $product = ItemClass::getById($itemId, true);
  47. if ($product->mainId != $this->mainId) {
  48. util::fail('不是您的花材');
  49. }
  50. $list = XjClass::getAllByCondition(['itemId' => $itemId, 'delStatus' => 0], null, '*');
  51. if (!empty($list)) {
  52. foreach ($list as $key => $val) {
  53. $shortCover = $val['cover'] ?? '';
  54. $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  55. $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  56. $list[$key]['cover'] = $cover;
  57. $list[$key]['bigCover'] = $bigCover;
  58. $list[$key]['shortCover'] = $shortCover;
  59. }
  60. }
  61. util::success(['list' => $list]);
  62. }
  63. //清除全部小菊 lqh 2021.12.8
  64. public function actionClearAll()
  65. {
  66. $get = Yii::$app->request->get();
  67. $itemId = $get['itemId'] ?? 0;
  68. $product = ItemClass::getById($itemId, true);
  69. if ($product->mainId != $this->mainId) {
  70. util::fail('不是您的花材');
  71. }
  72. XjClass::clearAll($itemId);
  73. util::complete('已删除');
  74. }
  75. //新增小菊 lqh 2021.12.8
  76. public function actionBatchAdd()
  77. {
  78. $post = Yii::$app->request->post();
  79. $itemId = $post['itemId'] ?? 0;
  80. $product = ItemClass::getById($itemId, true);
  81. if ($product->mainId != $this->mainId) {
  82. util::fail('不是您的花材');
  83. }
  84. $xjData = $post['xjData'] ?? '';
  85. if (empty($xjData)) {
  86. util::fail('请上传图片');
  87. }
  88. $arr = json_decode($xjData, true);
  89. if (is_array($arr) == false) {
  90. util::fail('请上传图片...');
  91. }
  92. XjClass::batchAddXj($arr, $this->shop, $product);
  93. util::complete('添加成功');
  94. }
  95. }