Exemplo n.º 1
0
  private void setOrderCountInfo(OrderCountInfo orderCountInfo, Order order) {

    orderCountInfo.setOrderCount(orderCountInfo.getOrderCount() + 1);
    orderCountInfo.setCoinAmount(Arith.add(order.getCoinAmount(), orderCountInfo.getCoinAmount()));
    orderCountInfo.setCouponsAmount(
        Arith.add(order.getCouponsAmount(), orderCountInfo.getCouponsAmount()));
    orderCountInfo.setGoodsAmount(
        Arith.add(order.getGoodsAmount(), orderCountInfo.getGoodsAmount()));
    orderCountInfo.setGoodsTransportAmount(
        Arith.add(order.getGoodsTransportAmount(), orderCountInfo.getGoodsTransportAmount()));
    orderCountInfo.setRealAmount(Arith.add(order.getRealAmount(), orderCountInfo.getRealAmount()));
  }
Exemplo n.º 2
0
  public Map<String, Object> getGridData(HttpServletRequest request, SysUnits sysUnits) {

    Map<String, Object> gridData = new HashMap<String, Object>();

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("unitId", sysUnits.getId());
    map.put("unitType", sysUnits.getUnitType());
    map.put("zoneCode", sysUnits.getZoneCode() + "%");

    String startDay_str = request.getParameter("startDay");
    String endDay_str = request.getParameter("endDay");
    String unitName = request.getParameter("unitName");

    List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
    if (null != startDay_str
        && !startDay_str.equals("")
        && null != endDay_str
        && !endDay_str.equals("")) {

      map.put("startDay", DateUtil.toDate(startDay_str, DateUtil.YYYY_MM_DD));
      map.put("endDay", DateUtil.toDate(endDay_str, DateUtil.YYYY_MM_DD));
      if (null != unitName && !"".equals(unitName)) {

        map.put("unitName", "%" + unitName + "%");
      }
      dataList = orderCountDao.getListMap(map);
    }

    if (null != dataList && !dataList.isEmpty()) {

      for (Map<String, Object> countData : dataList) {

        List<OrderCountInfo> infoList =
            orderCountInfoDao.getListByCountId(Long.valueOf(countData.get("ID") + ""));

        countData.put(
            "AVG_AMOUNT",
            Arith.div(
                null == countData.get("GOODS_AMOUNT")
                    ? 0d
                    : Double.valueOf(countData.get("GOODS_AMOUNT") + ""),
                null == countData.get("ORDER_COUNT")
                    ? 0d
                    : Double.valueOf(countData.get("ORDER_COUNT") + "")));
        if (null != infoList && !infoList.isEmpty()) {

          for (OrderCountInfo orderCountInfo : infoList) {

            int infoType = orderCountInfo.getInfoType();
            countData.put("ORDER_COUNT_" + infoType, orderCountInfo.getOrderCount());
            countData.put("REAL_AMOUNT_" + infoType, orderCountInfo.getRealAmount());
            countData.put("GOODS_AMOUNT_" + infoType, orderCountInfo.getGoodsAmount());
            countData.put("COIN_AMOUNT_" + infoType, orderCountInfo.getCoinAmount());
            countData.put(
                "GOODS_TRANSPORT_AMOUNT_" + infoType, orderCountInfo.getGoodsTransportAmount());
            countData.put("COUPONS_AMOUNT_" + infoType, orderCountInfo.getCouponsAmount());
            countData.put(
                "AVG_AMOUNT_" + infoType,
                Arith.div(
                    orderCountInfo.getGoodsAmount(),
                    Double.valueOf(orderCountInfo.getOrderCount())));
          }
        }
      }
    }
    long totalRows = null == dataList ? 0 : dataList.size();
    gridData.put("Rows", dataList);
    gridData.put("Total", totalRows);
    return gridData;
  }
