123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- declare (strict_types = 1);
- namespace app\model\admin;
- use library\basic\BaseModel;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class OrderInfo extends BaseModel
- {
- /**
- * 订单查询
- * @param $id
- * @return array|Model|null
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function getItem($id) {
- $data = $this
- ->field("of.*,(SELECT title from table_express where id = of.exp_id) as exp_name,".
- "(select order_id from table_order where id = of.o_id) as order_id,".
- "p.title as pro_title,p.img as pro_img"
- )
- ->alias("of")
- ->join('product p',"p.id = of.pro_id")
- ->where('of.id',$id)
- ->find();
- return $data;
- }
- /**
- * 获取列表数据
- * @param $page
- * @param $where
- * @param $pageCount
- * @param $desc
- */
- public function getList($page,$where = [],$pageCount = 20,$filed = '*',$desc = 'id desc'){
- $data = $this
- ->field("of.*,(SELECT title from table_express where id = of.exp_id) as exp_name,".
- "(select order_id from table_order where id = of.o_id) as order_id")
- ->alias("of")
- ->when(!empty($where),function ($query) use($where){
- if(!empty($where['sassid'])) {
- $query->where('of.sassid',$where['sassid']);
- }
- if(!empty($where['id'])) {
- $query->where('of.o_id',$where['id']);
- }
- if(!empty($where['uid'])) {
- $query->where('of.uid',$where['uid']);
- }
- if(!empty($where['name'])) {
- $query->whereLike('of.name',"%{$where['name']}%");
- }
- if(!empty($where['mobile'])) {
- $query->whereLike('of.mobile',"%{$where['mobile']}%");
- }
- if(!empty($where['order_id'])) {
- $query->whereLike('of.out_order_id',"%{$where['order_id']}%");
- }
- })
- ->order($desc)
- ->paginate(['list_rows'=>$pageCount,'page'=>$page])
- ->toArray();
- //echo $this->getLastSql();
- return [$data['total'],$data['data']];
- }
- /**
- * 导出某一项全部
- * @param array $where
- * @param string $desc
- */
- public function getAllList($where = [],$desc = 'id desc'){
- $data = $this
- ->field("of.*,(SELECT title from table_express where id = of.exp_id) as exp_name,".
- "(select order_id from table_order where id = of.o_id) as order_id,".
- "(select name from table_platform where id = of.platform_id) as platform_name,".
- "p.title as pro_name,p.csno"
- )
- ->alias("of")
- ->when(!empty($where),function ($query) use($where){
- if(!empty($where['sassid'])) {
- $query->where('of.sassid',$where['sassid']);
- }
- if(!empty($where['id'])) {
- $query->whereIn('of.o_id',$where['id']);
- }
- })
- ->leftJoin('product p','p.id=of.pro_id')
- ->order($desc)
- ->select()
- ->toArray();
- return $data;
- }
- }
|