You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.0 KiB
58 lines
2.0 KiB
<?php
|
|
|
|
namespace App\Admin\Repositories;
|
|
|
|
use App\Models\ImsCjdcOrderMain as Model;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Repositories\EloquentRepository;
|
|
|
|
class ImsCjdcOrderMain extends EloquentRepository
|
|
{
|
|
/**
|
|
* Model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $eloquentClass = Model::class;
|
|
|
|
public function get(Grid\Model $model)
|
|
{
|
|
|
|
$builder = new \App\Models\ImsCjdcOrderMain();
|
|
$builder = $builder::leftJoin('lanzu_user','lanzu_user.id','lanzu_order_main.user_id')
|
|
->with('market')
|
|
->select('lanzu_order_main.*','lanzu_user.nick_name')
|
|
->where('type',1)
|
|
->orderBy('lanzu_order_main.id','desc');//只取线上订单数据
|
|
|
|
$this->setSort($model);
|
|
$this->setPaginate($model);
|
|
|
|
$query = $builder;
|
|
$model->getQueries()->unique()->each(function ($value) use (&$query) {
|
|
if ($value['method'] == 'paginate') {
|
|
$value['arguments'][1] = $this->getGridColumns();
|
|
} elseif ($value['method'] == 'get') {
|
|
$value['arguments'] = [$this->getGridColumns()];
|
|
}elseif ($value['method']=='whereBetween'){
|
|
if ($value['arguments'][0]=='created_at'){
|
|
$value['arguments'][0] = 'lanzu_order_main.created_at';
|
|
$value['arguments'][1][0] = strtotime($value['arguments'][1][0]);
|
|
$value['arguments'][1][1] = strtotime($value['arguments'][1][1]);
|
|
}
|
|
}
|
|
$query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
|
|
});
|
|
|
|
$query = $query->toArray();
|
|
//如果订单状态为配送中 将state设置为31
|
|
foreach ($query['data'] as &$value){
|
|
if ($value['state']==3&&$value['shipping_type']==1&&!empty($value['horseman_id'])){
|
|
$value['state'] = 311;
|
|
}
|
|
}
|
|
|
|
$query = $model->makePaginator($query['total'],$query['data']);
|
|
return $query;
|
|
}
|
|
}
|