再来一单
This commit is contained in:
@@ -24,37 +24,6 @@ class Business
|
|||||||
Redis::setEx($set_str, 30 * 86400, json_encode([$set_info_str]));
|
Redis::setEx($set_str, 30 * 86400, json_encode([$set_info_str]));
|
||||||
}
|
}
|
||||||
Redis::setEx($set_info_str, 30 * 86400, json_encode($data));
|
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'],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拉消息
|
// 拉消息
|
||||||
|
|||||||
@@ -55,24 +55,49 @@ class Shopping extends Base
|
|||||||
switch ($message['operate_type']) {
|
switch ($message['operate_type']) {
|
||||||
// 初始化购物车
|
// 初始化购物车
|
||||||
case 'init':
|
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();
|
$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("
|
$car = Db::query("
|
||||||
SELECT * FROM `tb_cashier_cart` WHERE
|
SELECT * FROM `tb_cashier_cart` WHERE
|
||||||
`shop_id`={$message['shop_id']} AND
|
`shop_id`={$message['shop_id']} AND
|
||||||
`table_code`='{$message['table_code']}'
|
`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 = [
|
$snd_data = [
|
||||||
'msg' => '购物车初始化',
|
'msg' => '购物车初始化',
|
||||||
'operate_type' => 'init',
|
'operate_type' => 'init',
|
||||||
|
|||||||
@@ -115,10 +115,10 @@ class Events
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 即时聊天 转发
|
// 即时聊天 转发
|
||||||
if(strstr($message['type'], 'Chat')) {
|
// if(strstr($message['type'], 'Chat')) {
|
||||||
(new \extend\chat\model\Base)->handles($client_id, $message);
|
// (new \extend\chat\model\Base)->handles($client_id, $message);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
$type = $message['type'];
|
$type = $message['type'];
|
||||||
if(!empty($message['is_temporary']) && (empty($message['product_name']))) {
|
if(!empty($message['is_temporary']) && (empty($message['product_name']))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user