Browse Source

Merge branch 'phoenix' of ssh://120.24.33.109:11022/hyzjshwo/lanzu_api_hyperf into phoenix

# Conflicts:
#	app/Service/v3/Implementations/GoodsActivityService.php
#	app/Service/v3/Interfaces/GoodsActivityServiceInterface.php
#	config/autoload/dependencies.php
#	config/routes.php
master
weigang 5 years ago
parent
commit
26440cbb0d
  1. 28
      app/Constants/v3/Withdrawal.php
  2. 15
      app/Controller/v3/BalanceStatementController.php
  3. 18
      app/Controller/v3/GoodsController.php
  4. 19
      app/Controller/v3/SearchController.php
  5. 8
      app/Model/v3/GoodsActivity.php
  6. 10
      app/Model/v3/GoodsActivityBanner.php
  7. 15
      app/Model/v3/GoodsBanner.php
  8. 9
      app/Model/v3/Order.php
  9. 19
      app/Model/v3/StoreWithdrawal.php
  10. 7
      app/Service/v3/Implementations/CategoryService.php
  11. 14
      app/Service/v3/Implementations/GoodsActivityService.php
  12. 13
      app/Service/v3/Implementations/GoodsService.php
  13. 13
      app/Service/v3/Implementations/LocationService.php
  14. 41
      app/Service/v3/Implementations/OrderListService.php
  15. 13
      app/Service/v3/Implementations/RevenueListService.php
  16. 21
      app/Service/v3/Implementations/ShopCartService.php
  17. 29
      app/Service/v3/Implementations/WithdrawalListService.php
  18. 3
      app/Service/v3/Interfaces/GoodsActivityServiceInterface.php
  19. 2
      app/Service/v3/Interfaces/GoodsServiceInterface.php
  20. 1
      app/Service/v3/Interfaces/LocationServiceInterface.php
  21. 2
      app/Service/v3/Interfaces/RevenueListServiceInterface.php
  22. 2
      app/Service/v3/Interfaces/ShopCartServiceInterface.php
  23. 13
      app/Service/v3/Interfaces/WithdrawalListServiceInterface.php
  24. 1
      config/autoload/dependencies.php
  25. 2
      config/routes.php

28
app/Constants/v3/Withdrawal.php

@ -0,0 +1,28 @@
<?php
namespace App\Constants\v3;
use Hyperf\Constants\AbstractConstants;
use Hyperf\Constants\Annotation\Constants;
/**
* @Constants
*/
class Withdrawal extends AbstractConstants
{
/**
* @Message("待审核")
*/
const EXAMINE = 1;
/**
* @Message("已通过")
*/
const ACCEPT = 2;
/**
* @Message("已拒绝")
*/
const REFUSE = 3;
}

15
app/Controller/v3/BalanceStatementController.php

@ -5,6 +5,7 @@ namespace App\Controller\v3;
use App\Controller\BaseController; use App\Controller\BaseController;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\RevenueListServiceInterface; use App\Service\v3\Interfaces\RevenueListServiceInterface;
use App\Service\v3\Interfaces\WithdrawalListServiceInterface;
class BalanceStatementController extends BaseController class BalanceStatementController extends BaseController
{ {
@ -13,9 +14,21 @@ class BalanceStatementController extends BaseController
* @var RevenueListServiceInterface * @var RevenueListServiceInterface
*/ */
protected $revenueListService; protected $revenueListService;
/**
* @Inject
* @var WithdrawalListServiceInterface
*/
protected $withdrawalListService;
public function getRevenueListByUser() public function getRevenueListByUser()
{ {
$params = $this->request->all(); $params = $this->request->all();
return $this->success($this->revenueListService->check(46));
return $this->success($this->revenueListService->getListByUser(46));
}
public function getWithdrawalListByStore()
{
$params = $this->request->all();
return $this->success($this->withdrawalListService->getListByStore(7));
} }
} }

18
app/Controller/v3/GoodsController.php

