/** * @param orderId * @param percent */ public void payAllMoneyBackButService(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 sellerToPlatform = new FinanceUnit(originToSeller, percent); sellerToPlatform.setReceiver(originToSeller.getSender()); sellerToPlatform.setSender(originToSeller.getReceiver()); sellerToPlatform.setFinanceDetailsType(FinanceType.Return); FinanceUnit platformToCustomer = new FinanceUnit(originToPlatform, percent); platformToCustomer.setReceiver(originToPlatform.getSender()); platformToCustomer.setSender(originToPlatform.getReceiver()); platformToCustomer.setFinanceDetailsType(FinanceType.Return); insertDirectly(platformToCustomer); insertDirectly(sellerToPlatform); }
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); }
/** * 自动检测款项双方,同时设置币种 * * @param unit * @return */ public boolean insert(FinanceUnit unit) { String receiver = unit.getReceiver(); String sender = unit.getSender(); int userId = 0; if (receiver.contains(UserType.SELLER)) { // 收款人是卖家 String[] tmpArray = receiver.split("-"); userId = Integer.parseInt(tmpArray[1]); if (userId != 0) { // 给卖家设置币种 ShopSetting ss = shopSettingMapper.getShopSettingBySellerId(userId); if (ss == null) { throw new ShopException(); } int coinage = ss.getDefaultCoinage(); unit.setCoinage(coinage); } } else if (receiver.contains(UserType.TRANSLATOR)) { // 翻译人员默认是人民币 unit.setCoinage(Coinage.RMB); } else if (receiver.contains(UserType.ADMIN)) { // 收款人是管理员 if (sender.contains(UserType.CUSTOMER)) { unit.setCoinage(Coinage.RMB); } else if (sender.contains(UserType.SELLER)) { // String[] tmpArray = sender.split("-"); // userId = Integer.parseInt(tmpArray[1]); // ShopSetting ss = shopSettingMapper.getShopSettingBySellerId(userId); // if(ss == null){ // throw new ShopException(); // } // int coinage = ss.getDefaultCoinage(); // unit.setCoinage(coinage); unit.setCoinage(Coinage.Dollar); } } else if (receiver.contains(UserType.CUSTOMER)) { // 收款人是买家 unit.setCoinage(Coinage.RMB); } financeUnitMapper.insert(unit); return true; }