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 ...
随机推荐
- [Qt] 利用QtWebKit完成JavaScript访问C++对象
一. 介绍 在浏览器扩展或者WebApp的项目经常用的脚本语言javascript有很多局限性,比如,javascript语言不能够夸窗口访问js对象,不能直接读写磁盘文件(这个也正是发明人设计的安全 ...
- 9、Qt 事件处理机制
原文地址:http://mobile.51cto.com/symbian-272812.htm 在Qt中,事件被封装成一个个对象,所有的事件均继承自抽象类QEvent. 接下来依次谈谈Qt中有谁来产生 ...
- Socket心跳包机制
心跳包的发送,通常有两种技术方法1:应用层自己实现的心跳包 由应用程序自己发送心跳包来检测连接是否正常,大致的方法是:服务器在一个 Timer事件中定时 向客户端发送一个短小精悍的数据包,然后启动一个 ...
- 关于Unity中旧版动画系统的使用
Unity在5.X以后,有一个旧版的动画系统和新版的动画系统. 新版的动画系统是使用Unity动画编辑器来调的,调动画和控制动画 旧版的动画系统是用其他的第三方软件调好后导出到一个FBX文件里面,就是 ...
- tornado上传大文件以及多文件上传
tornado上传大文件问题解决方法 tornado默认上传限制为低于100M,但是由于需要上传大文件需求,网上很多说是用nginx,但我懒,同时不想在搞一个服务了. 解决方法: server = H ...
- (笔记)Linux下怎么安装tar.gz的软件
一般这种的就是源代码.先下载下来.然后cd到下载目录.用tar xvfz XXX.tar.gz的解压.然后进入解压后的目录. 打./configure生成配置文件.打make对源代码进行编译,生成库和 ...
- elasticsearch系列二:索引详解(快速入门、索引管理、映射详解、索引别名)
一.快速入门 1. 查看集群的健康状况 http://localhost:9200/_cat http://localhost:9200/_cat/health?v 说明:v是用来要求在结果中返回表头 ...
- JS 动态修改json字符串
<script type="text/javascript"> //1.将表单序列化成json字符串 $.fn.serializeObject = function() ...
- 系统中hosts文件有哪些作用
hosts文件位于系统盘C:\Windows\System32\drivers\etc中,hosts是一个没有扩展名的系统文件,其基本作用就是将一些常用的网址域名与其对应的IP地址建立一个关联“数据库 ...
- VMware安装与VMware下安装CentOS系统
1.下载安装VMware,我安装的是VMware 12.VMware从11开始不再支持32位系统,32位系统请安装VMware10. VMware官方功能特性介绍http://www.vmware.c ...