From 9a3d0fb9fb7d5d66c91488b60401e3e5ece57ae9 Mon Sep 17 00:00:00 2001 From: weigang Date: Tue, 3 Nov 2020 17:55:43 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E7=A9=BA=E5=95=86=E6=88=B7=202?= =?UTF-8?q?=E3=80=81=E7=A9=BA=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constants/v3/ErrorCode.php | 6 ++++++ app/Controller/v3/CommunityController.php | 14 ++++++++++++++ app/Model/v3/Order.php | 2 +- .../v3/Implementations/SeparateAccountsService.php | 4 ++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/Constants/v3/ErrorCode.php b/app/Constants/v3/ErrorCode.php index 7e6a60d..b05f653 100644 --- a/app/Constants/v3/ErrorCode.php +++ b/app/Constants/v3/ErrorCode.php @@ -216,6 +216,12 @@ class ErrorCode extends AbstractConstants */ const STORE_BUSINESSS_HOURS_ERROR = 711; + /** + * 用户社区绑定失败 + * @Message("绑定失败,稍后重试") + */ + const COMMUNITY_BIND_ERROR = 712; + /************************************/ /* 定位相关 751-800 */ /************************************/ diff --git a/app/Controller/v3/CommunityController.php b/app/Controller/v3/CommunityController.php index c4e9f93..5ad08fb 100644 --- a/app/Controller/v3/CommunityController.php +++ b/app/Controller/v3/CommunityController.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace App\Controller\v3; +use App\Commons\Log; +use App\Constants\v3\ErrorCode; use App\Controller\BaseController; use App\Model\v3\UserRelationBind; use App\Request\v3\CommunityBindRequest; @@ -19,12 +21,24 @@ class CommunityController extends BaseController */ protected $userCommunityService; + /** + * @Inject + * @var Log + */ + protected $log; + // public function bind(CommunityBindRequest $request) public function bind() { // $data = $request->validated(); $data = $this->request->all(); $jsonData = $data['json_data'] ?? json_encode([]); + + if (!$data['source_id'] || !$data['user_id']) { + $this->log->event('community_bind_error', ['request' => json_encode($data)]); + return $this->result(ErrorCode::COMMUNITY_BIND_ERROR,$data); + } + $res = $this->userCommunityService->bind(UserRelationBind::BIND_TYPE_COMMUNITY, $data['source_id'], $data['user_id'], $jsonData); return $this->success(['id' => $res->id]); } diff --git a/app/Model/v3/Order.php b/app/Model/v3/Order.php index 44eae8e..228478b 100644 --- a/app/Model/v3/Order.php +++ b/app/Model/v3/Order.php @@ -56,6 +56,6 @@ class Order extends Model public function store() { - return $this->belongsTo(Store::class, 'store_id', 'id'); + return $this->belongsTo(Store::class, 'store_id', 'id')->withTrashed(); } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/SeparateAccountsService.php b/app/Service/v3/Implementations/SeparateAccountsService.php index 7070ff4..17763e5 100644 --- a/app/Service/v3/Implementations/SeparateAccountsService.php +++ b/app/Service/v3/Implementations/SeparateAccountsService.php @@ -114,7 +114,7 @@ class SeparateAccountsService implements SeparateAccountsServiceInterface // 新商户流水 foreach ($orders as $key => &$order) { - $store = Store::query()->withoutGlobalScope('normal')->find($order['store_id']); + $store = Store::query()->withTrashed()->withoutGlobalScope('normal')->find($order['store_id']); $this->financialRecordService->storeByOLOrderComp($store->user_id, $orderMain->global_order_id ,$order['money']); } // =======商户订单收入流水 / End======= @@ -297,7 +297,7 @@ class SeparateAccountsService implements SeparateAccountsServiceInterface $message = []; // 商户 - $store = Store::query()->withoutGlobalScope('normal')->find($order->store_id); + $store = Store::query()->withTrashed()->withoutGlobalScope('normal')->find($order->store_id); // 新商户订单流水 $this->financialRecordService->storeByOFLOrderComp($store->user_id, $orderMain->global_order_id, $order->money);