异步更新数据
This commit is contained in:
@@ -7,6 +7,7 @@ use think\Log;
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
use app\common\library\GiftQueue;
|
||||
|
||||
class GiveGift extends Model
|
||||
{
|
||||
@@ -1000,13 +1001,23 @@ class GiveGift extends Model
|
||||
'type' => $type,//1金币购买 2送背包礼物
|
||||
'createtime' => time(),
|
||||
];
|
||||
$res = Db::name('vs_give_gift')->insertGetId($data);
|
||||
if(!$res){
|
||||
return false;
|
||||
|
||||
GiftQueue::push($data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//送礼回调处理任务
|
||||
public function change_user_give_gift_log_callback($give_gift_id,$data)
|
||||
{
|
||||
$from_id = $data['from_id'];
|
||||
$uid = $data['user_id'];
|
||||
$to_id = $data['gift_user'];
|
||||
$gift_price = $data['total_price'];
|
||||
$gid = $data['gift_id'];
|
||||
//记录公会流水
|
||||
if($from_type==2 && $from_id > 0){
|
||||
model('api/Guild')->guild_flow($from_id,$gift_price,$res);
|
||||
if($from_id > 0){
|
||||
model('api/Guild')->guild_flow($from_id,$gift_price,$give_gift_id);
|
||||
}
|
||||
//查询是否第一次送礼
|
||||
$is_first_gift = db::name('vs_give_gift')->where(['user_id'=>$uid])->count();
|
||||
@@ -1069,8 +1080,6 @@ class GiveGift extends Model
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use think\Db;
|
||||
use think\Log;
|
||||
use app\common\model\GiveGiftBase;
|
||||
use think\cache\driver\Redis;
|
||||
use app\api\model\GiveGift;
|
||||
|
||||
class GiftQueue
|
||||
{
|
||||
@@ -92,6 +93,7 @@ class GiftQueue
|
||||
$failed = 0;
|
||||
|
||||
$model = new GiveGiftBase();
|
||||
$gift_model = new GiveGift();
|
||||
|
||||
Log::info("开始处理送礼队列,批量大小: {$batchSize}");
|
||||
|
||||
@@ -129,6 +131,7 @@ class GiftQueue
|
||||
|
||||
if ($result) {
|
||||
$success++;
|
||||
$gift_model->change_user_give_gift_log_callback($result, $giftData);
|
||||
Log::info("送礼记录处理成功: {$uuid}, ID: {$result}");
|
||||
} else {
|
||||
$failed++;
|
||||
|
||||
Reference in New Issue
Block a user