This commit is contained in:
ASUS 2025-11-05 14:17:47 +08:00
parent 1b8274d084
commit 1555d77ae9
3 changed files with 5 additions and 14 deletions

View File

@ -16,12 +16,10 @@ use think\Model;
class Base extends Model
{
public static $db = null;
public static $client_id;
public static $shop_id;
public static $account;
public static $table_code;
public static $lock_name; // 锁单值
const RETRYCOUNT = 3;
const REDIS_TIME = 60 * 10; // redis 保存时间 10分钟
@ -423,7 +421,6 @@ class Base extends Model
});
// 收银机打印回执
if(strstr($msg_id,'cashier_order') && $error) {
$db = self::$db;
$redis->get($msg_id, function ($result) use ($redis_name, $msg_id, $error, $db){
$result = json_decode($result, true);
$serviceLog = [
@ -435,7 +432,7 @@ class Base extends Model
'fail_time' => date('Y-m-d H:i:s'),
'err_info' => $error,
];
$db->insert('mq_log')->cols($serviceLog)->query();
Db::name('mq_log')->insert($serviceLog);
});
}
$redis->del($msg_id);

View File

@ -24,7 +24,6 @@ class Shopping extends Base
{
self::$client_id = $client_id;
self::$shop_id = $message['shop_id'];
$db = self::$db;
// 验证 shop_id 和 table_code 是否存在
$shop = Db::query("
SELECT * FROM `tb_shop_info` WHERE

View File

@ -5,23 +5,18 @@ namespace plugin\webman\gateway;
use ba\Random;
use extend\workermans\model\Base;
use GatewayWorker\Lib\Gateway;
use support\Log;
use support\Redis;
use Workerman\Connection\TcpConnection;
use Workerman\Protocols\Http\Request;
use Workerman\Timer;
use Workerman\Worker;
use extend\workermans\model\Cashier;
use extend\workermans\model\Manage;
use extend\workermans\model\Onboc;
use extend\workermans\model\Pad;
use extend\workermans\model\RedisInit;
use extend\workermans\model\Shopping;
use support\think\Db;
class Events
{
public static $redis = null;
public static $db = null;
public static function onWorkerStart($worker)
{
// $url = 'http://127.0.0.1:8686/?method=sendToUid&account=101&params={"data_type":"order","order_id":"2541"}';
@ -254,7 +249,7 @@ class Events
$data = [];
// 如果是编辑,拿到已有数量
if($message['operate_type'] == 'edit' && !empty($message['id'])) {
$data = Base::$db->query("
$data = Db::query("
SELECT * FROM `tb_cashier_cart` WHERE
`id`={$message['id']}");
if($data) {
@ -266,7 +261,7 @@ class Events
}
}
$d_data = false;
$product = Base::$db->query("
$product = Db::query("
SELECT * FROM `tb_product` WHERE
`id`={$message['product_id']}");
// 如果是套餐商品, 拿到商品总数量
@ -290,7 +285,7 @@ class Events
}
}
if($d_data) {
$data_number = Base::$db->query("
$data_number = Db::query("
SELECT SUM(number) number FROM `tb_cashier_cart` WHERE
`shop_id`={$message['shop_id']} AND
`product_id`={$message['product_id']} AND