$uid, 'category' => 'gold_num', 'type' => $type, 'pm' => $pm, 'status' => 1]) ->where('number', '>', 0)->sum('number'); if ($n) { $refund_sum = UserBill::where(['uid' => $uid, 'category' => 'gold_num', 'type' => 'return', 'pm' => 0, 'status' => 1]) ->where('number', '>', 0)->sum('number'); } else { $refund_sum = 0; } return bcsub($sum, $refund_sum, 2); } public static function getUserGoldConsumption($uid) { $sum = UserBill::where(['uid' => $uid, 'category' => 'gold_num', 'pm' => 0, 'status' => 1]) ->where('number', '>', 0)->where('type','in','deduction,return,live_reward')->sum('number'); return $sum; } public static function getUserbalance($uid, $pm) { $sum = UserBill::where(['uid' => $uid, 'category' => 'now_money', 'pm' => $pm, 'status' => 1]) ->where('number', '>', 0)->sum('number'); return bcsub($sum, 0, 2); } }