...
|
...
|
@@ -497,41 +497,42 @@ truncate cv_verification_receive; |
|
|
public function send_gift_certificate_url($pid,$order_id,$time){
|
|
|
$order_info = Db::name('verification_order')->where(['id'=>$order_id])->find();
|
|
|
$store = Db::name('verification_store')->where(['id'=>$order_info['verification_store_id']])->find();
|
|
|
$activity = Db::name('verification_activity')->where(['id'=>$order_info['verification_activity_id']])->find();
|
|
|
//获取门店下的礼品券
|
|
|
if(!empty($activity['verification_coupon_ids'])){
|
|
|
|
|
|
//判断当前父级的所有下级的订单数,是否满足 send_rule_limit 的规则
|
|
|
$subIds = Db::name('user')->where(['pid'=>$pid])->column('id');
|
|
|
$subOrderCount = Db::name('verification_order')->where(['user_id'=>['in',$subIds],'type'=>['>','0']])->count();
|
|
|
|
|
|
//获取卡券
|
|
|
//当前活动对应的所有券
|
|
|
$coupon = Db::name('verification_coupon')->where(['id'=>['in',$activity['verification_coupon_ids']],'type'=>1,'send_rule_limit'=>$subOrderCount])->find();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!empty($coupon)){
|
|
|
//发送给pid用户
|
|
|
$save = [];
|
|
|
$save['verification_coupon_id'] = $store['verification_coupon_id'];
|
|
|
$save['verification_store_id'] = $store['id'];
|
|
|
$save['user_id'] = $pid;
|
|
|
//判断当前父级的所有下级的订单数,是否满足 send_rule_limit 的规则
|
|
|
$subIds = Db::name('user')->where(['pid'=>$pid])->column('id');
|
|
|
$subOrderCount = Db::name('verification_order')->where(['user_id'=>['in',$subIds],'type'=>['>','0']])->count();
|
|
|
|
|
|
//获取卡券
|
|
|
//当前活动对应的所有券
|
|
|
$wc = ['verification_store_id'=>$order_info['verification_store_id'],'type'=>1,'send_rule_limit'=>$subOrderCount];
|
|
|
$coupon = Db::name('verification_coupon')->where($wc)->find();
|
|
|
|
|
|
if(!empty($coupon)){
|
|
|
//发送给pid用户
|
|
|
$save = [];
|
|
|
$save['verification_coupon_id'] = $store['verification_coupon_id'];
|
|
|
$save['verification_store_id'] = $store['id'];
|
|
|
$save['user_id'] = $pid;
|
|
|
|
|
|
$save['type'] = 0;//使用情况
|
|
|
$save['closetime'] = $coupon['closetime'];
|
|
|
$save['receive_no'] = time().rand(1000,9999);
|
|
|
$res = (new \app\api\controller\v1\Index())->build($save['receive_no']);
|
|
|
$save['qr_code'] = $res;//二维码
|
|
|
$save['createtime'] = $time;
|
|
|
$save['verification_order_id'] = $order_id;
|
|
|
$save['coupon_type'] = $coupon['type'];
|
|
|
Db::name('verification_receive')->insert($save);
|
|
|
}
|
|
|
$save['type'] = 0;//使用情况
|
|
|
$save['closetime'] = $coupon['closetime'];
|
|
|
$save['receive_no'] = time().rand(1000,9999);
|
|
|
$res = (new \app\api\controller\v1\Index())->build($save['receive_no']);
|
|
|
$save['qr_code'] = $res;//二维码
|
|
|
$save['createtime'] = $time;
|
|
|
$save['verification_order_id'] = $order_id;
|
|
|
$save['coupon_type'] = $coupon['type'];
|
|
|
Db::name('verification_receive')->insert($save);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public function test_rule(){
|
|
|
$pid = 23;
|
|
|
$order_id = '223';
|
|
|
$pid = 1;
|
|
|
$order_id = '2';
|
|
|
$time = time();
|
|
|
$this->send_gift_certificate_url($pid,$order_id,$time);
|
|
|
}
|
...
|
...
|
|