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

     * @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. python numpy的transpose函数用法

    #MXNET的N*C*H*W在numpy打印时比较直观#mxnet卷积层# 输入数据格式是:batch * inchannel * height * width# 输出数据格式是:batch * ou ...

  2. 00-02.PHP 网站假设 之 学习PHP语法 [James建站]

    PHP 手册 Stig Sæther Bakken Alexander Aulbach Egon Schmid Jim Winstead Lars Torben Wilson Rasmus Lerdo ...

  3. 飞机找不到,流量哪去了?记一次移动WAP网关导致的问题

    这几天随着客户端一个新版本发布,运维发现CDN的流量猛跌: 话说流量就是金钱,流量就是工资.领导很生气,后果很严重.没什么好说的,赶紧查!一开始怀疑服务端有问题,先受伤的总是我们,当然这也是没错的,因 ...

  4. Solr系列一:Solr(Solr介绍、Solr应用架构、Solr安装使用)

    一.前言 前面已经学习了Lucene的分词.索引详解.搜索详解的知识,已经知道开发一个搜索引擎的流程了.现在就会有这样的一个问题:如果其他的系统也需要使用开发的搜索引擎怎么办呢?这个时候就需要把开发的 ...

  5. Java NIO案例

    Java 网络IO编程总结(BIO.NIO.AIO均含完整实例代码)   http://blog.csdn.net/anxpp/article/details/51512200 Java NIO框架N ...

  6. Erlang Trace机制

    从FTP模块学习先进的诊断技术(Erlang Trace机制) http://blog.yufeng.info/archives/466

  7. Spring定时器的两种实现方式

    有两种流行Spring定时器配置:Java的Timer类和OpenSymphony的Quartz. 1.Java Timer定时 首先继承java.util.TimerTask类实现run方法 imp ...

  8. Javascript实例教程:querySelector()方法接受一个CSS查询并返回匹配模式的第一个子孙元素,如果没有匹配的元素则返回null。

    文章简介:querySelector()方法接受一个CSS查询并返回匹配模式的第一个子孙元素,如果没有匹配的元素则返回null. querySelector()方法接受一个CSS查询并返回匹配模式的第 ...

  9. Uploading File using Ajax and receiving binary data in Asp.net (C#)[转]

    基础知识,可由此衍生.原文:http://uniapple.net/blog/?p=2050 In this post, I will show you how to upload a file us ...

  10. JSON.stringify报cyclic object value错误

    这是一个典型的循环引用的错误,一个对象里引用自己就会立刻得到这个错误: obj = { x:555, y: "hi" }; obj.myself = obj; try{ json ...