折扣
This commit is contained in:
@@ -117,6 +117,62 @@ class Events
|
||||
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') {
|
||||
// 添加在线客户端数量
|
||||
|
||||
Reference in New Issue
Block a user