...
|
...
|
@@ -374,11 +374,20 @@ class Wechat extends Api |
|
|
//是否与上级
|
|
|
if(!empty($myInfo['pid'])){
|
|
|
//上级
|
|
|
$this->getParent($myInfo['pid'],$order_info['verification_store_id'],$order_info['id']);
|
|
|
try{
|
|
|
$this->getParent($myInfo['pid'],$order_info['verification_store_id'],$order_info['id']);
|
|
|
}catch(\Exception $e){
|
|
|
Common::put_file_log('上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
}
|
|
|
//上级的上级
|
|
|
$w1['id'] = $myInfo['pid'];
|
|
|
$myInfoP = Db::name('user')->where($w1)->find();
|
|
|
$this->getParent($myInfoP['id'],$order_info['verification_store_id'],$order_info['id']);
|
|
|
try{
|
|
|
$w1['id'] = $myInfo['pid'];
|
|
|
$myInfoP = Db::name('user')->where($w1)->find();
|
|
|
$this->getParent($myInfoP['id'],$order_info['verification_store_id'],$order_info['id']);
|
|
|
}catch(\Exception $e){
|
|
|
Common::put_file_log('上级的上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -387,12 +396,13 @@ class Wechat extends Api |
|
|
private function getParent($pid,$verification_store_id,$order_id){
|
|
|
//上级身份
|
|
|
$time = time();
|
|
|
$w1 = [];
|
|
|
$w1['user_id'] = $pid;
|
|
|
$w1['verification_store_id'] = $verification_store_id;
|
|
|
$role = Db::name('verification_staff')->where($w1)->find();
|
|
|
if(in_array($role['type'],['1','3'])){
|
|
|
//属于代理 企业付款到佣金
|
|
|
$this->grant_commission($pid,$order_id);
|
|
|
//$this->grant_commission($pid,$order_id);
|
|
|
}else{
|
|
|
//属于普通用户 发送代金券
|
|
|
$this->send_voucher($pid,$verification_store_id,$order_id,$time);
|
...
|
...
|
@@ -401,6 +411,7 @@ class Wechat extends Api |
|
|
|
|
|
//发放代金券
|
|
|
public function send_voucher($pid,$verification_store_id,$order_id,$time){
|
|
|
$w1 = [];
|
|
|
$w1['verification_store_id'] = $verification_store_id;
|
|
|
$w1['closetime'] = ['<',$time];
|
|
|
$coupon = Db::name('verification_coupon')->where($w1)->select();
|
...
|
...
|
@@ -425,7 +436,8 @@ class Wechat extends Api |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 发放佣金
|
|
|
|
|
|
// 发放佣金 企业付款到零钱
|
|
|
public function grant_commission($pid=0,$order_id=0){
|
|
|
try{
|
|
|
$verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find();
|
...
|
...
|
@@ -439,7 +451,8 @@ class Wechat extends Api |
|
|
'desc' => '理赔', // 企业付款操作说明信息。必填
|
|
|
]);
|
|
|
if($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
|
|
|
//记录佣金表
|
|
|
//记录佣金表 后台没有配置
|
|
|
|
|
|
}else{
|
|
|
Common::put_file_log('失败-佣金发放',json_encode($result), 'grant_commission', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
}
|
...
|
...
|
|