Merge remote-tracking branch 'origin/master'

This commit is contained in:
2025-08-18 11:10:23 +08:00
3 changed files with 40 additions and 34 deletions

View File

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

View File

@@ -45,7 +45,7 @@ class CashController extends Frontend
public function withdraw() public function withdraw()
{ {
$amount = $this->request->get('amount'); $amount = $this->request->get('amount');
$isAlipay = $this->request->get('isAlipay/d'); $isAlipay = $this->request->get('isAlipay');
$userId = $this->getUserId(); $userId = $this->getUserId();
self::checkCanCash($userId); self::checkCanCash($userId);
$info = (new CommonInfo())->getByCode(930); $info = (new CommonInfo())->getByCode(930);

View File

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