From 06f323d6d3f5dd458a93852b8f7b7e40a63a73da Mon Sep 17 00:00:00 2001 From: weigang Date: Tue, 15 Sep 2020 09:37:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AD=9B=E6=BB=A4=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/GoodsRecommendController.php | 10 ++++++ app/Request/v3/GoodsRequest.php | 2 +- .../v3/Implementations/ActivityService.php | 33 +++++++++++++++---- .../v3/Implementations/SearchService.php | 12 ++++++- 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/app/Controller/v3/GoodsRecommendController.php b/app/Controller/v3/GoodsRecommendController.php index 7528c17..2f265d8 100644 --- a/app/Controller/v3/GoodsRecommendController.php +++ b/app/Controller/v3/GoodsRecommendController.php @@ -51,6 +51,11 @@ class GoodsRecommendController extends BaseController ->whereRaw(''.$goodsTable.'.deleted_at IS NULL') ->where(function ($query) use ($goodsTable) { $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1); + }) + ->where('time1', '<=', date('H:i')) + ->where(function ($query) { + $query->where('time2', '>=', date('H:i')) + ->orWhere('time4', '>=', date('H:i')); }); // $builder = Goods::query()->with('store') @@ -122,6 +127,11 @@ class GoodsRecommendController extends BaseController ->where(function ($query) use ($goodsTable) { $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1); }) + ->where('time1', '<=', date('H:i')) + ->where(function ($query) { + $query->where('time2', '>=', date('H:i')) + ->orWhere('time4', '>=', date('H:i')); + }) ->inRandomOrder() ->limit(20) ->get()->toArray(); diff --git a/app/Request/v3/GoodsRequest.php b/app/Request/v3/GoodsRequest.php index b135e2e..ff315a4 100644 --- a/app/Request/v3/GoodsRequest.php +++ b/app/Request/v3/GoodsRequest.php @@ -15,7 +15,7 @@ class GoodsRequest extends BaseFormRequest public function rules(): array { return [ - 'goods_id' => 'required|nonempty|integer|exists_enable:lanzu_goods_new,id,on_sale=1', + 'goods_id' => 'required|nonempty|integer', ]; } diff --git a/app/Service/v3/Implementations/ActivityService.php b/app/Service/v3/Implementations/ActivityService.php index e5ed0bf..eafe022 100644 --- a/app/Service/v3/Implementations/ActivityService.php +++ b/app/Service/v3/Implementations/ActivityService.php @@ -2,9 +2,11 @@ namespace App\Service\v3\Implementations; -use App\Constants\v3\ActivityType; +use App\Constants\v3\Goods as GoodsConstants; use App\Model\v3\GoodsActivity; +use App\Model\v3\Store; use App\Service\v3\Interfaces\ActivityServiceInterface; +use Hyperf\Utils\ApplicationContext; class ActivityService implements ActivityServiceInterface { @@ -26,16 +28,33 @@ class ActivityService implements ActivityServiceInterface public function allForAppletIndex($type, $marketId) { + + $storeTable = ApplicationContext::getContainer()->get(Store::class)->getTable(); + $goodsTable = ApplicationContext::getContainer()->get(GoodsActivity::class)->getTable(); + $builder = GoodsActivity::query() + ->join($storeTable, ''.$storeTable.'.id', '=', ''.$goodsTable.'.store_id') ->with(['store']) - ->where(['type' => $type]) - ->where(function ($query) use ($marketId) { - $query->whereJsonContains("market_ids", [(string)$marketId]) - ->orWhereJsonLength("market_ids", '=', 0); + ->where([''.$goodsTable.'.type' => $type]) + ->where(function ($query) use ($marketId, $goodsTable) { + $query->whereJsonContains(''.$goodsTable.'.market_ids', [(string)$marketId]) + ->orWhereJsonLength(''.$goodsTable.'.market_ids', '=', 0); + }) + ->where([''.$goodsTable.'.on_sale' => GoodsConstants::ON_SALE_YES]) + ->where(function ($query) use ($goodsTable) { + $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1); + }) + ->whereRaw(''.$goodsTable.'.deleted_at IS NULL') + ->where([''.$storeTable.'.market_id' => $marketId]) + ->where('time1', '<=', date('H:i')) + ->where(function ($query) { + $query->where('time2', '>=', date('H:i')) + ->orWhere('time4', '>=', date('H:i')); }); - return $builder->orderBy('sort', 'DESC') - ->orderBy('expire_time', 'ASC') + return $builder->select(''.$goodsTable.'.*')->addSelect(''.$goodsTable.'.sales as total_sales') + ->orderBy(''.$goodsTable.'.sort', 'DESC') + ->orderBy(''.$goodsTable.'.expire_time', 'ASC') ->get()->toArray(); } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/SearchService.php b/app/Service/v3/Implementations/SearchService.php index 4bc658a..151a601 100644 --- a/app/Service/v3/Implementations/SearchService.php +++ b/app/Service/v3/Implementations/SearchService.php @@ -38,6 +38,11 @@ class SearchService implements SearchServiceInterface ->with(['store']) ->where(function ($query) use ($goodsTable) { $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1); + }) + ->where('time1', '<=', date('H:i')) + ->where(function ($query) { + $query->where('time2', '>=', date('H:i')) + ->orWhere('time4', '>=', date('H:i')); }); if (isset($params['store_id']) && $params['store_id']) { @@ -102,7 +107,12 @@ class SearchService implements SearchServiceInterface $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1); }) ->whereRaw(''.$goodsTable.'.deleted_at IS NULL') - ->where([''.$storeTable.'.market_id' => $params['market_id']]); + ->where([''.$storeTable.'.market_id' => $params['market_id']]) + ->where('time1', '<=', date('H:i')) + ->where(function ($query) { + $query->where('time2', '>=', date('H:i')) + ->orWhere('time4', '>=', date('H:i')); + }); if (isset($params['store_id']) && $params['store_id']) { $builder->where([''.$storeTable.'.store_id' => $params['store_id']]); From c62ce29dcd4a4dae40c751055c493221167638e4 Mon Sep 17 00:00:00 2001 From: weigang Date: Tue, 15 Sep 2020 10:23:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E5=92=8C=E4=BC=98=E6=83=A0=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/HomeController.php | 1 - app/Controller/v3/NotifyController.php | 4 ++-- app/Model/v3/Coupon.php | 5 +++++ app/Service/v3/Implementations/BadgeService.php | 2 +- app/Service/v3/Implementations/CouponRecService.php | 2 +- app/Service/v3/Implementations/OrderOnlineService.php | 1 + app/Service/v3/Implementations/StoreLoginService.php | 1 - app/Service/v3/Implementations/UserAddressService.php | 2 +- 8 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/Controller/v3/HomeController.php b/app/Controller/v3/HomeController.php index e8186b5..0cce913 100644 --- a/app/Controller/v3/HomeController.php +++ b/app/Controller/v3/HomeController.php @@ -216,7 +216,6 @@ class HomeController extends BaseController $data['order_offline']['total'] = 0; $revenueByOrder = $this->revenueListService->getRevenueByUser($userId,$type,$dayStartTime,$dayEndTime); foreach ($revenueByOrder as $order){ - var_dump($order['money']); if($order['money_type'] == FinancialRecord::MONEY_TYPE_STORE_OL_ORDER_COMP){ //线上订单 $data['order_online']['total'] = bcadd($data['order_online']['total'],$order['money'],2); diff --git a/app/Controller/v3/NotifyController.php b/app/Controller/v3/NotifyController.php index 35b6199..d30dec5 100644 --- a/app/Controller/v3/NotifyController.php +++ b/app/Controller/v3/NotifyController.php @@ -134,7 +134,7 @@ class NotifyController extends BaseController || $message['result_code'] != 'SUCCESS' ) { $this->log->event( - LogLabel::ORDER_OFFLINE_PAY_NOTIFY_LOG, + LogLabel::ORDER_ONLINE_PAY_NOTIFY_LOG, $message ); Db::rollBack(); @@ -149,7 +149,7 @@ class NotifyController extends BaseController // 订单不存在 if (empty($orderMain)) { $this->log->event( - LogLabel::ORDER_OFFLINE_PAY_NOTIFY_LOG, + LogLabel::ORDER_ONLINE_PAY_NOTIFY_LOG, ['global_order_id_fail' => $message['out_trade_no']] ); Db::rollBack(); diff --git a/app/Model/v3/Coupon.php b/app/Model/v3/Coupon.php index 4d77051..35607c5 100644 --- a/app/Model/v3/Coupon.php +++ b/app/Model/v3/Coupon.php @@ -16,6 +16,10 @@ class Coupon extends Model 'discounts_text' ]; + protected $casts = [ + 'activity_available' => 'array' + ]; + public function getFullAmountTextAttribute() { return '满'.$this->attributes['full_amount'].'可用'; @@ -29,4 +33,5 @@ class Coupon extends Model return floatval($this->attributes['discounts'])."折"; } } + } diff --git a/app/Service/v3/Implementations/BadgeService.php b/app/Service/v3/Implementations/BadgeService.php index 020101f..e8d013d 100644 --- a/app/Service/v3/Implementations/BadgeService.php +++ b/app/Service/v3/Implementations/BadgeService.php @@ -155,7 +155,7 @@ class BadgeService implements BadgeServiceInterface * @inheritDoc */ public function clearStoreOrder($storeId, $badge = 'all') - {var_dump('badge_'.$badge.'_store_'.$storeId); + { $redis = ApplicationContext::getContainer()->get(Redis::class); if ($badge == 'all') { $redis->del('badge_paid_store_'.$storeId); # 移除商户待付款 diff --git a/app/Service/v3/Implementations/CouponRecService.php b/app/Service/v3/Implementations/CouponRecService.php index c987326..6791074 100644 --- a/app/Service/v3/Implementations/CouponRecService.php +++ b/app/Service/v3/Implementations/CouponRecService.php @@ -268,7 +268,7 @@ class CouponRecService implements CouponRecServiceInterface } // 活动商品可用,校验对应的优惠券可使用活动类型 - $intersects = array_intersect($goodsActivityTypes, $item['activity_available']); # 所有活动商品的活动类型和优惠券的可用活动类型求交集 + $intersects = array_intersect($goodsActivityTypes, (array)$item['activity_available']); # 所有活动商品的活动类型和优惠券的可用活动类型求交集 $canUseByTypes = array_diff($goodsActivityTypes, $intersects); # 所有活动商品的活动类型和上述交集求差集,如果为空则是可以用的,否则说明前者中有后者不能用的活动类型 if (!empty($canUseByTypes)) { $item['not_available_reason'] = '活动不可用'; diff --git a/app/Service/v3/Implementations/OrderOnlineService.php b/app/Service/v3/Implementations/OrderOnlineService.php index e77c471..066f6f1 100644 --- a/app/Service/v3/Implementations/OrderOnlineService.php +++ b/app/Service/v3/Implementations/OrderOnlineService.php @@ -126,6 +126,7 @@ class OrderOnlineService implements OrderOnlineServiceInterface $userAddr = $userAddrAndDPrice['address']['address']; $deliveryAmount = $userAddrAndDPrice['distribution_price']; $deliveryDistance = $userAddrAndDPrice['delivery_distance']; + // 优惠券数据,当前订单可用个优惠券 $couponRecs = $this->couponRecService->allForOnlineOrderAvailable($userId, $marketId); $canRealUseCoupons = $couponRecs['available']; diff --git a/app/Service/v3/Implementations/StoreLoginService.php b/app/Service/v3/Implementations/StoreLoginService.php index ceb4357..7cb4954 100644 --- a/app/Service/v3/Implementations/StoreLoginService.php +++ b/app/Service/v3/Implementations/StoreLoginService.php @@ -13,7 +13,6 @@ class StoreLoginService implements StoreLoginServiceInterface { $storeUsersModel = StoreUsers::query()->where('username',$account)->first(); $password = $this->stringHash($password,$storeUsersModel->salt); - var_dump($storeUsersModel,$password); if($storeUsersModel->password === $password){ return $storeUsersModel; }else{ diff --git a/app/Service/v3/Implementations/UserAddressService.php b/app/Service/v3/Implementations/UserAddressService.php index 3edb874..10bda1d 100644 --- a/app/Service/v3/Implementations/UserAddressService.php +++ b/app/Service/v3/Implementations/UserAddressService.php @@ -85,7 +85,7 @@ class UserAddressService implements UserAddressServiceInterface { $address = $this->get($userAddressId); $market = Market::query()->select('lng','lat')->find($marketId); - $distance = $this->locationService->getDistanceByTencent($address->lng,$address->lat,$market->lng,$market->lat); + $distance = $this->locationService->getDistanceByTencent($address['address']->lng,$address['address']->lat,$market->lng,$market->lat); $distributionPrice = $this->distributionPriceService->do($distance); $res['address'] = $address; $res['delivery_distance'] = $distance;