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

     * @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. Java虚拟机(JVM)体系结构概述及各种性能参数优化总结

    转自:http://blog.csdn.net/zhongwen7710/article/details/39213377 第一部分:相关的概念 数据类型 Java虚拟机中,数据类型可以分为两类:基本 ...

  2. List<Map<String, Object>>是什么意思

    List集合中的对象是一个Map对象,而这个Map对象的键是String类型,值是Object类型 List以Map接口对象为列表对象. Map以String为键,以Object为值. List里只能 ...

  3. Java如何获取正在运行的线程的Id?

    在Java编程中,如何获取正在运行的线程的Id? 以下示例演示如何使用getThreadId()方法获取正在运行的线程的Id. package com.yiibai; public class IdT ...

  4. 关于sdl_ttf使用字体库加载失败的问题

    今天同事拿着前期阶段开发的视频绘图库给另外一个同事的电脑上测试,结果发现老是出现打开字体库失败,但从打印的日志信息看,路径下确实存在字体库啊,这是什么原因? 于是没办法,搬到自己本级上再测试下,从他机 ...

  5. (转)关于linux挂载window下共享文件

    关于linux挂载window下共享文件的方法: ①事先建立linux下文件夹,例如“ /mnt/linux-folder”②用mount命令挂载    mount -o username=windo ...

  6. Git -- 相关命令

    git init : 将当前目录变成Git可以管理的仓库 git add :告诉Git,把文件添加到仓库 git commit -m "" :把文件提交到仓库 git status ...

  7. u3d fpsCounter

    因为u3d自己的stats下面的fpscounter不是实际意义上的fps,所以看到demo的fpsCounter,把它改写为c#的 using UnityEngine;using System.Co ...

  8. Xcode - 升级后模拟器无法响应电脑键盘

    链接 Q: I used to be able to type with my real mac keyboard after launching the iPhone Simulator. Typi ...

  9. CentOS 经常使用系统命令

    # uname -a # 查看内核/操作系统/CPU信息# head -n 1 /etc/issue   # 查看操作系统版本号# cat /proc/cpuinfo      # 查看CPU信息# ...

  10. C++ 中的constkeyword

    为什么使用const?採用符号常量写出的代码更easy维护:指针经常是边读边移动,而不是边写边移动:很多函数參数是仅仅读不写的.const最常见用途是作为数组的界和switch分情况标号(也能够用枚举 ...