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=[]; if($status!==""){ $where['status'] = $status; } $username = isset($this->post['username'])&&$this->post['username']!=="" ? trim($this->post['username']) :""; if($username!=""){ $where['username'] = ["like","%{$username}%"]; } $nickname = isset($this->post['nickname'])&&$this->post['nickname']!=="" ? trim($this->post['nickname']) :""; if($nickname!=""){ $where['nickname'] = ["like","%{$nickname}%"]; } $mobile = isset($this->post['mobile'])&&$this->post['mobile']!=="" ? trim($this->post['mobile']) :""; if($mobile!=""){ $where['mobile'] = ["like","%{$mobile}%"]; } $order_low = isset($this->post['order_low'])&&$this->post['order_low']!=="" ? $this->post['order_low'] :""; if($order_low!="") { $order_low = date("Y-m-d H:i:s", strtotime($order_low . " 00:00:00")); }else{ $order_low = "1970-01-01 00:00:00"; } $order_up = isset($this->post['order_up'])&&$this->post['order_up']!=="" ? $this->post['order_up'] :""; if($order_up!=""){ $order_up = date("Y-m-d H:i:s",strtotime($order_up." 23:59:59")); }else{ $order_up = date("Y-m-d H:i:s"); } $where['order_time'] = ["between",[$order_low,$order_up]]; $count= Db::name("order")->where($where)->count(); $total = ceil($count/$size); $page = $page>=$total? $total:$page; $list = Db::name("order a")->where($where)->page($page,$size)->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` ") ->order("order_time desc") ->select(); return app_show(0,"获取成功",["list"=>$list,"count"=>$count]); } /** * @param ordersn * @param post_code * @param post_company */ public function OrderDelivery(){ $ordersn = isset($this->post['ordersn'])&&$this->post['ordersn']!="" ? trim($this->post['ordersn']):""; if($ordersn==""){ return error_show(1004,"参数ordersn 不能为空"); } $orderinfo = Db::name("order")->where(["order_sn"=>$ordersn])->find(); if(empty($orderinfo)){ return error_show(1005,"订单不存在"); } if($orderinfo['is_del']==1){ return error_show(1005,"订单已删除"); } if($orderinfo['status']!=1){ return error_show(1005,"订单状态有误"); } $orderpost = Db::name("order_post")->where(["order_sn"=>$ordersn,"is_del"=>0])->find(); if(empty($orderpost)){ return error_show(1005,"订单地址信息不存在"); } $post_code = isset($this->post['post_code'])&&$this->post['post_code']!="" ? trim($this->post['post_code']):""; if($post_code==""){ return error_show(1004,"参数post_code 不能为空"); } $post_company = isset($this->post['post_company'])&&$this->post['post_company']!="" ? trim($this->post['post_company']):""; if($post_company==""){ return error_show(1004,"参数post_company 不能为空"); } $orderpost['post_code']=$post_code; $orderpost['post_name']=$post_company; $orderpost['updatetime']=date("Y-m-d H:i:s"); Db::startTrans(); try { $psot=Db::name("order_post")->update($orderpost); if($psot){ $orderinfo['status']=2; $orderinfo['delivery_time']=date("Y-m-d H:i:s"); $order= Db::name("order")->update($orderinfo); if($order){ write_log("订单{$ordersn}发货",$this->userinfo,"order","edit","0"); Db::commit(); return app_show(0,"订单物流信息新建成功"); } } Db::rollback(); return error_show(1004,"物流信息新建失败"); }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } }