1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- declare (strict_types = 1);
- namespace app\model\api;
- use library\basic\BaseModel;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class OrderInfoAsw extends BaseModel
- {
- /**
- * 获取列表数据
- * @param $page
- * @param $where
- * @param $pageCount
- * @param $desc
- */
- public function getList($page,$where = [],$pageCount = 20,$filed = '*',$desc = 'mo.id desc')
- {
- $data = $this
- ->field(
- "mo.id,mo.msg_mono,mo.mono,mo.status,mo.time as cl_time,mo.admin_time as cl_admin_time,(select order_id from table_order where id = of.o_id) as order_id,"
- . "mo.o_id,of.name,of.out_order_id,of.mobile,of.address,of.time,of.send_time,(SELECT title from table_express where id = of.exp_id) as exp_name,of.exp_number"
- )
- ->alias("mo")
- ->join('order_info of', "mo.of_id=of.id")
- ->when(!empty($where), function ($query) use ($where) {
- if(!empty($where['name'])) {
- $query->whereLike('of.name',"%{$where['name']}%");
- }
- if(!empty($where['id'])) {
- $query->whereLike('mo.o_id',$where['id']);
- }
- if(!empty($where['sassid'])) {
- $query->whereLike('mo.sassid',$where['sassid']);
- }
- if(!empty($where['uid'])) {
- $query->whereLike('mo.uid',$where['uid']);
- }
- if(!empty($where['mobile'])) {
- $query->whereLike('of.mobile',"%{$where['mobile']}%");
- }
- if(!empty($where['out_order_id'])) {
- $query->whereLike('of.out_order_id',"%{$where['out_order_id']}%");
- }
- if( $where['orderType'] == 1 ) {
- $query->whereLike('mo.status',0);
- }
- if( $where['orderType'] == 2 ) {
- $query->whereLike('mo.status',1);
- }
- //timeType[今日,昨日,最近7天,最近30天]
- if(!empty($where['timeType'])) {
- if($where['timeType'] == 'day') {
- $query->whereDay('mo.time');
- }
- if($where['timeType'] == 'yesterday') {
- $query->whereDay('mo.time','yesterday');
- }
- if($where['timeType'] == 'last7') {
- $query->whereTime('mo.time','-7 day');
- }
- if($where['timeType'] == 'last30') {
- $query->whereTime('mo.time','-30 day');
- }
- }
- })
- ->order($desc)
- ->paginate(['list_rows' => $pageCount, 'page' => $page])
- ->toArray();
- return [$data['total'], $data['data']];
- }
- }
|