hasOne(Account::class, 'id', 'account_id'); } /** * 转换佣金和金额 * @param $num int 金额或者佣金 单位为分 * @param $type string commission/money 需要获得的金额或者佣金 单位分 * * @throws RepositoryException */ public static function convertCommissionOrMoney(int $num, string $type) { \think\facade\Config::load('extra/commission_withdrawal', 'commission_withdrawal'); $config = config('commission_withdrawal')['withdrawal_proportion'] ?? []; if (!$config) { throw new RepositoryException("提现比例未配置,请先联系平台"); } if ($config["commission"] <= 0 || $config["money"] <= 0) { throw new RepositoryException("提现失败,系统错误"); } //如果想得到佣金 或者 金额 单位分 if ($type == AccountDataLog::TYPE_COMMISSION) { $total = Math::fen2Yuan($num) * ($config["commission"]) / ($config["money"]); } else { $total = $num * ($config["money"]) / ($config["commission"]); } return ceil($total); } }