正在显示
1 个修改的文件
包含
30 行增加
和
29 行删除
@@ -497,41 +497,42 @@ truncate cv_verification_receive; | @@ -497,41 +497,42 @@ truncate cv_verification_receive; | ||
497 | public function send_gift_certificate_url($pid,$order_id,$time){ | 497 | public function send_gift_certificate_url($pid,$order_id,$time){ |
498 | $order_info = Db::name('verification_order')->where(['id'=>$order_id])->find(); | 498 | $order_info = Db::name('verification_order')->where(['id'=>$order_id])->find(); |
499 | $store = Db::name('verification_store')->where(['id'=>$order_info['verification_store_id']])->find(); | 499 | $store = Db::name('verification_store')->where(['id'=>$order_info['verification_store_id']])->find(); |
500 | - $activity = Db::name('verification_activity')->where(['id'=>$order_info['verification_activity_id']])->find(); | ||
501 | - //获取门店下的礼品券 | ||
502 | - if(!empty($activity['verification_coupon_ids'])){ | ||
503 | - | ||
504 | - //判断当前父级的所有下级的订单数,是否满足 send_rule_limit 的规则 | ||
505 | - $subIds = Db::name('user')->where(['pid'=>$pid])->column('id'); | ||
506 | - $subOrderCount = Db::name('verification_order')->where(['user_id'=>['in',$subIds],'type'=>['>','0']])->count(); | ||
507 | - | ||
508 | - //获取卡券 | ||
509 | - //当前活动对应的所有券 | ||
510 | - $coupon = Db::name('verification_coupon')->where(['id'=>['in',$activity['verification_coupon_ids']],'type'=>1,'send_rule_limit'=>$subOrderCount])->find(); | 500 | + |
501 | + | ||
502 | + | ||
511 | 503 | ||
512 | - if(!empty($coupon)){ | ||
513 | - //发送给pid用户 | ||
514 | - $save = []; | ||
515 | - $save['verification_coupon_id'] = $store['verification_coupon_id']; | ||
516 | - $save['verification_store_id'] = $store['id']; | ||
517 | - $save['user_id'] = $pid; | 504 | + //判断当前父级的所有下级的订单数,是否满足 send_rule_limit 的规则 |
505 | + $subIds = Db::name('user')->where(['pid'=>$pid])->column('id'); | ||
506 | + $subOrderCount = Db::name('verification_order')->where(['user_id'=>['in',$subIds],'type'=>['>','0']])->count(); | ||
507 | + | ||
508 | + //获取卡券 | ||
509 | + //当前活动对应的所有券 | ||
510 | + $wc = ['verification_store_id'=>$order_info['verification_store_id'],'type'=>1,'send_rule_limit'=>$subOrderCount]; | ||
511 | + $coupon = Db::name('verification_coupon')->where($wc)->find(); | ||
512 | + | ||
513 | + if(!empty($coupon)){ | ||
514 | + //发送给pid用户 | ||
515 | + $save = []; | ||
516 | + $save['verification_coupon_id'] = $store['verification_coupon_id']; | ||
517 | + $save['verification_store_id'] = $store['id']; | ||
518 | + $save['user_id'] = $pid; | ||
518 | 519 | ||
519 | - $save['type'] = 0;//使用情况 | ||
520 | - $save['closetime'] = $coupon['closetime']; | ||
521 | - $save['receive_no'] = time().rand(1000,9999); | ||
522 | - $res = (new \app\api\controller\v1\Index())->build($save['receive_no']); | ||
523 | - $save['qr_code'] = $res;//二维码 | ||
524 | - $save['createtime'] = $time; | ||
525 | - $save['verification_order_id'] = $order_id; | ||
526 | - $save['coupon_type'] = $coupon['type']; | ||
527 | - Db::name('verification_receive')->insert($save); | ||
528 | - } | 520 | + $save['type'] = 0;//使用情况 |
521 | + $save['closetime'] = $coupon['closetime']; | ||
522 | + $save['receive_no'] = time().rand(1000,9999); | ||
523 | + $res = (new \app\api\controller\v1\Index())->build($save['receive_no']); | ||
524 | + $save['qr_code'] = $res;//二维码 | ||
525 | + $save['createtime'] = $time; | ||
526 | + $save['verification_order_id'] = $order_id; | ||
527 | + $save['coupon_type'] = $coupon['type']; | ||
528 | + Db::name('verification_receive')->insert($save); | ||
529 | } | 529 | } |
530 | + | ||
530 | } | 531 | } |
531 | 532 | ||
532 | public function test_rule(){ | 533 | public function test_rule(){ |
533 | - $pid = 23; | ||
534 | - $order_id = '223'; | 534 | + $pid = 1; |
535 | + $order_id = '2'; | ||
535 | $time = time(); | 536 | $time = time(); |
536 | $this->send_gift_certificate_url($pid,$order_id,$time); | 537 | $this->send_gift_certificate_url($pid,$order_id,$time); |
537 | } | 538 | } |
-
请 注册 或 登录 后发表评论