| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace addons\BusinessCard\backend\controllers;
- use addons\BusinessCard\common\models\BusinessCardMaterials;
- use addons\BusinessCard\common\models\BusinessCardMaterialsStatistics;
- use common\enums\StatusEnum;
- use Yii;
- class MaterialStatisticsController extends BaseController
- {
- public $enableCsrfValidation = false;
- public function actionIndex()
- {
- if (Yii::$app->request->isAjax && Yii::$app->request->isPost) {
- $post = Yii::$app->request->post();
- $where = [['=', 'mall_id', $this->mall_id], ['<>', 'status' , StatusEnum::DELETE]];
- if (isset($post['material_id']) && $post['material_id']) {
- $where[] = ['=', 'material_id', $post['material_id']];
- }
- if (isset($post['title']) && $post['title']) {
- $material_ids = BusinessCardMaterials::find()
- ->orWhere(['like', 'title', "%" . $post['title'] . "%", false])
- ->select('id')
- ->asArray()
- ->column();
- $where[] = ['in', 'material_id', $material_ids];
- }
- $params = [
- 'limit' => 10,
- 'with' => 'material',
- 'where' => $where,
- 'order' => 'id desc'
- ];
- $list = BusinessCardMaterialsStatistics::listPage($params);
- return $this->success('操作成功', $list);
- } else {
- return $this->render('index');
- }
- }
- }
|