购物车reload标识
This commit is contained in:
@@ -25,7 +25,7 @@ class Base extends Model
|
||||
|
||||
|
||||
// 分组推送(广播)
|
||||
public static function gateway_query(string $method, array $params)
|
||||
public static function gateway_query(string $method, array $params, bool $by_shop_id = false)
|
||||
{
|
||||
list($clientIdOrUid, $data) = $params;
|
||||
$data_arr = json_decode($data, true);
|
||||
@@ -46,7 +46,7 @@ class Base extends Model
|
||||
}elseif (strstr($data_arr['operate_type'], 'del')) {
|
||||
$operate_type = 'del';
|
||||
}elseif (strstr($data_arr['operate_type'], 'cleanup')) {
|
||||
$operate_type = 'cleanup';
|
||||
$operate_type = ' ';
|
||||
}elseif (strstr($data_arr['operate_type'], 'clearOrder')) {
|
||||
$operate_type = 'clearOrder';
|
||||
}elseif (strstr($data_arr['operate_type'], 'batch')) {
|
||||
@@ -72,7 +72,29 @@ class Base extends Model
|
||||
];
|
||||
$new_clientid_group = '';
|
||||
|
||||
if(!empty(self::$shop_id) && !empty($broadcast_arr['data']['table_code'])) {
|
||||
if ($by_shop_id) {
|
||||
$shopGroup = self::get_shopping_save_uid(self::$shop_id, 'all');
|
||||
// 如果有在线的 再发
|
||||
if($onl = Gateway::getClientIdCountByGroup($shopGroup)){
|
||||
// 发送广播并将 self::$client_id 排除在外
|
||||
// 排除收银机重复的client_id
|
||||
$table_arr = [];
|
||||
if(!empty(self::$table_code) && !empty($data_arr['type']) && $data_arr['type'] == 'shopping') {
|
||||
// 是客户端小程序才排除同桌子的
|
||||
$table_arr = Gateway::getClientIdByUid(self::$table_code);
|
||||
}
|
||||
// 排除自己
|
||||
$new_client_id = array_merge($table_arr, [self::$client_id]);
|
||||
// 去重
|
||||
$new_client_id = array_unique($new_client_id);
|
||||
$broadcast_arr['no_client_id'] = $new_client_id;
|
||||
$broadcast_json = json_encode($broadcast_arr);
|
||||
Gateway::sendToGroup($shopGroup, $broadcast_json, $new_client_id);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(!$by_shop_id && !empty(self::$shop_id) && !empty($broadcast_arr['data']['table_code'])) {
|
||||
if($operate_type == 'init') {
|
||||
// 如果是转桌操作,发广播初始化购物车 转出桌和转入桌都需要发通知
|
||||
$new_clientid_group = self::get_shopping_save_uid(self::$shop_id, $broadcast_arr['data']['new_table_code']);
|
||||
|
||||
@@ -415,7 +415,7 @@ class Cashier extends Base
|
||||
'table_code' => $message['table_code'],
|
||||
]
|
||||
];
|
||||
self::gateway_query('sendToClient', [$client_id, json_encode($snd_data)]);
|
||||
self::gateway_query('sendToClient', [$client_id, json_encode($snd_data)], true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ class Manage extends Base
|
||||
'table_code' => $message['table_code'],
|
||||
]
|
||||
];
|
||||
self::gateway_query('sendToClient', [$client_id, json_encode($snd_data)]);
|
||||
self::gateway_query('sendToClient', [$client_id, json_encode($snd_data)], true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ class Onboc extends Base
|
||||
'table_code' => $message['table_code'],
|
||||
]
|
||||
];
|
||||
self::gateway_query('sendToClient', [$client_id, json_encode($snd_data)]);
|
||||
self::gateway_query('sendToClient', [$client_id, json_encode($snd_data)], true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ class Pad extends Base
|
||||
'table_code' => $message['table_code'],
|
||||
]
|
||||
];
|
||||
self::gateway_query('sendToClient', [$client_id, json_encode($snd_data)]);
|
||||
self::gateway_query('sendToClient', [$client_id, json_encode($snd_data)], true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ class Shopping extends Base
|
||||
'table_code' => $message['table_code'],
|
||||
]
|
||||
];
|
||||
self::gateway_query('sendToClient', [$client_id, json_encode($snd_data)]);
|
||||
self::gateway_query('sendToClient', [$client_id, json_encode($snd_data)], true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +189,7 @@ class Events
|
||||
if(!empty($message['table_code'])) {
|
||||
// 绑定shopid和table_code 便于推送多端购物车同步 和 锁单
|
||||
$group = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']);
|
||||
|
||||
if(!empty($_SESSION[$client_id])) {
|
||||
// 绑定之前,必须先删除此client_id下的其他分组
|
||||
Gateway::leaveGroup($client_id, $_SESSION[$client_id]);
|
||||
@@ -196,6 +197,9 @@ class Events
|
||||
Gateway::joinGroup($client_id, $group);
|
||||
$_SESSION[$client_id] = $group;
|
||||
}
|
||||
// 店铺组
|
||||
$shopGroup = Base::get_shopping_save_uid($message['shop_id'], 'all');
|
||||
Gateway::joinGroup($client_id, $shopGroup);
|
||||
// 绑定shopid推送商品更新信息
|
||||
Gateway::joinGroup($client_id, 'product_update' . $message['shop_id']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user