544782275@qq.com 3 years ago
parent
commit
54c6837f93
1 changed files with 21 additions and 0 deletions
  1. 21 0
      application/api/controller/Pay.php

+ 21 - 0
application/api/controller/Pay.php

@@ -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);
+            }
+        }
     }
 }