ShopController.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace pt\controllers;
  3. use biz\shop\classes\ShopClass;
  4. use bizHd\merchant\services\ShopService;
  5. use common\components\stringUtil;
  6. use common\components\util;
  7. use Yii;
  8. class ShopController extends BaseController
  9. {
  10. //调整仅采购功能,允许零售使用所有功能 ssh 20220919
  11. public function actionChangeOnlyCg()
  12. {
  13. $get = Yii::$app->request->get();
  14. $id = $get['id'] ?? 0;
  15. $shop = ShopClass::getById($id, true);
  16. if (empty($shop)) {
  17. util::fail('没有找到门店');
  18. }
  19. if ($shop->ptStyle != 1) {
  20. util::fail('只能给零售店操作');
  21. }
  22. $shop->onlyCg = $shop->onlyCg == 0 ? 1 : 0;
  23. $shop->save();
  24. util::complete();
  25. }
  26. //门店列表 ssh 20210730
  27. public function actionList()
  28. {
  29. $where = [];
  30. $name = Yii::$app->request->get('name', '');
  31. if (!empty($name)) {
  32. if (stringUtil::isLetter($name)) {
  33. $where['py'] = ['like', $name];
  34. } else {
  35. $where['merchantName'] = ['like', $name];
  36. }
  37. }
  38. $list = ShopService::getShopList($where);
  39. util::success($list);
  40. }
  41. }