[色子游戏]玩家购买抽奖记录-优化样式
This commit is contained in:
@@ -24,4 +24,29 @@ class DicePlayerCoinRecordLogic extends BaseLogic
|
||||
$this->model = new DicePlayerCoinRecord();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加前:总抽奖次数 = 购买抽奖次数 + 赠送抽奖次数
|
||||
*/
|
||||
public function add(array $data): mixed
|
||||
{
|
||||
$data = $this->fillTotalDrawCount($data);
|
||||
return parent::add($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改前:总抽奖次数 = 购买抽奖次数 + 赠送抽奖次数
|
||||
*/
|
||||
public function edit($id, array $data): mixed
|
||||
{
|
||||
$data = $this->fillTotalDrawCount($data);
|
||||
return parent::edit($id, $data);
|
||||
}
|
||||
|
||||
private function fillTotalDrawCount(array $data): array
|
||||
{
|
||||
$paid = isset($data['paid_draw_count']) ? (int) $data['paid_draw_count'] : 0;
|
||||
$free = isset($data['free_draw_count']) ? (int) $data['free_draw_count'] : 0;
|
||||
$data['total_draw_count'] = $paid + $free;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user