限时折扣相关
This commit is contained in:
@@ -256,24 +256,17 @@ class Base
|
||||
// 添加redis 新
|
||||
public static function setredis_new(string $data, string $client_id)
|
||||
{
|
||||
// print_r('redis保存client_id---->' . $client_id . "\r\n");
|
||||
// print_r('redis保存值---->' . $data . "\r\n");
|
||||
// print_r('redis保存时间---->' . self::REDIS_TIME . "\r\n");
|
||||
$res = Redis::setex($client_id, self::REDIS_TIME, $data);
|
||||
// print_r('redis保存结果---->' . $res . "\r\n");
|
||||
Redis::setex('client_id:' . $client_id, self::REDIS_TIME, $data);
|
||||
}
|
||||
|
||||
// 消息回执
|
||||
public static function delredis_new(string $client_id, string $msg_id)
|
||||
{
|
||||
// 处理普通消息
|
||||
Redis::del($client_id);
|
||||
// print_r('回执---》' . $msg_id . date('Y-m-d H:i:s') . "\r\n");
|
||||
Redis::del('client_id:' . $client_id);
|
||||
// 如果是订单打印回执,直接删除
|
||||
if(strstr($msg_id, 'cashier_order')) {
|
||||
// print_r('打印回执---》' . $msg_id . date('Y-m-d H:i:s') . "\r\n");
|
||||
$uid = Gateway::getUidByClientId($client_id);
|
||||
// print_r('UID---》' . $uid . date('Y-m-d H:i:s') . "\r\n");
|
||||
Redis::del($uid);
|
||||
}
|
||||
}
|
||||
@@ -282,7 +275,6 @@ class Base
|
||||
// 定时器处理消息回执/在线列表/折扣信息
|
||||
public static function geteventredis_new()
|
||||
{
|
||||
// print_r('定时器' . "\r\n");
|
||||
$gateway = Gateway::class;
|
||||
// 处理折扣消息
|
||||
// self::savetimediscount();
|
||||
@@ -290,7 +282,7 @@ class Base
|
||||
$redis_name = Gateway::getAllClientSessions();
|
||||
foreach ($redis_name as $client_id => $client_id_data) {
|
||||
if(Gateway::isOnline($client_id)) {
|
||||
$result = Redis::get($client_id);
|
||||
$result = Redis::get('client_id:' . $client_id);
|
||||
// 处理普通消息
|
||||
if($result) {
|
||||
$msg_info_arr = json_decode($result, true);
|
||||
@@ -312,7 +304,7 @@ class Base
|
||||
// print_r('推送了-----' . "\r\n");
|
||||
// 推送以后新增推送次数
|
||||
$msg_info_arr['send_num'] += 1;
|
||||
Redis::setex($client_id, self::REDIS_TIME, json_encode($msg_info_arr), );
|
||||
Redis::setex('client_id:' . $client_id, self::REDIS_TIME, json_encode($msg_info_arr), );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -548,6 +540,15 @@ class Base
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function get_shopping_time_str($shop_id, $table_code)
|
||||
{
|
||||
return 'cart_update:' . $shop_id . ':' . $table_code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 购物车 多端同步 UID
|
||||
public static function get_shopping_save_uid($shop_id, $table_code)
|
||||
{
|
||||
@@ -925,7 +926,7 @@ class Base
|
||||
// 获取限时折扣
|
||||
public function getTimeInfo($message)
|
||||
{
|
||||
$redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
$redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
$time_dis_info = Redis::get($redis_str);
|
||||
if($time_dis_info) {
|
||||
$time_dis_info = json_decode($time_dis_info, true);
|
||||
@@ -942,7 +943,7 @@ class Base
|
||||
// 限时折扣修改
|
||||
public function setTimeInfo($message)
|
||||
{
|
||||
$redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
$redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
if(empty($message['data'])) {
|
||||
$res = Redis::del($redis_str);
|
||||
}else {
|
||||
@@ -966,7 +967,7 @@ class Base
|
||||
// 限时折扣删除
|
||||
public function delTimeInfo($message)
|
||||
{
|
||||
$redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
$redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
Redis::del($redis_str);
|
||||
$time_discount_info = Redis::get('time_discount:info');
|
||||
if($time_discount_info) {
|
||||
|
||||
@@ -55,7 +55,7 @@ class Cashier extends Base
|
||||
");
|
||||
}
|
||||
// 限时折扣
|
||||
$redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
$redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
$time_dis_info = Redis::get($redis_str);
|
||||
if($time_dis_info) {
|
||||
$time_dis_info = json_decode($time_dis_info, true);
|
||||
|
||||
@@ -44,7 +44,7 @@ class Manage extends Base
|
||||
");
|
||||
}
|
||||
// 限时折扣
|
||||
$redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
$redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
$time_dis_info = Redis::get($redis_str);
|
||||
if($time_dis_info) {
|
||||
$time_dis_info = json_decode($time_dis_info, true);
|
||||
|
||||
@@ -45,7 +45,7 @@ class Onboc extends Base
|
||||
");
|
||||
}
|
||||
// 限时折扣
|
||||
$redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
$redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
$time_dis_info = Redis::get($redis_str);
|
||||
if($time_dis_info) {
|
||||
$time_dis_info = json_decode($time_dis_info, true);
|
||||
|
||||
@@ -49,7 +49,7 @@ class Pad extends Base
|
||||
");
|
||||
}
|
||||
// 限时折扣
|
||||
$redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
$redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
$time_dis_info = Redis::get($redis_str);
|
||||
if($time_dis_info) {
|
||||
$time_dis_info = json_decode($time_dis_info, true);
|
||||
|
||||
@@ -170,7 +170,7 @@ class Events
|
||||
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';
|
||||
$redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount';
|
||||
// 限时折扣获取
|
||||
$snd_data = [
|
||||
'msg' => '折扣获取',
|
||||
|
||||
Reference in New Issue
Block a user