canyin-project/ybcy/controllers/channel/ScreenController.php
2024-11-01 16:07:54 +08:00

77 lines
2.5 KiB
PHP

<?php
namespace app\controllers\channel;
use Illuminate\Support\Facades\DB;
use Yii;
use yii\web\Controller;
use app\models\common\Store;
use app\models\common\Order;
class ScreenController extends Controller{
private $shop_id;
public function init(){
parent::init();
$configData=$_SESSION['configData'];
if(Yii::$app->request->hostInfo=="https://bkycms.com"){
$configData=[
'uniacid'=>39,
'module'=>"yb_wm",
'version_id'=>$_SESSION['configData']['version_id'],
];
}
$this->shop_id=Store::getMainStore($configData['uniacid'])['id'];
$this->shop_id=$this->shop_id?:0;
}
//快餐大屏幕
public function actionFastScreen(){
$result=axios_request();
$storeId=$result['storeId']?:$this->shop_id;
$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
$store=(new \yii\db\Query())
->select(['name'])
->from('{{%ybwm_store}}')
->where('id=:id',[':id'=>$storeId])->one();
if(!$store){
return json_encode(['code'=>2, 'msg'=>'商户不存在']);
}
$where="storeId=:storeId and createdAt>:start and createdAt<=:end and orderMode=2";
$data['storeId']=$storeId;
$data['start']=$beginToday;
$data['end']=$endToday;
$preparing=(new \yii\db\Query())
->select('id,callNo')
->from('{{%ybwm_instore_order}}')
->where($where." AND state=3 AND callNum=0",$data)->orderBy('changeAt desc')->limit('12')->all();
$pleaseTake=(new \yii\db\Query())
->select('id,callNo')
->from('{{%ybwm_instore_order}}')
->where($where." AND state=3 AND callNum>0",$data)->orderBy('changeAt desc')->limit('12')->all();
$list['preparing']=$preparing;
$list['pleaseTake']=$pleaseTake;
$list['storeName']=$store['name'];
$list['number']=count($preparing)?:0;
$list['day']=date('Y-m-d');
Yii::$app->redis->set('fastBy'.$storeId,json_encode($list));
return json_encode(['code'=>1, 'msg'=>'成功', 'data'=>$list]);
}
//排队大屏幕
public function actionQueuingScreen(){
$result=axios_request();
$storeId=$result['storeId']?:$this->shop_id;
$res=Order::getQueuingScreenInfo($storeId);
return json_encode(['code'=>1, 'msg'=>'成功', 'data'=>$res]);
}
}