@ -3,6 +3,7 @@
namespace App\Controller\v3; namespace App\Controller\v3;
use App\Controller\BaseController; use App\Controller\BaseController;
use App\Service\v3\Interfaces\ShopCartServiceInterface;
use App\Service\v3\Implementations\GoodsActivityService; use App\Service\v3\Implementations\GoodsActivityService;
use App\Service\v3\Interfaces\CollectStoreServiceInterface; use App\Service\v3\Interfaces\CollectStoreServiceInterface;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
@ -29,20 +30,29 @@ class GoodsController extends BaseController
*/ */
protected $collectService; protected $collectService;
/**
* @Inject
* @var ShopCartServiceInterface
*/
protected $shopCartService;
public function detail() public function detail()
{ {
$params = $this->request->all(); $params = $this->request->all();
//判断是普通商品还是特价商品 //判断是普通商品还是特价商品
if(isset($params['activity']) && $params['activity'] == Goods::IS_ACTIVITY){ if(isset($params['activity']) && $params['activity'] == Goods::IS_ACTIVITY){
$res['detail'] = $this->goodsActivityService->do($params['goods_id']);
$res['banner'] = $this->goodsActivityService->getBanner();
$res['detail'] = $this->goodsActivityService->detail($params['goods_id']);
$res['banner'] = $this->goodsActivityService->getBanner(1572);
}else{ }else{
$res['detail'] = $this->goodsService->do($params['goods_id']);
$res['banner'] = $this->goodsService->getBanner();
$res['detail'] = $this->goodsService->detail($params['goods_id']);
$res['banner'] = $this->goodsService->getBanner(1572);
} }
if(isset($params['user_id'])) { if(isset($params['user_id'])) {
$res['shopcart']['count'] = $this->shopCartService->check(111);
$res['shopcart']['total'] = $this->shopCartService->getTotal();
$res['detail']->store->is_collected = (bool)$this->collectService->check($params['user_id'], $params['store_id']); $res['detail']->store->is_collected = (bool)$this->collectService->check($params['user_id'], $params['store_id']);
}else{ }else{
$res['shopcart'] = '';
$res['detail']->store->is_collected = ''; $res['detail']->store->is_collected = '';
} }
return $this->success($res); return $this->success($res);

19
app/Controller/v3/SearchController.php

@ -5,6 +5,7 @@ namespace App\Controller\v3;
use App\Controller\BaseController; use App\Controller\BaseController;
use App\Request\v3\SearchGoodsRequest; use App\Request\v3\SearchGoodsRequest;
use App\Request\v3\SearchStoreRequest; use App\Request\v3\SearchStoreRequest;
use App\Service\v3\Interfaces\LocationServiceInterface;
use App\Service\v3\Interfaces\SearchServiceInterface; use App\Service\v3\Interfaces\SearchServiceInterface;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
@ -17,6 +18,12 @@ class SearchController extends BaseController
*/ */
protected $searchService; protected $searchService;
/**
* @Inject
* @var LocationServiceInterface
*/
protected $locationService;
/** /**
* 获取搜索热词 * 获取搜索热词
* 1、参数type区分是商品还是商户 * 1、参数type区分是商品还是商户
@ -62,4 +69,16 @@ class SearchController extends BaseController
return $this->success(['stores' => $data]); return $this->success(['stores' => $data]);
} }
/**
* 市场搜索
*
*/
public function market()
{
$keywords = $this->request->input('keywords','');
$cityId = $this->request->input('city_id',2163);
$data = $this->locationService->searchMarket($keywords,$cityId);
return $this->success(['markets' => $data]);
}
} }

8
app/Model/v3/GoodsActivity.php

