+
-
+
diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php
index b5df7269..de45a4a2 100644
--- a/app/Library/AppInfo.php
+++ b/app/Library/AppInfo.php
@@ -11,7 +11,7 @@ class AppInfo
protected $link = 'https://koogua.com';
- protected $version = '1.2.7';
+ protected $version = '1.2.8';
public function __get($name)
{
diff --git a/app/Services/LiveNotify.php b/app/Services/LiveNotify.php
index 82fcc768..f088a6bd 100644
--- a/app/Services/LiveNotify.php
+++ b/app/Services/LiveNotify.php
@@ -35,9 +35,7 @@ class LiveNotify extends Service
'action' => $action,
]));
- if (!$this->checkSign($sign, $time)) {
- return false;
- }
+ if (!$this->checkSign($sign, $time)) return false;
$result = false;
@@ -125,7 +123,7 @@ class LiveNotify extends Service
*/
protected function handleRecord()
{
-
+ return true;
}
/**
@@ -133,7 +131,7 @@ class LiveNotify extends Service
*/
protected function handleSnapshot()
{
-
+ return true;
}
/**
@@ -141,7 +139,7 @@ class LiveNotify extends Service
*/
protected function handlePorn()
{
-
+ return true;
}
protected function handleStreamBeginNotice(ChapterModel $chapter)
@@ -153,9 +151,7 @@ class LiveNotify extends Service
$keyName = "live_notify:{$chapter->id}";
- if ($cache->get($keyName)) {
- return;
- }
+ if ($cache->get($keyName)) return;
$cache->save($keyName, time(), 86400);
@@ -163,9 +159,7 @@ class LiveNotify extends Service
$courseUsers = $courseUserRepo->findByCourseId($chapter->course_id);
- if ($courseUsers->count() == 0) {
- return;
- }
+ if ($courseUsers->count() == 0) return;
$notice = new LiveBeginNotice();
@@ -206,13 +200,9 @@ class LiveNotify extends Service
*/
protected function checkSign($sign, $time)
{
- if (!$sign || !$time) {
- return false;
- }
+ if (!$sign || !$time) return false;
- if ($time < time()) {
- return false;
- }
+ if ($time < time()) return false;
$notify = $this->getSettings('live.notify');
diff --git a/app/Services/Logic/Notice/RefundFinish.php b/app/Services/Logic/Notice/RefundFinish.php
index 6defe9fb..cec2ff8e 100644
--- a/app/Services/Logic/Notice/RefundFinish.php
+++ b/app/Services/Logic/Notice/RefundFinish.php
@@ -8,7 +8,7 @@ use App\Repos\Refund as RefundRepo;
use App\Repos\User as UserRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\Sms\RefundFinish as SmsRefundFinishNotice;
-use App\Services\Logic\Notice\WeChat\OrderFinish as WeChatRefundFinishNotice;
+use App\Services\Logic\Notice\WeChat\RefundFinish as WeChatRefundFinishNotice;
use App\Services\Logic\Service as LogicService;
class RefundFinish extends LogicService
diff --git a/app/Services/Pay/Alipay.php b/app/Services/Pay/Alipay.php
index 25ce01dc..fb65b0fc 100644
--- a/app/Services/Pay/Alipay.php
+++ b/app/Services/Pay/Alipay.php
@@ -207,15 +207,15 @@ class Alipay extends PayService
/**
* 查询交易(扫码生成订单后可执行)
*
- * @param string $outTradeNo
+ * @param string $tradeNo
* @param string $type
* @return Collection|bool
*/
- public function find($outTradeNo, $type = 'wap')
+ public function find($tradeNo, $type = 'wap')
{
try {
- $order = ['out_trade_no' => $outTradeNo];
+ $order = ['out_trade_no' => $tradeNo];
$result = $this->gateway->find($order, $type);
@@ -235,14 +235,14 @@ class Alipay extends PayService
/**
* 关闭交易(扫码生成订单后可执行)
*
- * @param string $outTradeNo
+ * @param string $tradeNo
* @return bool
*/
- public function close($outTradeNo)
+ public function close($tradeNo)
{
try {
- $response = $this->gateway->close(['out_trade_no' => $outTradeNo]);
+ $response = $this->gateway->close(['out_trade_no' => $tradeNo]);
$result = $response->code == '10000';
@@ -262,14 +262,14 @@ class Alipay extends PayService
/**
* 撤销交易(未生成订单也可执行)
*
- * @param string $outTradeNo
+ * @param string $tradeNo
* @return bool
*/
- public function cancel($outTradeNo)
+ public function cancel($tradeNo)
{
try {
- $response = $this->gateway->cancel(['out_trade_no' => $outTradeNo]);
+ $response = $this->gateway->cancel(['out_trade_no' => $tradeNo]);
$result = $response->code == '10000';
diff --git a/app/Services/Pay/Wxpay.php b/app/Services/Pay/Wxpay.php
index 89ee126a..051b3187 100644
--- a/app/Services/Pay/Wxpay.php
+++ b/app/Services/Pay/Wxpay.php
@@ -208,15 +208,15 @@ class Wxpay extends PayService
/**
* 查询交易(扫码生成订单后可执行)
*
- * @param string $outTradeNo
+ * @param string $tradeNo
* @param string $type
* @return Collection|bool
*/
- public function find($outTradeNo, $type = 'wap')
+ public function find($tradeNo, $type = 'wap')
{
try {
- $order = ['out_trade_no' => $outTradeNo];
+ $order = ['out_trade_no' => $tradeNo];
$result = $this->gateway->find($order, $type);
@@ -236,14 +236,14 @@ class Wxpay extends PayService
/**
* 关闭交易(扫码生成订单后可执行)
*
- * @param string $outTradeNo
+ * @param string $tradeNo
* @return bool
*/
- public function close($outTradeNo)
+ public function close($tradeNo)
{
try {
- $response = $this->gateway->close(['out_trade_no' => $outTradeNo]);
+ $response = $this->gateway->close(['out_trade_no' => $tradeNo]);
$result = $response->result_code == 'SUCCESS';
@@ -263,12 +263,12 @@ class Wxpay extends PayService
/**
* 取消交易
*
- * @param string $outTradeNo
+ * @param string $tradeNo
* @return bool
*/
- public function cancel($outTradeNo)
+ public function cancel($tradeNo)
{
- return $this->close($outTradeNo);
+ return $this->close($tradeNo);
}
/**
diff --git a/app/Services/Refund.php b/app/Services/Refund.php
index 2297ca7e..5b0736ad 100644
--- a/app/Services/Refund.php
+++ b/app/Services/Refund.php
@@ -18,6 +18,7 @@ class Refund extends Service
'item_info' => [],
'refund_amount' => 0.00,
'service_fee' => 0.00,
+ 'service_rate' => 5.00,
];
switch ($order->item_type) {
@@ -27,8 +28,14 @@ class Refund extends Service
case OrderModel::ITEM_PACKAGE:
$result = $this->previewPackageRefund($order);
break;
- default:
- $result = $this->previewOtherRefund($order);
+ case OrderModel::ITEM_REWARD:
+ $result = $this->previewRewardRefund($order);
+ break;
+ case OrderModel::ITEM_VIP:
+ $result = $this->previewVipRefund($order);
+ break;
+ case OrderModel::ITEM_TEST:
+ $result = $this->previewTestRefund($order);
break;
}
@@ -42,6 +49,7 @@ class Refund extends Service
$itemInfo['course']['cover'] = kg_cos_cover_url($itemInfo['course']['cover']);
$serviceFee = $this->getServiceFee($order);
+ $serviceRate = $this->getServiceRate($order);
$refundPercent = 0.00;
$refundAmount = 0.00;
@@ -59,6 +67,7 @@ class Refund extends Service
'item_info' => $itemInfo,
'refund_amount' => $refundAmount,
'service_fee' => $serviceFee,
+ 'service_rate' => $serviceRate,
];
}
@@ -67,6 +76,7 @@ class Refund extends Service
$itemInfo = $order->item_info;
$serviceFee = $this->getServiceFee($order);
+ $serviceRate = $this->getServiceRate($order);
$totalMarketPrice = 0.00;
@@ -102,24 +112,51 @@ class Refund extends Service
'item_info' => $itemInfo,
'refund_amount' => $totalRefundAmount,
'service_fee' => $serviceFee,
+ 'service_rate' => $serviceRate,
];
}
+ protected function previewRewardRefund(OrderModel $order)
+ {
+ return $this->previewOtherRefund($order);
+ }
+
+ protected function previewVipRefund(OrderModel $order)
+ {
+ return $this->previewOtherRefund($order);
+ }
+
+ protected function previewTestRefund(OrderModel $order)
+ {
+ return $this->previewOtherRefund($order);
+ }
+
protected function previewOtherRefund(OrderModel $order)
{
$serviceFee = $this->getServiceFee($order);
+ $serviceRate = $this->getServiceRate($order);
$refundAmount = round($order->amount - $serviceFee, 2);
return [
'item_type' => $order->item_type,
- 'item_info' => [],
+ 'item_info' => $order->item_info,
'refund_amount' => $refundAmount,
'service_fee' => $serviceFee,
+ 'service_rate' => $serviceRate,
];
}
protected function getServiceFee(OrderModel $order)
+ {
+ $serviceRate = $this->getServiceRate($order);
+
+ $serviceFee = round($order->amount * $serviceRate / 100, 2);
+
+ return $serviceFee >= 0.01 ? $serviceFee : 0.00;
+ }
+
+ protected function getServiceRate(OrderModel $order)
{
$orderRepo = new OrderRepo();
@@ -139,7 +176,7 @@ class Refund extends Service
break;
}
- return round($order->amount * $serviceRate / 100, 2);
+ return $serviceRate;
}
protected function getCourseRefundPercent($courseId, $userId)
diff --git a/app/Validators/Refund.php b/app/Validators/Refund.php
index 1b309b91..c0a6d37d 100644
--- a/app/Validators/Refund.php
+++ b/app/Validators/Refund.php
@@ -42,9 +42,15 @@ class Refund extends Validator
public function checkAmount($orderAmount, $refundAmount)
{
+ if ($orderAmount <= 0 || $refundAmount <= 0) {
+ throw new BadRequestException('refund.invalid_amount');
+ }
+
if ($refundAmount > $orderAmount) {
throw new BadRequestException('refund.invalid_amount');
}
+
+ return (float)$refundAmount;
}
public function checkStatus($status)
diff --git a/config/errors.php b/config/errors.php
index ca812440..326947ff 100644
--- a/config/errors.php
+++ b/config/errors.php
@@ -289,6 +289,7 @@ $error['refund.review_note_too_short'] = '审核备注太短(少于2个字符
$error['refund.review_note_too_long'] = '审核备注太长(多于255个字符)';
$error['refund.cancel_not_allowed'] = '当前不允许取消退款';
$error['refund.review_not_allowed'] = '当前不允许审核退款';
+$error['refund.invalid_amount'] = '无效的退款金额';
$error['refund.invalid_status'] = '无效的状态类型';
/**
diff --git a/public/static/admin/css/common.css b/public/static/admin/css/common.css
index 1bba752e..22bc2a78 100644
--- a/public/static/admin/css/common.css
+++ b/public/static/admin/css/common.css
@@ -34,6 +34,18 @@
list-style: decimal;
}
+.red {
+ color: red;
+}
+
+.green {
+ color: green;
+}
+
+.gray {
+ color: gray;
+}
+
.loading {
padding: 30px;
text-align: center;
diff --git a/public/static/home/css/common.css b/public/static/home/css/common.css
index 738e4902..31aea755 100644
--- a/public/static/home/css/common.css
+++ b/public/static/home/css/common.css
@@ -1688,17 +1688,14 @@
}
.order-card {
- padding: 10px 0;
+ padding-bottom: 20px;
margin-bottom: 20px;
- background-color: white;
+ border-bottom: 1px dashed #e6e6e6;
color: #666;
- box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.order-card .header {
- padding-bottom: 10px;
margin-bottom: 10px;
- border-bottom: 1px solid #e6e6e6;
}
.order-card .header span {
diff --git a/scheduler.php b/scheduler.php
index c63390ad..97334ec0 100644
--- a/scheduler.php
+++ b/scheduler.php
@@ -13,9 +13,6 @@ $bin = '/usr/local/bin/php';
$scheduler->php($script, $bin, ['--task' => 'deliver', '--action' => 'main'])
->at('*/3 * * * *');
-$scheduler->php($script, $bin, ['--task' => 'notice', '--action' => 'main'])
- ->at('*/3 * * * *');
-
$scheduler->php($script, $bin, ['--task' => 'vod_event', '--action' => 'main'])
->at('*/5 * * * *');
@@ -34,6 +31,9 @@ $scheduler->php($script, $bin, ['--task' => 'server_monitor', '--action' => 'mai
$scheduler->php($script, $bin, ['--task' => 'close_trade', '--action' => 'main'])
->at('*/13 * * * *');
+$scheduler->php($script, $bin, ['--task' => 'notice', '--action' => 'main'])
+ ->everyMinute();
+
$scheduler->php($script, $bin, ['--task' => 'close_order', '--action' => 'main'])
->hourly(3);