|
|
@@ -3,8 +3,12 @@
|
|
|
namespace hd\controllers;
|
|
|
|
|
|
use bizHd\goods\classes\KindClass;
|
|
|
+use bizHd\item\classes\ItemClass;
|
|
|
+use bizHd\order\classes\OrderClass;
|
|
|
+use bizHd\order\classes\OrderGoodsClass;
|
|
|
+use bizHd\part\classes\PartClass;
|
|
|
+use bizHd\part\classes\PartItemClass;
|
|
|
use bizHd\work\classes\WorkClass;
|
|
|
-use bizHd\work\classes\WorkItemClass;
|
|
|
use common\components\dateUtil;
|
|
|
use Yii;
|
|
|
use common\components\util;
|
|
|
@@ -32,7 +36,7 @@ class StatKindController extends BaseController
|
|
|
|
|
|
$kindList = KindClass::getAllByCondition(['mainId' => $mainId, 'flower' => 1, 'delStatus' => 0, 'status' => 1], null, '*', 'id');
|
|
|
|
|
|
- $arr = [];
|
|
|
+ $kindStat = [];
|
|
|
|
|
|
$where = ['mainId' => $mainId, 'status' => 1];
|
|
|
$where['finishTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
@@ -45,16 +49,82 @@ class StatKindController extends BaseController
|
|
|
}
|
|
|
$kindName = $kindList[$kindId]['name'] ?? '';
|
|
|
$num = $work->num ?? 0;
|
|
|
- if (isset($arr[$kindId]['makeNum'])) {
|
|
|
- $arr[$kindId]['makeNum'] = bcadd($arr[$kindId]['makeNum'], $num);
|
|
|
+ $flowerNum = $work->flowerNum ?? 0;
|
|
|
+ $totalFlowerNum = bcmul($flowerNum, $num);
|
|
|
+ if (isset($kindStat[$kindId]['makeNum'])) {
|
|
|
+ $kindStat[$kindId]['makeNum'] = bcadd($kindStat[$kindId]['makeNum'], $num);
|
|
|
+ $kindStat[$kindId]['flowerNum'] = bcadd($totalFlowerNum, $kindStat[$kindId]['flowerNum']);
|
|
|
} else {
|
|
|
- $arr[$kindId]['makeNum'] = $num;
|
|
|
- $arr[$kindId]['name'] = $kindName;
|
|
|
+ $kindStat[$kindId]['makeNum'] = $num;
|
|
|
+ $kindStat[$kindId]['flowerNum'] = $totalFlowerNum;
|
|
|
+ $kindStat[$kindId]['kindName'] = $kindName;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //util::success(['list' => $incomeList, 'totalIncome' => $totalIncome]);
|
|
|
+ $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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $itemList = ItemClass::getAllByCondition(['mainId' => $mainId, 'delStatus' => 0], null, 'id,name,mainId,delStatus,ratio', 'id');
|
|
|
+
|
|
|
+ $partStat = [];
|
|
|
+
|
|
|
+ $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;
|
|
|
+ $smallNum = bcmul($ratio, $num);
|
|
|
+ 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]);
|
|
|
}
|
|
|
|
|
|
}
|