From 756dddf042bffdd514f0b0d05e0cc97552d2396b Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Thu, 23 Nov 2023 18:11:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E4=B8=9A=E7=BB=A9?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E8=BE=BE=E6=A0=87=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team-dividend/src/api/IndexController.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/plugins/team-dividend/src/api/IndexController.php b/plugins/team-dividend/src/api/IndexController.php index 21ac5bd2..d37095ed 100644 --- a/plugins/team-dividend/src/api/IndexController.php +++ b/plugins/team-dividend/src/api/IndexController.php @@ -5,6 +5,7 @@ namespace Yunshop\TeamDividend\Api; use app\common\components\ApiController; use app\common\models\Member; +use app\common\models\Order; use Illuminate\Support\Facades\DB; use Yunshop\TeamDividend\admin\models\MemberChild; use Yunshop\TeamDividend\models\CodeRecordModel; @@ -275,4 +276,41 @@ class IndexController extends ApiController return $this->errorJson('激活码使用失败'); } } + + + // 业绩是否完成 + public function performanceComplete(){ + // 基本参数 + $target = 500000; + $isComplete = 0; + $memberId = \YunShop::app()->getMemberId(); + $areaAmount = 0; + if($memberId > 0){ + // 获取直推下级列表 + $subIds = MemberChild::uniacid() + ->where('level',1) + ->where('member_id',$memberId) + ->pluck('child_id') + ->toArray(); + $subPerformance = [];// 每条线的业绩 + foreach($subIds as $subUid){ + $lineAllUid = MemberChild::uniacid()->where('member_id',$subUid)->pluck('child_id')->toArray(); + $lineAllUid[] = $subUid; + $subPerformance[$subUid] = Order::whereIn('uid',$lineAllUid)->where('status','>=',0)->sum('yz_order.price'); + } + // 计算业绩 + $teamAmount = (float)sprintf("%.2f",array_sum($subPerformance));// 总业绩 + $maxAmount = max($subPerformance);// 最大一条线的业绩 + $areaAmount = (float)sprintf("%.2f",$teamAmount - $maxAmount);// 小区业绩 = 总业绩 - 最大一条线的业绩 + $isComplete = $areaAmount >= $target ? 1 : 0; + } + + return $this->successJson('业绩是否完成', [ + 'is_complete' => $isComplete, + 'area_amount' => $areaAmount + ]); + } + + + } \ No newline at end of file