getMessage()); return false; } DB::commit(); return $BookGifts; } public static function getSendRecords($bid) { return BookGiftsSend::getSendRecords($bid); } public static function getSendRecordsV2($bid) { return BookGiftsSend::getSendRecordsV2($bid); } public static function getConsumeSendRecords($uid) { return BookGiftsSend::getConsumeSendRecords($uid); } protected static function payCoin($fee,$uid) { //DB::beginTransaction(); $res = $result1 = $result2 = null; $user = UserService::getById($uid); if($user->balance < $fee){ return false; } $decrease_recharge = 0; $decrease_reward =0; if ($user->charge_balance >= $fee) { $data['charge_balance'] = $fee; $charge_fee = $fee; $data['reward_balance'] = 0; $result1 = $user->decrement('balance', $fee); $result2 = $user->decrement('charge_balance', $fee); $decrease_recharge = $fee; } elseif ($user->charge_balance > 0) { $data['charge_balance'] = $user->charge_balance; $charge_fee = $user->charge_balance; $reword_fee = $data['reward_balance'] = $fee - $user->charge_balance; $result1 = $user->decrement('balance', $fee); $result2 = $user->decrement('charge_balance', $charge_fee); $result3 = $user->decrement('reward_balance', $reword_fee); $decrease_recharge = $charge_fee; $decrease_reward =$reword_fee; } else { $data['charge_balance'] = 0; $reword_fee = $data['reward_balance'] = $fee; $result1 = $user->decrement('balance', $fee); $result2 = $user->decrement('reward_balance', $reword_fee); $decrease_reward =$reword_fee; } if ($result2 && $result1) { //DB::commit(); return compact('decrease_recharge','decrease_reward','fee'); //return true; } //DB::rollback(); return false; } public static function getGiftsSendStatisticByBook($start,$end){ return BookGiftsSend::getGiftsSendStatisticByBook($start,$end); } public static function getGiftsSendStatisticByGift($start,$end){ return BookGiftsSend::getGiftsSendStatisticByGift($start,$end); } public static function getGiftsSendDaillyStatsByBook($start='',$end='') { return BookGiftsStatsByBook::getStats($start,$end); } public static function getGiftsSendDaillyStatsByGift() { return BookGiftsStatsByGift::getStats(); } }