XjController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\product\classes\XjClass;
  4. use biz\shop\classes\ShopExtClass;
  5. use common\components\util;
  6. use Yii;
  7. class XjController extends BaseController
  8. {
  9. //取出所有小菊 shish 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. //取出商家小菊 shish 20210904
  19. public function actionGetSjXj()
  20. {
  21. $list = XjClass::getSjXj($this->shopExt);
  22. util::success(['list' => $list]);
  23. }
  24. //取出所有小菊,带商家有没有标识 shish 20210904
  25. public function actionGetFilterXj()
  26. {
  27. $where = [];
  28. $where['shopId'] = $this->shopId;
  29. $where['status'] = 1;
  30. $list = XjClass::getShopXj($this->shopId);
  31. $ext = $this->shopExt;
  32. $xj = $ext->xj ?? '';
  33. $hasIds = [];
  34. if (!empty($xj)) {
  35. $hasIds = json_decode($xj, true);
  36. }
  37. if (!empty($list)) {
  38. foreach ($list as $key => $val) {
  39. $id = $val['id'] ?? 0;
  40. $list[$key]['has'] = 0;
  41. if (in_array($id, $hasIds)) {
  42. $list[$key]['has'] = 1;
  43. }
  44. }
  45. }
  46. util::success(['list' => $list]);
  47. }
  48. //清除全部小菊 lqh 2021.12.8
  49. public function actionClearAll()
  50. {
  51. XjClass::clearAll($this->shopId);
  52. ShopExtClass::clearXjALl($this->shopId);
  53. util::complete();
  54. }
  55. //新增小菊 lqh 2021.12.8
  56. public function actionAdd()
  57. {
  58. $post = Yii::$app->request->post();
  59. $cover = $post['cover']??'';
  60. if(empty($cover)){
  61. util::fail("请上传图片");
  62. }
  63. XjClass::addXj($this->shopId,$cover,$this->shopExt);
  64. util::complete();
  65. }
  66. }