XjController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\product\classes\XjClass;
  4. use common\components\imgUtil;
  5. use common\components\util;
  6. use Yii;
  7. class XjController extends BaseController
  8. {
  9. //取出所有小菊 ssh 20210904
  10. public function actionGetAllXj()
  11. {
  12. $where = [];
  13. $where['shopId'] = $this->shopId;
  14. $where['status'] = 1;
  15. $list = XjClass::getShopXj($this->shopId);
  16. util::success(['list' => $list]);
  17. }
  18. //取出商家上架的小菊 ssh 20210904
  19. public function actionGetSjXj()
  20. {
  21. $list = XjClass::getAllByCondition(['shopId' => $this->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 20210904
  35. public function actionGetFilterXj()
  36. {
  37. $list = XjClass::getAllByCondition(['shopId' => $this->shopId, 'delStatus' => 0], null, '*');
  38. if (!empty($list)) {
  39. foreach ($list as $key => $val) {
  40. $shortCover = $val['cover'] ?? '';
  41. $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  42. $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  43. $list[$key]['cover'] = $cover;
  44. $list[$key]['bigCover'] = $bigCover;
  45. $list[$key]['shortCover'] = $shortCover;
  46. }
  47. }
  48. util::success(['list' => $list]);
  49. }
  50. //清除全部小菊 lqh 2021.12.8
  51. public function actionClearAll()
  52. {
  53. XjClass::clearAll($this->shopId);
  54. //ShopExtClass::clearXjALl($this->shopId);
  55. util::complete('已删除');
  56. }
  57. //新增小菊 lqh 2021.12.8
  58. public function actionBatchAdd()
  59. {
  60. $post = Yii::$app->request->post();
  61. $xjData = $post['xjData'] ?? '';
  62. if (empty($xjData)) {
  63. util::fail('请上传图片');
  64. }
  65. $arr = json_decode($xjData, true);
  66. if (is_array($arr) == false) {
  67. util::fail('请上传图片...');
  68. }
  69. XjClass::batchAddXj($arr, $this->shop);
  70. util::complete('添加成功');
  71. }
  72. }