再来一单

This commit is contained in:
2025-12-10 10:01:02 +08:00
parent b620cfdb84
commit 1fac7669ce
3 changed files with 41 additions and 47 deletions

View File

@@ -24,37 +24,6 @@ class Business
Redis::setEx($set_str, 30 * 86400, json_encode([$set_info_str]));
}
Redis::setEx($set_info_str, 30 * 86400, json_encode($data));
if($open_id) {
// 保存的同时发送模版消息通知用户有未读消息
$config = [
'app_id' => config('cons.app_id'),
'secret' => config('cons.secret'),
'response_type' => 'array',
];
$app = Factory::officialAccount($config);
$acc_token = Redis::get('wx:ac:AccessToken');
if($acc_token) {
$app['access_token']->setToken($acc_token);
}
$wechat_res = $app->template_message->send([
'touser' => $open_id,
'template_id' => 'hGsUGZlWqWC9TMm4ZGZuz0OwE4gwSmvgbr5ecmTDvq4',
'miniprogram' => [
'appid' => 'wxd88fffa983758a30', // 零点八零
'pagepath' => 'pages/index/index', // 零点八零
],
'data' => [
'thing7' => $record['shop_name'],
'thing14' => $record['activity_detail'],
'time3' => $record['activity_time'],
'thing16' => $record['address'],
],
]);
}
}
// 拉消息

View File

@@ -55,24 +55,49 @@ class Shopping extends Base
switch ($message['operate_type']) {
// 初始化购物车
case 'init':
// 商户ID 和桌码ID
$table_code = self::get_shopping_send_id($message);
// 绑定桌码和 client_id
Gateway::bindUid($client_id, $table_code);
$rand = 'shopping_init' . Random::build();
$time_dis_info = null;
if(!empty($message['one_more_order'])) {
// 再来一单
if(empty($message['order_id'])) {
Gateway::sendToClient($client_id, json_encode(['msg' => 'order_id 必传']));
return;
}
$order_arr = Db::name('tb_order_detail')->where(['order_id' => $message['order_id']])->select()->toArray();
foreach ($order_arr as $k => $order) {
self::add_data([
'shop_id' => $message['shop_id'],
'sku_id' => $order['sku_id'],
'product_id' => $order['product_id'],
'number' => $order['num'],
'table_code' => $message['table_code'],
'product_name' => $order['product_name'],
'sku_name' => $order['sku_name'],
'product_type' => $order['product_type'],
'is_print' => $order['is_print'],
'create_time' => d(),
]);
}
}else {
// 商户ID 和桌码ID
$table_code = self::get_shopping_send_id($message);
// 绑定桌码和 client_id
Gateway::bindUid($client_id, $table_code);
// 限时折扣
$redis_str = Base::get_shopping_save_uid($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);
}else {
$time_dis_info = null;
}
}
$car = Db::query("
SELECT * FROM `tb_cashier_cart` WHERE
`shop_id`={$message['shop_id']} AND
`table_code`='{$message['table_code']}'
");
// 限时折扣
$redis_str = Base::get_shopping_save_uid($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);
}else {
$time_dis_info = null;
}
$snd_data = [
'msg' => '购物车初始化',
'operate_type' => 'init',

View File

@@ -115,10 +115,10 @@ class Events
}
// 即时聊天 转发
if(strstr($message['type'], 'Chat')) {
(new \extend\chat\model\Base)->handles($client_id, $message);
return;
}
// if(strstr($message['type'], 'Chat')) {
// (new \extend\chat\model\Base)->handles($client_id, $message);
// return;
// }
$type = $message['type'];
if(!empty($message['is_temporary']) && (empty($message['product_name']))) {