|
@@ -69,8 +69,29 @@ class ActivityUserService extends BaseService
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static function updateBettingAmount($memberId, $amount)
|
|
|
|
|
+ {
|
|
|
|
|
+ $activityUser = static::findOne([
|
|
|
|
|
+ 'member_id' => $memberId,
|
|
|
|
|
+ 'status' => static::$MODEL::STATUS_IN_PROGRESS
|
|
|
|
|
+ ]);
|
|
|
|
|
+ if ($activityUser) {
|
|
|
|
|
+ $activityUser->increment('effective_betting_amount', $amount);
|
|
|
|
|
+ if ($activityUser->effective_betting_amount >= $activityUser->betting_amount) {
|
|
|
|
|
+ $activityUser->status = static::$MODEL::STATUS_COMPLETE;
|
|
|
|
|
+ }
|
|
|
|
|
+ $activityUser->save();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static function finish($id)
|
|
|
|
|
+ {
|
|
|
|
|
+ $activityUser = static::findOne(['id' => $id]);
|
|
|
|
|
+ $activityUser->status = static::$MODEL::STATUS_COMPLETE;
|
|
|
|
|
+ $activityUser->save();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- public static function gift($id, $amount, $effectiveBettingAmount)
|
|
|
|
|
|
|
+ public static function gift($id, $amount, $bettingAmount)
|
|
|
{
|
|
{
|
|
|
$activityUser = static::findOne(['id' => $id]);
|
|
$activityUser = static::findOne(['id' => $id]);
|
|
|
if (!$activityUser) throw new Exception('活动不存在', HttpStatus::CUSTOM_ERROR);
|
|
if (!$activityUser) throw new Exception('活动不存在', HttpStatus::CUSTOM_ERROR);
|
|
@@ -78,12 +99,12 @@ class ActivityUserService extends BaseService
|
|
|
if ($activityUser->status == static::$MODEL::STATUS_COMPLETE) throw new Exception("充值失败:活动已完成", HttpStatus::CUSTOM_ERROR);
|
|
if ($activityUser->status == static::$MODEL::STATUS_COMPLETE) throw new Exception("充值失败:活动已完成", HttpStatus::CUSTOM_ERROR);
|
|
|
if ($activityUser->status != static::$MODEL::STATUS_APPLY) throw new Exception('充值失败:状态异常', HttpStatus::CUSTOM_ERROR);
|
|
if ($activityUser->status != static::$MODEL::STATUS_APPLY) throw new Exception('充值失败:状态异常', HttpStatus::CUSTOM_ERROR);
|
|
|
$activityUser->status = static::$MODEL::STATUS_IN_PROGRESS;
|
|
$activityUser->status = static::$MODEL::STATUS_IN_PROGRESS;
|
|
|
- $activityUser->effective_betting_amount = $effectiveBettingAmount;
|
|
|
|
|
|
|
+ $activityUser->betting_amount = $bettingAmount;
|
|
|
$activityUser->gift_amount = $amount;
|
|
$activityUser->gift_amount = $amount;
|
|
|
$activityUser->save();
|
|
$activityUser->save();
|
|
|
$memberId = $activityUser->member_id;
|
|
$memberId = $activityUser->member_id;
|
|
|
- $res = WalletService::updateBalance($memberId,$amount);
|
|
|
|
|
- BalanceLogService::addLog($memberId, $amount, $res['before_balance'], $res['after_balance'], "优惠活动", $activityUser->id, "$activityUser->title; 赠送:$activityUser->gift_amount; 打码量:$activityUser->effective_betting_amount");
|
|
|
|
|
|
|
+ $res = WalletService::updateBalance($memberId, $amount);
|
|
|
|
|
+ BalanceLogService::addLog($memberId, $amount, $res['before_balance'], $res['after_balance'], "优惠活动", $activityUser->id, "$activityUser->title; 赠送:$activityUser->gift_amount; 打码量:$activityUser->betting_amount");
|
|
|
|
|
|
|
|
$availableBalance = floatval($res['after_balance']);
|
|
$availableBalance = floatval($res['after_balance']);
|
|
|
// 去除多余0后,再用 sprintf 补足两位
|
|
// 去除多余0后,再用 sprintf 补足两位
|