|
@@ -735,7 +735,7 @@ class AgentTools{
|
|
|
}
|
|
|
$purchaseShopId = $purchaseData["shopId"];
|
|
|
$shopData = $this->dbShop->get(["id"=>$purchaseShopId,"enterpriseId"=>$this->enterpriseId,"deleteStatus"=>5]);
|
|
|
- if(empty($shopData) || empty($shopData["pTwoShopId"])){
|
|
|
+ if(empty($shopData) || empty($shopData["parentPath"])){
|
|
|
return ["code"=>-1,"msg"=>"门店被删除或者没有父级门店"];
|
|
|
}
|
|
|
//开始计算
|
|
@@ -748,30 +748,27 @@ class AgentTools{
|
|
|
return ["code"=>-1,"msg"=>"采购实际金额小于等于0"];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- $data=[];
|
|
|
$nowTime = time();
|
|
|
$levelAr = ["xxxx","one","two"];
|
|
|
|
|
|
-
|
|
|
- //获取门店父级列表
|
|
|
- if(empty($shopData["parentPath"])){
|
|
|
- return ["code"=>-1,"msg"=>"门店没有父级门店"];
|
|
|
- }
|
|
|
//从最底层开始更新等级
|
|
|
$pathData = array_reverse(explode(",", trim($shopData["parentPath"])));
|
|
|
$calcData=[];
|
|
|
$directorId = 0;//第一个董事店铺的id
|
|
|
+ $errorMsg = "";
|
|
|
+
|
|
|
for($i=0;$i<count($pathData);$i++){
|
|
|
if(empty($pathData[$i])){
|
|
|
continue;
|
|
|
}
|
|
|
$pData = $this->dbShop->get(["id"=>(int)$pathData[$i],"enterpriseId"=>$this->enterpriseId,"deleteStatus"=>5]);
|
|
|
if(empty($pData) || empty($pData["agentId"])){
|
|
|
+ $errorMsg .= "门店[{$pathData[$i]}]不存在或没有绑定负责人账号;";
|
|
|
continue;
|
|
|
}
|
|
|
$pAgentData = $this->dbNewAgent->get(["id"=>$pData["agentId"]]);
|
|
|
if(empty($pAgentData)){
|
|
|
+ $errorMsg .= "门店[{$pathData[$i]}]负责人账号为空;";
|
|
|
continue;
|
|
|
}
|
|
|
$per = 0;
|
|
@@ -786,9 +783,11 @@ class AgentTools{
|
|
|
//佣金本金
|
|
|
$pmoney = bcmul($purchaseMoney,$per,2);
|
|
|
if($pmoney<=0){
|
|
|
+ $errorMsg .= "门店[{$pathData[$i]}]佣金本金为{$pmoney};";
|
|
|
continue;
|
|
|
}
|
|
|
if($directorId>0 && $pData["level"]==3){
|
|
|
+ $errorMsg .= "门店[{$pathData[$i]}]不是第一级董事;";
|
|
|
continue;
|
|
|
}
|
|
|
$item = [
|
|
@@ -832,12 +831,13 @@ class AgentTools{
|
|
|
}
|
|
|
}
|
|
|
if($item["commission"]<=0){
|
|
|
+ $errorMsg .= "门店[{$pathData[$i]}]佣金为{$item["commission"]};";
|
|
|
continue;
|
|
|
}
|
|
|
$calcData[]=$item;
|
|
|
}
|
|
|
if(empty($calcData)){
|
|
|
- return ["code"=>-1,"msg"=>"没有符合佣金条件的上级"];
|
|
|
+ return ["code"=>-1,"msg"=>"没有符合佣金条件的上级:".$errorMsg];
|
|
|
}
|
|
|
$num=0;
|
|
|
//开启事务
|
|
@@ -907,10 +907,10 @@ class AgentTools{
|
|
|
}
|
|
|
if($num<=0){
|
|
|
$this->dbNewAgentDetail->rollBack();
|
|
|
- return ["code"=>-1,"msg"=>"数据更新失败:".$lms];
|
|
|
+ return ["code"=>-1,"msg"=>"数据更新失败:".$lms."[{$errorMsg}]"];
|
|
|
}
|
|
|
$this->dbNewAgentDetail->commit();
|
|
|
- return ["code"=>1,"msg"=>"执行成功".$lms];
|
|
|
+ return ["code"=>1,"msg"=>"执行成功".$lms."[{$errorMsg}]"];
|
|
|
}
|
|
|
|
|
|
|