|
|
@@ -1265,4 +1265,76 @@ class StatSaleClass extends BaseClass
|
|
|
util::success(['file' => $fileUrl, 'shortFile' => $file]);
|
|
|
}
|
|
|
|
|
|
+ public static function send($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';
|
|
|
+
|
|
|
+ $s = strtotime($currentStartTime);
|
|
|
+ $e = strtotime($currentEndTime);
|
|
|
+ $p = bcsub($e, $s);
|
|
|
+ $xx = bcmul(86400, 90);
|
|
|
+ if ($p > $xx) {
|
|
|
+ util::fail('查询时间不能超过三个月');
|
|
|
+ }
|
|
|
+ $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
+ $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
+ $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
|
|
|
+ $arr = [];
|
|
|
+ if (!empty($ghsOrderList)) {
|
|
|
+ foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
|
|
|
+ $book = $ghsOrder['book'] ?? 0;
|
|
|
+ $status = $ghsOrder['status'] ?? 0;
|
|
|
+ if ($book == 1 && $status == 2) {
|
|
|
+ //预订单待发货的不算收入
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if ($status == 0 || $status == 5) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $orderSn = $ghsOrder['orderSn'] ?? '';
|
|
|
+ $actPrice = $ghsOrder['actPrice'] ?? 0;
|
|
|
+ if ($actPrice <= 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $sendStaffId = $ghsOrder['sendStaffId']??0;
|
|
|
+ $sendStaffName = $ghsOrder['sendStaffName']??'未记名';
|
|
|
+ if(isset($arr[$sendStaffId])){
|
|
|
+ $arr[$sendStaffId]['orderNum'] = bcadd($arr[$sendStaffId]['orderNum'],1);
|
|
|
+ $arr[$sendStaffId]['amount'] = bcadd($arr[$sendStaffId]['amount'],$actPrice,2);
|
|
|
+ }else{
|
|
|
+ $arr[$sendStaffId] = ['staffName'=>$sendStaffName,'orderNum'=>1,'itemNum'=>0,'amount'=>$actPrice];
|
|
|
+ }
|
|
|
+ $orderItemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
|
|
|
+ if (!empty($orderItemList)) {
|
|
|
+ foreach ($orderItemList as $orderItem) {
|
|
|
+ $refundNum = $orderItem->refundNum ?? 0;
|
|
|
+ $num = $orderItem->xhNum ?? 0;
|
|
|
+ $remainNum = bcsub($num,$refundNum);
|
|
|
+ $arr[$sendStaffId]['itemNum'] = bcadd($arr[$sendStaffId]['itemNum'],$remainNum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (!empty($arr)) {
|
|
|
+ $arr = array_values($arr);
|
|
|
+ }
|
|
|
+ return $arr;
|
|
|
+ }
|
|
|
+
|
|
|
}
|