Exemplo n.º 3
0
  private List<Map<String, Object>> analysesData(Map<String, Object> paraMap, String orderDay) {
    // 结果List
    List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();

    /** 查询符合条件的 单位* */
    List<Map<String, Object>> unitInfoList = orderDao.getOrderAnalysesUnitInfoList(paraMap);

    for (Map<String, Object> tmpInfo : unitInfoList) {
      String shortName = StringUtil.objectToString(tmpInfo.get("shortName")); // 单位简称
      Object idObj = tmpInfo.get("unitID");
      Long unitID = Long.valueOf(idObj == null ? "0" : StringUtil.objectToString(idObj)); // 单位ID

      paraMap.put("unitIdOption", unitID); // 根据单位查询各单位的订单

      /** 查询符合条件的订单数据* */
      List<Order> orderList = orderDao.getOrderAnalysesData(paraMap);

      /** 分析订单数据* */
      if (!orderList.isEmpty()) {
        // 分析数据详情

        // 所有订单
        int orderCount = orderList.size(); // 所有订单量
        double goodsAmount = 0.0; // 商品金额
        double avgAmount = 0.0; // 客单价(商品金额/订单总数)
        double realAmount = 0.0; // 实付金额总数
        double coinAmount = 0.0; // 达人币总数
        double goodsTransportAmount = 0.0; // 订单总运费
        double couponsAmount = 0.0; // 优惠券总额
        // 有效订单
        int orderCount0 = 0; // 所有订单量
        double goodsAmount0 = 0.0; // 商品金额
        double avgAmount0 = 0.0; // 客单价(商品金额/订单总数)
        double realAmount0 = 0.0; // 实付金额总数
        double coinAmount0 = 0.0; // 达人币总数
        double goodsTransportAmount0 = 0.0; // 订单总运费
        double couponsAmount0 = 0.0; // 优惠券总额
        // 拒收订单
        int orderCount4 = 0; // 所有订单量
        double goodsAmount4 = 0.0; // 商品金额
        double avgAmount4 = 0.0; // 客单价(商品金额/订单总数)
        double realAmount4 = 0.0; // 实付金额总数
        double coinAmount4 = 0.0; // 达人币总数
        double goodsTransportAmount4 = 0.0; // 订单总运费
        double couponsAmount4 = 0.0; // 优惠券总额
        // 线下订单
        int orderCount2 = 0; // 所有订单量
        double goodsAmount2 = 0.0; // 商品金额
        double avgAmount2 = 0.0; // 客单价(商品金额/订单总数)
        double realAmount2 = 0.0; // 实付金额总数
        double coinAmount2 = 0.0; // 达人币总数
        double goodsTransportAmount2 = 0.0; // 订单总运费
        double couponsAmount2 = 0.0; // 优惠券总额
        // 线上订单
        int orderCount1 = 0; // 所有订单量
        double goodsAmount1 = 0.0; // 商品金额
        double avgAmount1 = 0.0; // 客单价(商品金额/订单总数)
        double realAmount1 = 0.0; // 实付金额总数
        double coinAmount1 = 0.0; // 达人币总数
        double goodsTransportAmount1 = 0.0; // 订单总运费
        double couponsAmount1 = 0.0; // 优惠券总额

        for (Order tmpOrder : orderList) {

          // 所有订单
          goodsAmount = Arith.add(goodsAmount, tmpOrder.getGoodsAmount());
          realAmount = Arith.add(realAmount, tmpOrder.getRealAmount());
          coinAmount = Arith.add(coinAmount, tmpOrder.getVipCoin());
          goodsTransportAmount =
              Arith.add(goodsTransportAmount, tmpOrder.getGoodsTransportAmount());
          couponsAmount = Arith.add(couponsAmount, tmpOrder.getCouponsAmount());

          // 有效订单
          if (tmpOrder.getDeliveryerStatus() == 12) {

            orderCount0++;
            goodsAmount0 = Arith.add(goodsAmount0, tmpOrder.getGoodsAmount());
            realAmount0 = Arith.add(realAmount0, tmpOrder.getRealAmount());
            coinAmount0 = Arith.add(coinAmount0, tmpOrder.getVipCoin());
            goodsTransportAmount0 =
                Arith.add(goodsTransportAmount0, tmpOrder.getGoodsTransportAmount());
            couponsAmount0 = Arith.add(couponsAmount0, tmpOrder.getCouponsAmount());
          }

          // 拒收订单
          if (tmpOrder.getDeliveryerStatus() == -11) {

            orderCount4++;
            goodsAmount4 = Arith.add(goodsAmount4, tmpOrder.getGoodsAmount());
            realAmount4 = Arith.add(realAmount4, tmpOrder.getRealAmount());
            coinAmount4 = Arith.add(coinAmount4, tmpOrder.getVipCoin());
            goodsTransportAmount4 =
                Arith.add(goodsTransportAmount4, tmpOrder.getGoodsTransportAmount());
            couponsAmount4 = Arith.add(couponsAmount4, tmpOrder.getCouponsAmount());
          }

          // 线下订单
          if (tmpOrder.getPayType() == 0) {

            orderCount2++;
            goodsAmount2 = Arith.add(goodsAmount2, tmpOrder.getGoodsAmount());
            realAmount2 = Arith.add(realAmount2, tmpOrder.getRealAmount());
            coinAmount2 = Arith.add(coinAmount2, tmpOrder.getVipCoin());
            goodsTransportAmount2 =
                Arith.add(goodsTransportAmount2, tmpOrder.getGoodsTransportAmount());
            couponsAmount2 = Arith.add(couponsAmount2, tmpOrder.getCouponsAmount());
          }

          // 线上订单
          if (tmpOrder.getPayType() == 1) {

            orderCount1++;
            goodsAmount1 = Arith.add(goodsAmount1, tmpOrder.getGoodsAmount());
            realAmount1 = Arith.add(realAmount1, tmpOrder.getRealAmount());
            coinAmount1 = Arith.add(coinAmount1, tmpOrder.getVipCoin());
            goodsTransportAmount1 =
                Arith.add(goodsTransportAmount1, tmpOrder.getGoodsTransportAmount());
            couponsAmount1 = Arith.add(couponsAmount1, tmpOrder.getCouponsAmount());
          }
        }

        if (orderCount != 0) {
          avgAmount = Arith.div(goodsAmount, orderCount + 0.0, 2);
        } else {
          avgAmount = 0;
        }
        if (orderCount0 != 0) {
          avgAmount0 = Arith.div(goodsAmount0, orderCount0 + 0.0, 2);
        } else {
          avgAmount0 = 0;
        }
        if (orderCount4 != 0) {
          avgAmount4 = Arith.div(goodsAmount4, orderCount4 + 0.0, 2);
        } else {
          avgAmount4 = 0;
        }
        if (orderCount2 != 0) {
          avgAmount2 = Arith.div(goodsAmount2, orderCount2 + 0.0, 2);
        } else {
          avgAmount2 = 0;
        }
        if (orderCount1 != 0) {
          avgAmount1 = Arith.div(goodsAmount1, orderCount1 + 0.0, 2);
        } else {
          avgAmount1 = 0;
        }

        Map<String, Object> analysisData = new HashMap<String, Object>();

        // 基本数据
        analysisData.put("ORDER_DAY", orderDay); // 数据统计的时间
        analysisData.put("UNIT_SHORT_NAME", shortName); // 单位简称
        // 所有订单
        analysisData.put("ORDER_COUNT", orderCount); // 所有订单量
        analysisData.put("GOODS_AMOUNT", goodsAmount); // 商品总金额
        analysisData.put("REAL_AMOUNT", realAmount); // 实付总金额
        analysisData.put("COIN_AMOUNT", coinAmount); // 达人币总量
        analysisData.put("GOODS_TRANSPORT_AMOUNT", goodsTransportAmount); // 总配送费
        analysisData.put("COUPONS_AMOUNT", couponsAmount); // 优惠券总额
        analysisData.put("AVG_AMOUNT", avgAmount); // 客单价
        // 有效订单
        analysisData.put("ORDER_COUNT_0", orderCount0); // 所有订单量
        analysisData.put("GOODS_AMOUNT_0", goodsAmount0); // 商品总金额
        analysisData.put("REAL_AMOUNT_0", realAmount0); // 实付总金额
        analysisData.put("COIN_AMOUNT_0", coinAmount0); // 达人币总量
        analysisData.put("GOODS_TRANSPORT_AMOUNT_0", goodsTransportAmount0); // 总配送费
        analysisData.put("COUPONS_AMOUNT_0", couponsAmount0); // 优惠券总额
        analysisData.put("AVG_AMOUNT_0", avgAmount0); // 客单价
        // 拒收订单
        analysisData.put("ORDER_COUNT_4", orderCount4); // 所有订单量
        analysisData.put("GOODS_AMOUNT_4", goodsAmount4); // 商品总金额
        analysisData.put("REAL_AMOUNT_4", realAmount4); // 实付总金额
        analysisData.put("COIN_AMOUNT_4", coinAmount4); // 达人币总量
        analysisData.put("GOODS_TRANSPORT_AMOUNT_4", goodsTransportAmount4); // 总配送费
        analysisData.put("COUPONS_AMOUNT_4", couponsAmount4); // 优惠券总额
        analysisData.put("AVG_AMOUNT_4", avgAmount4); // 客单价
        // 线下订单
        analysisData.put("ORDER_COUNT_2", orderCount2); // 所有订单量
        analysisData.put("GOODS_AMOUNT_2", goodsAmount2); // 商品总金额
        analysisData.put("REAL_AMOUNT_2", realAmount2); // 实付总金额
        analysisData.put("COIN_AMOUNT_2", coinAmount2); // 达人币总量
        analysisData.put("GOODS_TRANSPORT_AMOUNT_2", goodsTransportAmount2); // 总配送费
        analysisData.put("COUPONS_AMOUNT_2", couponsAmount2); // 优惠券总额
        analysisData.put("AVG_AMOUNT_2", avgAmount2); // 客单价
        // 线上订单
        analysisData.put("ORDER_COUNT_1", orderCount1); // 所有订单量
        analysisData.put("GOODS_AMOUNT_1", goodsAmount1); // 商品总金额
        analysisData.put("REAL_AMOUNT_1", realAmount1); // 实付总金额
        analysisData.put("COIN_AMOUNT_1", coinAmount1); // 达人币总量
        analysisData.put("GOODS_TRANSPORT_AMOUNT_1", goodsTransportAmount1); // 总配送费
        analysisData.put("COUPONS_AMOUNT_1", couponsAmount1); // 优惠券总额
        analysisData.put("AVG_AMOUNT_1", avgAmount1); // 客单价

        resultList.add(analysisData);
      }
    }

    return resultList;
  }
