Browse Source

Merge branch 'hotfix-0924' into master

master
weigang 5 years ago
parent
commit
777c52f35c
  1. 7
      app/JsonRpc/OrdersService.php
  2. 2
      app/Service/v3/Implementations/FinancialRecordService.php
  3. 40
      app/Service/v3/Implementations/OrderStatisticsService.php
  4. 12
      app/Service/v3/Implementations/ParamsTokenSsdbService.php
  5. 2
      app/Service/v3/Implementations/ShopCartUpdateService.php

7
app/JsonRpc/OrdersService.php

@ -290,6 +290,7 @@ class OrdersService implements OrdersServiceInterface
} }
// 处理用户和商户流水 // 处理用户和商户流水
$orderChildren = [];
if ($refundType == 'main') { # 整单退的话还得处理所有子订单的商户 if ($refundType == 'main') { # 整单退的话还得处理所有子订单的商户
$orderChildren = Order::query()->with('store:user_id')->where(['order_main_id' => $orderMain->global_order_id])->get(); $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') { # 退子订单或者退单品的话,商户只有一个 } 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->storeRefundDirect($orderChild->store->user_id, $orderChild->id, $refundAmount);
} }
$this->financialRecordService->userRefundDirect($orderMain->user_id, $orderMain->global_order_id, $refundAmount); $this->financialRecordService->userRefundDirect($orderMain->user_id, $orderMain->global_order_id, $refundAmount);
Db::commit(); 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 [ return [
"status" => 200, "status" => 200,
"code" => 0, "code" => 0,

2
app/Service/v3/Implementations/FinancialRecordService.php

@ -309,7 +309,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface
} }
$sumAmount = $financialRecord->where([ $sumAmount = $financialRecord->where([
'source_id' => $user_id,
'user_id' => $user_id,
'user_type' => $user_type 'user_type' => $user_type
])->whereIn('money_type', $money_type) ])->whereIn('money_type', $money_type)
->sum('money'); ->sum('money');

40
app/Service/v3/Implementations/OrderStatisticsService.php

@ -4,7 +4,10 @@
namespace App\Service\v3\Implementations; namespace App\Service\v3\Implementations;
use App\Constants\v3\OrderState; use App\Constants\v3\OrderState;
use App\Model\v3\Order; use App\Model\v3\Order;
use App\Model\v3\OrderGoods;
use App\Model\v3\OrderMain;
use \App\Service\v3\Interfaces\OrderStatisticsServiceInterface; use \App\Service\v3\Interfaces\OrderStatisticsServiceInterface;
use Hyperf\Utils\ApplicationContext;
class OrderStatisticsService implements OrderStatisticsServiceInterface class OrderStatisticsService implements OrderStatisticsServiceInterface
{ {
@ -26,14 +29,35 @@ class OrderStatisticsService implements OrderStatisticsServiceInterface
public function countOrder($storeId,$type,$startTime = '',$endTime = '') 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;
} }
} }

12
app/Service/v3/Implementations/ParamsTokenSsdbService.php

@ -31,13 +31,7 @@ class ParamsTokenSsdbService implements ParamsTokenServiceInterface
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); $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生成失败'); throw new ErrorCodeException(ErrorCode::TOKEN_GENERATE_ERROR, 'token生成失败');
} }
@ -51,7 +45,7 @@ class ParamsTokenSsdbService implements ParamsTokenServiceInterface
public function analyze($token) public function analyze($token)
{ {
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); $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) { if (false === $params) {
@ -62,7 +56,7 @@ class ParamsTokenSsdbService implements ParamsTokenServiceInterface
throw new ErrorCodeException(ErrorCode::TOKEN_NOT_EXISTS, 'token不存在'); throw new ErrorCodeException(ErrorCode::TOKEN_NOT_EXISTS, 'token不存在');
} }
return $params;
return json_decode($params, true);
} }
} }

2
app/Service/v3/Implementations/ShopCartUpdateService.php

@ -51,7 +51,7 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface
array_push($goodsArr,$goodsId); array_push($goodsArr,$goodsId);
$checkGoodsActivity = $this->goodsActivityService->checkOrderActivityCount($goodsArr); $checkGoodsActivity = $this->goodsActivityService->checkOrderActivityCount($goodsArr);
if(!$checkGoodsActivity){ if(!$checkGoodsActivity){
throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_BUY);
throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_RESTRICT_LIMIT);
} }
$goodsCheck = $this->goodsActivityService->check($goods,$num,$userId); $goodsCheck = $this->goodsActivityService->check($goods,$num,$userId);
}else{ }else{

Loading…
Cancel
Save