|
@@ -1519,15 +1519,20 @@ class StatisticsService extends Service
|
|
|
|
|
|
//新的进销存统计通用搜索底层抽象
|
|
|
public function statisticsJcNewCommonOrigin($data,$user,$field = []){
|
|
|
- $startStamp = strtotime(date("Y-m-01 00:00:00"));
|
|
|
+ if(! empty($data['count_month'])) {
|
|
|
+ $startStamp = $this->changeDateToDate($data['count_month']);
|
|
|
+ }else{
|
|
|
+ $startStamp = strtotime(date("Y-m-01 00:00:00"));
|
|
|
+ }
|
|
|
+ $endTimeStamp = strtotime('first day of next month', $startStamp) - 1;
|
|
|
|
|
|
//-------- 结存数量汇总 ---------- //
|
|
|
//上月结存
|
|
|
$last_month_stock = "SUM(CASE WHEN crt_time < $startStamp THEN number ELSE 0 END)";
|
|
|
//本月入库
|
|
|
- $this_month_in = "SUM(CASE WHEN crt_time >= $startStamp AND number > 0 THEN number ELSE 0 END)";
|
|
|
+ $this_month_in = "SUM(CASE WHEN crt_time >= $startStamp AND crt_time <= $endTimeStamp AND number > 0 THEN number ELSE 0 END)";
|
|
|
//本月出库
|
|
|
- $this_month_out = "SUM(CASE WHEN crt_time >= $startStamp AND number < 0 THEN number ELSE 0 END)";
|
|
|
+ $this_month_out = "SUM(CASE WHEN crt_time >= $startStamp AND crt_time <= $endTimeStamp AND number < 0 THEN number ELSE 0 END)";
|
|
|
//本月结存
|
|
|
$this_month_stock = "($last_month_stock + $this_month_in + $this_month_out)";
|
|
|
//-------- 结存数量汇总 ---------- //
|
|
@@ -1548,8 +1553,8 @@ class StatisticsService extends Service
|
|
|
$this_month_in_m = "ROUND(
|
|
|
SUM(
|
|
|
CASE
|
|
|
- WHEN crt_time >= $startStamp and number > 0 THEN (number * price)
|
|
|
- WHEN crt_time >= $startStamp and number = 0 and price >= 0 and order_type = '$order_type' THEN price
|
|
|
+ WHEN crt_time >= $startStamp and crt_time <= $endTimeStamp and number > 0 THEN (number * price)
|
|
|
+ WHEN crt_time >= $startStamp and crt_time <= $endTimeStamp and number = 0 and price >= 0 and order_type = '$order_type' THEN price
|
|
|
ELSE 0
|
|
|
END
|
|
|
),
|
|
@@ -1558,8 +1563,8 @@ class StatisticsService extends Service
|
|
|
$this_month_out_m = "ROUND(
|
|
|
SUM(
|
|
|
CASE
|
|
|
- WHEN crt_time >= $startStamp and number < 0 THEN (number * price)
|
|
|
- WHEN crt_time >= $startStamp and number = 0 and price < 0 and order_type = '$order_type' THEN price
|
|
|
+ WHEN crt_time >= $startStamp and crt_time <= $endTimeStamp and number < 0 THEN (number * price)
|
|
|
+ WHEN crt_time >= $startStamp and crt_time <= $endTimeStamp and number = 0 and price < 0 and order_type = '$order_type' THEN price
|
|
|
ELSE 0
|
|
|
END
|
|
|
),
|
|
@@ -1608,6 +1613,7 @@ class StatisticsService extends Service
|
|
|
//新的进销存统计
|
|
|
public function statisticsJcNew($data,$user){
|
|
|
$model = $this->statisticsJcNewCommon($data, $user);
|
|
|
+ $model->orderBy('product_id','desc');
|
|
|
$list = $this->limit($model,'',$data);
|
|
|
$list = $this->fillDataNew($list);
|
|
|
|