$val) { $shopAdminId = $val['shopAdminId']; if (isset($arr[$shopAdminId]) == false) { $arr[$shopAdminId] = ['amount' => 0, 'num' => 0]; } $arr[$shopAdminId]['amount'] = bcadd($val['amount'], $arr[$shopAdminId]['amount'], 2); $arr[$shopAdminId]['num'] = bcadd($val['num'], $arr[$shopAdminId]['num']); } $ids = array_keys($arr); $admin = ShopAdminClass::getByIds($ids); $show = []; foreach ($admin as $key => $val) { $adminId = $val['id']; $name = $val['name'] ?? ''; $amount = $arr[$adminId]['amount'] ?? 0.00; $num = $arr[$adminId]['num'] ?? 0; $show[] = [ 'name' => $name, 'amount' => $amount, 'num' => $num, 'id' => $val['id'], ]; } //排序 $show = arrayUtil::arraySort($show, 'amount'); return ['list' => $show]; } //增加业绩 ssh 2021.3.20 public static function addYj($main, $shop, $shopAdminId, $amount, $date = null) { $sjId = $shop->sjId ?? 0; $mainId = $main->id ?? 0; $date = isset($date) ? $date : date("Ymd"); $stat = self::getByCondition(['shopAdminId' => $shopAdminId, 'mainId' => $mainId, 'sjId' => $sjId, 'time' => $date], true); if (empty($stat)) { $stat = self::add(['sjId' => $sjId, 'shopAdminId' => $shopAdminId, 'mainId' => $mainId, 'time' => $date], true); } $stat->num += 1; $stat->totalNum += 1; $stat->amount = bcadd($amount, $stat->amount, 2); $stat->totalAmount = bcadd($amount, $stat->totalAmount, 2); $stat->save(); StatYjMonthClass::addYj($main, $shop, $shopAdminId, $amount); } }