Commit 1c32d4e8 authored by suntengda's avatar suntengda

update 活动绑定自提点接口 参数修改 offset改成page

parent 43576008
......@@ -20,6 +20,7 @@ class TakePlaceValidate extends \Validate\BaseValidate
'province' => 'require',
'city' => 'require',
'area' => 'require',
'page' => 'egt:1',
'offset' => 'egt:0',
'limit' => 'elt:500',
];
......@@ -34,6 +35,7 @@ class TakePlaceValidate extends \Validate\BaseValidate
"province" => "省不能为空",
"city" => "市不能为空",
"area" => "区不能为空",
'page' => '偏移量不能小于1',
"offset" => "偏移量不能小于0",
"limit" => "单次不能大于500条",
];
......@@ -55,6 +57,6 @@ class TakePlaceValidate extends \Validate\BaseValidate
public function sceneBindList()
{
return $this->append(['marketing_id' => 'require'])->only(['marketing_id','offset','limit']);
return $this->append(['marketing_id' => 'require'])->only(['marketing_id','page','limit']);
}
}
\ No newline at end of file
......@@ -64,10 +64,10 @@ class TakeplaceController extends Base
$marketingId = $this->params['marketing_id'];
$takePlaceName = $this->params['take_place_name'] ?? '';
$offset = $this->params['offset'] ?? 0;
$page = $this->params['page'] ?? 1;
$limit = $this->params['limit'] ?? 20;
$data = TakePlaceService::getPindanTakePlaceList($marketingId,$takePlaceName,$offset,$limit);
$data = TakePlaceService::getPindanTakePlaceList($marketingId,$takePlaceName,$page,$limit);
$this->success(['result'=>$data]);
}
......
......@@ -109,12 +109,13 @@ class TakePlaceService
* 获取拼单活动绑定的自提点列表
* @param $marketingPindanId
* @param string $takePlaceName
* @param int $offset
* @param int $page
* @param int $limit
* @return array
*/
public static function getPindanTakePlaceList($marketingPindanId,$takePlaceName='',$offset=0,$limit=20)
public static function getPindanTakePlaceList($marketingPindanId,$takePlaceName='',$page=1,$limit=20)
{
$offset = ($page-1)*$limit;
$res = ['list'=>[],'total'=>0];
$where = ['marketing_id' => $marketingPindanId];
$takePlaceName && $where['take_place_name[~]'] = $takePlaceName;
......@@ -129,7 +130,9 @@ class TakePlaceService
$makePlaceIds = array_column($relations,'take_place_id');
$takePlaceWhere = ['take_place_id'=>$makePlaceIds];
$res['list'] = TakePlace::select('*', $takePlaceWhere);
$res['total'] = TakePlace::count('*', $takePlaceWhere);
unset($where['ORDER'],$where['LIMIT']);
$res['total'] = MarketingTakePlace::count('*', $where);
$res['total_page'] = ceil($res['total']/$limit);
return $res;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment