Skip to content

Commit

Permalink
添加 error 日志,merit 强制转换整形
Browse files Browse the repository at this point in the history
  • Loading branch information
forecho committed Mar 25, 2016
1 parent f5f63b4 commit 46c86b0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion MeritBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ public function update(MeritTemplate $meritTemplate)
// is sub 判断是否是减法
$actionSub = ($meritTemplate->action_type == MeritTemplate::ACTIVE_TYPE_SUB);
if ($userMerit) {
$merit = call_user_func($actionSub ? 'bcsub' : 'bcadd', $userMerit->merit, $meritTemplate->increment);
$userMerit->setAttributes([
'merit' => call_user_func($actionSub ? 'bcsub' : 'bcadd', $userMerit->merit, $meritTemplate->increment)
'merit' => (integer)$merit
]);
} else {
$userMerit = new Merit();
Expand All @@ -126,6 +127,7 @@ public function update(MeritTemplate $meritTemplate)
]);
}
if (!$userMerit->save()) {
Yii::error('Merit 操作失败' . json_encode(array_values($userMerit->getFirstErrors())), 'error');
throw new Exception(array_values($userMerit->getFirstErrors())[0]);
}
$description = $meritTemplate->title . ': '
Expand Down

0 comments on commit 46c86b0

Please sign in to comment.