| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\models;
- use app\models\Cat;
- use app\models\Goods;
- use app\models\GoodsCat;
- use app\models\GoodsFullMinus;
- use yii\base\Model;
- class GoodsSearchForm extends Model
- {
- public $id;
- public function rules()
- {
- return [
- [['id'], 'integer'],
- ];
- }
- public function fullMinusSearch()
- {
- $query = GoodsFullMinus::find()->alias('gfm')->select(['gfm.*', 'g.name', 'c.name AS cname', 'g.status'])
- ->where(['gfm.store_id' => get_store_id(), 'g.is_delete' => 0, 'g.store_id' => get_store_id(), 'gfm.is_delete' => 0])
- ->leftJoin(['g' => Goods::tableName()], 'g.id=gfm.goods_id')
- ->leftJoin(['gc' => GoodsCat::tableName()], 'gc.goods_id=g.id')
- ->leftJoin(['c' => Cat::tableName()], 'gc.cat_id=c.id');
- $query->andWhere(['or', ['gc.is_delete' => 0, 'gc.store_id' => get_store_id()], 'isnull(gc.id)']);
- $query->andWhere('gfm.goods_id=:goods_id', [':goods_id' => $this->id])->groupBy('id');
- $res = pagination_make($query);
- return [
- 'code' => 0,
- 'data' => $res
- ];
- }
- }
|