update: more

This commit is contained in:
tokumeikoi 2021-12-28 01:49:33 +08:00
parent 6718a61890
commit 6ed9cc559e
16 changed files with 93 additions and 86 deletions

View File

@ -4,8 +4,10 @@ namespace App\Console\Commands;
use App\Models\Order;
use App\Models\User;
use App\Utils\CacheKey;
use App\Utils\Helper;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Matriphe\Larinfo;
class Test extends Command

View File

@ -146,11 +146,11 @@ class OrderController extends Controller
$orderService = new OrderService($order);
$order->user_id = $user->id;
$order->plan_id = $plan->id;
$order->cycle = $request->input('cycle');
$order->period = $request->input('period');
$order->trade_no = Helper::guid();
$order->total_amount = $request->input('total_amount');
if ($order->cycle === 'reset_price') {
if ($order->period === 'reset_price') {
$order->type = 4;
} else if ($user->plan_id !== NULL && $order->plan_id !== $user->plan_id) {
$order->type = 3;

View File

@ -22,6 +22,7 @@ class ManageController extends Controller
public function sort(Request $request)
{
ini_set('post_max_size', '1m');
DB::beginTransaction();
foreach ($request->input('sorts') as $k => $v) {
switch ($v['key']) {

View File

@ -79,20 +79,20 @@ class OrderController extends Controller
}
if ((!$plan->show && !$plan->renew) || (!$plan->show && $user->plan_id !== $plan->id)) {
if ($request->input('cycle') !== 'reset_price') {
if ($request->input('period') !== 'reset_price') {
abort(500, __('This subscription has been sold out, please choose another subscription'));
}
}
if (!$plan->renew && $user->plan_id == $plan->id && $request->input('cycle') !== 'reset_price') {
if (!$plan->renew && $user->plan_id == $plan->id && $request->input('period') !== 'reset_price') {
abort(500, __('This subscription cannot be renewed, please change to another subscription'));
}
if ($plan[$request->input('cycle')] === NULL) {
abort(500, __('This payment cycle cannot be purchased, please choose another cycle'));
if ($plan[$request->input('period')] === NULL) {
abort(500, __('This payment period cannot be purchased, please choose another period'));
}
if ($request->input('cycle') === 'reset_price') {
if ($request->input('period') === 'reset_price') {
if ($user->expired_at <= time() || !$user->plan_id) {
abort(500, __('Subscription has expired or no active subscription, unable to purchase Data Reset Package'));
}
@ -107,9 +107,9 @@ class OrderController extends Controller
$orderService = new OrderService($order);
$order->user_id = $request->session()->get('id');
$order->plan_id = $plan->id;
$order->cycle = $request->input('cycle');
$order->period = $request->input('period');
$order->trade_no = Helper::generateOrderNo();
$order->total_amount = $plan[$request->input('cycle')];
$order->total_amount = $plan[$request->input('period')];
if ($request->input('coupon_code')) {
$couponService = new CouponService($request->input('coupon_code'));

View File

@ -17,7 +17,7 @@ class OrderAssign extends FormRequest
'plan_id' => 'required',
'email' => 'required',
'total_amount' => 'required',
'cycle' => 'required|in:month_price,quarter_price,half_year_price,year_price,two_year_price,three_year_price,onetime_price,reset_price'
'period' => 'required|in:month_price,quarter_price,half_year_price,year_price,two_year_price,three_year_price,onetime_price,reset_price'
];
}
@ -27,8 +27,8 @@ class OrderAssign extends FormRequest
'plan_id.required' => '订阅不能为空',
'email.required' => '邮箱不能为空',
'total_amount.required' => '支付金额不能为空',
'cycle.required' => '订阅周期不能为空',
'cycle.in' => '订阅周期格式有误'
'period.required' => '订阅周期不能为空',
'period.in' => '订阅周期格式有误'
];
}
}

View File

@ -15,7 +15,7 @@ class OrderSave extends FormRequest
{
return [
'plan_id' => 'required',
'cycle' => 'required|in:month_price,quarter_price,half_year_price,year_price,two_year_price,three_year_price,onetime_price,reset_price'
'period' => 'required|in:month_price,quarter_price,half_year_price,year_price,two_year_price,three_year_price,onetime_price,reset_price'
];
}
@ -23,8 +23,8 @@ class OrderSave extends FormRequest
{
return [
'plan_id.required' => __('Plan ID cannot be empty'),
'cycle.required' => __('Plan cycle cannot be empty'),
'cycle.in' => __('Wrong plan cycle')
'period.required' => __('Plan period cannot be empty'),
'period.in' => __('Wrong plan period')
];
}
}

View File

@ -46,7 +46,7 @@ class OrderService
abort(500, '开通失败');
}
}
switch ((string)$order->cycle) {
switch ((string)$order->period) {
case 'onetime_price':
$this->buyByOneTime($plan);
break;
@ -54,7 +54,7 @@ class OrderService
$this->buyByResetTraffic();
break;
default:
$this->buyByCycle($order, $plan);
$this->buyByPeriod($order, $plan);
}
switch ((int)$order->type) {
@ -86,7 +86,7 @@ class OrderService
public function setOrderType(User $user)
{
$order = $this->order;
if ($order->cycle === 'reset_price') {
if ($order->period === 'reset_price') {
$order->type = 4;
} else if ($user->plan_id !== NULL && $order->plan_id !== $user->plan_id && ($user->expired_at > time() || $user->expired_at === NULL)) {
if (!(int)config('v2board.plan_change_enable', 1)) abort(500, '目前不允许更改订阅,请联系客服或提交工单操作');
@ -156,7 +156,7 @@ class OrderService
if ($user->expired_at === NULL) {
$this->getSurplusValueByOneTime($user, $order);
} else {
$this->getSurplusValueByCycle($user, $order);
$this->getSurplusValueByPeriod($user, $order);
}
}
@ -170,23 +170,23 @@ class OrderService
}
$notUsedTraffic = $plan->transfer_enable - (($user->u + $user->d) / 1073741824);
$result = $trafficUnitPrice * $notUsedTraffic;
$orderModel = Order::where('user_id', $user->id)->where('cycle', '!=', 'reset_price')->where('status', 3);
$orderModel = Order::where('user_id', $user->id)->where('period', '!=', 'reset_price')->where('status', 3);
$order->surplus_amount = $result > 0 ? $result : 0;
$order->surplus_order_ids = array_column($orderModel->get()->toArray(), 'id');
}
private function orderIsUsed(Order $order):bool
{
$month = self::STR_TO_TIME[$order->cycle];
$month = self::STR_TO_TIME[$order->period];
$orderExpireDay = strtotime('+' . $month . ' month', $order->created_at);
if ($orderExpireDay < time()) return true;
return false;
}
private function getSurplusValueByCycle(User $user, Order $order)
private function getSurplusValueByPeriod(User $user, Order $order)
{
$orderModel = Order::where('user_id', $user->id)
->where('cycle', '!=', 'reset_price')
->where('period', '!=', 'reset_price')
->where('status', 3);
$orders = $orderModel->get();
$orderSurplusMonth = 0;
@ -194,9 +194,9 @@ class OrderService
$userSurplusMonth = ($user->expired_at - time()) / 2678400;
foreach ($orders as $k => $item) {
// 兼容历史余留问题
if ($item->cycle === 'onetime_price') continue;
if ($item->period === 'onetime_price') continue;
if ($this->orderIsUsed($item)) continue;
$orderSurplusMonth = $orderSurplusMonth + self::STR_TO_TIME[$item->cycle];
$orderSurplusMonth = $orderSurplusMonth + self::STR_TO_TIME[$item->period];
$orderSurplusAmount = $orderSurplusAmount + ($item['total_amount'] + $item['balance_amount'] + $item['surplus_amount'] - $item['refund_amount']);
}
if (!$orderSurplusMonth || !$orderSurplusAmount) return;
@ -252,7 +252,7 @@ class OrderService
$this->user->d = 0;
}
private function buyByCycle(Order $order, Plan $plan)
private function buyByPeriod(Order $order, Plan $plan)
{
// change plan process
if ((int)$order->type === 3) {
@ -265,7 +265,7 @@ class OrderService
if ($order->type === 1) $this->buyByResetTraffic();
$this->user->plan_id = $plan->id;
$this->user->group_id = $plan->group_id;
$this->user->expired_at = $this->getTime($order->cycle, $this->user->expired_at);
$this->user->expired_at = $this->getTime($order->period, $this->user->expired_at);
}
private function buyByOneTime(Plan $plan)

View File

@ -1,4 +1,4 @@
-- Adminer 4.8.0 MySQL 5.7.29 dump
-- Adminer 4.8.1 MySQL 5.7.29 dump
SET NAMES utf8;
SET time_zone = '+00:00';
@ -43,6 +43,7 @@ CREATE TABLE `v2_coupon` (
`limit_use` int(11) DEFAULT NULL,
`limit_use_with_user` int(11) DEFAULT NULL,
`limit_plan_ids` varchar(255) DEFAULT NULL,
`limit_period` varchar(255) DEFAULT NULL,
`started_at` int(11) NOT NULL,
`ended_at` int(11) NOT NULL,
`created_at` int(11) NOT NULL,
@ -113,7 +114,7 @@ CREATE TABLE `v2_order` (
`coupon_id` int(11) DEFAULT NULL,
`payment_id` int(11) DEFAULT NULL,
`type` int(11) NOT NULL COMMENT '1新购2续费3升级',
`cycle` varchar(255) NOT NULL,
`period` varchar(255) NOT NULL,
`trade_no` varchar(36) NOT NULL,
`callback_no` varchar(255) DEFAULT NULL,
`total_amount` int(11) NOT NULL,
@ -369,4 +370,4 @@ CREATE TABLE `v2_user` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 2021-12-13 06:14:37
-- 2021-12-27 17:37:09

View File

@ -465,3 +465,6 @@ ALTER TABLE `v2_user`
ALTER TABLE `v2_payment`
ADD `icon` varchar(255) COLLATE 'utf8mb4_general_ci' NULL AFTER `name`;
ALTER TABLE `v2_coupon`
ADD `limit_period` varchar(255) COLLATE 'utf8_general_ci' NULL AFTER `limit_plan_ids`;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,15 +1,15 @@
window.settings.locales = {
'en-US': {
'request.error': 'Request failed',
// cycle_text
'cycle.month_price': 'Monthly',
'cycle.quarter_price': 'Quarterly',
'cycle.half_year_price': 'Semi-Annually',
'cycle.year_price': 'Annually',
'cycle.two_year_price': 'Biennially',
'cycle.three_year_price': 'Triennially',
'cycle.onetime_price': 'One Time',
'cycle.reset_price': 'Data Reset Package',
// period_text
'period.month_price': 'Monthly',
'period.quarter_price': 'Quarterly',
'period.half_year_price': 'Semi-Annually',
'period.year_price': 'Annually',
'period.two_year_price': 'Biennially',
'period.three_year_price': 'Triennially',
'period.onetime_price': 'One Time',
'period.reset_price': 'Data Reset Package',
// order_status
'order_status.no_paid': 'Pending Payment',
'order_status.opening': 'Pending Active',
@ -86,7 +86,7 @@ window.settings.locales = {
'login.forget_password': 'Forgot password',
// order
'order.table_no': 'Order Number #',
'order.table_cycle': 'Type / Cycle',
'order.table_period': 'Type / period',
'order.table_amount': 'Order Amount',
'order.table_status': 'Order Status',
'order.table_create_time': 'Creation Time',
@ -98,7 +98,7 @@ window.settings.locales = {
'order.please_check_credit_card': 'Please check credit card payment information',
'order.order_detail': 'Order Details',
'order.product': 'Product',
'order.type_cycle': 'Type / Cycle',
'order.type_period': 'Type / period',
'order.amount': 'Amount',
'order.traffic': 'Transfer Data',
'order.discount': 'Discount',
@ -123,7 +123,7 @@ window.settings.locales = {
'plan.buy': 'Subscribe now',
'plan.setting_subscribe': 'Configure Subscription',
'plan.discount': 'Discount',
'plan.cycle': 'Payment Cycle',
'plan.period': 'Payment period',
'plan.have_coupon': 'Have coupons?',
'plan.coupon_verify': 'Verify',
'plan.order_total_amount': 'Order Total',
@ -284,15 +284,15 @@ window.settings.locales = {
},
'zh-CN': {
'request.error': '请求失败',
// cycle_text
'cycle.month_price': '月付',
'cycle.quarter_price': '季付',
'cycle.half_year_price': '半年付',
'cycle.year_price': '年付',
'cycle.two_year_price': '两年付',
'cycle.three_year_price': '三年付',
'cycle.onetime_price': '一次性',
'cycle.reset_price': '重置流量包',
// period_text
'period.month_price': '月付',
'period.quarter_price': '季付',
'period.half_year_price': '半年付',
'period.year_price': '年付',
'period.two_year_price': '两年付',
'period.three_year_price': '三年付',
'period.onetime_price': '一次性',
'period.reset_price': '重置流量包',
// order_status
'order_status.no_paid': '待支付',
'order_status.opening': '开通中',
@ -369,7 +369,7 @@ window.settings.locales = {
'login.forget_password': '忘记密码',
// order
'order.table_no': '# 订单号',
'order.table_cycle': '周期',
'order.table_period': '周期',
'order.table_amount': '订单金额',
'order.table_status': '订单状态',
'order.table_create_time': '创建时间',
@ -381,7 +381,7 @@ window.settings.locales = {
'order.please_check_credit_card': '请检查信用卡支付信息',
'order.order_detail': '订单详情',
'order.product': '产品',
'order.type_cycle': '类型/周期',
'order.type_period': '类型/周期',
'order.amount': '金额',
'order.traffic': '流量',
'order.discount': '折扣',
@ -407,7 +407,7 @@ window.settings.locales = {
'plan.buy': '立即订阅',
'plan.setting_subscribe': '配置订阅',
'plan.discount': '折扣',
'plan.cycle': '付款周期',
'plan.period': '付款周期',
'plan.have_coupon': '有优惠券?',
'plan.coupon_verify': '验证',
'plan.order_total_amount': '订单总额',
@ -599,15 +599,15 @@ window.settings.locales = {
},
'ja-JP': {
'request.error': 'リクエストエラー',
// cycle_text
'cycle.month_price': '月払い',
'cycle.quarter_price': '四半期払い',
'cycle.half_year_price': '半年払い',
'cycle.year_price': '年払い',
'cycle.two_year_price': '2年払い',
'cycle.three_year_price': '3年払い',
'cycle.onetime_price': '一括払い',
'cycle.reset_price': 'データ通信量のカウントをリセット',
// period_text
'period.month_price': '月払い',
'period.quarter_price': '四半期払い',
'period.half_year_price': '半年払い',
'period.year_price': '年払い',
'period.two_year_price': '2年払い',
'period.three_year_price': '3年払い',
'period.onetime_price': '一括払い',
'period.reset_price': 'データ通信量のカウントをリセット',
// order_status
'order_status.no_paid': 'お支払い待ち',
'order_status.opening': '処理中',
@ -684,7 +684,7 @@ window.settings.locales = {
'login.forget_password': 'パスワードをお忘れの方は[こちら]',
// order
'order.table_no': '# オーダー番号',
'order.table_cycle': 'タイプ/お支払い周期',
'order.table_period': 'タイプ/お支払い周期',
'order.table_amount': 'ご注文の金額',
'order.table_status': 'ステータス',
'order.table_create_time': '作成日付',
@ -696,7 +696,7 @@ window.settings.locales = {
'order.please_check_credit_card': 'クレジットカードのお支払い情報をご確認ください',
'order.order_detail': '最終明細のご確認',
'order.product': 'お選びの定期購入',
'order.type_cycle': 'タイプ/お支払い周期',
'order.type_period': 'タイプ/お支払い周期',
'order.amount': '金額',
'order.traffic': 'データ通信量',
'order.discount': '割引き',
@ -721,7 +721,7 @@ window.settings.locales = {
'plan.buy': '今すぐ購入',
'plan.setting_subscribe': '定期購入の設定',
'plan.discount': '割引き',
'plan.cycle': 'お支払い周期',
'plan.period': 'お支払い周期',
'plan.have_coupon': 'キャンペーンコード',
'plan.coupon_verify': '確定',
'plan.order_total_amount': 'ご注文の合計金額',
@ -912,15 +912,15 @@ window.settings.locales = {
},
'vi-VN': {
'request.error': 'Yêu Cầu Thất Bại',
// cycle_text
'cycle.month_price': 'Tháng',
'cycle.quarter_price': 'Hàng quý',
'cycle.half_year_price': 'Nửa năm',
'cycle.year_price': 'Năm',
'cycle.two_year_price': 'Hai năm',
'cycle.three_year_price': 'Ba năm',
'cycle.onetime_price': 'Dài hạn',
'cycle.reset_price': 'Cập nhật dung lượng',
// period_text
'period.month_price': 'Tháng',
'period.quarter_price': 'Hàng quý',
'period.half_year_price': 'Nửa năm',
'period.year_price': 'Năm',
'period.two_year_price': 'Hai năm',
'period.three_year_price': 'Ba năm',
'period.onetime_price': 'Dài hạn',
'period.reset_price': 'Cập nhật dung lượng',
// order_status
'order_status.no_paid': 'Đợi Thanh toán',
'order_status.opening': 'Khai mạc',
@ -999,7 +999,7 @@ window.settings.locales = {
'login.forget_password': 'Quên mật khẩu',
// order
'order.table_no': '# Mã đơn hàng',
'order.table_cycle': 'Chu kì',
'order.table_period': 'Chu kì',
'order.table_amount': 'Tổng tiền đơn hàng',
'order.table_status': 'Trạng thái đơn hàng',
'order.table_create_time': 'Tạo thời gian',
@ -1011,7 +1011,7 @@ window.settings.locales = {
'order.please_check_credit_card': 'Vui lòng kiểm tra thông tin thanh toán thẻ',
'order.order_detail': 'Chi tiết đơn hàng',
'order.product': 'Sản phẩm',
'order.type_cycle': 'Loại hình/Chu kì',
'order.type_period': 'Loại hình/Chu kì',
'order.amount': 'Tổng cộng',
'order.traffic': 'Dung lượng',
'order.discount': 'Triết khấu',
@ -1036,7 +1036,7 @@ window.settings.locales = {
'plan.buy': 'Mua ngay',
'plan.setting_subscribe': 'Cài đặt',
'plan.discount': 'Triết khấu',
'plan.cycle': 'Chu kì thanh toán ',
'plan.period': 'Chu kì thanh toán ',
'plan.have_coupon': 'Có phiếu giảm giá',
'plan.coupon_verify': 'Xác minh',
'plan.order_total_amount': 'Tổng cộng',

File diff suppressed because one or more lines are too long

View File

@ -25,7 +25,7 @@
"You have an unpaid or pending order, please try again later or cancel it": "您有未付款或开通中的订单,请稍后再试或将其取消",
"This subscription has been sold out, please choose another subscription": "该订阅已售罄,请更换其它订阅",
"This subscription cannot be renewed, please change to another subscription": "该订阅无法续费,请更换其它订阅",
"This payment cycle cannot be purchased, please choose another cycle": "该订阅周期无法进行购买,请选择其它周期",
"This payment period cannot be purchased, please choose another period": "该订阅周期无法进行购买,请选择其它周期",
"Subscription has expired or no active subscription, unable to purchase Data Reset Package": "订阅已过期或无有效订阅,无法购买重置包",
"This subscription has expired, please change to another subscription": "订阅已过期,请更换其它订阅",
"Coupon failed": "优惠券使用失败",
@ -66,8 +66,8 @@
"Email verification code has been sent, please request again later": "验证码已发送,请过一会再请求",
"Email verification code": "邮箱验证码",
"Plan ID cannot be empty": "套餐ID不能为空",
"Plan cycle cannot be empty": "套餐周期不能为空",
"Wrong plan cycle": "套餐周期参数有误",
"Plan period cannot be empty": "套餐周期不能为空",
"Wrong plan period": "套餐周期参数有误",
"Ticket subject cannot be empty": "工单主题不能为空",
"Ticket level cannot be empty": "工单等级不能为空",
"Incorrect ticket level format": "工单等级参数有误",