Exemplo n.º 1
0
  /** 插入两条记录,一条是 买家付给平台,一条是平台付给卖家 */
  private boolean insertPaidOrder(Order order) {
    FinanceUnit unit = new FinanceUnit(order); // 买家付给平台
    unit.setReceiver(UserType.ADMIN);
    unit.setSender(contructID(order.getCustomerId(), UserType.CUSTOMER));
    unit.setMoney(order.getPriceRMB());
    unit.setFinanceDetailsType(FinanceType.Normal);
    insert(unit);

    FinanceUnit unit2 = new FinanceUnit(order); // 平台付给卖家
    unit2.setReceiver(contructID(order.getSellerId(), UserType.SELLER));
    unit2.setSender(UserType.ADMIN);
    unit2.setMoney(order.getOriginTotal());
    unit2.setFinanceDetailsType(FinanceType.Normal);
    insert(unit2);
    return true;
  }
Exemplo n.º 2
0
  public void payMoneyBackCauseReturnNoExcuse(int orderId, float percent) { // 无理由退货
    if (percent > 100) {
      System.err.println("the return money percent > 100 in payMoneyBack");
      return;
    }
    Order order = orderService.getOrderById(orderId);
    if (order.getOrderStatus() == OrderStatus.CLOSE) {
      return;
    }

    FinanceUnit originToSeller =
        getFinanceUnitByRelatedIdAndDetailsTypeForSeller(orderId, FinanceType.Normal);
    FinanceUnit originToPlatform =
        getFinanceUnitByRelatedIdAndDetailsTypeForAdmin(orderId, FinanceType.Normal);
    FinanceUnit serviceMoney =
        getFinanceUnitByRelatedIdAndDetailsTypeForAdmin(orderId, FinanceType.ServiceNormal);

    FinanceUnit sellerToPlatform = new FinanceUnit(originToSeller); // 不退运费
    float tmp_money = order.getOriginPrice() * percent / 100.0f;
    sellerToPlatform.setMoney(tmp_money);
    sellerToPlatform.setReceiver(originToSeller.getSender());
    sellerToPlatform.setSender(originToSeller.getReceiver());
    sellerToPlatform.setFinanceDetailsType(FinanceType.Return);

    FinanceUnit platformToCustomer = new FinanceUnit(originToPlatform); // 不退运费
    float money = order.getOriginPriceRMB() * percent / 100.0f;
    platformToCustomer.setMoney(money);
    platformToCustomer.setReceiver(originToPlatform.getSender());
    platformToCustomer.setSender(originToPlatform.getReceiver());
    platformToCustomer.setFinanceDetailsType(FinanceType.Return);

    FinanceUnit serviceMoneyBack = new FinanceUnit(serviceMoney, 100); // 服务费全退
    serviceMoneyBack.setReceiver(serviceMoney.getSender());
    serviceMoneyBack.setSender(serviceMoney.getReceiver());
    serviceMoneyBack.setFinanceDetailsType(FinanceType.ServiceBack);

    insertDirectly(platformToCustomer);
    insertDirectly(sellerToPlatform);
    insertDirectly(serviceMoneyBack);
  }
Exemplo n.º 3
0
 /**
  * 插入该订单的佣金记录
  *
  * @param order
  */
 public void insertServiceMoney(Order order) {
   List<OrderItem> orderItems = order.getOrderItems();
   float moneySum = 0;
   for (OrderItem item : orderItems) {
     int productLineId = item.getProductLineId();
     ProductLine productLine = productLineService.getProductLineById(productLineId);
     float serviceRate = productLine.getCommission();
     float money = serviceRate * item.getPrice() * item.getNum();
     moneySum += money;
   }
   FinanceUnit unit = new FinanceUnit(order);
   unit.setMoney(moneySum);
   unit.setReceiver(UserType.ADMIN);
   unit.setSender(contructID(order.getSellerId(), UserType.SELLER));
   unit.setFinanceType(FinanceType.Service);
   unit.setFinanceDetailsType(FinanceType.ServiceNormal);
   insert(unit);
 }
Exemplo n.º 4
0
  /** 插入某订单的退货仓库费 */
  public void insertStoreMoney(int orderId) {
    Order order = orderService.getOrderById(orderId);
    FinanceUnit unit = new FinanceUnit(order);
    unit.setFinanceType(FinanceType.Store);
    float money = 0f;

    List<OrderItem> orderItems = order.getOrderItems();
    for (OrderItem orderItem : orderItems) {
      int productId = orderItem.getProductId();
      Product product = productService.getSimpleProductById(productId);
      String size = product.getSizeWithPackage();
      float moneyTmp = computeStoreFee(size);
      money += (moneyTmp * orderItem.getNum());
    }
    int coinage = order.getCoinage();
    money = Coinage.convertToAimCoinage(coinage, money, Coinage.Dollar);
    unit.setMoney(money);
    unit.setSender(UserType.SELLER + "-" + order.getSellerId());
    unit.setReceiver(UserType.ADMIN);
    insert(unit);
  }