|
|
@@ -7,6 +7,7 @@ use biz\stat\classes\StatStockInClass;
|
|
|
use biz\stat\classes\StatStockOutClass;
|
|
|
use bizGhs\expend\classes\ExpendClass;
|
|
|
use bizGhs\order\classes\PurchaseOrderClass;
|
|
|
+use bizGhs\order\classes\StockWastageOrderClass;
|
|
|
use bizGhs\staff\classes\SalaryClass;
|
|
|
use bizHd\order\classes\OrderClass as HdOrderClass;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
@@ -20,6 +21,34 @@ class StatSaleClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\bizGhs\stat\models\StatSale';
|
|
|
|
|
|
+ public static function wastage($mainId)
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $where = [];
|
|
|
+ $where['mainId'] = $mainId;
|
|
|
+ $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';
|
|
|
+ $where['addTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
+ $list = StockWastageOrderClass::getAllByCondition($where, null, '*');
|
|
|
+ $totalPrice = 0;
|
|
|
+ if (!empty($list)) {
|
|
|
+ foreach ($list as $order) {
|
|
|
+ $price = $order['price'] ?? 0;
|
|
|
+ $totalPrice = bcadd($totalPrice, $price, 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $totalPrice = floatval($totalPrice);
|
|
|
+ return ['totalPrice' => $totalPrice];
|
|
|
+ }
|
|
|
+
|
|
|
public static function profile($mainId)
|
|
|
{
|
|
|
//收入:批发开单、零售开单(含门店、美团和微信客服)、出库
|