@ -39,10 +39,10 @@ class GoodsActivity extends Model
'total_seconds', 'total_seconds',
]; ];
protected $visible = [
'id', 'cover_img', 'name', 'original_price', 'price', 'inventory', 'store_id', 'spec', 'tags', 'sales',
'month_sales', 'cart_num', 'is_effective', 'noneffective_note', 'total_seconds',
];
// protected $visible = [
// 'id', 'cover_img', 'name', 'original_price', 'price', 'inventory', 'store_id', 'spec', 'tags', 'sales',
// 'month_sales', 'cart_num', 'is_effective', 'noneffective_note', 'total_seconds','store_id'
// ];
protected function boot(): void protected function boot(): void
{ {

10
app/Model/v3/GoodsActivityBanner.php

@ -11,4 +11,14 @@ class GoodsActivityBanner extends Model
use SoftDeletes; use SoftDeletes;
protected $table = 'lanzu_goods_activity_banners'; protected $table = 'lanzu_goods_activity_banners';
public function getBannerUrlAttribute()
{
$url = $this->attributes['path'];
if(strripos($url,"http") === false){
return config('alioss.img_host').'/'.$url;
}else{
return $url;
}
}
} }

15
app/Model/v3/GoodsBanner.php

@ -10,4 +10,19 @@ class GoodsBanner extends Model
{ {
use SoftDeletes; use SoftDeletes;
protected $table = 'lanzu_goods_banners'; protected $table = 'lanzu_goods_banners';
protected $appends = [
'banner_url',
];
public function getBannerUrlAttribute()
{
$url = $this->attributes['path'];
if(strripos($url,"http") === false){
return config('alioss.img_host').'/'.$url;
}else{
return $url;
}
}
} }

9
app/Model/v3/Order.php

@ -8,6 +8,15 @@ class Order extends Model
{ {
protected $table = 'lanzu_order'; protected $table = 'lanzu_order';
protected $appends = [
'created_at_text',
];
public function getCreatedAtTextAttribute()
{
return date('Y-m-d H:i:s', $this->attributes['created_at']);
}
public function orderGoods() public function orderGoods()
{ {
return $this->hasMany(OrderGoods::class, 'order_id', 'id'); return $this->hasMany(OrderGoods::class, 'order_id', 'id');

19
app/Model/v3/StoreWithdrawal.php

@ -0,0 +1,19 @@
<?php
namespace App\Model\v3;
use App\Model\Model;
use App\Constants\v3\Withdrawal;
class StoreWithdrawal extends Model
{
protected $table = 'lanzu_store_withdrawal';
protected $appends = [
'state_text',
];
public function getStateTextAttribute()
{
return Withdrawal::getMessage($this->attributes['state']);
}
}

7
app/Service/v3/Implementations/CategoryService.php

@ -58,7 +58,12 @@ class CategoryService implements CategoryServiceInterface
$returnData = []; $returnData = [];
foreach ($categories as $key => &$category) { foreach ($categories as $key => &$category) {
$value = json_decode($category, true); $value = json_decode($category, true);
$returnData[] = ['id' => $key, 'icon' => config('alioss.img_host').$value['icon'].OssThumbnail::THUMBNAIL_100_Q50, 'name' => $value['name']];
$iconUrl = $value['icon'];
if(strripos($iconUrl,"http") === false){
$iconUrl = config('alioss.img_host').'/'.$value['icon'];
}
$iconUrl = $iconUrl . OssThumbnail::THUMBNAIL_100_Q50;
$returnData[] = ['id' => $key, 'icon' => $iconUrl , 'name' => $value['name']];
} }
return $returnData; return $returnData;

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

@ -7,7 +7,6 @@ use App\Constants\v3\ErrorCode;
use App\Constants\v3\SsdbKeys; use App\Constants\v3\SsdbKeys;
use App\Service\v3\Interfaces\GoodsActivityServiceInterface; use App\Service\v3\Interfaces\GoodsActivityServiceInterface;
use App\TaskWorker\SSDBTask; use App\TaskWorker\SSDBTask;
use Hyperf\DbConnection\Db;
use App\Constants\v3\Store; use App\Constants\v3\Store;
use App\Constants\v3\Goods; use App\Constants\v3\Goods;
use App\Model\v3\GoodsActivity; use App\Model\v3\GoodsActivity;
@ -18,8 +17,7 @@ class GoodsActivityService implements GoodsActivityServiceInterface
{ {
public function do($goodsId) public function do($goodsId)
{ {
$res = GoodsActivity::query()->with('store')->where('id',$goodsId)->first();
return $res;
} }
@ -67,12 +65,18 @@ class GoodsActivityService implements GoodsActivityServiceInterface
// TODO: Implement undo() method. // TODO: Implement undo() method.
} }
public function getBanner()
public function getBanner($goodsId)
{ {
$banner = GoodsActivityBanner::query()->where('goods_id',1572)->get();
$banner = GoodsActivityBanner::query()->where('goods_id',$goodsId)->orderByDesc('type')->get();
return $banner; return $banner;
} }
public function detail($goodsId)
{
$res = GoodsActivity::query()->with('store')->where('id',$goodsId)->first();
return $res;
}
public function cacheRecord($goodsId, $num, $userId) public function cacheRecord($goodsId, $num, $userId)
{ {

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

@ -13,8 +13,7 @@ class GoodsService implements GoodsServiceInterface
{ {
public function do($goodsId) public function do($goodsId)
{ {
$res = Goods::query()->with('store')->where('id',$goodsId)->first();
return $res;
} }
@ -41,9 +40,15 @@ class GoodsService implements GoodsServiceInterface
// TODO: Implement undo() method. // TODO: Implement undo() method.
} }
public function getBanner()
public function getBanner($goodsId)
{ {
$banner = GoodsBanner::query()->where('goods_id',1572)->get();
$banner = GoodsBanner::query()->where('goods_id',$goodsId)->orderByDesc('type')->get();
return $banner; return $banner;
} }
public function detail($goodsId)
{
$res = Goods::query()->with('store')->where('id',$goodsId)->first();
return $res;
}
} }

13
app/Service/v3/Implementations/LocationService.php

@ -35,6 +35,19 @@ class LocationService implements LocationServiceInterface
return $res; return $res;
} }
public function searchMarket($keywords,$cityId = 2163)
{
$res = Market::query()->where([
['name','like','%'.$keywords.'%'],
['city_id','=',$cityId]
])
->get();
foreach ($res as &$v){
$v->Distance = $this->getDistance($v->lng,$v->lat,108.370333,22.813527);
}
return $res;
}
function getDistance($lng1, $lat1, $lng2, $lat2, $unit = 2, $decimal = 2) function getDistance($lng1, $lat1, $lng2, $lat2, $unit = 2, $decimal = 2)
{ {

41
app/Service/v3/Implementations/OrderListService.php

@ -58,14 +58,26 @@ class OrderListService implements OrderListServiceInterface
public function onlineByStore($storeId, $tab, $page=1, $pagesize=10) public function onlineByStore($storeId, $tab, $page=1, $pagesize=10)
{ {
$builder = OrderMain::query()
->select('id','global_order_id', 'money', 'state', 'market_id', 'created_at')
->with(['orders' => function($query) use ($storeId) {
$query->where('store_id',$storeId)->with('orderGoods');
}])
->where([
'type' => 1
]);
$builder = Order::Join('lanzu_order_main','lanzu_order.order_main_id','lanzu_order_main.id')
->select(
'lanzu_order.*',
'lanzu_order_main.address',
'lanzu_order_main.name',
'lanzu_order_main.delivery_time_note',
'lanzu_order_main.shipping_type',
'lanzu_order_main.global_order_id'
)
->with('orderGoods')
->where('lanzu_order.store_id', $storeId)
->where('lanzu_order_main.type',1);
$sw = [
'all'=>'',
'completed'=> OrderState::FINISH,
'unpaid'=> OrderState::UNPAID,
'receiving' => OrderState::RECEIVING,
'refund' => OrderState::REFUND
];
switch ($tab) { switch ($tab) {
case 'all': case 'all':
break; break;
@ -85,7 +97,18 @@ class OrderListService implements OrderListServiceInterface
$paginate = $builder->paginate($pagesize); $paginate = $builder->paginate($pagesize);
$orders = $paginate->toArray(); $orders = $paginate->toArray();
return ['has_more_pages' => $paginate->hasMorePages(), 'orders' => $orders['data']];
$res = ['has_more_pages' => $paginate->hasMorePages(), 'orders' => $orders['data']];
foreach ($res['orders'] as &$v){
switch ($v['shipping_type']) {
case 1:
$v['delivery_text'] = '服务站配送';
break;
case 2:
$v['delivery_text'] = '达达配送';
break;
}
}
return $res;
} }
public function offlineByStore($storeId, $tab, $page=1, $pagesize=10) public function offlineByStore($storeId, $tab, $page=1, $pagesize=10)

13
app/Service/v3/Implementations/RevenueListService.php

@ -15,14 +15,19 @@ class RevenueListService implements RevenueListServiceInterface
public function check($userId) public function check($userId)
{ {
$financialRecord = new FinancialRecord();
$mod = bcmod((string)$userId, '5', 0);
$financialRecord->suffix($mod);
return $financialRecord::query()->get();
} }
public function undo() public function undo()
{ {
// TODO: Implement undo() method. // TODO: Implement undo() method.
} }
public function getListByUser($userId)
{
$financialRecord = new FinancialRecord();
$mod = bcmod((string)$userId, '5', 0);
$financialRecord->suffix($mod);
return $financialRecord::query()->get();
}
} }

21
app/Service/v3/Implementations/ShopCartService.php

@ -36,6 +36,21 @@ class ShopCartService implements ShopCartServiceInterface
->get(); ->get();
foreach ($res as &$k){ foreach ($res as &$k){
$k->subtotal = '99.90'; $k->subtotal = '99.90';
foreach ($k->ShoppingCart as &$v){
switch (mt_rand(1,3)) {
case 1:
$str = '已下架';
break;
case 2:
$str = '已抢光';
break;
case 3:
$str = '已打烊';
break;
}
$v['goods']['invalid_cause'] = $str;
}
} }
return $res; return $res;
} }
@ -44,4 +59,10 @@ class ShopCartService implements ShopCartServiceInterface
{ {
return mt_rand(1,100); return mt_rand(1,100);
} }
public function getTotal()
{
$randomFloat = rand(100,999)/100;
return $randomFloat;
}
} }

