|
|
|
@ -160,18 +160,6 @@ class CouponService implements CouponServiceInterface |
|
|
|
{ |
|
|
|
$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)) { |
|
|
|
@ -218,12 +206,27 @@ class CouponService implements CouponServiceInterface |
|
|
|
|
|
|
|
foreach ($data as $key => &$item) { |
|
|
|
if (in_array($item->id, $couponIds)) { |
|
|
|
$item->msg = '今日已使用'; |
|
|
|
$notAvailable[$item->id] = $item; |
|
|
|
} else { |
|
|
|
$available[] = $item; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//如果存在特价商品 不给用券
|
|
|
|
$carIdsArr = explode(',',$carIds); |
|
|
|
$shopCarExists = ShopCar::whereIn('id',$carIdsArr) |
|
|
|
->where('money',0.01) |
|
|
|
->exists(); |
|
|
|
if($shopCarExists){ |
|
|
|
var_dump(1111); |
|
|
|
foreach ($available as $k => $v) { |
|
|
|
$v->msg = '特价商品不可使用'; |
|
|
|
$notAvailable[$v->id] = $v; |
|
|
|
} |
|
|
|
$available = []; |
|
|
|
} |
|
|
|
|
|
|
|
return [ |
|
|
|
'available' => $available, |
|
|
|
'not_available' => array_values($notAvailable) |
|
|
|
@ -334,7 +337,7 @@ class CouponService implements CouponServiceInterface |
|
|
|
'coupon_'.date('Ymd').'_used_'.$order_main->user_id, |
|
|
|
$coupon->system_coupon_id |
|
|
|
); |
|
|
|
return $res; |
|
|
|
return $remRes; |
|
|
|
} |
|
|
|
|
|
|
|
/* 删除-优惠券今日使用的缓存 |
|
|
|
@ -359,19 +362,22 @@ class CouponService implements CouponServiceInterface |
|
|
|
* 先查询是否正常使用优惠券 |
|
|
|
* 修改状态,退还领取记录库存,删除ssdb缓存 |
|
|
|
*/ |
|
|
|
public function orderRefundCoupon($global_order_id) |
|
|
|
public function orderRefundCoupons($global_order_id) |
|
|
|
{ |
|
|
|
$order_main = OrderMain::where('global_order_id',$global_order_id) |
|
|
|
->select('id','user_id') |
|
|
|
->first(); |
|
|
|
$time = time(); |
|
|
|
Db::beginTransaction(); |
|
|
|
try { |
|
|
|
$couponUses = CouponUserUse::query() |
|
|
|
->select('id','system_coupon_id','user_id','number','user_receive_id') |
|
|
|
->where('global_order_id',$global_order_id) |
|
|
|
->where('order_main_id',$order_main->id) |
|
|
|
->where('status',CouponUserUse::COUPON_USE_STATE_USED) |
|
|
|
->select(); |
|
|
|
if(!empty($couponUse)){ |
|
|
|
->get(); |
|
|
|
if(!empty($couponUses)){ |
|
|
|
foreach($couponUses as $use){ |
|
|
|
$use->status = CouponUserUse::COUPON_USE_STATE_USED; |
|
|
|
$use->status = CouponUserUse::COUPON_USE_STATE_CANCEL; |
|
|
|
$use->return_time = $time; |
|
|
|
$use->update_time = $time; |
|
|
|
$res = $use->save(); |
|
|
|
@ -397,6 +403,5 @@ class CouponService implements CouponServiceInterface |
|
|
|
Db::rollBack(); |
|
|
|
return false; |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |