兼容修改

This commit is contained in:
张松
2025-08-18 11:01:59 +08:00
parent 1bd5802209
commit d3cea2a46f
2 changed files with 39 additions and 33 deletions

View File

@@ -5,10 +5,8 @@ namespace app\api\model;
use app\admin\model\User;
use app\common\library\DatabaseRoute;
use app\common\model\Common;
use ba\Random;
use think\facade\Cache;
use support\Log;
use think\facade\Db;
use think\facade\Log;
use think\Model;
class TaskCenterRecord extends Model

View File

@@ -6,12 +6,14 @@ use app\api\model\CommonInfo;
use app\api\model\DiscSpinningRecord;
use app\api\model\Orders;
use app\api\model\TbUser;
use app\api\model\TbUserBlacklist;
use app\common\controller\Frontend;
use app\common\library\DatabaseRoute;
use app\exception\CzgException;
use app\exception\SysException;
use app\queue\redis\DiscReceiveQueue;
use extend\ba\Random;
use think\db\exception\DuplicateException;
use think\facade\Db;
use support\Log;
class DiscSpinningController extends Frontend
@@ -39,42 +41,48 @@ class DiscSpinningController extends Frontend
$resp = [];
runWithLock("user:disc-spinning:limit:user:lock:".$this->getUserId(), 60, function () use ($params, $userId, &$resp, $userInfo) {
DatabaseRoute::transactionXa(function () use ($params, $userId, &$resp, $userInfo) {
// 查询抽奖次数
$count = DiscSpinningRecord::countDraw($userId);
// 免费两次之后校验实名
if ($count == 2 && !TbUser::checkEnable($userInfo)) {
$this->error('请实名认证后继续抽奖');
}
Log::info("用户id: $userId, 抽奖次数: $count");
// 订单抽奖
if (!isset($params['source']) || $params['source'] == 1) {
$drawCount = (new CommonInfo())->getByCodeToInt(901);
if ($count >= $drawCount) {
$this->error('当日可抽奖次数已超限');
try {
// 查询抽奖次数
$count = DiscSpinningRecord::countDraw($userId);
// 免费两次之后校验实名
if ($count == 2 && !TbUser::checkEnable($userInfo)) {
$this->error('请实名认证后继续抽奖');
}
// 校验订单笔数
$orders = Orders::selectOrdersByDay($userId);
if (!$orders) {
throw new SysException("无可用抽奖机会");
Log::info("用户id: $userId, 抽奖次数: $count");
// 订单抽奖
if (!isset($params['source']) || $params['source'] == 1) {
$drawCount = (new CommonInfo())->getByCodeToInt(901);
if ($count >= $drawCount) {
$this->error('当日可抽奖次数已超限');
}
// 校验订单笔数
$orders = Orders::selectOrdersByDay($userId);
if (!$orders) {
throw new SysException("无可用抽奖机会");
}
$params['sourceId'] = $orders['orders_id'];
}else{
$this->error("八嘎");
}
$params['sourceId'] = $orders['orders_id'];
}else{
$this->error("八嘎");
}
if (!isset($params['sourceId'])) {
throw new CzgException("异常请求");
}
if (!isset($params['sourceId'])) {
throw new CzgException("异常请求");
}
$draws = self::draws($count + 1, $orders['pay_money'], $params['sourceId'], $userId, $params['source']);
$resp = $draws;
$draws = self::draws($count + 1, $orders['pay_money'], $params['sourceId'], $userId, $params['source']);
$resp = $draws;
// $this->receive($draws);
pushQueue(DiscReceiveQueue::class, [
'draws' => $resp
]);
pushQueue(DiscReceiveQueue::class, [
'draws' => $resp
]);
}catch (DuplicateException $e) {
(new TbUserBlacklist())->addBlackUser($userId, "重复抽奖");
throw $e;
}
});
});