Exemplo n.º 4
0
  public JxcBillCheckParams billCheck(Map<String, Object> reqMap) {
    // 单据审核返回对象
    JxcBillCheckParams checkParams = new JxcBillCheckParams();
    checkParams.setResultFlag(0);
    checkParams.setResultMsg("单据参数有误,请修改后再保存!");

    // 验证通过返回的单据对象
    JxcAllocation allocateBill = new JxcAllocation();

    // 调拨单参数map
    Map<String, Object> paraMap = JSONUtil.getMap(reqMap.get(SInvokeKeys.postData.value()) + "");

    String billNo = StringUtil.objectToString(paraMap.get("billNo"));
    String billCustomNo = StringUtil.objectToString(paraMap.get("billCustomNo"));

    String exStorageId = StringUtil.objectToString(paraMap.get("exStorageId"));
    String inStorageId = StringUtil.objectToString(paraMap.get("inStorageId"));
    String brokerId = StringUtil.objectToString(paraMap.get("brokerId"));

    String allocateDate = StringUtil.objectToString(paraMap.get("allocateDate"));
    String notes = StringUtil.objectToString(paraMap.get("notes"));
    String reviseMark = StringUtil.objectToString(paraMap.get("reviseMark"));

    // 单据编号
    allocateBill.setBillNo(billNo);

    // 自定义单据编号
    allocateBill.setBillCustomNo(billCustomNo);

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    try {
      // 调拨日期
      if (allocateDate != null && !"".equals(allocateDate)) {
        Date allocateTime = sdf.parse(allocateDate);
        allocateBill.setAllocateDate(allocateTime);
      }
    } catch (ParseException e) {
      System.err.println("字符串 转 日期出错");
      e.printStackTrace();
    }

    // 调出仓库
    if (exStorageId == null || "".equals(exStorageId)) {
      checkParams.setResultMsg("单据保存失败,原因:调出仓库ID不能为空!");
      return checkParams;
    }

    Long exStorageIdL = Long.valueOf(exStorageId);

    Storehouse exStorehouse = jxcStorehouseDao.get(exStorageIdL);
    if (exStorehouse == null) {
      checkParams.setResultMsg("单据保存失败,原因:调出仓库信息错误!");
      return checkParams;
    } else {
      allocateBill.setExportStorageId(exStorageIdL);
      allocateBill.setStorageExport(exStorehouse.getStoreName());
    }

    // 调入仓库
    if (inStorageId == null || "".equals(inStorageId)) {
      checkParams.setResultMsg("单据保存失败,原因:调入仓库ID不能为空!");
      return checkParams;
    }

    Long inStorageIdL = Long.valueOf(inStorageId);

    Storehouse inStorehouse = jxcStorehouseDao.get(inStorageIdL);
    if (inStorehouse == null) {
      checkParams.setResultMsg("单据保存失败,原因:调入仓库信息错误!");
      return checkParams;
    } else {
      allocateBill.setImportStorageId(inStorageIdL);
      allocateBill.setStorageImport(inStorehouse.getStoreName());
    }

    // 经手人
    if (brokerId != null && !"".equals(brokerId)) {
      Long brokerIdL = Long.valueOf(brokerId);

      SysUser broker = jxcSysUserDao.get(brokerIdL);
      if (broker == null) {
        checkParams.setResultMsg("单据保存失败,原因:经手人信息错误!");
        return checkParams;
      } else {
        allocateBill.setBrokerId(brokerIdL);
        allocateBill.setBroker(broker.getUserName());
      }
    }

    // 备注
    allocateBill.setNotes(notes);

    // 补单标记
    if (reviseMark == "1") {
      allocateBill.setReviseMark(1);
    } else {
      allocateBill.setReviseMark(0);
    }

    // 整单合计金额
    Double billTotalAmount = 0.00;

    // 整单合计差额
    Double billTotalDifference = 0.00;

    /** 调拨单明细处理* */
    // 调拨单据 明细对象
    JxcAllocationbillDetail billDetail;
    // 获取单据明细(商品)列表
    String billGoodsDetailJson = StringUtil.objectToString(paraMap.get("billGoodsList"));

    if (billGoodsDetailJson == null || "".equals(billGoodsDetailJson)) {
      checkParams.setResultMsg("单据保存失败,原因:商品信息为空!");
      return checkParams;
    }

    List<Map<String, Object>> billGoodsList = JSONUtil.jsonToListMap(billGoodsDetailJson);
    if (billGoodsList == null || billGoodsList.isEmpty()) {
      checkParams.setResultMsg("单据保存失败,原因:商品明细为空!");
      return checkParams;
    } else {
      for (Map<String, Object> goodsMap : billGoodsList) {
        // init 单据明细对象
        billDetail = new JxcAllocationbillDetail();
        // 商品信息
        Long goodsId = Long.valueOf(goodsMap.get("goodsId") + "");
        GoodsPrice goodsDetail = goodsPriceDao.get(goodsId);
        if (goodsDetail == null) {
          checkParams.setResultMsg("单据保存失败,原因:商品不存在!");
          return checkParams;
        } else {
          // 单据编号
          billDetail.setBillNo(billNo);

          // 调出仓库信息
          billDetail.setExportStorageId(exStorageIdL);
          billDetail.setExportStorage(exStorehouse.getStoreName());

          // 调入仓库信息
          billDetail.setImportStorageId(inStorageIdL);
          billDetail.setImportStorage(inStorehouse.getStoreName());

          // 商品信息
          billDetail.setGoodsId(goodsId);
          billDetail.setGoodsNickname(goodsDetail.getGoodsNickName());
          billDetail.setGoodsNumber(goodsDetail.getGoodsNumber());

          // 商品 成本原价
          String costSinglePrice = StringUtil.objectToString(goodsMap.get("costSinglePrice"));
          if (costSinglePrice == null || "".equals(costSinglePrice)) {
            billDetail.setCostSinglePrice(0.00);
          } else {
            Double singlePriceD = Double.valueOf(costSinglePrice);
            billDetail.setCostSinglePrice(singlePriceD);
          }

          // 商品 调拨单价
          String allocateSinglePrice =
              StringUtil.objectToString(goodsMap.get("allocateSinglePrice"));
          if (allocateSinglePrice == null || "".equals(allocateSinglePrice)) {
            billDetail.setCostSinglePrice(0.00);
          } else {
            Double allocateSinglePriceD = Double.valueOf(allocateSinglePrice);
            billDetail.setAllocateSinglePrice(allocateSinglePriceD);
          }

          // 商品数量
          String goodsCount = StringUtil.objectToString(goodsMap.get("goodsCount"));
          if (goodsCount == null || "".equals(goodsCount)) {
            billDetail.setGoodsCount(0);
          } else {
            Integer goodsCountI = Integer.valueOf(goodsCount);
            billDetail.setGoodsCount(goodsCountI);
          }

          // 该类商品 总差额
          Double totalDifference =
              Arith.mul(
                  Arith.sub(billDetail.getAllocateSinglePrice(), billDetail.getCostSinglePrice()),
                  Double.valueOf(billDetail.getGoodsCount()));
          billDetail.setTotalDifference(totalDifference);

          // 该类商品 总额
          Double totalAmount =
              Arith.mul(
                  billDetail.getAllocateSinglePrice(), Double.valueOf(billDetail.getGoodsCount()));
          billDetail.setTotalAmount(totalAmount);

          // 明细创建时间
          billDetail.setCreateDate(DateUtil.getSystemTime());

          // 备注信息
          billDetail.setNotes(goodsMap.get("goodsNotes") + "");

          // 保存明细
          jxcAllocationbillDetailDao.add(billDetail);

          // 整单总金额累加
          billTotalAmount = Arith.add(billTotalAmount, totalAmount);

          // 整单总差额累加
          billTotalDifference = Arith.add(billTotalDifference, totalDifference);
        }
      }
    }
    /** 单据明细处理完毕* */

    // 整单合计金额
    allocateBill.setTotalAmount(billTotalAmount);

    // 整单 合计差额
    allocateBill.setTotalDifference(billTotalDifference);

    // 制单人
    String billMakerId = StringUtil.objectToString(paraMap.get("billMakerId"));
    if (billMakerId != null && !"".equals(billMakerId)) {
      SysUser billMaker = jxcSysUserDao.get(Long.valueOf(billMakerId));
      allocateBill.setBillMaker(billMaker.getUserName());
    }

    // 制单日期
    allocateBill.setCreateDate(DateUtil.getSystemTime());

    // 单据校验通过
    checkParams.setResultFlag(1);
    checkParams.setResultMsg("单据校验通过");
    checkParams.setBill(allocateBill);
    return checkParams;
  }