fail('参数错误'); $storeMinRecharge = sys_config('store_user_min_recharge'); if ($price < $storeMinRecharge) return app('json')->fail('充值金额不能低于' . $storeMinRecharge); switch ((int)$type) { case 0: //支付充值余额 $paid_price = 0; if ($recharId) { $data = SystemGroupData::getDateValue($recharId); if ($data === false) { return app('json')->fail('您选择的充值方式已下架!'); } else { $paid_price = $data['give_money'] ?? 0; } } $get_money_num = 0; if ($get_money_type != 'now_money') { $paid_price = 0; $flag = false; $money_type = sys_data('money_type'); $usdt_price = 0; foreach ($money_type as $v) { if ($v['code'] == $get_money_type) { if (!$v['charge']) return app('json')->fail('不可充值币种'); if ($v['usdt_price'] == 0) { $usdt_price = get_huobi_price($v['code']); } else { $usdt_price = $v['usdt_price']; } if ($v['code'] == 'LALA') { $usdt_price = get_lala_ratio(); } } $flag = true; } if (!$flag) { return app('json')->fail('您选择的充值币种不存在!'); } $rmb_price = bcmul($usdt_price, us_price(), 8); if ($rmb_price <= 0) return app('json')->fail('不可充值币种'); $get_money_num = bcdiv($price, $rmb_price, 8); } $rechargeOrder = UserRecharge::addRecharge($request->uid(), $price, 'weixin', $paid_price, 0, $get_money_type, $get_money_num); // $rechargeOrder = UserRecharge::addRecharge($request->uid(), $price, 'routine', $paid_price); if (!$rechargeOrder) return app('json')->fail('充值订单生成失败!'); try { return app('json')->successful(UserRecharge::jsPay($rechargeOrder)); } catch (\Exception $e) { return app('json')->fail($e->getMessage()); } break; case 1: //佣金转入余额 if (UserRecharge::importNowMoney($request->uid(), $price)) return app('json')->successful('转入余额成功'); else return app('json')->fail(UserRecharge::getErrorInfo()); break; default: return app('json')->fail('缺少参数'); break; } } /** * 支付宝充值 * * @param Request $request * @return mixed */ public function ali(Request $request) { list($price, $recharId, $type, $get_money_type) = UtilService::postMore([['price', 0], ['rechar_id', 0], ['type', 0], ['get_money_type', 'now_money']], $request, true); if (!$price || $price <= 0) return app('json')->fail('参数错误'); $storeMinRecharge = sys_config('store_user_min_recharge'); if ($price < $storeMinRecharge) return app('json')->fail('充值金额不能低于' . $storeMinRecharge); switch ((int)$type) { case 0: //支付充值余额 $paid_price = 0; if ($recharId) { $data = SystemGroupData::getDateValue($recharId); if ($data === false) { return app('json')->fail('您选择的充值方式已下架!'); } else { $paid_price = $data['give_money'] ?? 0; } } $get_money_num = 0; if ($get_money_type != 'now_money') { $paid_price = 0; $flag = false; $money_type = sys_data('money_type'); $usdt_price = 0; foreach ($money_type as $v) { if ($v['code'] == $get_money_type) { if (!$v['charge']) return app('json')->fail('不可充值币种'); if ($v['usdt_price'] == 0) { $usdt_price = get_huobi_price($v['code']); } else { $usdt_price = $v['usdt_price']; } if ($v['code'] == 'LALA') { $usdt_price = get_lala_ratio(); } } $flag = true; } if (!$flag) { return app('json')->fail('您选择的充值币种不存在!'); } $rmb_price = bcmul($usdt_price, us_price(), 8); if ($rmb_price <= 0) return app('json')->fail('不可充值币种'); $get_money_num = bcdiv($price, $rmb_price, 8); } $rechargeOrder = UserRecharge::addRecharge($request->uid(), $price, 'ali', $paid_price, 0, $get_money_type, $get_money_num); // $rechargeOrder = UserRecharge::addRecharge($request->uid(), $price, 'routine', $paid_price); if (!$rechargeOrder) return app('json')->fail('充值订单生成失败!'); try { return app('json')->successful(UserRecharge::aliPay($rechargeOrder)); } catch (\Exception $e) { return app('json')->fail($e->getMessage()); } break; case 1: //佣金转入余额 if (UserRecharge::importNowMoney($request->uid(), $price)) return app('json')->successful('转入余额成功'); else return app('json')->fail(UserRecharge::getErrorInfo()); break; default: return app('json')->fail('缺少参数'); break; } } /** * 支付宝充值 * * @param Request $request * @return mixed */ public function app(Request $request) { list($price, $recharId, $type, $get_money_type) = UtilService::postMore([['price', 0], ['rechar_id', 0], ['type', 0], ['get_money_type', 'now_money']], $request, true); if (!$price || $price <= 0) return app('json')->fail('参数错误'); $storeMinRecharge = sys_config('store_user_min_recharge'); if ($price < $storeMinRecharge) return app('json')->fail('充值金额不能低于' . $storeMinRecharge); switch ((int)$type) { case 0: //支付充值余额 $paid_price = 0; if ($recharId) { $data = SystemGroupData::getDateValue($recharId); if ($data === false) { return app('json')->fail('您选择的充值方式已下架!'); } else { $paid_price = $data['give_money'] ?? 0; } } $get_money_num = 0; if ($get_money_type != 'now_money') { $paid_price = 0; $flag = false; $money_type = sys_data('money_type'); $usdt_price = 0; foreach ($money_type as $v) { if ($v['code'] == $get_money_type) { if (!$v['charge']) return app('json')->fail('不可充值币种'); if ($v['usdt_price'] == 0) { $usdt_price = get_huobi_price($v['code']); } else { $usdt_price = $v['usdt_price']; } if ($v['code'] == 'LALA') { $usdt_price = get_lala_ratio(); } } $flag = true; } if (!$flag) { return app('json')->fail('您选择的充值币种不存在!'); } $rmb_price = bcmul($usdt_price, us_price(), 8); if ($rmb_price <= 0) return app('json')->fail('不可充值币种'); $get_money_num = bcdiv($price, $rmb_price, 8); } $rechargeOrder = UserRecharge::addRecharge($request->uid(), $price, 'app', $paid_price, 0, $get_money_type, $get_money_num); // $rechargeOrder = UserRecharge::addRecharge($request->uid(), $price, 'routine', $paid_price); if (!$rechargeOrder) return app('json')->fail('充值订单生成失败!'); try { return app('json')->successful(UserRecharge::appPay($rechargeOrder)); } catch (\Exception $e) { return app('json')->fail($e->getMessage()); } break; case 1: //佣金转入余额 if (UserRecharge::importNowMoney($request->uid(), $price)) return app('json')->successful('转入余额成功'); else return app('json')->fail(UserRecharge::getErrorInfo()); break; default: return app('json')->fail('缺少参数'); break; } } /** * 公众号充值 * * @param Request $request * @return mixed */ public function wechat(Request $request) { list($price, $recharId, $from, $type, $get_money_type) = UtilService::postMore([['price', 0], ['rechar_id', 0], ['from', 'weixin'], ['type', 0], ['get_money_type', 'now_money']], $request, true); if (!$price || $price <= 0) return app('json')->fail('参数错误'); $storeMinRecharge = sys_config('store_user_min_recharge'); if ($price < $storeMinRecharge) return app('json')->fail('充值金额不能低于' . $storeMinRecharge); switch ((int)$type) { case 0: //支付充值余额 $paid_price = 0; if ($recharId) { $data = SystemGroupData::getDateValue($recharId); if ($data === false) { return app('json')->fail('您选择的充值方式已下架!'); } else { $paid_price = $data['give_money'] ?? 0; } } $get_money_num = 0; if ($get_money_type != 'now_money') { $paid_price = 0; $flag = false; $money_type = sys_data('money_type'); $usdt_price = 0; foreach ($money_type as $v) { if ($v['code'] == $get_money_type) { if (!$v['charge']) return app('json')->fail('不可充值币种'); if ($v['usdt_price'] == 0) { $usdt_price = get_huobi_price($v['code']); } else { $usdt_price = $v['usdt_price']; } if ($v['code'] == 'LALA') { $usdt_price = get_lala_ratio(); } $flag = true; } } if (!$flag) { return app('json')->fail('您选择的充值币种不存在!'); } $rmb_price = bcmul($usdt_price, us_price(), 8); if ($rmb_price <= 0) return app('json')->fail('不可充值币种'); $get_money_num = bcdiv($price, $rmb_price, 2); } $rechargeOrder = UserRecharge::addRecharge($request->uid(), $price, 'weixin', $paid_price, 0, $get_money_type, $get_money_num); if (!$rechargeOrder) return app('json')->fail('充值订单生成失败!'); try { if ($from == 'weixinh5') { $recharge = UserRecharge::wxH5Pay($rechargeOrder); } else { $recharge = UserRecharge::wxPay($rechargeOrder); } } catch (\Exception $e) { return app('json')->fail($e->getMessage()); } return app('json')->successful(['type' => $from, 'data' => $recharge]); break; case 1: //佣金转入余额 if (UserRecharge::importNowMoney($request->uid(), $price)) return app('json')->successful('转入余额成功'); else return app('json')->fail(UserRecharge::getErrorInfo()); break; default: return app('json')->fail('缺少参数'); break; } } /** * 充值额度选择 * @return mixed */ public function index() { $rechargeQuota = sys_data('user_recharge_quota') ?? []; $data['recharge_quota'] = $rechargeQuota; $recharge_attention = sys_config('recharge_attention'); $recharge_attention = explode("\n", $recharge_attention); $data['recharge_attention'] = $recharge_attention; return app('json')->successful($data); } }