|
|
@ -267,15 +267,15 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
->leftjoin('ims_system_coupon_user_use as u', 'u.user_receive_id', '=', 'r.id') |
|
|
->leftjoin('ims_system_coupon_user_use as u', 'u.user_receive_id', '=', 'r.id') |
|
|
->where([ |
|
|
->where([ |
|
|
['u.order_main_id', '=', $order_id], |
|
|
['u.order_main_id', '=', $order_id], |
|
|
['r.send_user_id', '>', 0], |
|
|
|
|
|
['r.rebate_type', '=', 1], |
|
|
|
|
|
['r.receive_type', '=', 4], |
|
|
|
|
|
|
|
|
// ['r.send_user_id', '>', 0],
|
|
|
|
|
|
// ['r.rebate_type', '=', 1],
|
|
|
|
|
|
// ['r.receive_type', '=', 4],
|
|
|
]) |
|
|
]) |
|
|
->whereIn('r.system_coupon_user_id',$coupon_ids) |
|
|
->whereIn('r.system_coupon_user_id',$coupon_ids) |
|
|
->select('r.user_id', 'r.send_user_id') |
|
|
->select('r.user_id', 'r.send_user_id') |
|
|
->first(); |
|
|
->first(); |
|
|
/* 如果使用的优惠券为转发活动优惠券 则给赠送者返一张优惠券*/ |
|
|
/* 如果使用的优惠券为转发活动优惠券 则给赠送者返一张优惠券*/ |
|
|
if (isset($coupon->send_user_id) && ($coupon->send_user_id) > 0) { |
|
|
|
|
|
|
|
|
if ($coupon) { |
|
|
//是否已返过券
|
|
|
//是否已返过券
|
|
|
$exists_coupon_rebate = Db::table('ims_system_coupon_user_receive') |
|
|
$exists_coupon_rebate = Db::table('ims_system_coupon_user_receive') |
|
|
->where([ |
|
|
->where([ |
|
|
@ -289,7 +289,7 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
Db::beginTransaction(); |
|
|
Db::beginTransaction(); |
|
|
try { |
|
|
try { |
|
|
//返券
|
|
|
//返券
|
|
|
if($exists_coupon_rebate->id){ |
|
|
|
|
|
|
|
|
if($exists_coupon_rebate){ |
|
|
//如果已有该优惠券 则领取数量 和 可用数量 自增1
|
|
|
//如果已有该优惠券 则领取数量 和 可用数量 自增1
|
|
|
Db::table('ims_system_coupon_user_receive') |
|
|
Db::table('ims_system_coupon_user_receive') |
|
|
->where([ |
|
|
->where([ |
|
|
@ -356,16 +356,6 @@ class CouponRebateService implements CouponRebateServiceInterface |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
$log_Data = array(); |
|
|
|
|
|
$log_Data['name'] = '返券'; |
|
|
|
|
|
$log_Data['user_id'] = $order_id; |
|
|
|
|
|
$log_Data['send_user_id'] = $coupon->send_user_id; |
|
|
|
|
|
$log_Data['order_main_id'] = $order_id; |
|
|
|
|
|
$log_Data['msg'] = '返券成功'; |
|
|
|
|
|
$this->log->event( |
|
|
|
|
|
LogLabel::COUPON_LOG, |
|
|
|
|
|
$log_Data |
|
|
|
|
|
); |
|
|
|
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|