package org.xmx0632.deliciousfruit.service; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.xmx0632.deliciousfruit.api.v1.bo.OrderRequest; import org.xmx0632.deliciousfruit.api.v1.bo.OrderRequest.Payment.PAYMENT_METHOD; import org.xmx0632.deliciousfruit.api.v1.bo.OrderResponse; import org.xmx0632.deliciousfruit.api.v1.bo.OrderResponse.PayByCashCoupon; import org.xmx0632.deliciousfruit.api.v1.bo.OrderResponse.PayByEcoupon; import org.xmx0632.deliciousfruit.api.v1.bo.OrderResponse.PayByGiftCard; import org.xmx0632.deliciousfruit.api.v1.bo.Result; import org.xmx0632.deliciousfruit.api.v1.bo.SettlementResponse.ProductFreeInfo; import org.xmx0632.deliciousfruit.api.v1.bo.SettlementResponse.PromotionDetails; import org.xmx0632.deliciousfruit.entity.UserAccount; public class IosPayoffServiceCreditCardOnDeliveryTest extends BaseIosPayoffServiceTestCase { private UserAccount userAccount = null; @Before public void setUp() throws Exception { super.setUp(); } @After public void tearDown() throws Exception { } // TODO 货到POS刷卡(10) @Test public void testProcessByPos() { // mock BigDecimal totalPrice = BigDecimal.valueOf(28); BigDecimal actualAmount = BigDecimal.valueOf(24.5); BigDecimal productPriceOff = null; List<ProductFreeInfo> productProductsFree = null; List<ProductFreeInfo> totalProductsFree = null; BigDecimal totalPriceOff = totalPrice.subtract(actualAmount); mockSettlementResponse(actualAmount, productPriceOff, productProductsFree, totalPriceOff, totalProductsFree, totalPrice, BigDecimal.valueOf(10)); mockDeductionPayService(new ArrayList<PayByCashCoupon>(), new ArrayList<PayByEcoupon>(), new ArrayList<PayByGiftCard>(), BigDecimal.ZERO, BigDecimal.ZERO); // verify logic OrderRequest request = createRequest(cashCoupons, giftCards, payAmountFromAccount, payAmountFromPonit, payPonit, orderList, PAYMENT_METHOD.CREDIT_CARD_ON_DELIVERY.getCode()); OrderResponse response = iosPayoffService.process(request, userAccount); assertNotNull(response); System.out.println("response:" + response); assertEquals(Result.SUCCESS_RESULT, response.getResult()); // 支付方式 assertEquals(PAYMENT_METHOD.CREDIT_CARD_ON_DELIVERY.getCode(), response.getPaymentMethod()); assertEquals(TRANSACTION_ID, response.getTransactionID()); assertEquals(totalPrice, response.getTotalPrice()); assertEquals(BigDecimal.valueOf(24.5), response.getPayAmount()); assertEquals("ORDER10000001", response.getOrderNumber()); assertEquals(BigDecimal.valueOf(10.0), response.getFreight()); assertEquals(BigDecimal.valueOf(10), response.getFreightPay()); // 享受的促销优惠 PromotionDetails promotionDetails = response.getPromotionDetails(); assertNotNull(promotionDetails); assertEquals(BigDecimal.valueOf(3.5), promotionDetails.getPriceOff()); List<ProductFreeInfo> productsFree = promotionDetails.getProductsFree(); assertNotNull(productsFree); assertEquals(0, productsFree.size()); } }