Browse Source

Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix

# Conflicts:
#	app/Model/v3/Goods.php
#	app/Model/v3/GoodsActivity.php
master
Lemon 5 years ago
parent
commit
7480a6ce0f
  1. 12
      app/Constants/v3/ErrorCode.php
  2. 9
      app/Controller/v3/GoodsRecommendController.php
  3. 3
      app/Controller/v3/NotifyController.php
  4. 26
      app/JsonRpc/BadgeService.php
  5. 10
      app/JsonRpc/BadgeServiceInterface.php
  6. 7
      app/Model/v3/Goods.php
  7. 9
      app/Model/v3/GoodsActivity.php
  8. 10
      app/Service/v3/Implementations/BannerService.php
  9. 4
      app/Service/v3/Implementations/GoodsActivityService.php
  10. 4
      app/Service/v3/Implementations/GoodsService.php
  11. 4
      app/Service/v3/Implementations/SearchService.php
  12. 1
      config/autoload/dependencies.php
  13. 4
      config/routes.php

12
app/Constants/v3/ErrorCode.php

@ -144,6 +144,12 @@ class ErrorCode extends AbstractConstants
*/
const STORE_NOT_AVAILABLE = 708;
/**
* 商户已休息
* @Message("当前商户已歇业")
*/
const STORE_REST = 709;
/************************************/
/* 定位相关 751-800 */
/************************************/
@ -242,6 +248,12 @@ class ErrorCode extends AbstractConstants
*/
const GOODS_ACTIVITY_CANNOT_USE_COUPON = 1156;
/**
* 活动商品不存在
* @Message("商品不存在")
*/
const GOODS_ACTIVITY_NOT_EXISTS = 1156;
/************************************/
/* 优惠券相关 1201-1250 */
/************************************/

9
app/Controller/v3/GoodsRecommendController.php

@ -28,7 +28,11 @@ class GoodsRecommendController extends BaseController
$page = $this->request->input('page', 1);
$pagesize = $this->request->input('pagesize', 10);
$builder = Goods::query()->with('store')->where('market_id', $marketId);
$builder = Goods::query()->with('store')
->where('market_id', $marketId)
->where(function ($query) {
$query->where('inventory', '>', 0)->orWhere('is_infinite', '=', 1);
});
switch ($tab) {
case Tabs::APPLET_INDEX_RECOMMEND:
@ -67,6 +71,9 @@ class GoodsRecommendController extends BaseController
$goods = Goods::query()
->with(['store'])
->where('market_id', $marketId)
->where(function ($query) {
$query->where('inventory', '>', 0)->orWhere('is_infinite', '=', 1);
})
->inRandomOrder()
->limit(20)
->get()->toArray();

3
app/Controller/v3/NotifyController.php

@ -323,8 +323,7 @@ class NotifyController extends BaseController
// 查询订单
$orderMain = OrderMain::query()
->whereIn('state', [OrderState::PAID, OrderState::DELIVERY, OrderState::COMPLETED, OrderState::EVALUATED, OrderState::REFUNDING])
->where(['global_order_id' => $message['global_order_id'], 'pay_type' => Payment::WECHAT])
->whereRaw('refund_time is null')
->where(['global_order_id' => $message['global_order_id'], 'pay_type' => Payment::WECHAT, 'refund_time' => 0])
->first();
// 订单不存在

26
app/JsonRpc/BadgeService.php

@ -0,0 +1,26 @@
<?php
namespace App\JsonRpc;
use Hyperf\RpcServer\Annotation\RpcService;
use Hyperf\Di\Annotation\Inject;
/**
* @RpcService(name="BadgeService", protocol="jsonrpc-http", server="jsonrpc-http", publishTo="")
* Class BadgeService
* @package App\JsonRpc
*/
class BadgeService implements BadgeServiceInterface
{
/**
* @Inject
* @var \App\Service\v3\Interfaces\BadgeServiceInterface
*/
protected $badgeService;
public function doByOrder($userId, $storeIds, $globalOrderId, $orderState)
{
// TODO: Implement doByOrder() method.
$this->badgeService->doByOrder($userId, $storeIds, $globalOrderId, $orderState);
}
}

10
app/JsonRpc/BadgeServiceInterface.php

@ -0,0 +1,10 @@
<?php
namespace App\JsonRpc;
interface BadgeServiceInterface
{
public function doByOrder($userId, $storeIds, $globalOrderId, $orderState);
}

7
app/Model/v3/Goods.php

@ -100,8 +100,7 @@ class Goods extends Model
public function getCartNumAttribute()
{
$userId = $this->request->user->id ?? 0;
return $userId ? (integer)$this->shopCartService->check($userId, $this->id,1) : 0;
return 0;
}
public function getIsEffectiveAttribute()
@ -134,8 +133,4 @@ class Goods extends Model
return $this->morphMany(ShoppingCart::class, 'goods');
}
public function getNameAttribute()
{
return $this->attributes['name'].' '.$this->attributes['goods_unit'];
}
}

