mybatis 之 parameterType="HashMap"参数包含list
/**
* 获得人气组合商品详情
* @param paramMap
* @return
*/
public List<Goods> getCheckGoodsCombination(Map paramMap);
/**
* 获得人气组合商品详情
*
* @param request
* @param response
* @param originalGoodsId
* @param checkGoodsIds
*/
@RequestMapping("/combination")
public void combination(HttpServletRequest request, HttpServletResponse response,
@RequestParam(value = "originalGoodsId", required = true) String originalGoodsId,
@RequestParam(value = "checkGoodsId", required = false) String checkGoodsIds) {
try {
ServiceMessage<List<Goods>> combinationResult = goodsDetailService.getCheckGoodsCombination(originalGoodsId, checkGoodsIds);
if (combinationResult.getStatus() != MsgStatus.NORMAL) {
this.setResultInfo(combinationResult.getStatus().getCode(), combinationResult.getMessage());
return;
}
List<Goods> goodsList = combinationResult.getResult();
DecimalFormat df = new DecimalFormat("0.00");
BigDecimal sumMarktPrice = new BigDecimal(0);
BigDecimal sumEcPrice = new BigDecimal(0);
for (Goods g : goodsList) {
// 如果是促销
if (g.getDiscountState().equals("enable")) {
long beginTime = DateUtils.dateAllToLong(g.getBeginTime());
long endTime = DateUtils.dateAllToLong(g.getEndTime());
long current = System.currentTimeMillis();
if (beginTime > current || endTime < current) {
g.setDiscountState("none");
}else{
g.setEcPrice(g.getDiscountPrice());
}
sumEcPrice = sumEcPrice.add(g.getEcPrice());
} else {
sumEcPrice = sumEcPrice.add(g.getEcPrice());
}
sumMarktPrice = sumMarktPrice.add(g.getMarketPrice());
// 转化为小数点两位
g.setEcPrice(new BigDecimal(df.format(g.getEcPrice())));
}
// 优惠价=网售价-市场价
BigDecimal promotePrice = sumEcPrice.subtract(sumMarktPrice);
//
_result.put("originalGoodsId", originalGoodsId);
// 优惠的价
_result.put("promotePrice", df.format(promotePrice));
// 组合售价之和
_result.put("combinationPrice", df.format(sumEcPrice));
// 组合结果集
_result.put("combinationResult", combinationResult.getResult());
_result.setMsg(combinationResult.getMessage());
_result.setStatus(combinationResult.getStatus().getCode());
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
write(request, response);
}
}
/**
* 获得人气组合商品详情
*
* @param originalGoodsId 原goodsId
* @param checkGoodsIds 选中的组合goodsId
* @return
*/
@Override
public ServiceMessage<List<Goods>> getCheckGoodsCombination(String originalGoodsId, String checkGoodsIds) {
try {
List<String> list = new ArrayList<String>();
String combinationType = "";
if (!"".equals(checkGoodsIds) && checkGoodsIds != null) {
if (checkGoodsIds.equals("0")) {
combinationType = "original";
} else {
combinationType = "combination";
checkGoodsIds = URLDecoder.decode(checkGoodsIds, "utf-8");
String[] checkArr = checkGoodsIds.split(",");
for (int i = 0; i < checkArr.length; i++) {
list.add(checkArr[i]);
}
}
} else {
list = null;
combinationType = "all";
//return super.returnParamsError("人气组合选中的组合checkGoodsIds为空");
}
if (originalGoodsId == null || "".equals(originalGoodsId)) {
return super.returnParamsError("人气组合原goodsId为空");
}
Map<String, Object> map = new HashMap<String, Object>();
map.put("originalGoodsId", originalGoodsId);
map.put("checkGoodsIds", list);
map.put("combinationType", combinationType);
List<Goods> combinationList = goodsMapper.getCheckGoodsCombination(map);
if (combinationList == null || combinationList.size() < 1) {
return super.returnException("查找不到人气组合商品");
}
return super.returnCorrectResult(combinationList);
} catch (Throwable e) {
logger.error(e);
return super.returnException("查询人气组合商品出错");
}
}
mybatis 之 parameterType="HashMap"参数包含list的更多相关文章
- MyBatis的parameterType传入参数类型
在mybatis映射接口的配置中,有select,insert,update,delete等元素都提到了parameterType的用法,parameterType为输入参数,在配置的时候,配置相应的 ...
- mybatis mapper文件sql语句传入hashmap参数
1.怎样在mybatis mapper文件sql语句传入hashmap参数? 答:直接这样写map就可以 <select id="selectTeacher" paramet ...
- Mybatis学习笔记——输入参数parameterType、Mybatis调用存储过程
输入参数:parameterType(两种取值符号) 1.类型为简单类型 区别: (1) #{可以为任意值} ${vaue}--->标识符只能是value (2) ...
- MyBatis传入多个参数的问题
一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...
- mybatis传入多个参数
一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...
- [转]MyBatis传入多个参数的问题 - mingyue1818
原文 http://www.cnblogs.com/mingyue1818/p/3714162.html 一.单个参数: public List<XXBean> getXXBeanLis ...
- (转载)MyBatis传入多个参数的问题
原文地址:https://www.cnblogs.com/mingyue1818/p/3714162.html 一.单个参数: public List<XXBean> getXXBeanL ...
- mybatis 传入多个参数
一.单个参数: public List<XXBean> getXXBeanList(@param("id")String id); <select id=&quo ...
- MyBatis传入多个参数的问题(转)
一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...
随机推荐
- Apche Kafka 的生与死 – failover 机制详解
转自:http://www.cnblogs.com/fxjwind/p/4972244.html Kafka 作为 high throughput 的消息中间件,以其性能,简单和稳定性,成为当前实时流 ...
- Windows IOT 开发入门(准备工作)
终于抽出空来了,将最近研究的东西记录下来,物联网,万物皆可联网.然后可以做到智能家居,智能生活,智能城市....一大堆.吹牛的就不说了. 在实际应用中都是一个个小的传感器在收集数据,同时把数据直接或者 ...
- python numpy访问行列元素的方法
import numpy as np a = np.array([[2,1],[10,5]]) print(a) print(a[:,1])#col 1 print(a[1])#row 1 print ...
- Mxnet学习资源
MxNet 学习笔记(1):MxNet中的NDArray http://mxnet.incubator.apache.org/api/python/symbol/symbol.html api文档 M ...
- 【3】JVM-OutOfMemory异常重现
JVM中常见的OOM,那么如何通过自己编写代码产生这些OOM异常呢?通过写代码重现异常,是为了避免在工作中写出有OOM BUG的代码.之前虽然看过相关文章,但是没自己写过这些代码,这次在编写的实际过程 ...
- python-切片实例
针对list或tuple取指定范围的操作.可以使用切片(slice),非常有用 1.list:可变数组 L=['a','b','c','d','e'] >>> L[0:3] #从第0 ...
- SpringMVC系列(四)使用 POJO 对象绑定请求参数值
在实际开发中如果参数太多就不能使用@RequestParam去一个一个的映射了,需要定义一个实体参数对象(POJO)来映射请求参数.Spring MVC 会按请求参数名和 POJO 属性名进行自动匹配 ...
- Swing 是一个为Java设计的GUI工具包
Swing 是一个为Java设计的GUI工具包. Swing是JAVA基础类的一部分. Swing包括了图形用户界面(GUI)器件如:文本框,按钮,分隔窗格和表. Swing提供许多比AWT更好的屏幕 ...
- (转)TCP连接异常断开检测
TCP是一种面向连接的协议,连接的建立和断开需要通过收发相应的分节来实现.某些时候,由于网络的故障或是一方主机的突然崩溃而另一方无法检测到,以致始终保持着不存在的连接.下面介绍一种方法来检测这种异常断 ...
- 浅谈android中只使用一个TextView实现高仿京东,淘宝各种倒计时
今天给大家带来的是只使用一个TextView实现一个高仿京东.淘宝.唯品会等各种电商APP的活动倒计时.近期公司一直加班也没来得及时间去整理,今天难得歇息想把这个分享给大家.只求共同学习,以及自己兴许 ...