IndexController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * IndexController.php
  4. * todo 文件描述
  5. * Created on 2024/12/3 上午10:49
  6. * @author: hankaige
  7. */
  8. namespace app\modules\client\controllers\v1\cashier;
  9. use app\models\CashierActionLog;
  10. use app\modules\client\models\v1\cashier\IndexForm;
  11. use yii\helpers\ArrayHelper;
  12. class IndexController extends BaseController
  13. {
  14. /**
  15. * 收银台首页统计数据
  16. * @return \yii\web\Response
  17. * @author: hankaige
  18. * @Time: 2024/12/4 下午1:44
  19. */
  20. public function actionIndex():\yii\web\Response
  21. {
  22. $form = new IndexForm();
  23. $form->store_id = get_store_id();
  24. $form->md_id = $this->md_id;
  25. return $this->asJson($form->indexData());
  26. }
  27. /**
  28. * 获取扫码商品列表
  29. * @return \yii\web\Response
  30. * @author: hankaige
  31. * @Time: 2024/12/4 下午1:47
  32. */
  33. public function actionGetGoodsByCode():\yii\web\Response
  34. {
  35. $form = new IndexForm();
  36. $form->store_id = get_store_id();
  37. $form->md_id = $this->md_id;
  38. $form->attributes = get_params();
  39. return $this->asJson($form->getGoods());
  40. }
  41. public function actionGetActionLog()
  42. {
  43. $day = get_params('day');
  44. if(empty($day)){
  45. $day = date('Y-m-d');
  46. $startTime = strtotime(date($day.' 00:00:00'));
  47. $endTime = strtotime(date($day.' 23:59:59'));
  48. }else{
  49. $startTime = strtotime(date($day.' 00:00:00'));
  50. $endTime = strtotime(date($day.' 23:59:59'));
  51. }
  52. $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');
  53. $result = pagination_make($query,true);
  54. foreach($result['list'] as &$item){
  55. $item['created_at'] = date('Y-m-d H:i:s',$item['created_at']);
  56. $item['action_text'] = CashierActionLog::TEXT[$item['action']];
  57. }
  58. return $this->asJson(['code' => 0,'data' => $result]);
  59. }
  60. }