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/Controller/v3/GoodsController.php b/app/Controller/v3/GoodsController.php index 7e647e7..dd8bdf2 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,20 +30,29 @@ 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['banner'] = $this->goodsActivityService->getBanner(); + $res['detail'] = $this->goodsActivityService->detail($params['goods_id']); + $res['banner'] = $this->goodsActivityService->getBanner(1572); }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'])) { + $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{ + $res['shopcart'] = ''; $res['detail']->store->is_collected = ''; } return $this->success($res); 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/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/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 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 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'); 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/CategoryService.php b/app/Service/v3/Implementations/CategoryService.php index c49de5e..e2aeda0 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; diff --git a/app/Service/v3/Implementations/GoodsActivityService.php b/app/Service/v3/Implementations/GoodsActivityService.php index 5b2abc9..884dfa7 100644 --- a/app/Service/v3/Implementations/GoodsActivityService.php +++ b/app/Service/v3/Implementations/GoodsActivityService.php @@ -7,7 +7,6 @@ use App\Constants\v3\ErrorCode; use App\Constants\v3\SsdbKeys; use App\Service\v3\Interfaces\GoodsActivityServiceInterface; use App\TaskWorker\SSDBTask; -use Hyperf\DbConnection\Db; use App\Constants\v3\Store; use App\Constants\v3\Goods; use App\Model\v3\GoodsActivity; @@ -18,8 +17,7 @@ class GoodsActivityService implements GoodsActivityServiceInterface { 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. } - 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; } + public function detail($goodsId) + { + $res = GoodsActivity::query()->with('store')->where('id',$goodsId)->first(); + return $res; + } + public function cacheRecord($goodsId, $num, $userId) { diff --git a/app/Service/v3/Implementations/GoodsService.php b/app/Service/v3/Implementations/GoodsService.php index 2dba4f5..1ed75e7 100644 --- a/app/Service/v3/Implementations/GoodsService.php +++ b/app/Service/v3/Implementations/GoodsService.php @@ -13,8 +13,7 @@ class GoodsService implements GoodsServiceInterface { 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. } - 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; } + + 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/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/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) 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/ShopCartService.php b/app/Service/v3/Implementations/ShopCartService.php index 9b1380e..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; } @@ -44,4 +59,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/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/GoodsActivityServiceInterface.php b/app/Service/v3/Interfaces/GoodsActivityServiceInterface.php index 2081197..13b6719 100644 --- a/app/Service/v3/Interfaces/GoodsActivityServiceInterface.php +++ b/app/Service/v3/Interfaces/GoodsActivityServiceInterface.php @@ -7,6 +7,7 @@ interface GoodsActivityServiceInterface public function do($goodsId); public function check($goodsId,$num,$userId); public function undo(); - public function getBanner(); + public function getBanner($goodsId); + public function detail($goodsId); public function checkOrderActivityCount($orderGoods, $limitNum=1); } \ 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 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/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/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 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\RevenueListService::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\WithdrawalListServiceInterface::class => \App\Service\v3\Implementations\WithdrawalListService::class, ]; diff --git a/config/routes.php b/config/routes.php index ef8a931..4acfd98 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]]); // 需要登录的路由 @@ -115,5 +116,6 @@ 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'); Router::post('payment/wechatpayOnline', 'App\Controller\v3\PaymentController@wechatpayOnline'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]); \ No newline at end of file