/**
     * 获得人气组合商品详情

     * @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的更多相关文章

  1. MyBatis的parameterType传入参数类型

    在mybatis映射接口的配置中,有select,insert,update,delete等元素都提到了parameterType的用法,parameterType为输入参数,在配置的时候,配置相应的 ...

  2. mybatis mapper文件sql语句传入hashmap参数

    1.怎样在mybatis mapper文件sql语句传入hashmap参数? 答:直接这样写map就可以 <select id="selectTeacher" paramet ...

  3. Mybatis学习笔记——输入参数parameterType、Mybatis调用存储过程

    输入参数:parameterType(两种取值符号) 1.类型为简单类型 区别:     (1) #{可以为任意值}         ${vaue}--->标识符只能是value     (2) ...

  4. MyBatis传入多个参数的问题

    一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...

  5. mybatis传入多个参数

    一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...

  6. [转]MyBatis传入多个参数的问题 - mingyue1818

    原文  http://www.cnblogs.com/mingyue1818/p/3714162.html 一.单个参数: public List<XXBean> getXXBeanLis ...

  7. (转载)MyBatis传入多个参数的问题

    原文地址:https://www.cnblogs.com/mingyue1818/p/3714162.html 一.单个参数: public List<XXBean> getXXBeanL ...

  8. mybatis 传入多个参数

    一.单个参数: public List<XXBean> getXXBeanList(@param("id")String id); <select id=&quo ...

  9. MyBatis传入多个参数的问题(转)

    一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...

随机推荐

  1. find & grep 命令 in linux(转)

    Linux下面工作,有些命令能够大大提高效率.本文就向大家介绍find.grep命令,他哥俩可以算是必会的linux命令,我几乎每天都要用到他们.本文结构如下: -exec,find命令对匹配的文件执 ...

  2. 【转】【Python】Python多进程与多线程

    1.1 multiprocessing multiprocessing是多进程模块,多进程提供了任务并发性,能充分利用多核处理器.避免了GIL(全局解释锁)对资源的影响. 有以下常用类: 类 描述 P ...

  3. vb.net与c#相互转换工具

    vb.net与c#相互转换工具:  http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx http://www.dotne ...

  4. MyBatis整合Spring MVC

    前面几篇文章已经讲到了mybatis与spring 的集成.目前主流的Web MVC框架,除了Struts这个主力外,还有Spring MVC,主要是由于 Spring MVC 配置比较简单,使用起来 ...

  5. e802. 创建一个位置大小的JProgressBar组件

    A progress bar with an unknown maximum typically displays an animation until the task is complete. N ...

  6. 一个类似于postman的协议测试工具

    协议测试工具使用postman相当便捷,不过有一个问题,就是每个人都要装一个这个东西,并且测试文件导来导去,还是觉得麻烦了点. 最重要的是postman不能修改,有一些定制功能postman明显力不从 ...

  7. ASP.NET EntityFrameworkCore code first 多对多设计

    摘要:参考网址:https://docs.microsoft.com/zh-cn/ef/core/get-started/full-dotnet/new-db场景:使用ASP.NETEntityFra ...

  8. ASM实例原始磁盘搜索路径

    discovery diskstring==>ASM实例原始磁盘搜索路径,一般搜索/dev/raw/  /dev/oracleasm/ 初始化参数文件中为:asm_diskstring asmc ...

  9. MySQL谨慎使用"replace into"

    From: http://blog.xupeng.me/2013/10/11/mysql-replace-into-trap/ MySQL 对 SQL 有很多扩展,有些用起来很方便,但有一些被误用之后 ...

  10. 使用redis镜像

    运行容器 runoob@runoob:~/redis$ docker run -p : -v $PWD/data:/data -d redis:3.2 redis-server --appendonl ...