From 24b9d9893bb96cdc26839bfc813a90fc2fc9b00f Mon Sep 17 00:00:00 2001 From: huhao <915664508@qq.com> Date: Wed, 14 Mar 2018 15:16:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=87=E7=AB=A0=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E7=BD=AE=E9=A1=B6=E8=A2=AB=E6=8B=92=E7=BB=9D=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E4=BD=99=E9=A2=9D=E6=B2=A1=E6=9C=89=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AdminControllers/NewsPinnedController.php | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/packages/slimkit-plus-news/src/AdminControllers/NewsPinnedController.php b/packages/slimkit-plus-news/src/AdminControllers/NewsPinnedController.php index 476ffce14..ed1647fdb 100644 --- a/packages/slimkit-plus-news/src/AdminControllers/NewsPinnedController.php +++ b/packages/slimkit-plus-news/src/AdminControllers/NewsPinnedController.php @@ -23,8 +23,8 @@ use Illuminate\Http\Request; use Illuminate\Support\Carbon; use Zhiyi\Plus\Http\Controllers\Controller; -use Zhiyi\Plus\Models\WalletCharge as WalletChargeModel; use Zhiyi\Component\ZhiyiPlus\PlusComponentNews\Models\News; +use Zhiyi\Plus\Packages\Currency\Processes\User as UserProcess; use Zhiyi\Component\ZhiyiPlus\PlusComponentNews\Models\NewsPinned; class NewsPinnedController extends Controller @@ -112,32 +112,30 @@ public function accept(NewsPinned $pinned, Carbon $datetime) return response()->json([], 204); } - public function reject(NewsPinned $pinned, Carbon $datetime) + public function reject(NewsPinned $pinned, Carbon $datetime, UserProcess $userProcess) { $pinned->state = 2; $pinned->expires_at = $datetime; - $charge = new WalletChargeModel(); - $charge->user_id = $pinned->user_id; - $charge->channel = 'system'; - $charge->action = 1; - $charge->amount = $pinned->amount; - $charge->subject = '退还资讯置顶申请费用'; - $charge->body = sprintf('退还资讯《%s》的置顶申请费用', $pinned->news->title); - $charge->status = 1; - - $pinned->getConnection()->transaction(function () use ($pinned, $charge) { + $pinned->getConnection()->transaction(function () use ($pinned, $userProcess) { $pinned->save(); - $pinned->user->wallet()->increment('balance', $charge->amount); - $charge->save(); - - $pinned->user->sendNotifyMessage('news:pinned:reject', sprintf('资讯《%s》的置顶申请已被驳回', $pinned->news->title), [ - 'news' => $pinned->news, - 'pinned' => $pinned, - ]); + $newTitile = $pinned->news->title; + $body = sprintf('资讯《%s》的置顶申请已被驳回,退还%s积分', $newTitile, $pinned->amount); + $userProcess->receivables( + $pinned->user_id, + $pinned->amount, + $pinned->news->user_id, + '退还资讯置顶申请费用', + $body + ); + $pinned->user->sendNotifyMessage( + 'news:pinned:reject', + $body, + ['news' => $pinned->news, 'pinned' => $pinned] + ); }); - return response()->json([], 204); + return response()->json(null, 204); } /**