Browse Source

订单起送价下单判断

master
weigang 5 years ago
parent
commit
27fadd82bb
  1. 6
      app/Constants/v3/ErrorCode.php
  2. 4
      app/Controller/v3/ShopCartController.php
  3. 6
      app/Service/v3/Implementations/InitialDeliveryService.php
  4. 12
      app/Service/v3/Implementations/OrderOnlineService.php
  5. 2
      app/Service/v3/Interfaces/InitialDeliveryServiceInterface.php
  6. 2
      config/autoload/dependencies.php

6
app/Constants/v3/ErrorCode.php

@ -83,6 +83,12 @@ class ErrorCode extends AbstractConstants
*/ */
const ORDER_REFUND_FAIL = 610; const ORDER_REFUND_FAIL = 610;
/**
* 下单失败
* @Message("订单金额未满起送价")
*/
const ORDER_NOT_ENOUGH_INITIAL_DELIVERY = 611;
/************************************/ /************************************/
/* 支付相关 651-700 */ /* 支付相关 651-700 */
/************************************/ /************************************/

4
app/Controller/v3/ShopCartController.php

@ -3,7 +3,7 @@
namespace App\Controller\v3; namespace App\Controller\v3;
use App\Controller\BaseController; use App\Controller\BaseController;
use App\Service\v3\Interfaces\IntialDeliveryServiceInterface;
use App\Service\v3\Interfaces\InitialDeliveryServiceInterface;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\ShopCartServiceInterface; use App\Service\v3\Interfaces\ShopCartServiceInterface;
@ -16,7 +16,7 @@ class ShopCartController extends BaseController
protected $shopCartService; protected $shopCartService;
/** /**
* @Inject * @Inject
* @var IntialDeliveryServiceInterface
* @var InitialDeliveryServiceInterface
*/ */
protected $intialDeliveryService; protected $intialDeliveryService;
public function detail() public function detail()

6
app/Service/v3/Implementations/IntialDeliveryService.php → app/Service/v3/Implementations/InitialDeliveryService.php

@ -4,10 +4,10 @@
namespace App\Service\v3\Implementations; namespace App\Service\v3\Implementations;
use App\Constants\v3\SsdbKeys; use App\Constants\v3\SsdbKeys;
use App\Model\v3\SystemConfig; use App\Model\v3\SystemConfig;
use App\Service\v3\Interfaces\IntialDeliveryServiceInterface;
use App\Service\v3\Interfaces\InitialDeliveryServiceInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Utils\ApplicationContext;
use App\TaskWorker\SSDBTask; use App\TaskWorker\SSDBTask;
class IntialDeliveryService implements IntialDeliveryServiceInterface
class InitialDeliveryService implements InitialDeliveryServiceInterface
{ {
public function do() public function do()
@ -32,7 +32,7 @@ class IntialDeliveryService implements IntialDeliveryServiceInterface
if($intialDelivery === false || empty($intialDelivery)) { if($intialDelivery === false || empty($intialDelivery)) {
$systemConfig = SystemConfig::query()->where('menu_name','initial_delivery_amount')->first(); $systemConfig = SystemConfig::query()->where('menu_name','initial_delivery_amount')->first();
$intialDelivery = number_format($systemConfig->value,2); $intialDelivery = number_format($systemConfig->value,2);
$ssdb->exec('set',SsdbKeys::INTIAL_DELIVERY_AMOUNT,$intialDelivery);
$ssdb->exec('setnx',SsdbKeys::INTIAL_DELIVERY_AMOUNT,$intialDelivery);
return $intialDelivery; return $intialDelivery;
} }
return $intialDelivery; return $intialDelivery;

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

@ -24,6 +24,7 @@ use App\Service\v3\Interfaces\CouponRecServiceInterface;
use App\Service\v3\Interfaces\CouponServiceInterface; use App\Service\v3\Interfaces\CouponServiceInterface;
use App\Service\v3\Interfaces\GoodsActivityServiceInterface; use App\Service\v3\Interfaces\GoodsActivityServiceInterface;
use App\Service\v3\Interfaces\GoodsServiceInterface; use App\Service\v3\Interfaces\GoodsServiceInterface;
use App\Service\v3\Interfaces\InitialDeliveryServiceInterface;
use App\Service\v3\Interfaces\PaymentServiceInterface; use App\Service\v3\Interfaces\PaymentServiceInterface;
use App\Service\v3\Interfaces\ShopCartUpdateServiceInterface; use App\Service\v3\Interfaces\ShopCartUpdateServiceInterface;
use App\Service\v3\Interfaces\UserAddressServiceInterface; use App\Service\v3\Interfaces\UserAddressServiceInterface;
@ -93,6 +94,11 @@ class OrderOnlineService implements OrderOnlineServiceInterface
*/ */
protected $badgeService; protected $badgeService;
/**
* @var InitialDeliveryServiceInterface
*/
protected $initialDeliveryService;
/** /**
* 下单 * 下单
* @param $marketId * @param $marketId
@ -252,6 +258,12 @@ class OrderOnlineService implements OrderOnlineServiceInterface
throw new ErrorCodeException(ErrorCode::ORDER_TOTAL_AMOUNT_ERROR); throw new ErrorCodeException(ErrorCode::ORDER_TOTAL_AMOUNT_ERROR);
} }
// 校验订单总金额是否满足起送
$initDeliveryAmount = $this->initialDeliveryService->get();
if ($orderAmount < $initDeliveryAmount) {
throw new ErrorCodeException(ErrorCode::ORDER_NOT_ENOUGH_INITIAL_DELIVERY, "[{$initDeliveryAmount}]");
}
$dataMain = [ $dataMain = [
'market_id' => $marketId, 'market_id' => $marketId,
'order_num' => $globalOrderId, 'order_num' => $globalOrderId,

2
app/Service/v3/Interfaces/IntialDeliveryServiceInterface.php → app/Service/v3/Interfaces/InitialDeliveryServiceInterface.php

@ -4,7 +4,7 @@
namespace App\Service\v3\Interfaces; namespace App\Service\v3\Interfaces;
interface IntialDeliveryServiceInterface
interface InitialDeliveryServiceInterface
{ {
public function do(); public function do();
public function check(); public function check();

2
config/autoload/dependencies.php

@ -84,5 +84,5 @@ return [
\App\Service\v3\Interfaces\OrderStatisticsServiceInterface::class => \App\Service\v3\Implementations\OrderStatisticsService::class, \App\Service\v3\Interfaces\OrderStatisticsServiceInterface::class => \App\Service\v3\Implementations\OrderStatisticsService::class,
\App\Service\v3\Interfaces\UserRelationBindServiceInterface::class => \App\Service\v3\Implementations\UserCommunityBindService::class, \App\Service\v3\Interfaces\UserRelationBindServiceInterface::class => \App\Service\v3\Implementations\UserCommunityBindService::class,
\App\Service\v3\Interfaces\BadgeServiceInterface::class => \App\Service\v3\Implementations\BadgeService::class, \App\Service\v3\Interfaces\BadgeServiceInterface::class => \App\Service\v3\Implementations\BadgeService::class,
\App\Service\v3\Interfaces\IntialDeliveryServiceInterface::class => \App\Service\v3\Implementations\IntialDeliveryService::class,
\App\Service\v3\Interfaces\InitialDeliveryServiceInterface::class => \App\Service\v3\Implementations\InitialDeliveryService::class,
]; ];
Loading…
Cancel
Save