verifyParam($param); //参数验证 if ($verifyResult['status'] != 1) { return $verifyResult; } switch ($param['user_type']) { case 3: //商户 break; case 4: //门店 $SupplierModel = new SSupplierModel(); break; } $where = $this->Term($param); $fields = $param['fields'] ? $param['fields'] : '*'; try { $list = $SupplierModel->getSelect($where, '', '', $fields); //供货商 return $list ? $list : []; } catch (\Exception $e) { return []; } } /** * 查询条件 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * ] * @return mixed */ public function Term($param) { $where = [ 'merchant_id' => $param['merchant_id'], 'status' => 1 ]; if ($param['user_type'] == 4) { $where['store_id'] = $param['store_id']; } return $where; } /** * 参数验证 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * fields * ] * @return mixed */ public function verifyParam($param) { if (!in_array($param['user_type'], ['3', '4']) || empty($param['merchant_id']) || ($param['user_type'] == 4 && empty($param['store_id']))) { return callBack(statusCode()['error'], "登录超时"); } return callBack(statusCode()['success'], "验证成功"); } }