29
app/Service/v3/Implementations/WithdrawalListService.php

@ -0,0 +1,29 @@
<?php
namespace App\Service\v3\Implementations;
use App\Service\v3\Interfaces\WithdrawalListServiceInterface;
use App\Model\v3\StoreWithdrawal;
class WithdrawalListService implements WithdrawalListServiceInterface
{
public function do()
{
// TODO: Implement do() method.
}
public function check()
{
// TODO: Implement check() method.
}
public function undo()
{
// TODO: Implement undo() method.
}
public function getListByStore($storeId)
{
$res = StoreWithdrawal::query()->where('store_id',$storeId)->get();
return $res;
}
}

3
app/Service/v3/Interfaces/GoodsActivityServiceInterface.php

@ -7,6 +7,7 @@ interface GoodsActivityServiceInterface
public function do($goodsId); public function do($goodsId);
public function check($goodsId,$num,$userId); public function check($goodsId,$num,$userId);
public function undo(); public function undo();
public function getBanner();
public function getBanner($goodsId);
public function detail($goodsId);
public function checkOrderActivityCount($orderGoods, $limitNum=1); public function checkOrderActivityCount($orderGoods, $limitNum=1);
} }

2
app/Service/v3/Interfaces/GoodsServiceInterface.php

@ -7,5 +7,5 @@ interface GoodsServiceInterface
public function do($goodsId); public function do($goodsId);
public function check($goodsId,$num = 1); public function check($goodsId,$num = 1);
public function undo(); public function undo();
public function getBanner();
public function getBanner($goodsId);
} }

1
app/Service/v3/Interfaces/LocationServiceInterface.php

