|
@@ -80,5 +80,26 @@ class Pay extends Controller
|
|
|
$mail_str = implode(',',$engineer_mail_arr);
|
|
|
mail_push($mail_str);
|
|
|
}
|
|
|
+ //如果有推荐人,给推荐人发推荐优惠券
|
|
|
+ $user_id = Db::name('store_order')->where('id',$order_id)->value('user_id');
|
|
|
+ $pid = Db::name('store_member')->where('id',$user_id)->value('pid');
|
|
|
+ if($pid){
|
|
|
+ $coupon_list = Db::name('store_coupon_config')->where('status',1)->where('is_deleted',0)->where('type',3)->select();
|
|
|
+ if(empty($coupon_list)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ foreach ($coupon_list as $value){
|
|
|
+ $data = array(
|
|
|
+ 'config_id' => $value['id'],
|
|
|
+ 'user_id' => $pid,
|
|
|
+ 'title' => $value['title'],
|
|
|
+ 'low_amount' => $value['low_amount'],
|
|
|
+ 'amount' => $value['amount'],
|
|
|
+ 'start' => date('Y-m-d'),
|
|
|
+ 'end' => date('Y-m-d', strtotime('+'.$value['low_day'].' days') )
|
|
|
+ );
|
|
|
+ Db::table('store_coupon_list')->insert($data);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|