request->get(); $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today'; $startTime = $get['startTime'] ?? ''; $endTime = $get['endTime'] ?? ''; $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true); $start = $period['startTime']; $end = $period['endTime']; $currentStartDate = date('Y-m-d', strtotime($start)); $currentEndDate = date('Y-m-d', strtotime($end)); $currentStartTime = $currentStartDate . ' 00:00:00'; $currentEndTime = $currentEndDate . ' 23:59:59'; $mainId = $this->mainId; $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', 'id'); $makeStat = []; $where = ['mainId' => $mainId, 'status' => 1]; $where['finishTime'] = ['between', [$currentStartTime, $currentEndTime]]; $workList = WorkClass::getAllByCondition($where, null, '*', null, true); if (!empty($workList)) { foreach ($workList as $work) { $kindId = $work->kindId ?? 0; if (empty($kindId)) { continue; } $staffId = $work->finishStaffId ?? 0; $num = $work->num ?? 0; $flowerNum = $work->flowerNum ?? 0; $staffName = $staffList[$staffId]['name'] ?? ''; if (isset($makeStat[$flowerNum][$staffId]['num'])) { $makeStat[$flowerNum][$staffId]['num'] = bcadd($makeStat[$flowerNum][$staffId]['num'], $num); } else { $makeStat[$flowerNum][$staffId]['num'] = $num; $makeStat[$flowerNum][$staffId]['name'] = $staffName; } } } util::success(['makeStat' => $makeStat]); } //花束相关统计 ssh 20230320 public function actionProfile() { $get = Yii::$app->request->get(); $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today'; $startTime = $get['startTime'] ?? ''; $endTime = $get['endTime'] ?? ''; $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true); $start = $period['startTime']; $end = $period['endTime']; $currentStartDate = date('Y-m-d', strtotime($start)); $currentEndDate = date('Y-m-d', strtotime($end)); $currentStartTime = $currentStartDate . ' 00:00:00'; $currentEndTime = $currentEndDate . ' 23:59:59'; $mainId = $this->mainId; $kindList = KindClass::getAllByCondition(['mainId' => $mainId, 'flower' => 1], null, '*', 'id'); $kindStat = []; $workTotalUseSmallNum = 0; $where = ['mainId' => $mainId, 'status' => 1]; $where['finishTime'] = ['between', [$currentStartTime, $currentEndTime]]; $workList = WorkClass::getAllByCondition($where, null, '*', null, true); if (!empty($workList)) { foreach ($workList as $work) { $kindId = $work->kindId ?? 0; if (empty($kindId)) { continue; } $kindName = $kindList[$kindId]['name'] ?? ''; $num = $work->num ?? 0; $smallNumber = $work->flowerNum ?? 0; $totalMakeSmallNum = bcmul($smallNumber, $num); $workTotalUseSmallNum = bcadd($workTotalUseSmallNum, $totalMakeSmallNum); if (isset($kindStat[$kindId]['makeNum'])) { $kindStat[$kindId]['makeNum'] = bcadd($kindStat[$kindId]['makeNum'], $num); $kindStat[$kindId]['makeSmallNum'] = bcadd($totalMakeSmallNum, $kindStat[$kindId]['makeSmallNum']); } else { $kindStat[$kindId]['makeNum'] = $num; $kindStat[$kindId]['makeSmallNum'] = $totalMakeSmallNum; $kindStat[$kindId]['kindName'] = $kindName; if (isset($kindStat[$kindId]['saleNum']) == false) { $kindStat[$kindId]['saleNum'] = 0; } } } } $where = ['mainId' => $mainId, 'payStatus' => 1, 'payTime' => ['between', [$currentStartTime, $currentEndTime]]]; $orderList = OrderClass::getAllByCondition($where, null, '*', null, true); if (!empty($orderList)) { foreach ($orderList as $order) { $orderSn = $order->orderSn ?? ''; $sonList = OrderGoodsClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true); if (!empty($sonList)) { foreach ($sonList as $son) { $flower = $son->flower ?? 0; if ($flower == 0) { continue; } $kindId = $son->kindId ?? 0; if (empty($kindId)) { continue; } $num = $son->num ?? 0; $kindName = $kindList[$kindId]['name'] ?? ''; if (isset($kindStat[$kindId]['saleNum'])) { $kindStat[$kindId]['saleNum'] = bcadd($kindStat[$kindId]['saleNum'], $num); } else { $kindStat[$kindId]['saleNum'] = $num; $kindStat[$kindId]['kindName'] = $kindName; if (isset($kindStat[$kindId]['makeNum']) == false) { $kindStat[$kindId]['makeNum'] = 0; $kindStat[$kindId]['makeSmallNum'] = 0; } } } } } } $itemList = ItemClass::getAllByCondition(['mainId' => $mainId, 'delStatus' => 0], null, 'id,name,mainId,delStatus,ratio', 'id'); $partStat = []; $partTotalSmallNum = 0; $partTotalNum = 0; $partList = PartClass::getAllByCondition(['mainId' => $mainId, 'addTime' => ['between', [$currentStartTime, $currentEndTime]]], null, '*', null, true); if (!empty($partList)) { foreach ($partList as $part) { $orderSn = $part->orderSn ?? ''; $partItemList = PartItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true); if (!empty($partItemList)) { foreach ($partItemList as $pItem) { $productId = $pItem->productId ?? 0; $ratio = $itemList[$productId]['ratio'] ?? 10; $ratioType = $itemList[$productId]['ratioType'] ?? 0; if ($ratioType == 1) { continue; } $name = $itemList[$productId]['name'] ?? ''; $num = $pItem->itemNum ?? 0; $num = floatval($num); $partTotalNum = bcadd($partTotalNum, $num); $smallNum = bcmul($ratio, $num); $partTotalSmallNum = bcadd($partTotalSmallNum, $smallNum); if (isset($partStat[$productId]['num'])) { $partStat[$productId]['num'] = bcadd($partStat[$productId]['num'], $num); $partStat[$productId]['smallNum'] = bcadd($partStat[$productId]['smallNum'], $smallNum); } else { $partStat[$productId]['num'] = $num; $partStat[$productId]['smallNum'] = $smallNum; $partStat[$productId]['name'] = $name; } } } } } util::success(['kindStat' => $kindStat, 'partStat' => $partStat, 'workTotalUseSmallNum' => $workTotalUseSmallNum, 'partTotalSmallNum' => $partTotalSmallNum, 'partTotalNum' => $partTotalNum]); } //绿植相关的统计 ssh 20230320 public function actionLzProfile() { $get = Yii::$app->request->get(); $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today'; $startTime = $get['startTime'] ?? ''; $endTime = $get['endTime'] ?? ''; $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true); $start = $period['startTime']; $end = $period['endTime']; $currentStartDate = date('Y-m-d', strtotime($start)); $currentEndDate = date('Y-m-d', strtotime($end)); $currentStartTime = $currentStartDate . ' 00:00:00'; $currentEndTime = $currentEndDate . ' 23:59:59'; $mainId = $this->mainId; $kindList = KindClass::getAllByCondition(['mainId' => $mainId, 'flower' => 0], null, '*', 'id'); $kindStat = []; $cgTotalNum = 0; $saleTotalNum = 0; $where = ['mainId' => $mainId, 'status' => 3]; $where['entryTime'] = ['between', [$currentStartTime, $currentEndTime]]; $lzList = PlantCgClass::getAllByCondition($where, null, '*', null, true); if (!empty($lzList)) { foreach ($lzList as $lz) { $orderSn = $lz->orderSn ?? ''; $lzItemList = PlantCgItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true); if (!empty($lzItemList)) { foreach ($lzItemList as $lzItem) { $kindId = $lzItem->kindId ?? 0; if (empty($kindId)) { continue; } $num = $lzItem->num ?? 0; $cgTotalNum = bcadd($cgTotalNum, $num); $kindName = $kindList[$kindId]['name'] ?? ''; if (isset($kindStat[$kindId]['cgNum'])) { $kindStat[$kindId]['cgNum'] = bcadd($kindStat[$kindId]['cgNum'], $num); } else { $kindStat[$kindId]['cgNum'] = $num; $kindStat[$kindId]['kindName'] = $kindName; if (isset($kindStat[$kindId]['saleNum']) == false) { $kindStat[$kindId]['saleNum'] = 0; } } } } } } $where = ['mainId' => $mainId, 'payStatus' => 1, 'payTime' => ['between', [$currentStartTime, $currentEndTime]]]; $orderList = OrderClass::getAllByCondition($where, null, '*', null, true); if (!empty($orderList)) { foreach ($orderList as $order) { $orderSn = $order->orderSn ?? ''; $sonList = OrderGoodsClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true); if (!empty($sonList)) { foreach ($sonList as $son) { $flower = $son->flower ?? 0; if ($flower == 1) { continue; } $kindId = $son->kindId ?? 0; if (empty($kindId)) { continue; } $num = $son->num ?? 0; $saleTotalNum = bcadd($saleTotalNum, $num); $kindName = $kindList[$kindId]['name'] ?? ''; if (isset($kindStat[$kindId]['saleNum'])) { $kindStat[$kindId]['saleNum'] = bcadd($kindStat[$kindId]['saleNum'], $num); } else { $kindStat[$kindId]['saleNum'] = $num; $kindStat[$kindId]['kindName'] = $kindName; if (isset($kindStat[$kindId]['cgNum']) == false) { $kindStat[$kindId]['cgNum'] = 0; } } } } } } util::success(['kindStat' => $kindStat, 'saleTotalNum' => $saleTotalNum, 'cgTotalNum' => $cgTotalNum]); } }