diff --git a/Envoy.blade.php b/Envoy.blade.php index e7a1442..39d6cc9 100644 --- a/Envoy.blade.php +++ b/Envoy.blade.php @@ -10,7 +10,7 @@ @task('git_dev') cd /lanzu_api - git pull origin phoenix + git pull origin develop @if($composer == true) composer update --lock @endif diff --git a/app/Constants/v3/ErrorCode.php b/app/Constants/v3/ErrorCode.php index 6e4ce80..45690fa 100644 --- a/app/Constants/v3/ErrorCode.php +++ b/app/Constants/v3/ErrorCode.php @@ -354,4 +354,26 @@ class ErrorCode extends AbstractConstants * @Message("获取收货地址失败") */ const LOCATION_USER_ADDRESS = 1303; + + /************************************/ + /* token相关 1351-1400 */ + /************************************/ + + /** + * token生成失败 + * @Message("token生成失败") + */ + const TOKEN_GENERATE_ERROR = 1351; + + /** + * token解析失败 + * @Message("token解析失败") + */ + const TOKEN_ANALYZE_ERROR = 1352; + + /** + * token解析失败 + * @Message("token解析失败") + */ + const TOKEN_NOT_EXISTS = 1353; } \ No newline at end of file diff --git a/app/Constants/v3/Shipping.php b/app/Constants/v3/Shipping.php index fbcccf7..52e7a47 100644 --- a/app/Constants/v3/Shipping.php +++ b/app/Constants/v3/Shipping.php @@ -14,4 +14,9 @@ class Shipping extends AbstractConstants * @Message("服务站配送") */ const TYPE_LANZU = 1; + + /** + * @Message("用户自提") + */ + const TYPE_SELF_TAKE = 3; } \ No newline at end of file diff --git a/app/Constants/v3/SsdbKeys.php b/app/Constants/v3/SsdbKeys.php index d088313..f153fb1 100644 --- a/app/Constants/v3/SsdbKeys.php +++ b/app/Constants/v3/SsdbKeys.php @@ -75,4 +75,9 @@ class SsdbKeys extends AbstractConstants */ const INTIAL_DELIVERY_AMOUNT = 'intial_delivery_amount'; + /** + * @Message("Params Token Key Prefix") + */ + const PARAMS_TOKEN = 'params_token_v3_'; + } \ No newline at end of file diff --git a/app/Controller/v3/OrderOnlineController.php b/app/Controller/v3/OrderOnlineController.php index b89558a..eb475fe 100644 --- a/app/Controller/v3/OrderOnlineController.php +++ b/app/Controller/v3/OrderOnlineController.php @@ -203,7 +203,8 @@ class OrderOnlineController extends BaseController $params['delivery_time_note'], ($params['service_money'] ?? 0), $couponIds, - $params['plat'] ?: '' + $params['plat'] ?: '', + ($params['self_take'] ?? 0) ); return $this->success(['data' => $data]); diff --git a/app/Controller/v3/ParamsTokenController.php b/app/Controller/v3/ParamsTokenController.php new file mode 100644 index 0000000..c728245 --- /dev/null +++ b/app/Controller/v3/ParamsTokenController.php @@ -0,0 +1,40 @@ +paramsTokenService->generate($this->request->all()); + return $this->success(['token' => $token]); + } + + /** + * 解析token获取对应参数数据 + * @return \Psr\Http\Message\ResponseInterface + */ + public function analyze() + { + $params = $this->paramsTokenService->analyze($this->request->input('token')); + return $this->success($params); + } +} \ No newline at end of file diff --git a/app/Request/v3/OrderOnlineRequest.php b/app/Request/v3/OrderOnlineRequest.php index 26859ca..f8d0a76 100644 --- a/app/Request/v3/OrderOnlineRequest.php +++ b/app/Request/v3/OrderOnlineRequest.php @@ -31,6 +31,7 @@ class OrderOnlineRequest extends BaseFormRequest 'coupon_ids' => '', 'service_money' => 'numeric', 'plat' => '', + 'self_take' => '', ]; } diff --git a/app/Service/v3/Implementations/OrderOnlineService.php b/app/Service/v3/Implementations/OrderOnlineService.php index 57219a8..daf598d 100644 --- a/app/Service/v3/Implementations/OrderOnlineService.php +++ b/app/Service/v3/Implementations/OrderOnlineService.php @@ -8,6 +8,7 @@ use App\Constants\v3\LogLabel; use App\Constants\v3\OrderState; use App\Constants\v3\OrderType; use App\Constants\v3\Payment; +use App\Constants\v3\Shipping; use App\Constants\v3\SsdbKeys; use App\Exception\ErrorCodeException; use App\Model\v3\Coupon; @@ -112,9 +113,10 @@ class OrderOnlineService implements OrderOnlineServiceInterface * @param int $serviceMoney * @param null $receiveCouponIds * @param string $plat + * @param int $selfTake * @return array[] */ - public function do($marketId, $userId, $userAddrId, $storeList, $totalMoney, $deliveryTimeNote='尽快送达', $serviceMoney=0, $receiveCouponIds=null, $plat=''){ + public function do($marketId, $userId, $userAddrId, $storeList, $totalMoney, $deliveryTimeNote='尽快送达', $serviceMoney=0, $receiveCouponIds=null, $plat='', $selfTake=0){ $redis = ApplicationContext::getContainer()->get(Redis::class); $isCacheInventory = false; @@ -138,6 +140,13 @@ class OrderOnlineService implements OrderOnlineServiceInterface $deliveryAmount = $userAddrAndDPrice['distribution_price']; $deliveryDistance = $userAddrAndDPrice['delivery_distance']; + // 配送方式,默认是服务站配送 + $shippingType = Shipping::TYPE_LANZU; + + if ($selfTake == 1) { + $shippingType = Shipping::TYPE_SELF_TAKE; + } + // 优惠券数据,当前订单可用个优惠券 $couponRecs = $this->couponRecService->allForOnlineOrderAvailable($userId, $marketId); $canRealUseCoupons = $couponRecs['available']; @@ -296,6 +305,7 @@ class OrderOnlineService implements OrderOnlineServiceInterface } $dataMain = [ + 'shipping_type' => $shippingType, 'market_id' => $marketId, 'order_num' => $globalOrderId, 'global_order_id' => $globalOrderId, diff --git a/app/Service/v3/Implementations/ParamsTokenSsdbService.php b/app/Service/v3/Implementations/ParamsTokenSsdbService.php new file mode 100644 index 0000000..39850c9 --- /dev/null +++ b/app/Service/v3/Implementations/ParamsTokenSsdbService.php @@ -0,0 +1,68 @@ +get(SSDBTask::class); + + $kvs = []; + foreach ($params as $key => $value) { + $kvs[] = $key; + $kvs[] = $value; + } + + if(false === $ssdb->exec('multi_hset', SsdbKeys::PARAMS_TOKEN.$token, $kvs)) { + throw new ErrorCodeException(ErrorCode::TOKEN_GENERATE_ERROR, 'token生成失败'); + } + + return $token; + } + + /** + * 解析token获取对应数据参数 + * @param $token + */ + public function analyze($token) + { + $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); + $params = $ssdb->exec('hgetall', SsdbKeys::PARAMS_TOKEN.$token); + + if (false === $params) { + + throw new ErrorCodeException(ErrorCode::TOKEN_ANALYZE_ERROR, 'token解析失败'); + } + + if (empty($params)) { + throw new ErrorCodeException(ErrorCode::TOKEN_NOT_EXISTS, 'token不存在'); + } + + return $params; + } + +} \ No newline at end of file diff --git a/app/Service/v3/Interfaces/OrderOnlineServiceInterface.php b/app/Service/v3/Interfaces/OrderOnlineServiceInterface.php index 5c53302..77b3420 100644 --- a/app/Service/v3/Interfaces/OrderOnlineServiceInterface.php +++ b/app/Service/v3/Interfaces/OrderOnlineServiceInterface.php @@ -6,7 +6,7 @@ use Hyperf\Database\Model\Model; interface OrderOnlineServiceInterface { - public function do($marketId, $userId, $userAddrId, $storeList, $totalMoney, $deliveryTimeNote='尽快送达', $serviceMoney, $receiveCouponIds=null, $plat=''); + public function do($marketId, $userId, $userAddrId, $storeList, $totalMoney, $deliveryTimeNote='尽快送达', $serviceMoney, $receiveCouponIds=null, $plat='', $selfTake=0); /** * 订单是否存在,有效 diff --git a/app/Service/v3/Interfaces/ParamsTokenServiceInterface.php b/app/Service/v3/Interfaces/ParamsTokenServiceInterface.php new file mode 100644 index 0000000..66b5cf3 --- /dev/null +++ b/app/Service/v3/Interfaces/ParamsTokenServiceInterface.php @@ -0,0 +1,20 @@ + \App\Service\v3\Implementations\BadgeService::class, \App\Service\v3\Interfaces\InitialDeliveryServiceInterface::class => \App\Service\v3\Implementations\InitialDeliveryService::class, \App\Service\v3\Interfaces\ServiceEvaluateServiceInterface::class => \App\Service\v3\Implementations\ServiceEvaluateService::class, - // \Hyperf\Crontab\Strategy\StrategyInterface::class => \Hyperf\Crontab\Strategy\TaskWorkerStrategy::class, + \App\Service\v3\Interfaces\ParamsTokenServiceInterface::class => \App\Service\v3\Implementations\ParamsTokenSsdbService::class, ]; diff --git a/config/routes.php b/config/routes.php index fa8aa28..11eefa3 100644 --- a/config/routes.php +++ b/config/routes.php @@ -94,6 +94,8 @@ Router::addGroup('/v3/', function () { Router::post('market/services', 'App\Controller\v3\LocationController@getMarketsInfo'); Router::post('home/aboutLanzu', 'App\Controller\v3\HomeController@aboutLanzu'); Router::post('orderOffline/review', 'App\Controller\v3\OrderOfflineController@review'); + Router::post('paramsToken/generate', 'App\Controller\v3\ParamsTokenController@generate'); + Router::post('paramsToken/analyze', 'App\Controller\v3\ParamsTokenController@analyze'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]); // 需要登录的路由