|
|
|
@ -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(); |
|
|
|
|
|
|
|
} |
|
|
|
|