panlumeng 3 роки тому
батько
коміт
40372c4681

+ 36 - 12
application/Admin/controller/Stock.php

@@ -23,38 +23,62 @@ class Stock extends Base
         $page = isset($this->post['page'])&&$this->post['page']!="" ? intval($this->post['page']) : 1;
         $size = isset($this->post['size'])&&$this->post['size']!="" ? intval($this->post['size']) :10;
         $status = isset($this->post['status'])&&$this->post['status']!=="" ? intval($this->post['status']) :"";
-        $where=[];
+        $where=['a.is_del'=>0];
         if($status!==""){
-            $where['status'] = $status;
+            $where['a.status'] = $status;
         }
         $username =  isset($this->post['username'])&&$this->post['username']!=="" ? trim($this->post['username']) :"";
         if($username!=""){
-            $where['username'] = ["like","%{$username}%"];
+            $where['a.username'] = ["like","%{$username}%"];
         }
         $nickname =  isset($this->post['nickname'])&&$this->post['nickname']!=="" ? trim($this->post['nickname']) :"";
         if($nickname!=""){
-            $where['nickname'] = ["like","%{$nickname}%"];
+            $where['v.nickname'] = ["like","%{$nickname}%"];
         }
         $mobile =  isset($this->post['mobile'])&&$this->post['mobile']!=="" ? trim($this->post['mobile']) :"";
         if($mobile!=""){
-            $where['mobile'] = ["like","%{$mobile}%"];
+            $where['v.mobile'] = ["like","%{$mobile}%"];
         }
         $stock_low =  isset($this->post['stock_low'])&&$this->post['stock_low']!=="" ? intval($this->post['stock_low'])
             :"";
-        $wherestock="1=1";
+       // $wherestock="1=1";
         if($stock_low!=""){
-           // $where['stock_balance'] = [">=",$stock_low];
-            $wherestock .=" and stock_balance>={$stock_low}";
+            $where['stock_balance'] = [">=",$stock_low];
+           // $wherestock .=" and stock_balance>={$stock_low}";
         }
         $stock_up =  isset($this->post['stock_up'])&&$this->post['stock_up']!=="" ? intval($this->post['stock_up']) :"";
         if($stock_up!=""){
-           // $where['stock_balance'] = ["<=",$stock_up];
-            $wherestock .=" and stock_balance<={$stock_up}";
+           $where['stock_balance'] = ["<=",$stock_up];
+            //$wherestock .=" and stock_balance<={$stock_up}";
         }
-        $count= Db::name("stock_list")->where($where)->where($wherestock)->count();
+        $count= Db::name("account")->alias('a')
+            ->join("fc_rela_account b","a.id = b.accountid","left")
+            ->join("fc_account_info v","b.account_info = v.id","left")
+            ->join("fc_account_stock d","a.id = d.accountid","left")
+            ->where($where)->count();
         $total = ceil($count/$size);
         $page = $page>=$total? $total:$page;
-        $list = Db::name("stock_list")->where($where)->where($wherestock)->page($page,$size)->field("id,username,status,nickname,mobile,stock_balance,stock_update")->order("stock_update desc")->select();
+        $list = Db::name("account")->alias('a')->where($where)->page($page,$size)
+            ->join("fc_rela_account b","a.id = b.accountid","left")
+            ->join("fc_account_info v","b.account_info = v.id","left")
+            ->join("fc_account_stock d","a.id = d.accountid","left")
+            ->field("`a`.`id` AS `id`,
+                        `a`.`username` AS `username`,
+                        `a`.`status` AS `status`,
+                        `a`.`starttime` AS `starttime`,
+                        `a`.`expiretime` AS `expiretime`,
+                        `a`.`activetime` AS `activetime`,
+                        `a`.`addtime` AS `addtime`,
+                        `v`.`nickname` AS `nickname`,
+                        `v`.`avatar` AS `avatar`,
+                        `v`.`mobile` AS `mobile`,
+                        `v`.`remark` AS `remark`,
+                        ifnull( `d`.`stock_total`, 0 ) AS `stock_total`,
+                        ifnull( `d`.`stock_used`, 0 ) AS `stock_used`,
+                        ifnull( `d`.`stock_balance`, 0 ) AS `stock_balance`,
+                        ifnull( `d`.`stock_delivery`, 0 ) AS `stock_delivery`,
+                        ifnull( `d`.`updatetime`, '' ) AS `stock_update` ")
+            ->order("d.updatetime desc")->select();
         return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
     }
 

+ 34 - 2
application/Home/controller/Order.php

@@ -72,8 +72,40 @@ class Order extends Base
         if($id==""){
             return error_show(1004,"参数id 不能为空");
         }
-        $order = Db::name("order_info")->where(["is_del"=>0,"accountid"=>$this->userinfo['id'],"id"=>$id])->field("id,
-        order_sn,order_num,order_time,delivery_time,status, post_code,post_name,provice_name,city_name,area_name,addr,contector,contector_mobile,nickname,unit,unit_weight")->find();
+        $order = Db::name("order")->alias('a')->where(["a.is_del"=>0,"a.accountid"=>$this->userinfo['id'],"a.id"=>$id])
+            ->join("fc_order_post b","a.order_sn =b.order_sn","left")
+            ->join("fc_addr c","b.addrid= c.id","left")
+            ->join("fc_account e","a.accountid= e.id","left")
+            ->join("fc_rela_account f","a.accountid = f.accountid","left")
+            ->join("fc_account_info g","f.account_info = g.id","left")
+            ->field("`a`.`id` AS `id`,
+                        `a`.`order_sn` AS `order_sn`,
+                        `a`.`accountid` AS `accountid`,
+                        `a`.`order_num` AS `order_num`,
+                        `a`.`status` AS `status`,
+                        `a`.`is_del` AS `is_del`,
+                        `a`.`delivery_time` AS `delivery_time`,
+                        `a`.`order_time` AS `order_time`,
+                        `b`.`addrid` AS `addrid`,
+                        `b`.`order_num` AS `border_num`,
+                        `b`.`post_code` AS `post_code`,
+                        `b`.`post_name` AS `post_name`,
+                        `b`.`status` AS `bstatus`,
+                        `c`.`addr` AS `addr`,
+                        `c`.`provice` AS `provice`,
+                        `c`.`city` AS `city`,
+                        `c`.`provice_name` AS `provice_name`,
+                        `c`.`city_name` AS `city_name`,
+                        `c`.`area` AS `area`,
+                        `c`.`area_name` AS `area_name`,
+                        `c`.`contector` AS `contector`,
+                        `c`.`mobile` AS `contector_mobile`,
+                        `e`.`username` AS `username`,
+                        `g`.`nickname` AS `nickname`,
+                        `g`.`mobile` AS `mobile`,
+                        `a`.`unit_weight` AS `unit_weight`,
+                        `a`.`unit` AS `unit` ")
+            ->find();
         if(empty($order)){
             return error_show(1005,"未找到订单数据");
         }