作者 郭文星
@@ -382,7 +382,7 @@ class Wechat extends Api @@ -382,7 +382,7 @@ class Wechat extends Api
382 if(!empty($myInfo['pid'])){ 382 if(!empty($myInfo['pid'])){
383 //上级 383 //上级
384 try{ 384 try{
385 - $this->getParent($myInfo['pid'],$order_info['verification_store_id'],$order_info['id']); 385 + $this->getParent($myInfo['pid'],$order_info['verification_coupon_ids'],$order_info['id']);
386 }catch(\Exception $e){ 386 }catch(\Exception $e){
387 Common::put_file_log('上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__); 387 Common::put_file_log('上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__);
388 }die; 388 }die;
@@ -391,7 +391,7 @@ class Wechat extends Api @@ -391,7 +391,7 @@ class Wechat extends Api
391 $w1['id'] = $myInfo['pid']; 391 $w1['id'] = $myInfo['pid'];
392 $myInfoP = Db::name('user')->where($w1)->find(); 392 $myInfoP = Db::name('user')->where($w1)->find();
393 if(!empty($myInfoP['pid'])){ 393 if(!empty($myInfoP['pid'])){
394 - $this->getParent($myInfoP['pid'],$order_info['verification_store_id'],$order_info['id']); 394 + $this->getParent($myInfoP['pid'],$order_info['verification_coupon_ids'],$order_info['id']);
395 } 395 }
396 }catch(\Exception $e){ 396 }catch(\Exception $e){
397 Common::put_file_log('上级的上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__); 397 Common::put_file_log('上级的上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__);
@@ -400,7 +400,8 @@ class Wechat extends Api @@ -400,7 +400,8 @@ class Wechat extends Api
400 } 400 }
401 401
402 //支付后,根据用户角色 处理对应的事情 402 //支付后,根据用户角色 处理对应的事情
403 - private function getParent($pid,$verification_store_id,$order_id){ 403 + private function getParent($pid,$verification_coupon_ids,$order_id){
  404 +
404 //上级身份 405 //上级身份
405 $time = time(); 406 $time = time();
406 $w1 = []; 407 $w1 = [];
@@ -412,15 +413,14 @@ class Wechat extends Api @@ -412,15 +413,14 @@ class Wechat extends Api
412 $this->grant_commission($pid,$order_id); 413 $this->grant_commission($pid,$order_id);
413 }else{ 414 }else{
414 //属于普通用户 发送代金券 415 //属于普通用户 发送代金券
415 - $this->send_voucher($pid,$verification_store_id,$order_id,$time); 416 + $this->send_voucher($pid,$verification_coupon_ids,$order_id,$time);
416 } 417 }
417 } 418 }
418 419
419 - //发放代金券  
420 - public function send_voucher($pid,$verification_store_id,$order_id,$time){ 420 + //发放 对应活动包含的券
  421 + public function send_voucher($pid,$verification_coupon_ids,$order_id,$time){
421 $w1 = []; 422 $w1 = [];
422 - $w1['verification_store_id'] = $verification_store_id;  
423 - $w1['closetime'] = ['<',$time]; 423 + $w1['id'] = ['in',$verification_coupon_ids];
424 $coupon = Db::name('verification_coupon')->where($w1)->select(); 424 $coupon = Db::name('verification_coupon')->where($w1)->select();
425 if(!empty($coupon)){ 425 if(!empty($coupon)){
426 foreach($coupon as $k=>$v){ 426 foreach($coupon as $k=>$v){
@@ -534,4 +534,8 @@ class Wechat extends Api @@ -534,4 +534,8 @@ class Wechat extends Api
534 } 534 }
535 535
536 } 536 }
  537 +
  538 +
  539 +
  540 +
537 } 541 }