AllianceController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\admin\controllers;
  8. use Yii;
  9. use Exception;
  10. use app\models\Goods;
  11. use app\models\GoodsCat;
  12. use app\modules\admin\models\SaasCategoryForm;
  13. use app\modules\admin\models\StoreForm;
  14. use yii\helpers\Json;
  15. class AllianceController extends BaseController
  16. {
  17. //获取店铺类型列表
  18. public function actionStoreTypeList()
  19. {
  20. $form = new SaasCategoryForm();
  21. return $this->asJson($form->getList(false));
  22. }
  23. //店铺列表
  24. public function actionStoreList(){
  25. $form = new StoreForm();
  26. return $this->asJson($form->getAllianceList());
  27. }
  28. //模糊店铺信息
  29. public function actionStoreListByName(){
  30. $form = new StoreForm();
  31. return $this->asJson($form->getStoreIdByStoreName());
  32. }
  33. //商品信息
  34. public function actionGoodsList(){
  35. return $this->asJson(Goods::getAllianceList(get_params()));
  36. }
  37. /**
  38. * 商盟检测商品列表
  39. */
  40. public function actionDiyGoodsList()
  41. {
  42. $params = get_params();
  43. try {
  44. $goods_id = Json::decode($params['goods_id']);
  45. } catch (\Exception $e) {
  46. $goods_id = explode(',', $params['goods_id']);
  47. }
  48. $query = Goods::find()->alias('g')
  49. ->where([
  50. 'g.is_delete' => 0,
  51. 'g.status' => 1,
  52. 'g.md_food_id' => 0
  53. ])->andWhere(['not like', 'g.name', '当面付']);
  54. if ($goods_id) {
  55. $query->andWhere(['in','g.id', $goods_id]);
  56. }
  57. $query->select(['g.goods_num', 'g.status', 'g.product_type', 'g.virtual_sales', 'g.name', 'g.id', 'g.service', 'g.attr', 'g.cover_pic', 'g.attr', 'g.use_attr', 'g.price', 'g.original_price'])->orderBy('g.created_at desc, g.updated_at desc');
  58. $list = pagination_make($query);
  59. return $this->asJson([
  60. 'code' => 0,
  61. 'msg' => 'success',
  62. 'data' => [
  63. 'data' => $list['list'],
  64. 'pageNo' => $list['pageNo'],
  65. 'totalCount' => $list['totalCount']
  66. ]
  67. ]);
  68. }
  69. }