|
|
@@ -2,9 +2,11 @@
|
|
|
|
|
|
namespace bizGhs\stat\classes;
|
|
|
|
|
|
+use bizGhs\order\classes\OrderClass;
|
|
|
use bizGhs\shop\classes\ShopAdminClass;
|
|
|
use bizGhs\shop\models\ShopAdmin;
|
|
|
use common\components\arrayUtil;
|
|
|
+use common\components\dateUtil;
|
|
|
use Yii;
|
|
|
use bizGhs\base\classes\BaseClass;
|
|
|
|
|
|
@@ -13,6 +15,77 @@ class StatYjClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\bizGhs\stat\models\StatYj';
|
|
|
|
|
|
+ public static function profile($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'];
|
|
|
+ $where['time'] = ['between', [$start, $end]];
|
|
|
+
|
|
|
+ $currentStartDate = date('Y-m-d', strtotime($start));
|
|
|
+ $currentEndDate = date('Y-m-d', strtotime($end));
|
|
|
+ $currentStartTime = $currentStartDate . ' 00:00:00';
|
|
|
+ $currentEndTime = $currentEndDate . ' 23:59:59';
|
|
|
+
|
|
|
+ $arr = [];
|
|
|
+
|
|
|
+ //批发开单
|
|
|
+ $where = ['mainId' => $mainId];
|
|
|
+ $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
+
|
|
|
+ $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
|
|
|
+ if (!empty($ghsOrderList)) {
|
|
|
+ foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
|
|
|
+ $shopAdminId = $ghsOrder['shopAdminId'] ?? 0;
|
|
|
+ $shopAdminName = $ghsOrder['shopAdminName'] ?? '';
|
|
|
+ $actPrice = $ghsOrder['actPrice'] ?? 0;
|
|
|
+ $arr[$shopAdminId]['id'] = $shopAdminId;
|
|
|
+ $arr[$shopAdminId]['name'] = $shopAdminName;
|
|
|
+ if (isset($arr[$shopAdminId]['pfAmount']) == false) {
|
|
|
+ $arr[$shopAdminId]['pfAmount'] = 0;
|
|
|
+ $arr[$shopAdminId]['pfNum'] = 0;
|
|
|
+ }
|
|
|
+ if (isset($arr[$shopAdminId]['amount']) == false) {
|
|
|
+ $arr[$shopAdminId]['amount'] = 0;
|
|
|
+ $arr[$shopAdminId]['num'] = 0;
|
|
|
+ }
|
|
|
+ $arr[$shopAdminId]['pfAmount'] = bcadd($arr[$shopAdminId]['pfAmount'], $actPrice, 2);
|
|
|
+ $arr[$shopAdminId]['pfNum'] = bcadd($arr[$shopAdminId]['pfNum'], 1);
|
|
|
+ $arr[$shopAdminId]['num'] = bcadd($arr[$shopAdminId]['num'], 1);
|
|
|
+ $arr[$shopAdminId]['amount'] = bcadd($arr[$shopAdminId]['amount'], $arr[$shopAdminId]['pfAmount'], 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $hdWhere = ['mainId' => $mainId];
|
|
|
+ $hdWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
+ $hdOrderList = \bizHd\order\classes\OrderClass::getAllByCondition($hdWhere, null, '*');
|
|
|
+ foreach ($hdOrderList as $hdKey => $hdOrder) {
|
|
|
+ $shopAdminId = $hdOrder['shopAdminId'] ?? 0;
|
|
|
+ $shopAdminName = $hdOrder['shopAdminName'] ?? '';
|
|
|
+ $actPrice = $hdOrder['actPrice'] ?? 0;
|
|
|
+ $arr[$shopAdminId]['id'] = $shopAdminId;
|
|
|
+ $arr[$shopAdminId]['name'] = $shopAdminName;
|
|
|
+ if (isset($arr[$shopAdminId]['lsAmount']) == false) {
|
|
|
+ $arr[$shopAdminId]['lsAmount'] = 0;
|
|
|
+ $arr[$shopAdminId]['lsNum'] = 0;
|
|
|
+ }
|
|
|
+ if (isset($arr[$shopAdminId]['amount']) == false) {
|
|
|
+ $arr[$shopAdminId]['amount'] = 0;
|
|
|
+ $arr[$shopAdminId]['num'] = 0;
|
|
|
+ }
|
|
|
+ $arr[$shopAdminId]['lsAmount'] = bcadd($arr[$shopAdminId]['lsAmount'], $actPrice, 2);
|
|
|
+ $arr[$shopAdminId]['lsNum'] = bcadd($arr[$shopAdminId]['lsNum'], 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//业绩列表 ssh 2021.3.15
|
|
|
public static function getYjList($where)
|
|
|
{
|