@Override
  public void addOrder(
      List<ShopTemp> shopsList,
      short orderType,
      String userId,
      String userAddressId,
      Integer payofflineflag,
      HttpServletRequest request) {

    Order_list order_list = new Order_list();
    order_list.setLastUpdateTime(new Date());
    Order_detail order_detail = null;
    switch (orderType) {
      case 1:
        String providerId = "";
        for (ShopTemp shopTemp : shopsList) {

          productService.updateStockNumber(
              shopTemp.getProduct().getProductId(), 0 - shopTemp.getCount());
          if (shopTemp.getProviderId().equals(providerId)) {
            // 同一订单
            order_list.setTotalamt(order_list.getTotalamt() + shopTemp.getTotalamt());
            order_detail = new Order_detail();
            order_detail.setOrderId(order_list.getOrderId());
            order_detail.setTotalamt(shopTemp.getTotalamt());
            order_detail.setPrice(shopTemp.getPrice());
            order_detail.setProductId(shopTemp.getProduct().getProductId());
            order_detail.setOrderType(orderType);
            order_detail.setQuantity((short) shopTemp.getCount());
            order_list.setPayofflineflag(payofflineflag.shortValue());
            order_detail.setValidflag((short) 1);
            detailDao.insert(order_detail);
            commonDao.update(order_list);

          } else {

            providerId = shopTemp.getProviderId();
            // 新订单 9999999999
            order_list = new Order_list();
            order_list.setStatus("01");
            order_list.setOrderType(orderType);
            order_list.setUserId(userId);
            order_list.setUserAddressId(userAddressId);
            order_list.setProviderid(shopTemp.getProviderId());
            order_list.setTotalamt(shopTemp.getTotalamt());
            order_list.setOrderId(
                UtilDate.getNowDateNo_()
                    + "0"
                    + orderType
                    + shopTemp.getProviderId()
                    + (new Random().nextInt(899999) + 100000)); // TBD
            order_list.setCreateTime(new Date());
            order_list.setRequireinvoice(Short.parseShort(request.getParameter("requireinvoice")));
            order_list.setInvoicetype(Short.parseShort(request.getParameter("invoicetype")));
            order_list.setInvoicetitle(request.getParameter("invoicetitle"));
            order_list.setInvoicecontent(request.getParameter("invoicecontent"));
            order_list.setPaymentway(request.getParameter("paymentway"));
            order_list.setInvoiceprinted((short) 0);
            order_list.setRemark(request.getParameter("remark"));
            order_list.setLastUpdateTime(new Date());
            order_list.setPayofflineflag(payofflineflag.shortValue());
            order_list.setValidflag((short) 1);
            listDao.insert(order_list);

            order_detail = new Order_detail();
            order_detail.setOrderId(order_list.getOrderId());
            order_detail.setTotalamt(shopTemp.getTotalamt());
            order_detail.setPrice(shopTemp.getPrice());
            order_detail.setProductId(shopTemp.getProduct().getProductId());
            order_detail.setOrderType(orderType);
            order_detail.setQuantity((short) shopTemp.getCount());
            order_detail.setValidflag((short) 1);
            detailDao.insert(order_detail);
          }
        }
        break;

      case 2:
        String count = request.getParameter("count");
        String groupbuyid = request.getParameter("groupbuyid");
        Product_ext_groupBuy groupbuy = null;
        groupBuyService.updateStockNumber(groupbuyid, 0 - Integer.parseInt(count));
        groupbuy = groupBuyService.getgroupBuyProductByMethod(3, groupbuyid, "1").get(0);

        order_list.setStatus("01");
        order_list.setOrderType(orderType);
        order_list.setUserId(userId);
        order_list.setUserAddressId(userAddressId);
        order_list.setProviderid(groupbuy.getProduct().getProviderId());
        order_list.setTotalamt(groupbuy.getGroupBuyPrice() * Integer.parseInt(count));
        order_list.setOrderId(
            UtilDate.getNowDateNo_()
                + "0"
                + orderType
                + groupbuy.getProduct().getProviderId()
                + (new Random().nextInt(899999) + 100000));
        order_list.setCreateTime(new Date());
        Short requireinvoice = Short.parseShort(request.getParameter("requireinvoice"));
        order_list.setRequireinvoice(requireinvoice);
        if (requireinvoice.equals(1)) {
          order_list.setInvoicetype(Short.parseShort(request.getParameter("invoicetype")));
          order_list.setInvoicetitle(request.getParameter("invoicetitle"));
          order_list.setInvoicecontent(request.getParameter("invoicecontent"));
        }
        order_list.setPaymentway(request.getParameter("paymentway"));
        order_list.setInvoiceprinted((short) 0);
        order_list.setPayofflineflag(payofflineflag.shortValue());
        order_list.setValidflag((short) 1);
        order_list.setRemark(request.getParameter("remark"));

        commonDao.insert(order_list);

        order_detail = new Order_detail();
        order_detail.setOrderId(order_list.getOrderId());
        order_detail.setPrice(groupbuy.getGroupBuyPrice());
        order_detail.setProductId(groupbuy.getGroupbuyid());
        order_detail.setOrderType(orderType);
        order_detail.setQuantity(Short.parseShort(count));
        order_detail.setTotalamt(groupbuy.getGroupBuyPrice() * Integer.parseInt(count));
        order_detail.setValidflag((short) 1);
        detailDao.insert(order_detail);

        break;
      case 3:
        String bigdealcount = request.getParameter("count");
        String bigdealid = request.getParameter("bigdealid");
        Product_ext_bigDeal bigDeal =
            bigDealService.getbigDealProductByMethod(3, bigdealid, "1").get(0);

        order_list.setStatus("08");
        order_list.setOrderType(orderType);
        order_list.setProviderid(bigDeal.getProduct().getProviderId());
        order_list.setTotalamt(bigDeal.getReferencePrice() * Integer.parseInt(bigdealcount));
        order_list.setUserId(userId);
        order_list.setOrderId(
            UtilDate.getNowDateNo_()
                + "0"
                + orderType
                + bigDeal.getProduct().getProviderId()
                + (new Random().nextInt(899999) + 100000));
        order_list.setCreateTime(new Date());
        order_list.setInvoiceprinted((short) 0);
        order_list.setRemark(request.getParameter("remark"));
        order_list.setPayofflineflag((short) 1);
        order_list.setValidflag((short) 1);

        commonDao.insert(order_list);

        order_detail = new Order_detail();
        order_detail.setOrderId(order_list.getOrderId());
        order_detail.setPrice(bigDeal.getReferencePrice());
        order_detail.setProductId(bigDeal.getBigdealId());
        order_detail.setOrderType(orderType);
        order_detail.setQuantity(Short.parseShort(bigdealcount));
        order_detail.setTotalamt(bigDeal.getReferencePrice() * Integer.parseInt(bigdealcount));
        order_detail.setValidflag((short) 1);
        detailDao.insert(order_detail);
        break;

      case 4:
        String productCount = request.getParameter("count");
        String productId = request.getParameter("productId");
        Product_ext_shop product_ext_shop1 = null;
        product_ext_shop1 = ext_shopService.getShopProductByMethod(5, productId).get(0);

        order_list.setStatus("01");
        order_list.setOrderType((short) 1);
        order_list.setUserId(userId);
        order_list.setUserAddressId(userAddressId);
        order_list.setProviderid(product_ext_shop1.getProduct().getProviderId());
        if (product_ext_shop1.getPromoteflag() == 1) {
          order_list.setTotalamt(
              product_ext_shop1.getPromotePrice() * Integer.parseInt(productCount));
        } else {
          order_list.setTotalamt(
              product_ext_shop1.getOriginalPrice() * Integer.parseInt(productCount));
        }
        order_list.setOrderId(
            UtilDate.getNowDateNo_()
                + "0"
                + orderType
                + product_ext_shop1.getProduct().getProviderId()
                + (new Random().nextInt(899999) + 100000));
        order_list.setCreateTime(new Date());
        order_list.setRequireinvoice(Short.parseShort(request.getParameter("requireinvoice")));
        order_list.setInvoicetype(Short.parseShort(request.getParameter("invoicetype")));
        order_list.setInvoicetitle(request.getParameter("invoicetitle"));
        order_list.setInvoicecontent(request.getParameter("invoicecontent"));
        order_list.setPaymentway(request.getParameter("paymentway"));
        order_list.setInvoiceprinted((short) 0);
        order_list.setPayofflineflag(payofflineflag.shortValue());
        order_list.setValidflag((short) 1);
        order_list.setRemark(request.getParameter("remark"));

        commonDao.insert(order_list);

        order_detail = new Order_detail();
        order_detail.setOrderId(order_list.getOrderId());

        if (product_ext_shop1.getPromoteflag() == 1) {
          order_detail.setPrice(product_ext_shop1.getPromotePrice());
        } else {
          order_detail.setPrice(product_ext_shop1.getOriginalPrice());
        }

        order_detail.setProductId(product_ext_shop1.getProductId());
        order_detail.setOrderType(orderType);
        order_detail.setQuantity(Short.parseShort(productCount));

        if (product_ext_shop1.getPromoteflag() == 1) {
          order_detail.setTotalamt(
              product_ext_shop1.getPromotePrice() * Integer.parseInt(productCount));
        } else {
          order_detail.setTotalamt(
              product_ext_shop1.getOriginalPrice() * Integer.parseInt(productCount));
        }

        order_detail.setValidflag((short) 1);
        detailDao.insert(order_detail);

        break;

      case 5:
        String providerProductCount = request.getParameter("count");
        String providerProductProductId = request.getParameter("productId");
        Product product = null;
        product = productService.getProductListByMethod(2, null, providerProductProductId).get(0);

        order_list.setStatus("01");
        order_list.setOrderType((short) 1);
        order_list.setUserId(userId);
        order_list.setUserAddressId(userAddressId);
        order_list.setProviderid(product.getProviderId());
        order_list.setTotalamt(product.getShopPrice());
        order_list.setOrderId(
            UtilDate.getNowDateNo_()
                + "0"
                + orderType
                + product.getProviderId()
                + (new Random().nextInt(899999) + 100000));
        order_list.setCreateTime(new Date());
        order_list.setRequireinvoice(Short.parseShort(request.getParameter("requireinvoice")));
        order_list.setInvoicetype(Short.parseShort(request.getParameter("invoicetype")));
        order_list.setInvoicetitle(request.getParameter("invoicetitle"));
        order_list.setInvoicecontent(request.getParameter("invoicecontent"));
        order_list.setPaymentway(request.getParameter("paymentway"));
        order_list.setInvoiceprinted((short) 0);
        order_list.setPayofflineflag(payofflineflag.shortValue());
        order_list.setValidflag((short) 1);
        order_list.setRemark(request.getParameter("remark"));

        commonDao.insert(order_list);

        order_detail = new Order_detail();
        order_detail.setOrderId(order_list.getOrderId());

        order_detail.setPrice(product.getShopPrice());

        order_detail.setProductId(product.getProductId());
        order_detail.setOrderType(orderType);
        order_detail.setQuantity(Short.parseShort(providerProductCount));

        order_detail.setTotalamt(product.getShopPrice() * Integer.parseInt(providerProductCount));

        order_detail.setValidflag((short) 1);
        detailDao.insert(order_detail);

        break;

      default:
        break;
    }
  }
  public Order_list addLeaseOrder(
      List<ShopTemp> shopTempList,
      short orderType,
      String userId,
      String userAddressId,
      Integer payofflineflag,
      int invoicetype,
      String remark,
      String paymentway) {
    Order_list order_list = new Order_list();
    // Product_ext_shop product_ext_shop11 =
    // ext_shopService.getShopProductByMethod(5, productId1).get(0);

    // Double totalamt =
    // leaseBusinessService.calculateTotalRentPrice(productId1,
    // productCount1, lease_period,
    // product_ext_shop11.getOriginalPrice());

    order_list.setStatus("01");
    order_list.setOrderType(orderType);
    order_list.setUserId(userId);
    order_list.setUserAddressId(userAddressId);
    String fixedProviderId = "01"; // TBD
    order_list.setOrderId(
        UtilDate.getNowDateNo_()
            + "0"
            + orderType
            + fixedProviderId
            + (new Random().nextInt(899999) + 100000));
    order_list.setCreateTime(new Date());
    // order_list.setRequireinvoice(Short.parseShort(request.getParameter("requireinvoice")));
    order_list.setInvoicetype((short) invoicetype);
    // order_list.setInvoicetitle(request.getParameter("invoicetitle"));
    // order_list.setInvoicecontent(request.getParameter("invoicecontent"));
    order_list.setPaymentway(paymentway);
    // order_list.setInvoiceprinted((short) 0);
    order_list.setPayofflineflag(payofflineflag.shortValue());
    order_list.setValidflag((short) 1);
    order_list.setRemark(remark);

    order_list.setLastUpdateTime(new Date());

    List<Order_detail> order_details = new ArrayList<Order_detail>();
    for (ShopTemp shopTemp : shopTempList) {
      productService.updateStockNumber(
          shopTemp.getProduct().getProductId(), 0 - shopTemp.getCount());
      // 同一订单

      order_list.setProviderid(shopTemp.getProviderId());
      Order_detail order_detail = new Order_detail();
      order_detail.setOrderId(order_list.getOrderId());
      double totalamt =
          leaseBusinessService.calculateTotalRentPrice(
              shopTemp.getProduct().getProductId(),
              shopTemp.getCount(),
              shopTemp.getLeaseCycle(),
              shopTemp.getYajin());
      order_list.setTotalamt(order_list.getTotalamt() + totalamt);
      order_detail.setTotalamt(totalamt);
      order_detail.setPrice(shopTemp.getPrice());
      order_detail.setProductId(shopTemp.getProduct().getProductId());
      order_detail.setOrderType(orderType);
      order_detail.setQuantity((short) shopTemp.getCount());
      order_list.setPayofflineflag(payofflineflag.shortValue());
      order_detail.setValidflag((short) 1);
      order_details.add(order_detail);
      detailDao.insert(order_detail);

      // lease
      Lease lease = new Lease();
      lease.setProductId(shopTemp.getProduct().getProductId());
      lease.setLeaseType(shopTemp.getLeaseType());
      lease.setLeaseCycle(shopTemp.getLeaseCycle());
      lease.setUserId(userId);
      lease.setOrderId(order_list.getOrderId());
      leaseDaoService.saveLease(lease);
    }

    order_list.setOrder_detail(order_details);
    commonDao.insert(order_list);

    return order_list;
  }