|
@@ -115,6 +115,7 @@ class PartnerTools{
|
|
|
if(empty($res)){
|
|
|
return false;
|
|
|
}else{
|
|
|
+ $this->getPartnerData($userData["id"], $userData["userCenterId"]);
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -244,21 +245,22 @@ class PartnerTools{
|
|
|
if(empty($bottomPartnerData)){
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
//计算顶层收益
|
|
|
$topData = $this->calcMoney($bottomData["parentData"],$bottomData["commission"]);
|
|
|
if(!empty($topData)){
|
|
|
+ $topPartnerData = $this->getPartnerData($topData["parentData"]["id"], $topData["parentData"]["userCenterId"]);
|
|
|
+ if(empty($topPartnerData)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
//记录顶层收益
|
|
|
$data[]=[
|
|
|
"orderMoney"=>$orderMoney,//订单支付金额
|
|
|
"calcMoney"=>$topData["money"],//佣金计算金额
|
|
|
"sourceCustomerId"=>$topData["childId"],//来源客户id
|
|
|
- "partnerId"=>$topData["parentId"],//收钱合伙人id
|
|
|
+ "partnerId"=>$topPartnerData["id"],//收钱合伙人账号id
|
|
|
+ "customerId"=>$topPartnerData["customerId"],//收钱合伙人
|
|
|
+ "userCenterId"=>$topPartnerData["userCenterId"],//收钱合伙人
|
|
|
"commission"=>$topData["commission"],//佣金金额
|
|
|
"per"=>$topData["per"],//佣金比例
|
|
|
"type"=>1,//1表示子级合伙人收益计算收益,0表示子级消费计算收益
|
|
@@ -275,7 +277,9 @@ class PartnerTools{
|
|
|
"orderMoney"=>$orderMoney,//订单支付金额
|
|
|
"calcMoney"=>$bottomData["money"],//佣金计算金额
|
|
|
"sourceCustomerId"=>$bottomData["childId"],//来源客户id
|
|
|
- "partnerId"=>$bottomData["parentId"],//收钱合伙人id
|
|
|
+ "partnerId"=>$bottomPartnerData["id"],//收钱合伙人账号id
|
|
|
+ "customerId"=>$bottomPartnerData["customerId"],//收钱合伙人
|
|
|
+ "userCenterId"=>$bottomPartnerData["userCenterId"],//收钱合伙人
|
|
|
"commission"=>$bottomData["commission"],//佣金金额
|
|
|
"per"=>$bottomData["per"],//佣金比例
|
|
|
"type"=>0,
|
|
@@ -287,23 +291,25 @@ class PartnerTools{
|
|
|
"time"=>$nowTime,
|
|
|
"partnerId"=>$bottomPartnerData["id"],
|
|
|
];
|
|
|
- //添加佣金余额和明细
|
|
|
- //可以新建一个佣金余额表newCommissionPartner
|
|
|
- //newCommissionDetail9
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ $num=0;
|
|
|
+ foreach($data as $k=>$v){
|
|
|
+ $count = $this->dbNewCommissionDetail->count(["orderId"=>$v["orderId"],"partnerId"=>$v["partnerId"]]);
|
|
|
+ if($count>0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $id = $this->dbNewCommissionDetail->insert($v);
|
|
|
+ if(!empty($id)){
|
|
|
+ $num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if($num<=0){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
//佣金更新完后验证设置合伙人
|
|
|
if($bottomData["isUpgrade"]==1){
|
|
|
$this->setPartner($bottomData["childId"]);
|
|
|
}
|
|
|
- return $data;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
public function getPartnerData($customerId,$userCenterId){
|