diff --git a/app/Service/v3/Implementations/CouponRecService.php b/app/Service/v3/Implementations/CouponRecService.php index c1870fa..ac57d12 100644 --- a/app/Service/v3/Implementations/CouponRecService.php +++ b/app/Service/v3/Implementations/CouponRecService.php @@ -2,17 +2,24 @@ namespace App\Service\v3\Implementations; -use App\Model\ShopCar; use App\Model\v3\Coupon; use App\Model\v3\CouponRec; use App\Service\v3\Interfaces\CouponRecServiceInterface; +use App\Service\v3\Interfaces\ShopCartServiceInterface; use Hyperf\DbConnection\Db; use Hyperf\Redis\Redis; use Hyperf\Utils\ApplicationContext; +use Hyperf\Di\Annotation\Inject; class CouponRecService implements CouponRecServiceInterface { + /** + * @Inject + * @var ShopCartServiceInterface + */ + protected $shopCartService; + public function do() { // TODO: Implement do() method. @@ -148,12 +155,22 @@ class CouponRecService implements CouponRecServiceInterface * 2、筛选出其中当日使用过的优惠券 * 3、筛选出其中活动商品不可用的优惠券(订单中有活动商品且活动商品不可使用优惠券) * 4、筛选出其中活动商品可用但商品的活动类型不符合优惠券活动使用类型的要求(订单中有活动商品可以用优惠券,但是活动类型type和优惠券中的available活动类型不可用) - * @param $cartIds * @param $userId * @param $marketId */ - public function allForOnlineOrderAvailable($cartIds, $userId, $marketId) + public function allForOnlineOrderAvailable($userId, $marketId) { + // 获取购物车数据 + $carts = $this->shopCartService->allForUser($userId, $marketId); + $totalAmount = $carts['total']; + + // 获取用户可用优惠券(1) + $coupons = CouponRec::query() + ->join('lanzu_coupon as coupon', 'coupon.id', '=', '') + ->where(['user_id' => $userId]) + ->where('number_remain', '>', 0) + ->whereIn('status', [0,1]) + ->get(); } diff --git a/app/Service/v3/Implementations/OrderOfflineService.php b/app/Service/v3/Implementations/OrderOfflineService.php index 4fdc741..f0e76e5 100644 --- a/app/Service/v3/Implementations/OrderOfflineService.php +++ b/app/Service/v3/Implementations/OrderOfflineService.php @@ -2,6 +2,7 @@ namespace App\Service\v3\Implementations; +use App\Commons\Log; use App\Constants\v3\ErrorCode; use App\Constants\v3\LogLabel; use App\Constants\v3\OrderState; @@ -26,6 +27,12 @@ class OrderOfflineService implements OrderOfflineServiceInterface */ protected $paymentService; + /** + * @Inject + * @var Log + */ + protected $log; + public function do($storeId, $userId, $money, $plat ='') { try { @@ -62,8 +69,9 @@ class OrderOfflineService implements OrderOfflineServiceInterface // 店铺今天的订单数 $count = Order::query() - ->where(['store_id' => $storeId, 'type' => OrderType::OFFLINE]) - ->whereBetween('created_at', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]) + ->join('lanzu_order_main as main', 'main.id', '=', 'lanzu_order.order_main_id') + ->where(['lanzu_order.store_id' => $storeId, 'main.type' => OrderType::OFFLINE]) + ->whereBetween('lanzu_order.created_at', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]) ->count(); // 子订单数据