From a1553dbfb6bc932c5bf798a27efbd86fc0ed8b0d Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 5 Sep 2020 11:18:46 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=95=86=E5=93=81?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=BA=97=E9=93=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=E8=BF=94=E5=9B=9E=E8=B4=AD=E7=89=A9=E8=BD=A6=E6=80=BB?= =?UTF-8?q?=E4=BB=B7=20=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/GoodsController.php | 13 +++++++++++-- app/Model/v3/GoodsActivity.php | 8 ++++---- .../v3/Implementations/GoodsActivityService.php | 9 +++++++-- app/Service/v3/Implementations/GoodsService.php | 9 +++++++-- app/Service/v3/Implementations/ShopCartService.php | 6 ++++++ .../v3/Interfaces/GoodsActivityServiceInterface.php | 1 + .../v3/Interfaces/ShopCartServiceInterface.php | 2 ++ 7 files changed, 38 insertions(+), 10 deletions(-) diff --git a/app/Controller/v3/GoodsController.php b/app/Controller/v3/GoodsController.php index 7e647e7..4f620f8 100644 --- a/app/Controller/v3/GoodsController.php +++ b/app/Controller/v3/GoodsController.php @@ -3,6 +3,7 @@ namespace App\Controller\v3; use App\Controller\BaseController; +use App\Service\v3\Interfaces\ShopCartServiceInterface; use App\Service\v3\Implementations\GoodsActivityService; use App\Service\v3\Interfaces\CollectStoreServiceInterface; use Hyperf\Di\Annotation\Inject; @@ -29,18 +30,26 @@ class GoodsController extends BaseController */ protected $collectService; + /** + * @Inject + * @var ShopCartServiceInterface + */ + protected $shopCartService; + public function detail() { $params = $this->request->all(); //判断是普通商品还是特价商品 if(isset($params['activity']) && $params['activity'] == Goods::IS_ACTIVITY){ - $res['detail'] = $this->goodsActivityService->do($params['goods_id']); + $res['detail'] = $this->goodsActivityService->detail($params['goods_id']); $res['banner'] = $this->goodsActivityService->getBanner(); }else{ - $res['detail'] = $this->goodsService->do($params['goods_id']); + $res['detail'] = $this->goodsService->detail($params['goods_id']); $res['banner'] = $this->goodsService->getBanner(); } if(isset($params['user_id'])) { + $res['shopcart']['check'] = $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']); }else{ $res['detail']->store->is_collected = ''; diff --git a/app/Model/v3/GoodsActivity.php b/app/Model/v3/GoodsActivity.php index b7b3bf9..ccff8c3 100644 --- a/app/Model/v3/GoodsActivity.php +++ b/app/Model/v3/GoodsActivity.php @@ -39,10 +39,10 @@ class GoodsActivity extends Model '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 { diff --git a/app/Service/v3/Implementations/GoodsActivityService.php b/app/Service/v3/Implementations/GoodsActivityService.php index 8938dd7..c83dfc1 100644 --- a/app/Service/v3/Implementations/GoodsActivityService.php +++ b/app/Service/v3/Implementations/GoodsActivityService.php @@ -12,8 +12,7 @@ class GoodsActivityService implements GoodsActivityServiceInterface { public function do($goodsId) { - $res = GoodsActivity::query()->with('store')->where('id',$goodsId)->first(); - return $res; + } @@ -50,4 +49,10 @@ class GoodsActivityService implements GoodsActivityServiceInterface $banner = GoodsActivityBanner::query()->where('goods_id',1572)->get(); return $banner; } + + public function detail($goodsId) + { + $res = GoodsActivity::query()->with('store')->where('id',$goodsId)->first(); + return $res; + } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/GoodsService.php b/app/Service/v3/Implementations/GoodsService.php index 082359c..64bdd99 100644 --- a/app/Service/v3/Implementations/GoodsService.php +++ b/app/Service/v3/Implementations/GoodsService.php @@ -12,8 +12,7 @@ class GoodsService implements GoodsServiceInterface { public function do($goodsId) { - $res = Goods::query()->with('store')->where('id',$goodsId)->first(); - return $res; + } @@ -45,4 +44,10 @@ class GoodsService implements GoodsServiceInterface $banner = GoodsBanner::query()->where('goods_id',1572)->get(); return $banner; } + + public function detail($goodsId) + { + $res = Goods::query()->with('store')->where('id',$goodsId)->first(); + return $res; + } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/ShopCartService.php b/app/Service/v3/Implementations/ShopCartService.php index 9b1380e..83c426b 100644 --- a/app/Service/v3/Implementations/ShopCartService.php +++ b/app/Service/v3/Implementations/ShopCartService.php @@ -44,4 +44,10 @@ class ShopCartService implements ShopCartServiceInterface { return mt_rand(1,100); } + + public function getTotal() + { + $randomFloat = rand(100,999)/100; + return $randomFloat; + } } \ No newline at end of file diff --git a/app/Service/v3/Interfaces/GoodsActivityServiceInterface.php b/app/Service/v3/Interfaces/GoodsActivityServiceInterface.php index 3ed8c71..7084c83 100644 --- a/app/Service/v3/Interfaces/GoodsActivityServiceInterface.php +++ b/app/Service/v3/Interfaces/GoodsActivityServiceInterface.php @@ -8,4 +8,5 @@ interface GoodsActivityServiceInterface public function check($goodsId,$num = 1); public function undo(); public function getBanner(); + public function detail($goodsId); } \ No newline at end of file diff --git a/app/Service/v3/Interfaces/ShopCartServiceInterface.php b/app/Service/v3/Interfaces/ShopCartServiceInterface.php index 30c8975..eb9c0cc 100644 --- a/app/Service/v3/Interfaces/ShopCartServiceInterface.php +++ b/app/Service/v3/Interfaces/ShopCartServiceInterface.php @@ -11,4 +11,6 @@ interface ShopCartServiceInterface public function undo(); public function countGoods(); + + public function getTotal(); } \ No newline at end of file From 5e1ee6981705b31aa0afe9267128fdaa7eebd505 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 5 Sep 2020 11:25:04 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/GoodsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controller/v3/GoodsController.php b/app/Controller/v3/GoodsController.php index 4f620f8..dd98e2f 100644 --- a/app/Controller/v3/GoodsController.php +++ b/app/Controller/v3/GoodsController.php @@ -48,7 +48,7 @@ class GoodsController extends BaseController $res['banner'] = $this->goodsService->getBanner(); } if(isset($params['user_id'])) { - $res['shopcart']['check'] = $this->shopCartService->check(111); + $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']); }else{ From 8d1670616c48ae89c8d8ddfe3ce58910608caaf9 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 5 Sep 2020 11:27:25 +0800 Subject: [PATCH 03/14] test --- app/Controller/v3/GoodsController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Controller/v3/GoodsController.php b/app/Controller/v3/GoodsController.php index dd98e2f..b6298fe 100644 --- a/app/Controller/v3/GoodsController.php +++ b/app/Controller/v3/GoodsController.php @@ -52,6 +52,7 @@ class GoodsController extends BaseController $res['shopcart']['total'] = $this->shopCartService->getTotal(); $res['detail']->store->is_collected = (bool)$this->collectService->check($params['user_id'], $params['store_id']); }else{ + $res['shopcart'] = ''; $res['detail']->store->is_collected = ''; } return $this->success($res); From d8e637786e6e00fe506703a400f93d67e1e42b1d Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 5 Sep 2020 12:33:32 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E6=8F=90=E7=8E=B0=E6=98=8E=E7=BB=86mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constants/v3/Withdrawal.php | 28 ++++++++++++++++++ .../v3/BalanceStatementController.php | 15 +++++++++- app/Model/v3/StoreWithdrawal.php | 19 ++++++++++++ .../v3/Implementations/RevenueListService.php | 13 ++++++--- .../Implementations/WithdrawalListService.php | 29 +++++++++++++++++++ .../RevenueListServiceInterface.php | 2 ++ .../WithdrawalListServiceInterface.php | 13 +++++++++ config/autoload/dependencies.php | 1 + config/routes.php | 1 + 9 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 app/Constants/v3/Withdrawal.php create mode 100644 app/Model/v3/StoreWithdrawal.php create mode 100644 app/Service/v3/Implementations/WithdrawalListService.php create mode 100644 app/Service/v3/Interfaces/WithdrawalListServiceInterface.php diff --git a/app/Constants/v3/Withdrawal.php b/app/Constants/v3/Withdrawal.php new file mode 100644 index 0000000..53da40e --- /dev/null +++ b/app/Constants/v3/Withdrawal.php @@ -0,0 +1,28 @@ +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)); } } \ No newline at end of file diff --git a/app/Model/v3/StoreWithdrawal.php b/app/Model/v3/StoreWithdrawal.php new file mode 100644 index 0000000..72d1654 --- /dev/null +++ b/app/Model/v3/StoreWithdrawal.php @@ -0,0 +1,19 @@ +attributes['state']); + } +} \ No newline at end of file diff --git a/app/Service/v3/Implementations/RevenueListService.php b/app/Service/v3/Implementations/RevenueListService.php index aefe342..563f8dc 100644 --- a/app/Service/v3/Implementations/RevenueListService.php +++ b/app/Service/v3/Implementations/RevenueListService.php @@ -15,14 +15,19 @@ class RevenueListService implements RevenueListServiceInterface public function check($userId) { - $financialRecord = new FinancialRecord(); - $mod = bcmod((string)$userId, '5', 0); - $financialRecord->suffix($mod); - return $financialRecord::query()->get(); + } public function undo() { // TODO: Implement undo() method. } + + public function getListByUser($userId) + { + $financialRecord = new FinancialRecord(); + $mod = bcmod((string)$userId, '5', 0); + $financialRecord->suffix($mod); + return $financialRecord::query()->get(); + } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/WithdrawalListService.php b/app/Service/v3/Implementations/WithdrawalListService.php new file mode 100644 index 0000000..5dd2d1a --- /dev/null +++ b/app/Service/v3/Implementations/WithdrawalListService.php @@ -0,0 +1,29 @@ +where('store_id',$storeId)->get(); + return $res; + } +} \ No newline at end of file diff --git a/app/Service/v3/Interfaces/RevenueListServiceInterface.php b/app/Service/v3/Interfaces/RevenueListServiceInterface.php index 0dfc696..e3b3132 100644 --- a/app/Service/v3/Interfaces/RevenueListServiceInterface.php +++ b/app/Service/v3/Interfaces/RevenueListServiceInterface.php @@ -11,4 +11,6 @@ interface RevenueListServiceInterface public function check($userId); public function undo(); + + public function getListByUser($userId); } \ No newline at end of file diff --git a/app/Service/v3/Interfaces/WithdrawalListServiceInterface.php b/app/Service/v3/Interfaces/WithdrawalListServiceInterface.php new file mode 100644 index 0000000..9b68af4 --- /dev/null +++ b/app/Service/v3/Interfaces/WithdrawalListServiceInterface.php @@ -0,0 +1,13 @@ + \App\Service\v3\Implementations\GoodsActivityService::class, \App\Service\v3\Interfaces\DeliveryMoneyServiceInterface::class => \App\Service\v3\Implementations\DeliveryMoneyService::class, \App\Service\v3\Interfaces\RevenueListServiceInterface::class => \App\Service\v3\Implementations\RevenueListService::class, + \App\Service\v3\Interfaces\WithdrawalListServiceInterface::class => \App\Service\v3\Implementations\WithdrawalListService::class, ]; diff --git a/config/routes.php b/config/routes.php index e3418b5..c853a65 100644 --- a/config/routes.php +++ b/config/routes.php @@ -115,4 +115,5 @@ Router::addGroup('/v3/', function () { Router::post('collectStore/getListByUser', 'App\Controller\v3\CollectStoreController@getListByUser'); Router::post('balanceStatement/getRevenueListByUser', 'App\Controller\v3\BalanceStatementController@getRevenueListByUser'); Router::post('orderOnline/add', 'App\Controller\v3\OrderOnlineController@add'); + Router::post('store/storeWithdrawalList', 'App\Controller\v3\BalanceStatementController@getWithdrawalListByStore'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]); \ No newline at end of file From 854e3d8a6b2dd34ad82fa8e21bb7fa9cfd98b87d Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 5 Sep 2020 14:24:20 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E5=A4=B1=E6=95=88=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/ShopCartService.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/Service/v3/Implementations/ShopCartService.php b/app/Service/v3/Implementations/ShopCartService.php index 83c426b..a50e49b 100644 --- a/app/Service/v3/Implementations/ShopCartService.php +++ b/app/Service/v3/Implementations/ShopCartService.php @@ -36,6 +36,21 @@ class ShopCartService implements ShopCartServiceInterface ->get(); foreach ($res as &$k){ $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; } From 059d3b8bce008ebad4784bdd1e0c3cf144f9b2d2 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 5 Sep 2020 15:36:29 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E5=95=86=E5=AE=B6=E7=BA=BF=E4=B8=8A?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/OrderListService.php | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/app/Service/v3/Implementations/OrderListService.php b/app/Service/v3/Implementations/OrderListService.php index 50dda64..d8aec92 100644 --- a/app/Service/v3/Implementations/OrderListService.php +++ b/app/Service/v3/Implementations/OrderListService.php @@ -58,14 +58,26 @@ class OrderListService implements OrderListServiceInterface 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) { case 'all': break; @@ -85,7 +97,18 @@ class OrderListService implements OrderListServiceInterface $paginate = $builder->paginate($pagesize); $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) From b992427e62662d31a9cbd28cd1760b5d5fb4be7c Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 5 Sep 2020 15:43:58 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85=20ba?= =?UTF-8?q?nner=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/GoodsActivityService.php | 2 +- app/Service/v3/Implementations/GoodsService.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Service/v3/Implementations/GoodsActivityService.php b/app/Service/v3/Implementations/GoodsActivityService.php index c83dfc1..9af1d6e 100644 --- a/app/Service/v3/Implementations/GoodsActivityService.php +++ b/app/Service/v3/Implementations/GoodsActivityService.php @@ -46,7 +46,7 @@ class GoodsActivityService implements GoodsActivityServiceInterface public function getBanner() { - $banner = GoodsActivityBanner::query()->where('goods_id',1572)->get(); + $banner = GoodsActivityBanner::query()->where('goods_id',1572)->orderByDesc('type')->get(); return $banner; } diff --git a/app/Service/v3/Implementations/GoodsService.php b/app/Service/v3/Implementations/GoodsService.php index 64bdd99..ad36b59 100644 --- a/app/Service/v3/Implementations/GoodsService.php +++ b/app/Service/v3/Implementations/GoodsService.php @@ -41,7 +41,7 @@ class GoodsService implements GoodsServiceInterface public function getBanner() { - $banner = GoodsBanner::query()->where('goods_id',1572)->get(); + $banner = GoodsBanner::query()->where('goods_id',1572)->orderByDesc('type')->get(); return $banner; } From ded753b5be9d188f4a3c7dcbba96dec64241c5e9 Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 5 Sep 2020 16:08:14 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9banner=20=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=98=AF=E5=90=A6=E6=9C=89http?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/CategoryService.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Service/v3/Implementations/CategoryService.php b/app/Service/v3/Implementations/CategoryService.php index c49de5e..b7195e2 100644 --- a/app/Service/v3/Implementations/CategoryService.php +++ b/app/Service/v3/Implementations/CategoryService.php @@ -58,7 +58,12 @@ class CategoryService implements CategoryServiceInterface $returnData = []; foreach ($categories as $key => &$category) { $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; From c6f832f7e0640a57c6e02d2bc6ddef6c48625120 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 5 Sep 2020 16:10:14 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E7=BA=BF=E4=B8=8A=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=97=B6=E9=97=B4=20=E8=BD=AC=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/v3/Order.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/Model/v3/Order.php b/app/Model/v3/Order.php index 709e33c..b7da4b4 100644 --- a/app/Model/v3/Order.php +++ b/app/Model/v3/Order.php @@ -8,6 +8,15 @@ class Order extends Model { 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() { return $this->hasMany(OrderGoods::class, 'order_id', 'id'); From 5f26d67f7d089de9fc8c6292b21a76c3defb9ebd Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 5 Sep 2020 16:24:55 +0800 Subject: [PATCH 10/14] =?UTF-8?q?fix=20=E9=A6=96=E9=A1=B5=E5=88=86?= =?UTF-8?q?=E7=B1=BBicon=20dcat=E6=95=B0=E6=8D=AE=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/CategoryService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Service/v3/Implementations/CategoryService.php b/app/Service/v3/Implementations/CategoryService.php index b7195e2..e2aeda0 100644 --- a/app/Service/v3/Implementations/CategoryService.php +++ b/app/Service/v3/Implementations/CategoryService.php @@ -60,7 +60,7 @@ class CategoryService implements CategoryServiceInterface $value = json_decode($category, true); $iconUrl = $value['icon']; if(strripos($iconUrl,"http") === false){ - $iconUrl = config('alioss.img_host').$value['icon']; + $iconUrl = config('alioss.img_host').'/'.$value['icon']; } $iconUrl = $iconUrl . OssThumbnail::THUMBNAIL_100_Q50; $returnData[] = ['id' => $key, 'icon' => $iconUrl , 'name' => $value['name']]; From b29104d4943f23b678995f0d87d396957b6f1fbb Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 5 Sep 2020 16:38:55 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0bannerUrl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/v3/GoodsBanner.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/Model/v3/GoodsBanner.php b/app/Model/v3/GoodsBanner.php index 598e031..37d33cd 100644 --- a/app/Model/v3/GoodsBanner.php +++ b/app/Model/v3/GoodsBanner.php @@ -10,4 +10,19 @@ class GoodsBanner extends Model { use SoftDeletes; 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; + } + } } \ No newline at end of file From 9a2bbca592b4137531e1c051a587d5079d27f478 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 5 Sep 2020 16:47:38 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=B8=82=E5=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/SearchController.php | 19 +++++++++++++++++++ .../v3/Implementations/LocationService.php | 13 +++++++++++++ .../Interfaces/LocationServiceInterface.php | 1 + config/routes.php | 1 + 4 files changed, 34 insertions(+) diff --git a/app/Controller/v3/SearchController.php b/app/Controller/v3/SearchController.php index 9d8581c..45d9552 100644 --- a/app/Controller/v3/SearchController.php +++ b/app/Controller/v3/SearchController.php @@ -5,6 +5,7 @@ namespace App\Controller\v3; use App\Controller\BaseController; use App\Request\v3\SearchGoodsRequest; use App\Request\v3\SearchStoreRequest; +use App\Service\v3\Interfaces\LocationServiceInterface; use App\Service\v3\Interfaces\SearchServiceInterface; use Hyperf\Di\Annotation\Inject; use Psr\Http\Message\ResponseInterface; @@ -17,6 +18,12 @@ class SearchController extends BaseController */ protected $searchService; + /** + * @Inject + * @var LocationServiceInterface + */ + protected $locationService; + /** * 获取搜索热词 * 1、参数type区分是商品还是商户 @@ -62,4 +69,16 @@ class SearchController extends BaseController 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]); + } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/LocationService.php b/app/Service/v3/Implementations/LocationService.php index 9cfd504..c922c74 100644 --- a/app/Service/v3/Implementations/LocationService.php +++ b/app/Service/v3/Implementations/LocationService.php @@ -35,6 +35,19 @@ class LocationService implements LocationServiceInterface 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) { diff --git a/app/Service/v3/Interfaces/LocationServiceInterface.php b/app/Service/v3/Interfaces/LocationServiceInterface.php index 95eb3af..6bed48b 100644 --- a/app/Service/v3/Interfaces/LocationServiceInterface.php +++ b/app/Service/v3/Interfaces/LocationServiceInterface.php @@ -10,4 +10,5 @@ interface LocationServiceInterface public function check(); public function undo(); public function getMarketListByLocation($cityIds); + public function searchMarket($key,$cityId = 2163); } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index c853a65..aa393d1 100644 --- a/config/routes.php +++ b/config/routes.php @@ -90,6 +90,7 @@ Router::addGroup('/v3/', function () { Router::post('search/stores', 'App\Controller\v3\SearchController@stores'); Router::post('goodsRecommend/getByTab', 'App\Controller\v3\GoodsRecommendController@getByTab'); Router::post('store/index', 'App\Controller\v3\StoreController@index'); + Router::post('Search/market', 'App\Controller\v3\SearchController@market'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]); // 需要登录的路由 From c19643fe9a6b56859eb3d90650258a6d5c4285fe Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 5 Sep 2020 16:50:51 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E7=89=B9=E4=BB=B7=E5=95=86=E5=93=81=20ba?= =?UTF-8?q?nner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/v3/GoodsActivityBanner.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Model/v3/GoodsActivityBanner.php b/app/Model/v3/GoodsActivityBanner.php index 14d9c38..144be84 100644 --- a/app/Model/v3/GoodsActivityBanner.php +++ b/app/Model/v3/GoodsActivityBanner.php @@ -11,4 +11,14 @@ class GoodsActivityBanner extends Model use SoftDeletes; 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; + } + } } \ No newline at end of file From 5da26902c584ebd1c735f29b92a4e55cdf82938c Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 5 Sep 2020 17:01:39 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/GoodsController.php | 4 ++-- app/Service/v3/Implementations/GoodsActivityService.php | 4 ++-- app/Service/v3/Implementations/GoodsService.php | 4 ++-- app/Service/v3/Interfaces/GoodsActivityServiceInterface.php | 2 +- app/Service/v3/Interfaces/GoodsServiceInterface.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Controller/v3/GoodsController.php b/app/Controller/v3/GoodsController.php index b6298fe..dd8bdf2 100644 --- a/app/Controller/v3/GoodsController.php +++ b/app/Controller/v3/GoodsController.php @@ -42,10 +42,10 @@ class GoodsController extends BaseController //判断是普通商品还是特价商品 if(isset($params['activity']) && $params['activity'] == Goods::IS_ACTIVITY){ $res['detail'] = $this->goodsActivityService->detail($params['goods_id']); - $res['banner'] = $this->goodsActivityService->getBanner(); + $res['banner'] = $this->goodsActivityService->getBanner(1572); }else{ $res['detail'] = $this->goodsService->detail($params['goods_id']); - $res['banner'] = $this->goodsService->getBanner(); + $res['banner'] = $this->goodsService->getBanner(1572); } if(isset($params['user_id'])) { $res['shopcart']['count'] = $this->shopCartService->check(111); diff --git a/app/Service/v3/Implementations/GoodsActivityService.php b/app/Service/v3/Implementations/GoodsActivityService.php index 9af1d6e..306c98a 100644 --- a/app/Service/v3/Implementations/GoodsActivityService.php +++ b/app/Service/v3/Implementations/GoodsActivityService.php @@ -44,9 +44,9 @@ class GoodsActivityService implements GoodsActivityServiceInterface // TODO: Implement undo() method. } - public function getBanner() + public function getBanner($goodsId) { - $banner = GoodsActivityBanner::query()->where('goods_id',1572)->orderByDesc('type')->get(); + $banner = GoodsActivityBanner::query()->where('goods_id',$goodsId)->orderByDesc('type')->get(); return $banner; } diff --git a/app/Service/v3/Implementations/GoodsService.php b/app/Service/v3/Implementations/GoodsService.php index ad36b59..455e678 100644 --- a/app/Service/v3/Implementations/GoodsService.php +++ b/app/Service/v3/Implementations/GoodsService.php @@ -39,9 +39,9 @@ class GoodsService implements GoodsServiceInterface // TODO: Implement undo() method. } - public function getBanner() + public function getBanner($goodsId) { - $banner = GoodsBanner::query()->where('goods_id',1572)->orderByDesc('type')->get(); + $banner = GoodsBanner::query()->where('goods_id',$goodsId)->orderByDesc('type')->get(); return $banner; } diff --git a/app/Service/v3/Interfaces/GoodsActivityServiceInterface.php b/app/Service/v3/Interfaces/GoodsActivityServiceInterface.php index 7084c83..6fb627c 100644 --- a/app/Service/v3/Interfaces/GoodsActivityServiceInterface.php +++ b/app/Service/v3/Interfaces/GoodsActivityServiceInterface.php @@ -7,6 +7,6 @@ interface GoodsActivityServiceInterface public function do($goodsId); public function check($goodsId,$num = 1); public function undo(); - public function getBanner(); + public function getBanner($goodsId); public function detail($goodsId); } \ No newline at end of file diff --git a/app/Service/v3/Interfaces/GoodsServiceInterface.php b/app/Service/v3/Interfaces/GoodsServiceInterface.php index 5c36a96..bafe7c2 100644 --- a/app/Service/v3/Interfaces/GoodsServiceInterface.php +++ b/app/Service/v3/Interfaces/GoodsServiceInterface.php @@ -7,5 +7,5 @@ interface GoodsServiceInterface public function do($goodsId); public function check($goodsId,$num = 1); public function undo(); - public function getBanner(); + public function getBanner($goodsId); } \ No newline at end of file