Bladeren bron

收发记录优化

zck 2 weken geleden
bovenliggende
commit
efe38d12c5
1 gewijzigde bestanden met toevoegingen van 69 en 0 verwijderingen
  1. 69 0
      application/api/controller/Manufacture.php

+ 69 - 0
application/api/controller/Manufacture.php

@@ -1607,4 +1607,73 @@ class Manufacture extends Api
             ->select();
         $this->success('成功',$list);
     }
+
+     //获取产量计酬日期节点(用于菜单栏)
+public function getDateNodes()
+{
+    if ($this->request->isGet() === false) {
+        $this->error('请求错误');
+    }
+    
+    //获取所有不重复的年份
+    $yearList = \db('设备_产量计酬')
+        ->field("DISTINCT DATE_FORMAT(sczl_rq, '%Y') as year")
+        ->where('sczl_rq', 'not null')
+        ->order('year', 'desc')
+        ->select();
+    
+    foreach ($yearList as $key => $year) {
+        //根据年份获取不重复的月份
+        $monthList = \db('设备_产量计酬')
+            ->field("DISTINCT DATE_FORMAT(sczl_rq, '%m') as month")
+            ->where('sczl_rq', 'not null')
+            ->where("DATE_FORMAT(sczl_rq, '%Y') = '{$year['year']}'")
+            ->order('month', 'asc')
+            ->select();
+        
+        foreach ($monthList as $k => $month) {
+            //根据年份和月份获取不重复的日期
+            $dayList = \db('设备_产量计酬')
+                ->field("DISTINCT DATE_FORMAT(sczl_rq, '%d') as day")
+                ->where('sczl_rq', 'not null')
+                ->where("DATE_FORMAT(sczl_rq, '%Y') = '{$year['year']}'")
+                ->where("DATE_FORMAT(sczl_rq, '%m') = '{$month['month']}'")
+                ->order('day', 'asc')
+                ->select();
+            
+            $monthList[$k]['day_list'] = $dayList;
+        }
+        
+        $yearList[$key]['month_list'] = $monthList;
+    }
+    
+    $this->success('获取成功', $yearList);
+}
+//获取产量计酬详情数据
+public function getCfdataDetail()
+{
+    if ($this->request->isGet() === false) {
+        $this->error('请求错误');
+    }
+    
+    $param = $this->request->param();
+    if (empty($param['year']) || empty($param['month']) || empty($param['day'])) {
+        $this->error('请选择日期');
+    }
+    
+    //拼接日期进行筛选
+    $date = $param['year'] . '-' . $param['month'] . '-' . $param['day'];
+    
+    //查询数据
+    $list = \db('设备_产量计酬')
+        ->where("DATE_FORMAT(sczl_rq, '%Y-%m-%d') = '{$date}'")
+        ->field('订单编号, 子订单编号, 款号, 尺码, 数量, sczl_bh')
+        ->select();
+    
+    if (empty($list)) {
+        $this->success('暂无数据', []);
+    }
+    
+    $this->success('获取成功', $list);
+}
 }