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 ...
随机推荐
- Android 8 AudioPolicy 分析
AudioTrack最终会调用AudioPolicyManager::getOutput(); frameworks\av\services\audiopolicy\managerdefault\Au ...
- Flume exec 测试
环境:ubuntu 1604 软件:①apache-flume-1.7.0-bin.tar.gz,解压后放到 /usr/local/ 下面.②sudo apt-get install apache2 ...
- 用ARM实现音乐电子相册
(前段时间在做嵌入式的课程设计,特将学习心得整理如下) 一.开发工具及环境介绍 1.ARM处理器 ARM处理器是一个32位元精简指令集(RISC)处理器架构,其广泛地使用在许多嵌入式系统设计. ARM ...
- redis实现区间查询
###redis实现区间查询 在实际开发中经常遇到这样需求:服务端对于客户端不同的版本区间会做些不同的配置,那么客户端一个版本过来怎么快速的定位是属于哪个版本区间呢?可以利用`Sorted Sets` ...
- Windows查看占用端口的进程及其对应的应用程序并关闭之
^_^ C:\Users\dsp> C:\Users\dsp>netstat -ano | findstr " TCP LISTENING TCP TIME_WAIT TCP T ...
- poj 1700 Crossing River C++/Java
http://poj.org/problem?id=1700 题目大意: 有n个人要过坐船过河,每一个人划船有个时间a[i],每次最多两个人坐一条船过河.且过河时间为两个人中速度慢的,求n个人过河的最 ...
- RNAcentral 数据库简介
RNAcentral 是EBI 开发的一个非编码RNA的数据库. 网址如下: http://rnacentral.org/ RNAcentral 整合了包括 Ensembl, GENCODE,Gree ...
- 植物 miRNA 研究
相比动物miRNA 而言, 植物miRNA 的研究相对较少. 植物miRNA 相比动物miRNA , 有以下特点: 1) 植物miRNA 的长度为 21 nt 左右, 动物miRNA 长度在 22 ~ ...
- C# 获取文件夹下的所有文件的文件名
String path = @"X:\xxx\xxx"; //第一种方法 var files = Directory.GetFiles(path, "*.txt" ...
- 10个样式各异的CSS3 Loading加载动画
前几天我在园子里分享过2款很酷的CSS3 Loading加载动画,今天又有10个最新的Loading动画分享给大家,这些动画的样式都不一样,实现起来也并不难,你很容易把它们应用在项目中,先来看看效果图 ...