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 ...
随机推荐
- Java注释规范整理
Version:0.9 StartHTML:-1 EndHTML:-1 StartFragment:00000099 EndFragment:00018736 在软件开发的过程中总是强调注释的规范,但 ...
- 实践:C++平台迁移以及如何用C#做C++包装层
在前面,我们看过OpenTK与MOgre,这二个项目都是C#项目,但是他的实现都是C++.他们简单来说就是一个包装层.常见的包装方式有二种,一种就是我们熟知的显式P/Invoke(DllImport) ...
- Obj模型功能完善(物体材质,光照,法线贴图).Cg着色语言+OpenTK+F#实现.
这篇文章给大家讲Obj模型里一些基本功能的完善,包含Cg着色语言,矩阵转换,光照,多重纹理,法线贴图的运用. 在上篇中,我们用GLSL实现了基本的phong光照,这里用Cg着色语言来实现另一钟Blin ...
- SpringMVC系列(十)<mvc:default-servlet-handler/>(处理静态资源)和<mvc:annotation-driven />
一.<mvc:default-servlet-handler/>处理静态资源 若将 DispatcherServlet 请求映射配置为 /,则 Spring MVC 将捕获WEB 容器的所 ...
- Type cvc-complex-type.2.4.c: The matching wildcard is strict...
这个问题困扰了我两次,分别说一下原因:1. 如网上一些网友所言,是在配置Spring的标签库的时候有拼写错误或者遗漏.下面贴一个标准3.0的吧: <?xml version="1.0& ...
- MQ遇到的错误(2035 或 2013认证错误)
java 连接 IBM MQ时出现 2035 或 2013认证错误的解决 com.ibm.msg.client.jms.DetailedJMSSecurityException: JMSWMQ2013 ...
- Yii2查询之where条件拼装
目录 1 语法 2 哈希格式 3 运算符格式 3.1 对比 3.2 and 3.3 or 3.4 not 3.5 between和not between 3.6 in和not in 3.7 like ...
- Vue中计算属性与class,style绑定
var vm=new Vue({ el:'#app', data:{ a:2, }, computed:{ //这里的b是计算属性:默认getter b:{ get:function(){ retur ...
- mysql4.5 更改密码,登录命令行闪退
登录到命令行 修改密码: 格式:mysql> set password for 用户名@localhost = password('新密码'); 例子:mysql> set passwor ...
- js 事件详解 冒泡
起因:正常情况下我点击s2时是先弹出我是children,再弹出我是father,但是却出现了先弹出我是father,后弹出我是children的情况,这种情况是在和安卓app交互的h5页面中出现的, ...