mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
falta rellenar presupuesto
This commit is contained in:
@ -90,4 +90,35 @@ class TarifaEnvioModel extends \App\Models\GoBaseModel
|
||||
->orLike("t2.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function getTarifaEnvio($paisId, string $cp, $peso, $tipo_envio){
|
||||
// Si el pais es españa se tienen que tener en cuenta los postales
|
||||
// Se busca primero la tarifa a la que corresponde
|
||||
$builder = $this->db->table($this->table . " t1")
|
||||
->select("t1.id AS tarifa_envio_id, t2.importe_fijo as importe_fijo")
|
||||
->join("tarifas_envios_zonas t2", "t1.id = t2.tarifa_envio_id")
|
||||
->where("t1.pais_id", $paisId)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t2.is_deleted", 0);
|
||||
|
||||
if($paisId == 1) {// España
|
||||
$builder->where("CAST(t2.cp_inicial AS UNSIGNED)<=", intval($cp))
|
||||
->where("CAST(t2.cp_final AS UNSIGNED) >=", intval($cp));
|
||||
}
|
||||
$tarifas = $builder->get()->getResultObject();
|
||||
|
||||
$resultado = [];
|
||||
|
||||
$model = model('App\Models\Tarifas\TarifaEnvioPrecioModel');
|
||||
foreach($tarifas as $tarifa){
|
||||
$precio_tarifas = $model->getEnvioPrecio($tarifa->tarifa_envio_id, $peso, $tipo_envio);
|
||||
foreach($precio_tarifas as $precio_tarifa){
|
||||
$precio_tarifa->importe_fijo = $tarifa->importe_fijo;
|
||||
array_push($resultado, $precio_tarifa);
|
||||
}
|
||||
}
|
||||
|
||||
return $resultado;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user