From 55af31eb18d263f3ce62c42b6c0b56121d01e1bd Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 24 Sep 2020 16:24:20 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=90=8C=E7=B1=BB=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=95=86=E5=93=81=E8=B4=AD=E4=B9=B0=E9=99=90=E5=88=B6=E7=9A=84?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/ShopCartUpdateService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Service/v3/Implementations/ShopCartUpdateService.php b/app/Service/v3/Implementations/ShopCartUpdateService.php index c6dd87a..72fd76f 100644 --- a/app/Service/v3/Implementations/ShopCartUpdateService.php +++ b/app/Service/v3/Implementations/ShopCartUpdateService.php @@ -51,7 +51,7 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface array_push($goodsArr,$goodsId); $checkGoodsActivity = $this->goodsActivityService->checkOrderActivityCount($goodsArr); if(!$checkGoodsActivity){ - throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_BUY); + throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_RESTRICT_LIMIT); } $goodsCheck = $this->goodsActivityService->check($goods,$num,$userId); }else{ From 29d1cca38d108f413f375d1f1ff5498d93c18306 Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 24 Sep 2020 18:17:02 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=95=86=E6=88=B7badge=EF=BC=8C=E7=BA=BF?= =?UTF-8?q?=E4=B8=8A=E8=AE=A2=E5=8D=95=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/JsonRpc/OrdersService.php | 7 ++++ .../OrderStatisticsService.php | 40 +++++++++++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/app/JsonRpc/OrdersService.php b/app/JsonRpc/OrdersService.php index 68cc52e..c0329c0 100644 --- a/app/JsonRpc/OrdersService.php +++ b/app/JsonRpc/OrdersService.php @@ -290,6 +290,7 @@ class OrdersService implements OrdersServiceInterface } // 处理用户和商户流水 + $orderChildren = []; if ($refundType == 'main') { # 整单退的话还得处理所有子订单的商户 $orderChildren = Order::query()->with('store:user_id')->where(['order_main_id' => $orderMain->global_order_id])->get(); @@ -304,12 +305,18 @@ class OrdersService implements OrdersServiceInterface } } elseif ($refundType == 'sub'||$refundType == 'goods') { # 退子订单或者退单品的话,商户只有一个 + $orderChildren = Order::query()->with('store:user_id')->where(['id' => $order_child_id])->get(); $this->financialRecordService->storeRefundDirect($orderChild->store->user_id, $orderChild->id, $refundAmount); } $this->financialRecordService->userRefundDirect($orderMain->user_id, $orderMain->global_order_id, $refundAmount); Db::commit(); + + // 记录badge + $orderChildIds = array_values(array_column($orderChildren, 'store_id')); + $this->badgeService->doByOrder($orderMain->user_id, $orderChildIds, $orderMain->global_order_id, OrderState::REFUNDED); + return [ "status" => 200, "code" => 0, diff --git a/app/Service/v3/Implementations/OrderStatisticsService.php b/app/Service/v3/Implementations/OrderStatisticsService.php index 99b14bb..ae586b2 100644 --- a/app/Service/v3/Implementations/OrderStatisticsService.php +++ b/app/Service/v3/Implementations/OrderStatisticsService.php @@ -4,7 +4,10 @@ namespace App\Service\v3\Implementations; use App\Constants\v3\OrderState; use App\Model\v3\Order; +use App\Model\v3\OrderGoods; +use App\Model\v3\OrderMain; use \App\Service\v3\Interfaces\OrderStatisticsServiceInterface; +use Hyperf\Utils\ApplicationContext; class OrderStatisticsService implements OrderStatisticsServiceInterface { @@ -26,14 +29,35 @@ class OrderStatisticsService implements OrderStatisticsServiceInterface public function countOrder($storeId,$type,$startTime = '',$endTime = '') { - $builder = Order::join('lanzu_order_main','lanzu_order_main.global_order_id','lanzu_order.order_main_id') - ->where('lanzu_order.store_id',$storeId); - if(!empty($startTime) && !empty($endTime)){ - $builder->whereBetween('lanzu_order_main.created_at',[$startTime,$endTime]); + $childTable = ApplicationContext::getContainer()->get(Order::class)->getTable(); + $mainTable = ApplicationContext::getContainer()->get(OrderMain::class)->getTable(); + $goodsTable = ApplicationContext::getContainer()->get(OrderGoods::class)->getTable(); + + $builder = OrderMain::query() + ->join($childTable, ''.$childTable.'.order_main_id', '=', ''.$mainTable.'.global_order_id') + ->join($goodsTable, ''.$goodsTable.'.order_id', '=', ''.$childTable.'.id') + ->where([''.$childTable.'.store_id' => $storeId, ''.$mainTable.'.type' => $type]) + ->whereIn(''.$mainTable.'.state', array_merge(OrderState::FINISH, [OrderState::REFUNDED,OrderState::REFUND_REFUSE])) + ->whereIn(''.$goodsTable.'.status', [1,2]); + + if ($startTime) { + $builder = $builder->where(''.$mainTable.'.created_at', '>=', $startTime); + } + + if ($endTime) { + $builder = $builder->where(''.$mainTable.'.created_at', '<=', $endTime); } - $count = $builder->whereIn('lanzu_order_main.state', OrderState::FINISH) - ->where('type',$type) - ->count(); - return $count; + + return $builder->groupBy(''.$mainTable.'.id')->count(); + + // $builder = Order::join('lanzu_order_main','lanzu_order_main.global_order_id','lanzu_order.order_main_id') + // ->where('lanzu_order.store_id',$storeId); + // if(!empty($startTime) && !empty($endTime)){ + // $builder->whereBetween('lanzu_order_main.created_at',[$startTime,$endTime]); + // } + // $count = $builder->whereIn('lanzu_order_main.state', OrderState::FINISH) + // ->where('type',$type) + // ->count(); + // return $count; } } \ No newline at end of file From b9c0a7192aa77a1a305bbf3cfbc4d9af39c7185e Mon Sep 17 00:00:00 2001 From: weigang Date: Fri, 25 Sep 2020 09:35:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E4=BD=99=E9=A2=9D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/FinancialRecordService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Service/v3/Implementations/FinancialRecordService.php b/app/Service/v3/Implementations/FinancialRecordService.php index 61e3b7d..74c23f0 100644 --- a/app/Service/v3/Implementations/FinancialRecordService.php +++ b/app/Service/v3/Implementations/FinancialRecordService.php @@ -309,7 +309,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface } $sumAmount = $financialRecord->where([ - 'source_id' => $user_id, + 'user_id' => $user_id, 'user_type' => $user_type ])->whereIn('money_type', $money_type) ->sum('money'); From c315c9ee3f1a75d8858fd2429e09bab4eb89e0a6 Mon Sep 17 00:00:00 2001 From: weigang Date: Fri, 25 Sep 2020 09:57:44 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=96=B0token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/ParamsTokenSsdbService.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/Service/v3/Implementations/ParamsTokenSsdbService.php b/app/Service/v3/Implementations/ParamsTokenSsdbService.php index 39850c9..966c9ae 100644 --- a/app/Service/v3/Implementations/ParamsTokenSsdbService.php +++ b/app/Service/v3/Implementations/ParamsTokenSsdbService.php @@ -31,13 +31,7 @@ class ParamsTokenSsdbService implements ParamsTokenServiceInterface $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); - $kvs = []; - foreach ($params as $key => $value) { - $kvs[] = $key; - $kvs[] = $value; - } - - if(false === $ssdb->exec('multi_hset', SsdbKeys::PARAMS_TOKEN.$token, $kvs)) { + if(false === $ssdb->exec('hset', SsdbKeys::PARAMS_TOKEN, $token, json_encode($params))) { throw new ErrorCodeException(ErrorCode::TOKEN_GENERATE_ERROR, 'token生成失败'); } @@ -51,7 +45,7 @@ class ParamsTokenSsdbService implements ParamsTokenServiceInterface public function analyze($token) { $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); - $params = $ssdb->exec('hgetall', SsdbKeys::PARAMS_TOKEN.$token); + $params = $ssdb->exec('hget', SsdbKeys::PARAMS_TOKEN, $token); if (false === $params) { @@ -62,7 +56,7 @@ class ParamsTokenSsdbService implements ParamsTokenServiceInterface throw new ErrorCodeException(ErrorCode::TOKEN_NOT_EXISTS, 'token不存在'); } - return $params; + return json_decode($params, true); } } \ No newline at end of file