Browse Source

删除多余方法 修改优惠券失效提示

master
Lemon 5 years ago
parent
commit
579cd1fd60
  1. 48
      app/Service/CouponService.php

48
app/Service/CouponService.php

@ -219,9 +219,8 @@ class CouponService implements CouponServiceInterface
->where('money',0.01)
->exists();
if($shopCarExists){
var_dump(1111);
foreach ($available as $k => $v) {
$v->msg = '特价商品不可使用';
$v->msg = '不可使用';
$notAvailable[$v->id] = $v;
}
$available = [];
@ -295,51 +294,6 @@ class CouponService implements CouponServiceInterface
return $setRes&&$expireRes;
}
/**
* 取消订单返券
* @param $order_id
* @return bool
*/
public function refundOrderCoupons($global_order_id){
$order_main = OrderMain::where('global_order_id',$global_order_id)
->select('id','user_id')
->first();
$order_id = $order_main->id;
$coupon = CouponUserUse::where([
['order_main_id','=',$order_id],
['status','=',CouponUserUse::COUPON_USE_STATE_USED],
])
->select('id','user_receive_id','number')
->first();
if (empty($coupon)) {
return '';
}
// 返回用户优惠券数量并更新状态
$res = Db::update("UPDATE ims_system_coupon_user_receive SET number_remain=number_remain+{$coupon->number}, status=IF(number=number_remain,0,1), update_time=".time().""
." WHERE id={$coupon->user_receive_id} AND number>=(number_remain+{$coupon->number})");
// 更新使用记录状态为已退回
CouponUserUse::where([
['id','=',$coupon->id],
['status','=',CouponUserUse::COUPON_USE_STATE_USED],
])
->update([
'status' => CouponUserUse::COUPON_USE_STATE_CANCEL,
'return_time' => time(),
'update_time' => time(),
]);
//删除当日 redis 使用记录缓存
$redis = ApplicationContext::getContainer()->get(Redis::class);
$remRes = $redis->sRem(
'coupon_'.date('Ymd').'_used_'.$order_main->user_id,
$coupon->system_coupon_id
);
return $remRes;
}
/* 删除-优惠券今日使用的缓存
* @param $userId
* @param $couponId

Loading…
Cancel
Save