|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace hd\controllers;
|
|
|
|
|
|
+use bizHd\ghs\classes\GhsClass;
|
|
|
use bizHd\product\classes\ProductClass;
|
|
|
use bizHd\purchase\classes\PurchaseItemClass;
|
|
|
use common\components\arrayUtil;
|
|
|
@@ -17,7 +18,7 @@ class StatCgController extends BaseController
|
|
|
{
|
|
|
$get = Yii::$app->request->get();
|
|
|
$where = ['mainId' => $this->mainId];
|
|
|
- $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today';
|
|
|
+ $searchTime = !empty($get['searchTime']) ? $get['searchTime'] : 'today';
|
|
|
$startTime = $get['startTime'] ?? '';
|
|
|
$endTime = $get['endTime'] ?? '';
|
|
|
$period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
|
|
|
@@ -26,9 +27,21 @@ class StatCgController extends BaseController
|
|
|
$startDate = date("Y-m-d 00:00:00", strtotime($start));
|
|
|
$endDate = date("Y-m-d 23:59:59", strtotime($end));
|
|
|
$where['payTime'] = ['between', [$startDate, $endDate]];
|
|
|
- if (isset($get['ghsId']) && !empty($get['ghsId'])) {
|
|
|
+ if (!empty($get['ghsId'])) {
|
|
|
$where['ghsId'] = $get['ghsId'];
|
|
|
}
|
|
|
+
|
|
|
+ $showGhsParam = $get['showGhsParam'] ?? 0;
|
|
|
+ $ghsProduct = [];
|
|
|
+ if ($showGhsParam == 1) {
|
|
|
+ $ghsId = $get['ghsId'] ?? 0;
|
|
|
+ $ghs = GhsClass::getById($ghsId, true);
|
|
|
+ if (!empty($ghs)) {
|
|
|
+ $ghsMainId = $ghs->mainId ?? 0;
|
|
|
+ $ghsProduct = ProductClass::getAllByCondition(['mainId' => $ghsMainId, 'delStatus' => 0], null, 'id,name,itemId', 'itemId');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$list = PurchaseItemClass::getAllByCondition($where, null, '*');
|
|
|
if (empty($list)) {
|
|
|
util::success(['list' => $list]);
|
|
|
@@ -41,8 +54,10 @@ class StatCgController extends BaseController
|
|
|
$totalAmount = 0;
|
|
|
foreach ($list as $key => $val) {
|
|
|
$productId = $val['productId'] ?? 0;
|
|
|
+ $ptItemId = $val['itemId'] ?? 0;
|
|
|
$xhUnitType = $val['xhUnitType'] ?? 0;
|
|
|
$xhUnitPrice = $val['xhUnitPrice'] ?? 0;
|
|
|
+
|
|
|
$ratio = $val['ratio'] ?? 20;
|
|
|
$beforeNum = bcsub($val['xhNum'], $val['refundNum'], 2);
|
|
|
if ($xhUnitType == 0) {
|
|
|
@@ -53,8 +68,17 @@ class StatCgController extends BaseController
|
|
|
$amount = bcmul($num, $xhUnitPrice, 2);
|
|
|
$totalNum = bcadd($totalNum, $num, 2);
|
|
|
$totalAmount = bcadd($totalAmount, $amount, 2);
|
|
|
- $name = $productInfo[$productId]['name'] ?? '';
|
|
|
- $py = $productInfo[$productId]['py'] ?? '';
|
|
|
+ $myCurrentInfo = $productInfo[$productId] ?? [];
|
|
|
+
|
|
|
+ if ($showGhsParam == 1) {
|
|
|
+ $myGhsItem = $ghsProduct[$ptItemId] ?? [];
|
|
|
+ $name = $myGhsItem['name'] ?? '未找到';
|
|
|
+ $py = $myGhsItem['py'] ?? '';
|
|
|
+ } else {
|
|
|
+ $name = $myCurrentInfo['name'] ?? '';
|
|
|
+ $py = $myCurrentInfo['py'] ?? '';
|
|
|
+ }
|
|
|
+
|
|
|
$stat[$productId]['productId'] = $productId;
|
|
|
$stat[$productId]['name'] = $name;
|
|
|
$stat[$productId]['py'] = $py;
|