|
|
@@ -5,10 +5,12 @@ namespace bizGhs\stat\classes;
|
|
|
use biz\shop\classes\ShopAdminClass;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
use bizHd\order\classes\SettleClass;
|
|
|
+use common\components\dateUtil;
|
|
|
use common\components\dict;
|
|
|
use bizHd\order\classes\OrderClass as HdOrderClass;
|
|
|
use bizGhs\clear\classes\ClearClass;
|
|
|
use bizGhs\base\classes\BaseClass;
|
|
|
+use Yii;
|
|
|
|
|
|
class StatKdClass extends BaseClass
|
|
|
{
|
|
|
@@ -23,9 +25,21 @@ class StatKdClass extends BaseClass
|
|
|
|
|
|
//批发开单 pf 零售开单 ls 批发结账 pfJz 零售尾款 lsWk
|
|
|
|
|
|
- $todayDate = date('Y-m-d');
|
|
|
- $todayStartTime = $todayDate . ' 00:00:00';
|
|
|
- $todayEndTime = $todayDate . ' 23:59:59';
|
|
|
+
|
|
|
+ $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';
|
|
|
+
|
|
|
$staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId, 'isPt' => 0], null, '*', 'id', true);
|
|
|
$kf = [];
|
|
|
if (!empty($staffList)) {
|
|
|
@@ -126,7 +140,8 @@ class StatKdClass extends BaseClass
|
|
|
|
|
|
//批发开单
|
|
|
$where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
- $where['payTime'] = ['between', [$todayStartTime, $todayEndTime]];
|
|
|
+ $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
+
|
|
|
$ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
|
|
|
if (!empty($ghsOrderList)) {
|
|
|
foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
|
|
|
@@ -202,7 +217,7 @@ class StatKdClass extends BaseClass
|
|
|
|
|
|
//零售开单
|
|
|
$hdWhere = ['mainId' => $mainId, 'status' => ['in', [HdOrderClass::ORDER_STATUS_UN_SEND, HdOrderClass::ORDER_STATUS_SENDING, HdOrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
- $hdWhere['payTime'] = ['between', [$todayStartTime, $todayEndTime]];
|
|
|
+ $hdWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
$hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
|
|
|
foreach ($hdOrderList as $hdKey => $hdOrder) {
|
|
|
$payWay = $hdOrder['payWay'] ?? 0;
|
|
|
@@ -299,7 +314,7 @@ class StatKdClass extends BaseClass
|
|
|
|
|
|
//批发结帐收入
|
|
|
$clearWhere = ['ghsShopId' => $ghsShopId, 'status' => 2];
|
|
|
- $clearWhere['payTime'] = ['between', [$todayStartTime, $todayEndTime]];
|
|
|
+ $clearWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
$clearList = ClearClass::getAllByCondition($clearWhere, null, '*');
|
|
|
if (!empty($clearList)) {
|
|
|
foreach ($clearList as $cKey => $clear) {
|
|
|
@@ -365,7 +380,7 @@ class StatKdClass extends BaseClass
|
|
|
|
|
|
//零售尾款收入
|
|
|
$settleWhere = ['shopId' => $lsShopId, 'status' => 2];
|
|
|
- $settleWhere['payTime'] = ['between', [$todayStartTime, $todayEndTime]];
|
|
|
+ $settleWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
$settleList = SettleClass::getAllByCondition($settleWhere, null, '*');
|
|
|
|
|
|
if (!empty($settleList)) {
|