| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- /**
- * IndexController.php
- * todo 文件描述
- * Created on 2024/12/3 上午10:49
- * @author: hankaige
- */
- namespace app\modules\client\controllers\v1\cashier;
- use app\models\CashierActionLog;
- use app\modules\client\models\v1\cashier\IndexForm;
- use yii\helpers\ArrayHelper;
- class IndexController extends BaseController
- {
- /**
- * 收银台首页统计数据
- * @return \yii\web\Response
- * @author: hankaige
- * @Time: 2024/12/4 下午1:44
- */
- public function actionIndex():\yii\web\Response
- {
- $form = new IndexForm();
- $form->store_id = get_store_id();
- $form->md_id = $this->md_id;
- return $this->asJson($form->indexData());
- }
- /**
- * 获取扫码商品列表
- * @return \yii\web\Response
- * @author: hankaige
- * @Time: 2024/12/4 下午1:47
- */
- public function actionGetGoodsByCode():\yii\web\Response
- {
- $form = new IndexForm();
- $form->store_id = get_store_id();
- $form->md_id = $this->md_id;
- $form->attributes = get_params();
- return $this->asJson($form->getGoods());
- }
- public function actionGetActionLog()
- {
- $day = get_params('day');
- if(empty($day)){
- $day = date('Y-m-d');
- $startTime = strtotime(date($day.' 00:00:00'));
- $endTime = strtotime(date($day.' 23:59:59'));
- }else{
- $startTime = strtotime(date($day.' 00:00:00'));
- $endTime = strtotime(date($day.' 23:59:59'));
- }
- $query = CashierActionLog::find()->with(['user'])->where(['store_id' => get_store_id(), 'md_id' => $this->md_id])->andWhere(['and',['>','created_at',$startTime],['<','created_at',$endTime]])->orderBy('created_at DESC');
- $result = pagination_make($query,true);
- foreach($result['list'] as &$item){
- $item['created_at'] = date('Y-m-d H:i:s',$item['created_at']);
- $item['action_text'] = CashierActionLog::TEXT[$item['action']];
- }
- return $this->asJson(['code' => 0,'data' => $result]);
- }
- }
|