|
|
|
@ -3,6 +3,7 @@ |
|
|
|
namespace App\Service; |
|
|
|
|
|
|
|
use App\Model\OrderMain; |
|
|
|
use App\Model\ShopCar; |
|
|
|
use Hyperf\Di\Annotation\Inject; |
|
|
|
use Hyperf\DbConnection\Db; |
|
|
|
use App\Model\CouponUserRecType; |
|
|
|
@ -155,12 +156,23 @@ class CouponService implements CouponServiceInterface |
|
|
|
* 获取用户当前订单可用的优惠券列表 |
|
|
|
* 按分类(1订单 等优惠)分组返回 |
|
|
|
*/ |
|
|
|
public function getUserAvailableCoupons($orderAmount,$userId,$marketId,$type,$storetypeId) |
|
|
|
public function getUserAvailableCoupons($orderAmount,$userId,$marketId,$type,$storetypeId,$carIds) |
|
|
|
{ |
|
|
|
$storetypeIds = explode(',', str_replace(',', ',', $storetypeId)); |
|
|
|
|
|
|
|
$available = []; |
|
|
|
$notAvailable = []; |
|
|
|
//如果存在特价商品 不给用券
|
|
|
|
$carIdsArr = explode(',',$carIds); |
|
|
|
$shopCarExists = ShopCar::whereIn('id',$carIdsArr) |
|
|
|
->where('money',0.01) |
|
|
|
->exists(); |
|
|
|
if($shopCarExists){ |
|
|
|
return [ |
|
|
|
'available' => $available, |
|
|
|
'not_available' => array_values($notAvailable) |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
$storetypeIds = explode(',', str_replace(',', ',', $storetypeId)); |
|
|
|
|
|
|
|
if (empty($orderAmount) || empty($userId)) { |
|
|
|
return [ |
|
|
|
|