Example #1
0
 /** 得到发货单应该显示的邮费 分摊邮费 + 邮费补差 - 邮费补差退款 + 换货邮费 */
 public Money getInvoicePostFee() {
   Money invoicePostFee = Money.valueOf(0);
   for (OrderItem item : orderItem) {
     invoicePostFee = invoicePostFee.add(item.getInvoicePostFee());
   }
   return invoicePostFee;
 }
 /**
  * 计算实付金额所占百分比
  *
  * @return
  */
 private BigDecimal getPaymentPercent(Money curPayableFee, Money totalPayableFee) {
   if (curPayableFee == null || totalPayableFee == null || totalPayableFee.getCent() == 0l) {
     return BigDecimal.ZERO;
   }
   BigDecimal paymentPercentBig =
       new BigDecimal(curPayableFee.getCent())
           .divide(new BigDecimal(totalPayableFee.getCent()), 4, BigDecimal.ROUND_HALF_UP);
   return paymentPercentBig;
 }
  /**
   * 获得订单总应付金额
   *
   * @param originalOrder
   * @return
   */
  public Money getTotalPayableFee(OriginalOrder originalOrder) {
    Money totalPayableFee = Money.valueOf(0);
    if (originalOrder == null
        || CollectionUtils.isEmpty(originalOrder.getOriginalOrderItemList())) {
      return totalPayableFee;
    }

    for (OriginalOrderItem originalOrderItem : originalOrder.getOriginalOrderItemList()) {
      totalPayableFee = totalPayableFee.add(originalOrderItem.getPayableFee());
    }
    return totalPayableFee;
  }
  /**
   * 计算获取分摊优惠金额 计算公式:实付金额所占百分比 * 店铺优惠金额
   *
   * @return
   */
  private Money getItemMjzDiscountFee(
      Money curPayableFee, Money totalPayableFee, Money discountFee) {
    Money partMjzDiscountFee = Money.valueOf(0);
    if (curPayableFee == null || totalPayableFee == null || discountFee == null) {
      return partMjzDiscountFee;
    }
    // 获得当前实付金额所占百分比
    BigDecimal paymentPercentBig = getPaymentPercent(curPayableFee, totalPayableFee);
    // 计算店铺优惠金额的分摊金额
    BigDecimal partMjzDiscountFeeBig =
        paymentPercentBig.multiply(new BigDecimal(discountFee.getAmount()));
    // 转为Money对象
    partMjzDiscountFee = Money.valueOf(partMjzDiscountFeeBig.doubleValue());

    return partMjzDiscountFee;
  }
 /**
  * 获取整单优惠(需要分摊减去的优惠:100-店铺优惠,35-满返满送(返现))
  *
  * @param promotionInfoList 订单优惠详情
  * @return
  */
 private Money getDiscountFee(List<PromotionInfo> promotionInfoList) {
   Money discountFee = Money.valueOf(0);
   if (promotionInfoList == null) {
     return discountFee;
   }
   for (PromotionInfo promotionInfo : promotionInfoList) {
     if (StringUtils.isBlank(promotionInfo.getSkuId())
         && (StringUtils.equals(
                 promotionInfo.getCouponType(), PromotionType.JD_SHOUJIHONGBAO.getDesc())
             || StringUtils.equals(
                 promotionInfo.getCouponType(), PromotionType.JD_JINGDOU.getDesc())
             || StringUtils.equals(
                 promotionInfo.getCouponType(), PromotionType.JD_JINGDONGQUAN.getDesc())
             || StringUtils.equals(
                 promotionInfo.getCouponType(), PromotionType.JD_LIPINKA.getDesc()))) {
       discountFee = discountFee.add(promotionInfo.getDiscountFee());
     }
   }
   return discountFee;
 }
 /**
  * 获取整单优惠(需要分摊减去的优惠:100-店铺优惠,35-满返满送(返现))
  *
  * @param promotionInfoList 订单优惠详情
  * @return
  */
 private Money getSelfDiscountFee(List<PromotionInfo> promotionInfoList) {
   Money selfDiscountFee = Money.valueOf(0);
   if (promotionInfoList == null) {
     return selfDiscountFee;
   }
   for (PromotionInfo promotionInfo : promotionInfoList) {
     if (StringUtils.isBlank(promotionInfo.getSkuId())
         && (StringUtils.equals(
                 promotionInfo.getCouponType(), PromotionType.JD_TAOZHUANG.getDesc())
             || StringUtils.equals(
                 promotionInfo.getCouponType(), PromotionType.JD_SHANTUAN.getDesc())
             || StringUtils.equals(
                 promotionInfo.getCouponType(), PromotionType.JD_TUANGOU.getDesc())
             || StringUtils.equals(
                 promotionInfo.getCouponType(), PromotionType.JD_DANPINCUXIAO.getDesc())
             || StringUtils.equals(
                 promotionInfo.getCouponType(), PromotionType.JD_MANFANMANSONG.getDesc())
             || StringUtils.equals(
                 promotionInfo.getCouponType(), PromotionType.JD_DIANPU.getDesc()))) {
       selfDiscountFee = selfDiscountFee.add(promotionInfo.getDiscountFee());
     }
   }
   return selfDiscountFee;
 }
Example #7
0
/** User: liubin Date: 14-3-28 */
@javax.persistence.Table(name = "t_mealset_item")
@Cacheable
@org.hibernate.annotations.Cache(
    usage = CacheConcurrencyStrategy.READ_ONLY,
    region = Constants.ENTITY_CACHE_NAME)
@Entity
public class MealsetItem implements EntityClass<Integer> {

  private Integer id;

  /** 套餐价 */
  private Money price = Money.valueOf(0);

  /** 套餐中的数量 */
  private Integer amount;

  /** 套餐id */
  private Integer mealsetId;

  @JsonIgnore private Mealset mealset;

  /** 商品id */
  private Integer productId;

  private Product product;

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "mealset_id", insertable = false, updatable = false)
  @JsonIgnore
  public Mealset getMealset() {
    return mealset;
  }

  public void setMealset(Mealset mealset) {
    this.mealset = mealset;
  }

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "product_id", insertable = false, updatable = false)
  public Product getProduct() {
    return product;
  }

  public void setProduct(Product product) {
    this.product = product;
  }

  @GeneratedValue(strategy = GenerationType.AUTO)
  @Id
  public Integer getId() {
    return id;
  }

  public void setId(Integer id) {
    this.id = id;
  }

  @javax.persistence.Column(name = "mealset_id")
  @Basic
  public Integer getMealsetId() {
    return mealsetId;
  }

  public void setMealsetId(Integer mealsetId) {
    this.mealsetId = mealsetId;
  }

  @javax.persistence.Column(name = "product_id")
  @Basic
  public Integer getProductId() {
    return productId;
  }

  public void setProductId(Integer productId) {
    this.productId = productId;
  }

  @javax.persistence.Column(name = "price")
  @Basic
  public Money getPrice() {
    return price;
  }

  public void setPrice(Money price) {
    this.price = price;
  }

  @javax.persistence.Column(name = "amount")
  @Basic
  public Integer getAmount() {
    return amount;
  }

  public void setAmount(Integer amount) {
    this.amount = amount;
  }

  @Override
  public String toString() {
    return "MealsetItem{"
        + "id="
        + id
        + ", price="
        + price
        + ", amount="
        + amount
        + ", mealsetId="
        + mealsetId
        + ", mealset="
        + mealset.getName()
        + ", productId="
        + productId
        + ", product="
        + product.getName()
        + '}';
  }
}