9
app/Model/v3/GoodsActivity.php

@ -2,7 +2,6 @@
namespace App\Model\v3;
use App\Constants\v3\Goods;
use App\Constants\v3\Goods as GoodsConstants;
use App\Constants\v3\SsdbKeys;
use App\Model\Model;
@ -69,8 +68,7 @@ class GoodsActivity extends Model
public function getCartNumAttribute()
{
$userId = $this->request->user->id ?? 0;
return $userId ? (integer)$this->shopCartService->check($userId, $this->id,Goods::IS_ACTIVITY) : 0;
return 0;
}
public function getIsEffectiveAttribute()
@ -112,9 +110,4 @@ class GoodsActivity extends Model
return $img_host . $item;
});
}
public function getNameAttribute()
{
return $this->attributes['name'].' '.$this->attributes['goods_unit'];
}
}

10
app/Service/v3/Implementations/BannerService.php

@ -10,11 +10,11 @@ class BannerService implements BannerServiceInterface
public function all($type, $marketId)
{
$builder = Banner::query()
->where(['type' => $type]);
if ($marketId != -1) {
$builder = $builder->whereJsonContains('market_ids', [(string)$marketId]);
}
->where(['type' => $type])
->where(function ($query) use ($marketId) {
$query->whereJsonContains('market_ids', [(string)$marketId])
->orWhereJsonLength('market_ids', '=', 0);
});
return $builder->get()->toArray();
}

4
app/Service/v3/Implementations/GoodsActivityService.php

@ -24,7 +24,7 @@ class GoodsActivityService implements GoodsActivityServiceInterface
{
if (empty($goods)) {
return ErrorCode::GOODS_ACTIVITY_ON_SALE_NO;
return ErrorCode::GOODS_ACTIVITY_NOT_EXISTS;
}
// 活动是否已经结束
@ -34,7 +34,7 @@ class GoodsActivityService implements GoodsActivityServiceInterface
// 商户歇业
if($goods->store->is_rest == 1){
return ErrorCode::GOODS_ACTIVITY_ON_SALE_NO;
return ErrorCode::STORE_REST;
}
// 商品下架或已删除

4
app/Service/v3/Implementations/GoodsService.php

@ -21,12 +21,12 @@ class GoodsService implements GoodsServiceInterface
{
if (empty($goods)) {
return ErrorCode::GOODS_ON_SALE_NO;
return ErrorCode::GOODS_NOT_EXISTS;
}
// 商户歇业
if($goods->store->is_rest == 1){
return ErrorCode::GOODS_ON_SALE_NO;
return ErrorCode::STORE_REST;
}
// 商品下架或已删除
if($goods->on_sale == 0 || !is_null($goods->deleted_at)){

4
app/Service/v3/Implementations/SearchService.php

@ -19,7 +19,9 @@ class SearchService implements \App\Service\v3\Interfaces\SearchServiceInterface
return $query->select(['id', 'logo', 'name']);
}])
->where(['market_id' => $params['market_id']])
->where('inventory', '>', 0);
->where(function ($query) {
$query->where('inventory', '>', 0)->orWhere('is_infinite', '=', 1);
});;
if (isset($params['type_id']) && $params['type_id']) {
$typeIds = explode(',', $params['type_id']);

1
config/autoload/dependencies.php

@ -81,6 +81,7 @@ return [
\App\Service\v3\Interfaces\AttachmentServiceInterface::class => \App\Service\v3\Implementations\AttachmentService::class,
\App\JsonRpc\PrintServiceInterface::class => \App\JsonRpc\FeieService::class,
\App\JsonRpc\LocationServiceInterface::class => \App\JsonRpc\LocationService::class,
\App\JsonRpc\BadgeServiceInterface::class => \App\JsonRpc\BadgeService::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\BadgeServiceInterface::class => \App\Service\v3\Implementations\BadgeService::class,

4
config/routes.php

@ -141,6 +141,10 @@ Router::addGroup('/v3/', function () {
Router::post('userAddress/getAddressAndDistributionPrice', 'App\Controller\v3\UserAddressController@getAddressAndDistributionPrice');
Router::post('withdraw/applyByStore', 'App\Controller\v3\WithdrawController@applyByStore');
Router::post('community/bind', 'App\Controller\v3\CommunityController@bind');
Router::post('serviceEvaluate/evaluate', 'App\Controller\ServiceEvaluateController@evaluate');
Router::post('serviceEvaluate/isPersonnel', 'App\Controller\ServiceEvaluateController@isPersonnel');
Router::post('serviceEvaluate/getPersonnelInfo', 'App\Controller\ServiceEvaluateController@getPersonnelInfo');
Router::post('serviceEvaluate/getEvaluateList', 'App\Controller\ServiceEvaluateController@getEvaluateList');
},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]);
// 微信支付回调

Loading…
Cancel
Save