Browse Source

收藏列表+午餐列表

Cherry 2 years ago
parent
commit
6073ee5f16

+ 15 - 11
application/api/controller/Pond.php

@@ -228,36 +228,40 @@ class Pond extends Api
      * @ApiMethod (GET)
      * @ApiParams (name=limit,type="int", required=false,description="每页数量")
      * @ApiParams (name=page,type="int", required=false,description="页数")
-     * @ApiParams (name=status,type="int", required=true,description="0=全部;1=未开始;2=已结束")
-     * @ApiReturnParams (name="id", type="int", required=true, description="供货信息id")
-     * @ApiReturn ({"code":1,"msg":"ok","time":"1672301111","data":{"total":1,"per_page":15,"current_page":1,"last_page":1,"data":[{"id":1,"user_id":3,"images":"/uploads/20221229/bed687fe17a0b7f3a9e84f8d1580879c.png","fish_kinds":"白莲","description":"十年养鱼经验","publish_time":1672301081,"fish_name": "高铁垂钓中心","fish_address":"临沂","fish_num":"1024斤","phone":"13161001120","pay_time":0,"pay_no":"","pay_money":"0.00","status":1,"publish_status":0,"createtime":1672301106,"updatetime":1672301106,"deletetime":null,"pay_time_text":"1970-01-01 08:00:00","status_text":"Status 1","publish_status_text":"Publish_status 0"}]}})
+     * @ApiParams (name=status,type="int", required=true,description="0=今日进行;1=未开始;2=已结束")
+     * @ApiReturnParams (name="lunch_num", type="int", required=true, description="午餐订购数量")
+     * @ApiReturn ({"code":1,"msg":"ok","time":"1680759306","data":{"total":2,"per_page":15,"current_page":1,"last_page":1,"data":[{"id":444,"type":1,"show_images":"http://yutang.zhousi.hdlkeji.com/uploads/20230327/83e103697d24ea91145083aa813f1f6c.png","yutang_name":"啦啦啦1","moshi":1,"lunch_num":0,"type_text":"Type 1","put_time_text":"","tuisong_text":""}]}})
      */
     public function lunch_list(){
         $page = input('page', 1);
         $limit = input('limit');
         $status = input('status',0);
 
-        $where = [];
+        $method_model = new Method();
+        $query = $method_model->field('id,type,show_images,yutang_name,moshi');
         switch ($status){
             case 0:
-                $where = [];
+                $query = $query->where('huodong_time',date('Y-m-d',time()));
                 break;
             case 1:
-                $where = [];
+                $query = $query->where('huodong_time','>',date('Y-m-d',time()));
                 break;
             case 2:
-                $where = [];
+                $query = $query->where('huodong_time','<',date('Y-m-d',time()));
                 break;
         }
 
-
-        $method_model = new Method();
-        $list = $method_model->where('user_id', $this->auth->id)
+        $list = $query->where('user_id', $this->auth->id)
             ->where('eat', 2)
             ->order('huodong_time', 'DESC')
             ->paginate($limit, false, ['page' => $page]);
 
-        var_dump($list);
+        $order_model = new Order();
+        foreach ($list as &$v){
+            $v['lunch_num'] = $order_model->where('method_id',$v['id'])->where('eat',2)->sum('number');
+        }
+
+        $this->success('ok',$list);
     }
 
 

+ 5 - 1
application/api/controller/User.php

@@ -507,12 +507,16 @@ class User extends Api
         $shoucang_model = new Shoucang();
         $time_model = new Time();
         $yutang_model = new \app\admin\model\Yutang();
-        $list = $shoucang_model->alias('s')->join('method m', 'm.id=s.method_id')->where('s.user_id', $this->auth->id)->order('s.id', 'DESC')->field('m.*')->paginate();
+        $list = $shoucang_model->alias('s')
+            ->join('method m', 'm.id=s.method_id')
+            ->join('user u', 'm.user_id=u.id')
+            ->where('s.user_id', $this->auth->id)->order('s.id', 'DESC')->field('m.*,u.mobile')->paginate();
         foreach ($list as &$value) {
             $rebate = rebate($value['type'], $value['moshi']);
             $value['lijianjin'] = $rebate['reduction'];
             $value['price'] = $time_model->where('m_id', $value['id'])->where('type', 1)->order('price', 'asc')->value('price');;
             $value['pingfen'] = $yutang_model->where('id', $value['yutang_id'])->value('pingjie');
+            $value['time_list'] = $time_model->where('m_id', $value['id'])->select();
         }
         $this->success('我的收藏列表', $list);
     }

+ 1 - 0
application/api/controller/Yorder.php

@@ -99,6 +99,7 @@ class Yorder extends Api
             'type' => $method_info['type'],
             'moshi' => $method_info['moshi'],
             'phone' => $this->auth->mobile,
+            'eat' => $data['eat'],
         ];
         //zhifu
         Db::startTrans();

File diff suppressed because it is too large
+ 201 - 193
public/api.html


Some files were not shown because too many files changed in this diff