|
|
@@ -0,0 +1,66 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\api\controller;
|
|
|
+
|
|
|
+
|
|
|
+use app\common\controller\Api;
|
|
|
+use think\Db;
|
|
|
+use think\Request;
|
|
|
+
|
|
|
+class MonthlyGarments extends Api
|
|
|
+{
|
|
|
+ protected $noNeedLogin = ['*'];
|
|
|
+ protected $noNeedRight = ['*'];
|
|
|
+
|
|
|
+ public function _initialize()
|
|
|
+ {
|
|
|
+ if (isset($_SERVER['HTTP_ORIGIN'])) {
|
|
|
+ header('Access-Control-Expose-Headers: __token__');
|
|
|
+ }
|
|
|
+ check_cors_request();
|
|
|
+ parent::_initialize();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 样衣进度左侧数据
|
|
|
+ */
|
|
|
+ public function getDateTree()
|
|
|
+ {
|
|
|
+ if (!$this->request->isGet()) {
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $results = \db('月度样衣进度')
|
|
|
+ ->field([
|
|
|
+ 'DATE_FORMAT(下单日期, "%Y-%m-%d")' => '日期',
|
|
|
+ 'DATE_FORMAT(下单日期, "%Y-%m")' => '年月'
|
|
|
+ ])
|
|
|
+ ->whereNull('Mod_rq')
|
|
|
+ ->whereNotNull('下单日期')
|
|
|
+ ->order('下单日期 ASC')
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ $formattedData = [];
|
|
|
+
|
|
|
+ foreach ($results as $row) {
|
|
|
+ $yearMonth = $row['年月'];
|
|
|
+ $monthDay = $row['日期'];
|
|
|
+
|
|
|
+ if (!isset($formattedData[$yearMonth])) {
|
|
|
+ $formattedData[$yearMonth] = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!in_array($monthDay, $formattedData[$yearMonth])) {
|
|
|
+ $formattedData[$yearMonth][] = $monthDay;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ krsort($formattedData);
|
|
|
+
|
|
|
+ foreach ($formattedData as &$dates) {
|
|
|
+ rsort($dates);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('成功', $formattedData);
|
|
|
+ }
|
|
|
+}
|