| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace addons\Clerk\backend\controllers;
- use addons\Clerk\common\models\ClerkLog;
- use addons\Store\common\models\Store;
- use common\enums\AddonsEnum;
- use common\enums\StatusEnum;
- use common\models\mall\MallAddons;
- use common\models\user\User;
- /**
- * 默认控制器
- *
- * Class DefaultController
- * @package addons\Clerk\backend\controllers
- */
- class ClerkLogController extends BaseController
- {
- //核销记录
- public function actionIndex()
- {
- if (\Yii::$app->request->isAjax) {
- if (\Yii::$app->request->isGet) {
- $params = \Yii::$app->request->get();
- $where[] = ['mall_id' => $this->mall_id];
- $where[] = ['status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]];
- $where[] = ['verify_type' => ClerkLog::VERIFY_ELECTRON_COUPON];
- if (!empty($get['keyword'])) {
- $user_list = User::lists(['where'=>[['mall_id'=>$this->mall_id],[
- 'or',
- ['like', 'mobile', $get['keyword']]
- ]],'select'=>'id']);
- $user_ids = array_column($user_list,'id');
- $where[] = ['user_id'=>$user_ids];
- }
- if (!empty($params['user_id'])) $where[] = ['user_id'=>$params['user_id']];
- if (!empty($params['start'])) $where[] = $where[] = ['>=', 'created_at', strtotime($params['start'])];
- if (!empty($params['end'])) $where[] =$where[] = ['<=', 'created_at', strtotime($params['end'])];
- $params['where'] = $where;
- $params['order'] = 'id DESC';
- $params['select'] = 'id,mall_id,store_id,clerk_id,user_id,mobile,commission,title,created_at';
- $pageData = ClerkLog::listPage($params, false);
- if (!empty($pageData['list'])) {
- $user_ids = array_column($pageData['list'], 'user_id');
- $store_ids = array_column($pageData['list'], 'store_id');
- $user_list = User ::lists(['where' => [['id' => $user_ids]], 'select' => 'id,nickname,mobile,username', 'index' => 'id']);
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_STORE)) {
- $store_list = Store::lists(['where' => [['id' => $store_ids]], 'select' => 'id,store_name', 'index' => 'id']);
- }
- foreach ($pageData['list'] as &$item) {
- $item['nickname'] = $item['mobile'] = $item['username'] = $item['store_name'] = '';
- if (isset($user_list[$item['user_id']])) {
- $user = $user_list[$item['user_id']];
- $item['nickname'] = $user['nickname'];
- $item['mobile'] = $user['mobile'];
- $item['username'] = $user['username'];
- }
- if (isset($store_list[$item['store_id']])) {
- $item['store_name'] = $store_list[$item['store_id']]['store_name'];
- }
- }
- }
- return $this->success('操作成功', $pageData);
- }
- }
- return $this->render('index',[
- ]);
- }
- }
|