示例#1
0
  /**
   * 查找托管计划
   *
   * @return
   */
  public TrusteeshipCommodity findPlanById(Long id) {

    IpoTrusteeshipCommodity dbShipCommodity = shipCommodityMapper.findById(id);
    TrusteeshipCommodity entity = new TrusteeshipCommodity();
    BeanUtils.copyProperties(dbShipCommodity, entity);
    return entity;
  }
示例#2
0
  /**
   * 新增商户申购的托管商品
   *
   * @param trusteeship
   * @return
   */
  @Transactional
  public int saveApply(Trusteeship trusteeship) {
    Long planId = trusteeship.getTrusteeshipCommodityId();
    IpoTrusteeshipCommodity shipCommodity = shipCommodityMapper.findById(planId);
    BigDecimal purchaseRate = shipCommodity.getPurchaseRate();
    Long applyAmount = trusteeship.getApplyAmount();
    // 约定入库数量等于申请数量,只能全部审核通过或全部审核不通过
    Long instorageAmount = applyAmount;
    trusteeship.setInstorageAmount(instorageAmount);
    trusteeship.setCreateDate(new Date());
    trusteeship.setState(TrusteeshipConstant.State.APPLY.getCode());
    Long effectiveAmount =
        new BigDecimal(instorageAmount)
            .multiply(purchaseRate)
            .divide(new BigDecimal(100))
            .longValue();
    trusteeship.setEffectiveAmount(effectiveAmount);
    trusteeship.setPositionAmount(instorageAmount - effectiveAmount);

    return shipMapper.insertApply(trusteeship);
  }