|
@@ -7,16 +7,52 @@ use JinDouYun\Cache\CustomerCache;
|
|
use JinDouYun\Dao\Order\DOrderIndex;
|
|
use JinDouYun\Dao\Order\DOrderIndex;
|
|
use JinDouYun\Dao\Order\DOrder;
|
|
use JinDouYun\Dao\Order\DOrder;
|
|
|
|
|
|
|
|
+use JinDouYun\Dao\CommissionPartner\DNewCommissionBalanceDetail;
|
|
|
|
+use JinDouYun\Dao\CommissionPartner\DNewCommissionCash;
|
|
|
|
+use JinDouYun\Dao\CommissionPartner\DNewCommissionDetail;
|
|
|
|
+use JinDouYun\Dao\CommissionPartner\DNewCommissionPartner;
|
|
|
|
+
|
|
class PartnerTools{
|
|
class PartnerTools{
|
|
private $dbCustomer;
|
|
private $dbCustomer;
|
|
|
|
+
|
|
|
|
+ private $dbNewCommissionPartner;
|
|
|
|
+ private $dbNewCommissionDetail;
|
|
|
|
+ private $dbNewCommissionCash;
|
|
|
|
+ private $dbNewCommissionBalanceDetail;
|
|
|
|
+
|
|
|
|
+
|
|
private $enterpriseId;
|
|
private $enterpriseId;
|
|
private $cutTable = 1;//客户按照企业id分表
|
|
private $cutTable = 1;//客户按照企业id分表
|
|
private $errorMsg = "";
|
|
private $errorMsg = "";
|
|
public function __construct($enterpriseId){
|
|
public function __construct($enterpriseId){
|
|
$this->enterpriseId = $enterpriseId;
|
|
$this->enterpriseId = $enterpriseId;
|
|
|
|
+ //用户表
|
|
$this->dbCustomer = new DCustomer('default');
|
|
$this->dbCustomer = new DCustomer('default');
|
|
- $tableName = $this->dbCustomer->getTableName($this->dbCustomer->get_Table(), $this->enterpriseId, $this->cutTable);
|
|
|
|
- $this->dbCustomer->setTable($tableName);
|
|
|
|
|
|
+ $customerTableName = $this->dbCustomer->getTableName($this->dbCustomer->get_Table(), $this->enterpriseId, $this->cutTable);
|
|
|
|
+ $this->dbCustomer->setTable($customerTableName);
|
|
|
|
+
|
|
|
|
+ //新分销合伙人表
|
|
|
|
+ $this->dbNewCommissionPartner = new DNewCommissionPartner('default');
|
|
|
|
+ $newCommissionPartnerTableName = $this->dbNewCommissionPartner->getTableName($this->dbNewCommissionPartner->get_Table(), $this->enterpriseId, $this->cutTable);
|
|
|
|
+ $this->dbNewCommissionPartner->setTable($newCommissionPartnerTableName);
|
|
|
|
+
|
|
|
|
+ //新分销佣金明细表
|
|
|
|
+ $this->dbNewCommissionDetail = new DNewCommissionDetail('default');
|
|
|
|
+ $newCommissionDetailTableName = $this->dbNewCommissionDetail->getTableName($this->dbNewCommissionDetail->get_Table(), $this->enterpriseId, $this->cutTable);
|
|
|
|
+ $this->dbNewCommissionDetail->setTable($newCommissionDetailTableName);
|
|
|
|
+
|
|
|
|
+ //新分销合伙人提现表
|
|
|
|
+ $this->dbNewCommissionCash = new DNewCommissionCash('default');
|
|
|
|
+ $newCommissionCashTableName = $this->dbNewCommissionCash->getTableName($this->dbNewCommissionCash->get_Table(), $this->enterpriseId, $this->cutTable);
|
|
|
|
+ $this->dbNewCommissionCash->setTable($newCommissionCashTableName);
|
|
|
|
+
|
|
|
|
+ //新分销合伙人余额明细表
|
|
|
|
+ $this->dbNewCommissionBalanceDetail = new DNewCommissionBalanceDetail('default');
|
|
|
|
+ $newCommissionBalanceDetailTableName = $this->dbNewCommissionBalanceDetail->getTableName($this->dbNewCommissionBalanceDetail->get_Table(), $this->enterpriseId, $this->cutTable);
|
|
|
|
+ $this->dbNewCommissionBalanceDetail->setTable($newCommissionBalanceDetailTableName);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -136,8 +172,10 @@ class PartnerTools{
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
$per = 0.1;//佣金比例
|
|
$per = 0.1;//佣金比例
|
|
|
|
+ $isUpgrade = 0;
|
|
if($money>=20000 && $customerData["isPartner"]==0){
|
|
if($money>=20000 && $customerData["isPartner"]==0){
|
|
$per = 0.05;
|
|
$per = 0.05;
|
|
|
|
+ $isUpgrade = 1;
|
|
}
|
|
}
|
|
$resData=[
|
|
$resData=[
|
|
"childId"=>$customerData["id"],
|
|
"childId"=>$customerData["id"],
|
|
@@ -146,7 +184,8 @@ class PartnerTools{
|
|
"parentData"=>$parentData,
|
|
"parentData"=>$parentData,
|
|
"per"=>$per,
|
|
"per"=>$per,
|
|
"money"=>$money,
|
|
"money"=>$money,
|
|
- "commission"=>$money * $per
|
|
|
|
|
|
+ "commission"=>$money * $per,
|
|
|
|
+ "isUpgrade"=>$isUpgrade
|
|
];
|
|
];
|
|
return $resData;
|
|
return $resData;
|
|
}
|
|
}
|
|
@@ -213,19 +252,27 @@ class PartnerTools{
|
|
"per"=>$topData["per"],//佣金比例
|
|
"per"=>$topData["per"],//佣金比例
|
|
"type"=>1,//1表示子级合伙人收益计算收益,0表示子级消费计算收益
|
|
"type"=>1,//1表示子级合伙人收益计算收益,0表示子级消费计算收益
|
|
"orderId"=>$orderData["id"],
|
|
"orderId"=>$orderData["id"],
|
|
|
|
+ "status"=>0,
|
|
|
|
+ "title"=>"合伙人收益分佣",
|
|
|
|
+ "isUpgrade"=>$topData["isUpgrade"],
|
|
|
|
+ "mono"=>"",
|
|
"time"=>$nowTime,
|
|
"time"=>$nowTime,
|
|
];
|
|
];
|
|
}
|
|
}
|
|
//记录底层收益
|
|
//记录底层收益
|
|
$data[]=[
|
|
$data[]=[
|
|
"orderMoney"=>$orderMoney,//订单支付金额
|
|
"orderMoney"=>$orderMoney,//订单支付金额
|
|
- "calcMoney"=>$topData["money"],//佣金计算金额
|
|
|
|
- "sourceCustomerId"=>$topData["childId"],//来源客户id
|
|
|
|
- "partnerId"=>$topData["parentId"],//收钱合伙人id
|
|
|
|
- "commission"=>$topData["commission"],//佣金金额
|
|
|
|
- "per"=>$topData["per"],//佣金比例
|
|
|
|
|
|
+ "calcMoney"=>$bottomData["money"],//佣金计算金额
|
|
|
|
+ "sourceCustomerId"=>$bottomData["childId"],//来源客户id
|
|
|
|
+ "partnerId"=>$bottomData["parentId"],//收钱合伙人id
|
|
|
|
+ "commission"=>$bottomData["commission"],//佣金金额
|
|
|
|
+ "per"=>$bottomData["per"],//佣金比例
|
|
"type"=>0,
|
|
"type"=>0,
|
|
"orderId"=>$orderData["id"],
|
|
"orderId"=>$orderData["id"],
|
|
|
|
+ "status"=>0,
|
|
|
|
+ "title"=>"子级消费分佣",
|
|
|
|
+ "isUpgrade"=>$bottomData["isUpgrade"],
|
|
|
|
+ "mono"=>"",
|
|
"time"=>$nowTime,
|
|
"time"=>$nowTime,
|
|
];
|
|
];
|
|
//添加佣金余额和明细
|
|
//添加佣金余额和明细
|
|
@@ -236,8 +283,8 @@ class PartnerTools{
|
|
|
|
|
|
|
|
|
|
//佣金更新完后验证设置合伙人
|
|
//佣金更新完后验证设置合伙人
|
|
- if($orderMoney>20000 && $customerData["isPartner"]==0){
|
|
|
|
- $this->setPartner($customerData["id"]);
|
|
|
|
|
|
+ if($bottomData["isUpgrade"]==1){
|
|
|
|
+ $this->setPartner($bottomData["childId"]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|