@ -10,4 +10,5 @@ interface LocationServiceInterface
public function check(); public function check();
public function undo(); public function undo();
public function getMarketListByLocation($cityIds); public function getMarketListByLocation($cityIds);
public function searchMarket($key,$cityId = 2163);
} }

2
app/Service/v3/Interfaces/RevenueListServiceInterface.php

@ -11,4 +11,6 @@ interface RevenueListServiceInterface
public function check($userId); public function check($userId);
public function undo(); public function undo();
public function getListByUser($userId);
} }

2
app/Service/v3/Interfaces/ShopCartServiceInterface.php

@ -11,4 +11,6 @@ interface ShopCartServiceInterface
public function undo(); public function undo();
public function countGoods(); public function countGoods();
public function getTotal();
} }

13
app/Service/v3/Interfaces/WithdrawalListServiceInterface.php

@ -0,0 +1,13 @@
<?php
namespace App\Service\v3\Interfaces;
interface WithdrawalListServiceInterface
{
public function do();
public function check();
public function undo();
public function getListByStore($storeId);
}

1
config/autoload/dependencies.php

@ -65,4 +65,5 @@ return [
\App\Service\v3\Interfaces\RevenueListServiceInterface::class => \App\Service\v3\Implementations\RevenueListService::class, \App\Service\v3\Interfaces\RevenueListServiceInterface::class => \App\Service\v3\Implementations\RevenueListService::class,
\App\Service\v3\Interfaces\CouponRecServiceInterface::class => \App\Service\v3\Implementations\CouponRecService::class, \App\Service\v3\Interfaces\CouponRecServiceInterface::class => \App\Service\v3\Implementations\CouponRecService::class,
\App\Service\v3\Interfaces\PaymentServiceInterface::class => \App\Service\v3\Implementations\PaymentService::class, \App\Service\v3\Interfaces\PaymentServiceInterface::class => \App\Service\v3\Implementations\PaymentService::class,
\App\Service\v3\Interfaces\WithdrawalListServiceInterface::class => \App\Service\v3\Implementations\WithdrawalListService::class,
]; ];

2
config/routes.php

@ -90,6 +90,7 @@ Router::addGroup('/v3/', function () {
Router::post('search/stores', 'App\Controller\v3\SearchController@stores'); Router::post('search/stores', 'App\Controller\v3\SearchController@stores');
Router::post('goodsRecommend/getByTab', 'App\Controller\v3\GoodsRecommendController@getByTab'); Router::post('goodsRecommend/getByTab', 'App\Controller\v3\GoodsRecommendController@getByTab');
Router::post('store/index', 'App\Controller\v3\StoreController@index'); Router::post('store/index', 'App\Controller\v3\StoreController@index');
Router::post('Search/market', 'App\Controller\v3\SearchController@market');
},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]);
// 需要登录的路由 // 需要登录的路由
@ -115,5 +116,6 @@ Router::addGroup('/v3/', function () {
Router::post('collectStore/getListByUser', 'App\Controller\v3\CollectStoreController@getListByUser'); Router::post('collectStore/getListByUser', 'App\Controller\v3\CollectStoreController@getListByUser');
Router::post('balanceStatement/getRevenueListByUser', 'App\Controller\v3\BalanceStatementController@getRevenueListByUser'); Router::post('balanceStatement/getRevenueListByUser', 'App\Controller\v3\BalanceStatementController@getRevenueListByUser');
Router::post('orderOnline/add', 'App\Controller\v3\OrderOnlineController@add'); Router::post('orderOnline/add', 'App\Controller\v3\OrderOnlineController@add');
Router::post('store/storeWithdrawalList', 'App\Controller\v3\BalanceStatementController@getWithdrawalListByStore');
Router::post('payment/wechatpayOnline', 'App\Controller\v3\PaymentController@wechatpayOnline'); Router::post('payment/wechatpayOnline', 'App\Controller\v3\PaymentController@wechatpayOnline');
},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]);
Loading…
Cancel
Save