package org.xmx0632.deliciousfruit.service; import java.math.BigDecimal; import java.util.List; import org.xmx0632.deliciousfruit.api.v1.bo.OrderRequest; import org.xmx0632.deliciousfruit.api.v1.bo.OrderRequest.OrderItem; import org.xmx0632.deliciousfruit.api.v1.bo.OrderRequest.OrderRequestReceiver; import org.xmx0632.deliciousfruit.api.v1.bo.OrderRequest.Payment; import org.xmx0632.deliciousfruit.api.v1.bo.OrderRequest.Payment.CashCouponPay; import org.xmx0632.deliciousfruit.api.v1.bo.OrderRequest.Payment.DeliveryPeriod; import org.xmx0632.deliciousfruit.api.v1.bo.OrderRequest.Payment.GiftCardPay; import org.xmx0632.deliciousfruit.api.v1.bo.SettlementResponse; import org.xmx0632.deliciousfruit.api.v1.bo.SettlementResponse.ProductFreeInfo; import org.xmx0632.deliciousfruit.api.v1.bo.SettlementResponse.PromotionDetails; import org.xmx0632.deliciousfruit.api.v1.bo.SettlementResponse.PromotionInfo; public class IosPayoffServiceTestHelper { public static final String TRANSACTION_ID = "transactionID"; public static PromotionInfo setupPromotionInfo(BigDecimal productPriceOff, List<ProductFreeInfo> productProductsFree, BigDecimal totalPriceOff, List<ProductFreeInfo> totalProductsFree) { PromotionInfo promotionInfo = new PromotionInfo(); promotionInfo.setPromotionForProduct(new PromotionDetails( productPriceOff, productProductsFree)); promotionInfo.setPromotionForTotal(new PromotionDetails(totalPriceOff, totalProductsFree)); return promotionInfo; } public static SettlementResponse setupSettlementResponse( BigDecimal actualAmount, BigDecimal productPriceOff, List<ProductFreeInfo> productProductsFree, BigDecimal totalPriceOff, List<ProductFreeInfo> totalProductsFree, BigDecimal totalPrice, BigDecimal freightPay) { PromotionInfo promotionInfo = setupPromotionInfo(productPriceOff, productProductsFree, totalPriceOff, totalProductsFree); SettlementResponse settlementResponse = new SettlementResponse(); settlementResponse.setTransactionID(TRANSACTION_ID); settlementResponse.setActualAmount(actualAmount); settlementResponse.setPromotionInfo(promotionInfo); settlementResponse.setTotalPrice(totalPrice); settlementResponse.setFreightPay(freightPay); return settlementResponse; } public static Payment setupPayment(List<CashCouponPay> cashCoupons, List<GiftCardPay> giftCards, BigDecimal payAmountFromAccount, BigDecimal payAmountFromPonit, int payPonit, String paymentMethod) { Payment payment = new Payment(); payment.setPaymentMethod(paymentMethod); payment.setCashCoupons(cashCoupons);// 现金券支付金额(1:1) payment.setGiftCards(giftCards);// 礼品卡支付金额(1:1) payment.setPayAmountFromAccount(payAmountFromAccount);// 账户支付(1:1) payment.setPayAmountFromPonit(payAmountFromPonit);// 积分支付(100:1) payment.setPayPonit(payPonit); return payment; } public static OrderRequestReceiver setupReceiverInfo() { OrderRequestReceiver receiverInfo = new OrderRequestReceiver(); receiverInfo.setAddress("西湖大道12345号"); receiverInfo.setCity("杭州市"); receiverInfo.setDistrict("西湖区"); receiverInfo.setName("地址1"); receiverInfo.setPhoneNumber("05711234567"); receiverInfo.setProvince("浙江省"); return receiverInfo; } public static OrderRequest setupOrderRequest(List<OrderItem> orderList, DeliveryPeriod deliveryPeriod, Payment payment, OrderRequestReceiver receiverInfo) { OrderRequest request = new OrderRequest(); request.setDeliveryPeriod(deliveryPeriod); request.setOrderList(orderList); request.setPayment(payment); request.setReceiverInfo(receiverInfo); request.setTransactionID(TRANSACTION_ID); return request; } }