|
|
|
@ -68,8 +68,42 @@ class CouponController extends BaseController |
|
|
|
$userId = $this->request->input("user_id"); |
|
|
|
$receiveType = $this->request->input("receive_type"); |
|
|
|
$ids = $this->request->input("ids"); |
|
|
|
$type = $this->request->input("test",0); |
|
|
|
|
|
|
|
|
|
|
|
$ids = is_array($ids)?implode(',',$ids):$ids; |
|
|
|
|
|
|
|
$cps = Coupon::whereIn('id', $ids)->get(); |
|
|
|
$now = time(); |
|
|
|
$success = []; |
|
|
|
$fail = []; |
|
|
|
foreach ($cps as $key => $cp) { |
|
|
|
|
|
|
|
|
|
|
|
$crt = CouponUserRecType::where('system_coupon_user_id',$cp->id)->first(); |
|
|
|
|
|
|
|
//TODO 会有超发情况
|
|
|
|
$cr = new CouponRec; |
|
|
|
$cr->user_id = $userId; |
|
|
|
$cr->system_coupon_user_id = $cp->id; |
|
|
|
$cr->order_main_id = 0; |
|
|
|
$cr->receive_time = $now; |
|
|
|
$cr->number = $crt->one_receive_number; |
|
|
|
$cr->nnumber_remain = $crt->one_receive_number; |
|
|
|
$cr->status = 0; |
|
|
|
$cr->update_time = $now; |
|
|
|
$cr->receive_type = $receiveType; |
|
|
|
if($cr->save()){ |
|
|
|
$success[] = $cp; |
|
|
|
}else{ |
|
|
|
$fail[] = $cp; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->success([ |
|
|
|
'success'=>$success, |
|
|
|
'fail'=>$fail, |
|
|
|
]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|