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

     * @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. 基础 | batchnorm原理及代码详解

    https://blog.csdn.net/qq_25737169/article/details/79048516 https://www.cnblogs.com/bonelee/p/8528722 ...

  2. Opengl绘制我们的小屋(二)第一人称漫游

    这章我们先讲第一人称漫游的实现.在openTK里,我们用函数Matrix4.LookAt(caram.Eye,caram.Target,Vector3.UnitY)来放置摄像机,其中三个参数分别与摄像 ...

  3. F# 图形数学基础。

    这几天,在看Unity3D,很有意思,其中看到,第一人称控制器,就想看到里面的一些控制脚本是如何实现,才发现,学到的好多数据知识已经还给老师了,还好,走遍大江南北,跟着的书不多,唯一的二本高数没丢. ...

  4. 【转】JS对Cookie的读写删除

    JavaScript是运行在客户端的脚本,因此一般是不能够设置Session的,因为Session是运行在服务器端的.而cookie是运行在客户端的,所以可以用JS来设置cookie. 假设有这样一种 ...

  5. unity3d-----Collider 组件参考

    Collider 组件参考 点击 属性检查器 下面的 添加组件 按钮,然后从 添加碰撞组件 中选择需要的 Collider 组件,即可添加 Collider组件到节点上. Collider 组件属性 ...

  6. 我的openwrt开发相关文章

    openwrt学习笔记: 在openwrt的学习过程中,走了非常多的弯路.一直以来有个期盼.希望能够出个简易教程,希望openwrt的同仁们能够更加高速的入手. . openwrt学习笔记(三十二): ...

  7. Linux 文件类型及操作

    一.  文件类型 1.Linux文件类型如下图所示: 2.Linux文件类型有许多种,不同的文件类型代表特殊意义,使用以下命令可以查看文件类型: [root@VMredhat6 ~]# ls  -l  ...

  8. php-fpm的pool php-fpm慢执行日志 open_basedir php-fpm进程管理

    php-fpm的pool • vim /usr/local/php/etc/php-fpm.conf//在[global]部分增加 • include = etc/php-fpm.d/*.conf • ...

  9. MBProgressHUD 第三方库使用

    关键操作:   效果如下:   ViewController.h #import <UIKit/UIKit.h> #import "MBProgressHUD.h" @ ...

  10. 为npm设置代理

    npm全称为Node Packaged Modules.它是一个用于管理基于node.js编写的package的命令行工具.其本身就是基于node.js写的,这有点像gem与ruby的关系. 在我们的 ...