All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.mingsoft.freight.action.web.FreightAction Maven / Gradle / Ivy

/**
The MIT License (MIT) * Copyright (c) 2016 铭飞科技(mingsoft.net)

 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:

 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.

 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package net.mingsoft.freight.action.web;

import net.mingsoft.base.entity.ResultData;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.freight.action.BaseAction;
import net.mingsoft.freight.biz.IFreightBiz;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * 运费详情计算前段接口
 * @author 铭飞开源团队
 * @date 2019年7月16日
 */
@Controller("webFreight")
@RequestMapping("/freight")
public class FreightAction extends BaseAction {
	/**
	 * 注入运费基础业务层
	 */
	@Autowired
	private IFreightBiz freightBiz;
	/**
	 * 计算总运费
	 * @param response
	 * @param request
	 * @return
	 */
	@RequestMapping("/cost")
	@ResponseBody
	public ResultData cost(HttpServletResponse response, HttpServletRequest request){
		//通过城市id去匹配所有有这个城市的物流公司
		String faCityId = BasicUtil.getString("faCityId");
		//寄件重量
		double scale = Double.parseDouble(BasicUtil.getString("scale"));
		//寄件总数
		int count = BasicUtil.getInt("count");
		if(StringUtils.isBlank(faCityId)){
			return ResultData.build().error(getResString("err.empty", this.getResString("freight.city.id")));
		}
		return ResultData.build().success(freightBiz.cost(faCityId,scale,count));
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy