购物车reload标识

This commit is contained in:
张松
2025-11-28 15:20:30 +08:00
parent d52d96469a
commit 23c7ecd848
7 changed files with 34 additions and 8 deletions

View File

@@ -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']);