|
|
@@ -173,36 +173,27 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|
|
*/
|
|
|
public function count(): int
|
|
|
{
|
|
|
- /*$fields = ['mw.*','mwr.maintain_exp_type','mwr.other_exp_type'];
|
|
|
+ $fields = ['mw.*','mwr.maintain_exp_type','mwr.other_exp_type'];
|
|
|
$orders = ['mw.id' => 'desc'];
|
|
|
$having = 'mw.id > 0';
|
|
|
$queryWhere = $this->queryWhere();
|
|
|
- //dd($queryWhere,$this->searchWhere);
|
|
|
// 派单搜索条件 - 订单坐标距离排序
|
|
|
if($this->lat && $this->lon){
|
|
|
$fields[] = Db::raw('ROUND(6371* 1000 * ACOS(COS(RADIANS('.$this->lat.')) * COS(RADIANS(mw.lat)) * COS(RADIANS(mw.lon) - RADIANS('.$this->lon.')) + SIN(RADIANS('.$this->lat.')) * SIN(RADIANS(mw.lat))), 2) AS user_distance');
|
|
|
$orders = 'user_distance';
|
|
|
- $having = '(user_distance - mw.distance) <= 0';
|
|
|
- if($this->range){
|
|
|
- $having = 'user_distance <= '.$this->range;
|
|
|
+ $having .= ' AND (user_distance - mw.distance) <= 0'; // 添加条件而不是覆盖
|
|
|
+ if ($this->range) {
|
|
|
+ $having = 'user_distance <= ' . $this->range;
|
|
|
+ } else {
|
|
|
+ $having .= ' AND user_distance <= ' . $this->range; // 如果 $this->range 为空,确保 $having 包含所有条件
|
|
|
}
|
|
|
}
|
|
|
- return MasterWorker::alias('mw')
|
|
|
+ return count(MasterWorker::alias('mw')
|
|
|
->join('master_worker_register mwr', 'mwr.worker_id = mw.id')
|
|
|
->where($this->searchWhere)
|
|
|
->where($queryWhere)
|
|
|
->field($fields)
|
|
|
- ->limit($this->limitOffset, $this->limitLength)
|
|
|
->having($having)
|
|
|
- ->order($orders)
|
|
|
- ->count();*/
|
|
|
-
|
|
|
- return MasterWorker::alias('mw')
|
|
|
- ->join('master_worker_register mwr', 'mwr.worker_id = mw.id')
|
|
|
- ->field([
|
|
|
- 'mw.*'])
|
|
|
- ->where($this->searchWhere)->where($this->queryWhere())
|
|
|
- ->count();
|
|
|
- //return $this->count;
|
|
|
+ ->select()->toArray());
|
|
|
}
|
|
|
}
|