This commit is contained in:
parent
355d59446f
commit
3c45d268fd
|
|
@ -259,11 +259,13 @@ class Base extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 定时器处理消息回执/在线列表
|
// 定时器处理消息回执/在线列表/折扣信息
|
||||||
public static function geteventredis_new()
|
public static function geteventredis_new()
|
||||||
{
|
{
|
||||||
print_r('定时器' . "\r\n");
|
print_r('定时器' . "\r\n");
|
||||||
$gateway = Gateway::class;
|
$gateway = Gateway::class;
|
||||||
|
// 处理折扣消息
|
||||||
|
self::savetimediscount();
|
||||||
// 处理消息(包含推送)
|
// 处理消息(包含推送)
|
||||||
$redis_name = Gateway::getAllClientSessions();
|
$redis_name = Gateway::getAllClientSessions();
|
||||||
foreach ($redis_name as $client_id => $client_id_data) {
|
foreach ($redis_name as $client_id => $client_id_data) {
|
||||||
|
|
@ -354,6 +356,24 @@ class Base extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function savetimediscount()
|
||||||
|
{
|
||||||
|
$table = Redis::get('time_discount_info');
|
||||||
|
if($table) {
|
||||||
|
$table_arr = json_decode($table, true);
|
||||||
|
foreach ($table_arr as $k => $v) {
|
||||||
|
if(!Gateway::getClientCountByGroup($v)) {
|
||||||
|
print_r($v . '过期');
|
||||||
|
unset($table_arr[$k]);
|
||||||
|
Redis::del($v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Redis::set('time_discount_info', json_encode($table_arr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function saveonlinelist(array $client_id_list)
|
public static function saveonlinelist(array $client_id_list)
|
||||||
{
|
{
|
||||||
if(is_array($client_id_list)) {
|
if(is_array($client_id_list)) {
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,62 @@ class Events
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!empty($message['operate_type'])) {
|
||||||
|
// 桌码
|
||||||
|
if(empty($message['table_code']) || empty($message['shop_id'])) {
|
||||||
|
Gateway::sendToClient($client_id, json_encode(['msg' => '桌码或shop_id不能为空']));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||||
|
// 限时折扣修改
|
||||||
|
if($message['operate_type'] == 'time_discount_save') {
|
||||||
|
if(empty($message)) {
|
||||||
|
$res = Redis::del($redis_str);
|
||||||
|
}else {
|
||||||
|
$res = Redis::set($redis_str, $message['data']);
|
||||||
|
// 将桌号存入redis 以便及时删除
|
||||||
|
$time_discount_info = Redis::get('time_discount_info');
|
||||||
|
if($time_discount_info) {
|
||||||
|
$time_discount_info_arr = json_decode($time_discount_info, true);
|
||||||
|
$time_discount_info_arr = array_merge($time_discount_info_arr, $redis_str);
|
||||||
|
Redis::set('time_discount_info', json_encode($time_discount_info_arr));
|
||||||
|
}else {
|
||||||
|
Redis::set('time_discount_info', json_encode($redis_str));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$snd_data = [
|
||||||
|
'msg' => '折扣修改',
|
||||||
|
'operate_type' => $message['operate_type'],
|
||||||
|
'msg_id' => '',
|
||||||
|
'type' => 'time_discount',
|
||||||
|
'status' => $res,
|
||||||
|
'data' => json_decode($message, true),
|
||||||
|
];
|
||||||
|
Gateway::sendToClient($client_id, json_encode($snd_data));
|
||||||
|
return;
|
||||||
|
}elseif ($message['operate_type'] == 'time_discount_get') {
|
||||||
|
// 限时折扣获取
|
||||||
|
$snd_data = [
|
||||||
|
'msg' => '折扣获取',
|
||||||
|
'operate_type' => $message['operate_type'],
|
||||||
|
'msg_id' => '',
|
||||||
|
'type' => 'time_discount',
|
||||||
|
'status' => 1,
|
||||||
|
'data' => Redis::get($redis_str),
|
||||||
|
];
|
||||||
|
Gateway::sendToClient($client_id, json_encode($snd_data));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!empty($message['operate_type']) && $message['operate_type'] == 'time_discount_get') {
|
||||||
|
// 桌码
|
||||||
|
if(empty($message['table_code'])) {
|
||||||
|
Gateway::sendToClient($client_id, json_encode(['msg' => '桌码或data不能为空']));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 只在初始化的时候绑定
|
// 只在初始化的时候绑定
|
||||||
if(!empty($message['operate_type']) && $message['operate_type'] == 'init') {
|
if(!empty($message['operate_type']) && $message['operate_type'] == 'init') {
|
||||||
// 添加在线客户端数量
|
// 添加在线客户端数量
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue