package com.tmerclub.cloud.systemtest.test.marketing;

import com.tmerclub.cloud.common.order.dto.OrderDTO;
import com.tmerclub.cloud.common.product.vo.app.CategoryAppVO;
import com.tmerclub.cloud.coupon.vo.CouponVO;
import com.tmerclub.cloud.discount.dto.DiscountItemDTO;
import com.tmerclub.cloud.order.vo.OrderDetailVO;
import com.moyuer.cloud.systemtest.api.amount.CategoryApi;
import com.moyuer.cloud.systemtest.api.amount.PayApi;
import com.moyuer.cloud.systemtest.api.amount.ProductApi;
import com.moyuer.cloud.systemtest.api.login.UserApi;
import com.moyuer.cloud.systemtest.api.marketing.CouponApi;
import com.moyuer.cloud.systemtest.api.marketing.DiscountApi;
import com.moyuer.cloud.systemtest.api.order.MyOrderApi;
import com.moyuer.cloud.systemtest.api.order.OrderApi;
import com.moyuer.cloud.systemtest.api.platform.ScoreConfigApi;
import com.moyuer.cloud.systemtest.api.platform.UserLevelApi;
import com.moyuer.cloud.systemtest.api.platform.UserRightsApi;
import com.moyuer.cloud.systemtest.api.store.ShopWalletApi;
import com.moyuer.cloud.systemtest.api.store.TransportApi;
import com.moyuer.cloud.systemtest.api.supplier.SupplierProductApi;
import com.moyuer.cloud.systemtest.data.amount.PreSaleSpuData;
import com.moyuer.cloud.systemtest.data.amount.SpuData;
import com.moyuer.cloud.systemtest.data.marketing.CouponData;
import com.moyuer.cloud.systemtest.data.marketing.DiscountData;
import com.moyuer.cloud.systemtest.data.order.OrderAdminDtoData;
import com.moyuer.cloud.systemtest.data.order.OrderDtoData;
import com.moyuer.cloud.systemtest.data.order.SubmitOrderDtoData;
import com.moyuer.cloud.systemtest.data.order.WalletAssert;
import com.moyuer.cloud.systemtest.data.platform.CategoryDtoData;
import com.moyuer.cloud.systemtest.data.platform.ScoreConfigDtoData;
import com.moyuer.cloud.systemtest.data.platform.UserLevelDtoData;
import com.moyuer.cloud.systemtest.data.platform.UserRightsDtoData;
import com.moyuer.cloud.systemtest.data.store.DeliveryData;
import com.moyuer.cloud.systemtest.data.supplier.SupplierProductData;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author lpj
 */
public class DiscountAmountTest {
    private List<Long> getCategoryId() {
        List<CategoryAppVO> categoryAppVOList = CategoryApi.listShopCategory(true);
        Long shopCategoryId = categoryAppVOList.get(categoryAppVOList.size() - 1).getCategoryId();
        Long categoryId = CategoryApi.listSigningCategory(true).get(0).getCategoryId();
        CategoryApi.update(CategoryDtoData.getCategoryDTO(categoryId));
        return Stream.of(categoryId, shopCategoryId).collect(Collectors.toList());
    }

    /**
     * 广州荔湾区可配送，8元运费商品
     * */
    @DataProvider(name = "realProductDelivery")
    private Object[][] realProductDeliveryNoFree() {
        TransportApi.addTransport(DeliveryData.getTransportDTO(), true);
        Long transportId = TransportApi.infoTransport(true).get(0).getTransportId();
        Long productId = ProductApi.createProduct(SpuData.getRealSpu(getCategoryId().get(0), getCategoryId().get(1), transportId, 18800L), true);
        return new Object[][]{{productId}};
    }

    @DataProvider(name = "virtualProduct")
    private Object[][] virtualProduct() {
        Long shopCategoryId = CategoryApi.listShopCategory(true).get(CategoryApi.listShopCategory(true).size()-1).getCategoryId();
        Long categoryId = CategoryApi.listSigningCategory(true).get(0).getCategoryId();
        Long productId = ProductApi.createProduct(SpuData.getUnRealSpu(categoryId, shopCategoryId, 18800L, 1), true);
        return new Object[][]{{productId}};
    }

    @DataProvider(name = "depositPreSaleProduct")
    private Object[][] depositPreSaleProduct() {
        TransportApi.addTransport(DeliveryData.getTransportDTO(), true);
        Long transportId = TransportApi.infoTransport(true).get(0).getTransportId();
        Long productId = ProductApi.createProduct(PreSaleSpuData.getDepositPreSaleSpu(getCategoryId().get(0), getCategoryId().get(1), transportId, 18800L), true);
        return new Object[][]{{productId}};
    }

    @DataProvider(name = "supplierProduct")
    private Object[][] supplierProduct() {
        Long supplierProductId = SupplierProductData.getSupplierProductId(6600L, DeliveryData.getSupplierFreeFeeDelivery(true), true);
        Long productId = SupplierProductData.getProductId(supplierProductId, 18800L, 1, null, true, true);
        return new Object[][]{{productId, supplierProductId}};
    }

    @Test(description = "多优惠金额叠加实物订单", dataProvider = "realProductDelivery")
    public void discountAmountTestWithRealProduct(Long productId) throws InterruptedException {
        //新建满减活动
        List<DiscountItemDTO> discountItemDTOList = Arrays.asList(DiscountData.getDiscountItemDTO(10000L,1000L), DiscountData.getDiscountItemDTO(10100L, 5000L));
        List<Long> productIds = Collections.singletonList(productId);
        DiscountApi.save(DiscountData.getDiscount(0, 0, discountItemDTOList, 50000L, 1, productIds, 1), true);
        //获取满减活动id
        Long discountId = DiscountApi.getDiscountPage(true).get(0).getDiscountId();

        //新建店铺代金券
        CouponApi.saveShopCoupon(CouponData.getCouponDTO(1, 0, 1, 1000L, 300L, null, 2, 10, 100, 1, productIds));
        //获取店铺优惠券id
        Long shopCouponId = CouponApi.getShopCouponPage().get(0).getCouponId();
        //用户领取店铺优惠券
        CouponApi.receive(shopCouponId);

        //新建平台代金券
        CouponApi.savePlatformCoupon(CouponData.getCouponDTO(1, 0, 1, 1000L, 300L, null, 2, 10, 100, 0, productIds));
        //获取优惠券id
        Long platformCouponId = CouponApi.getPlatformCouponPage().get(0).getCouponId();
        //用户领取优惠券
        CouponApi.receive(platformCouponId);

        //新增打8折权益
        Long discountUserRightsId = UserRightsApi.save(UserRightsDtoData.getDiscounttUserRightsDTO(80));
        //新增包邮权益
        Long freeFeeUserRightsId = UserRightsApi.save(UserRightsDtoData.getFreeFeeUserRightsDTO());
        //用户会员等级添加包邮和打8折权益
        UserLevelApi.update(UserLevelDtoData.getUserLevelDTO(UserApi.getUserInfo().getUserLevelId(), Arrays.asList(discountUserRightsId, freeFeeUserRightsId)));

        //修改积分配置，每15积分抵扣一元，最大使用积分比例100%
        ScoreConfigApi.update(ScoreConfigDtoData.getScoreConfigDTO(15L, 100D));

        OrderDTO orderDTO = OrderDtoData.getOrderDtoData(productId, 1);
        //用户使用优惠券
        orderDTO.setCouponIds(Arrays.asList(CouponApi.getUserCouponPage().get(0).getCouponUserId(), CouponApi.getUserCouponPage().get(1).getCouponUserId()));
        //使用150积分
        orderDTO.setIsScorePay(1);
        orderDTO.setUserUseScore(150L);
        //确认订单
        MyOrderApi.confirm(orderDTO);
        //用户提交订单
        List<Long> orderNumberList = MyOrderApi.submit(SubmitOrderDtoData.getSubmitOrderDtoData(productId));

        //商家修改订单金额为50元
        TimeUnit.SECONDS.sleep(2L);
        OrderApi.changeOrderAmount(OrderAdminDtoData.getOrderAdminDto(orderNumberList.get(0), 5000L, 0L));

        //根据订单id支付订单
        PayApi.orderPay(orderNumberList);
        TimeUnit.SECONDS.sleep(2L);
        //对订单进行退款
        Long refundId = OrderRefund.realOrderRefund(orderNumberList.get(0));
        TimeUnit.SECONDS.sleep(2L);

        //删除会员权益
        UserRightsApi.delete(discountUserRightsId);
        UserRightsApi.delete(freeFeeUserRightsId);

        //用户删除领取的店铺优惠券
        CouponApi.deleteUserCoupon(CouponApi.getUserCouponPage().get(0).getCouponUserId());

        //根据平台优惠券id获取优惠券信息
        CouponVO platformCouponVO = CouponApi.getPlatformCouponInfo(platformCouponId);
        //修改平台优惠券为暂不投放
        CouponApi.updatePlatformCoupon(CouponData.getUpdateCouponDTO(platformCouponVO));
        //删除平台代金券券
        CouponApi.deletePlatformCoupon(platformCouponId);

        //根据店铺优惠券id获取店铺优惠券信息
        CouponVO shopCouponVO = CouponApi.getShopCouponInfo(shopCouponId);
        //修改店铺优惠券为暂不投放
        CouponApi.updateShopCoupon(CouponData.getUpdateCouponDTO(shopCouponVO));
        //删除店铺代金券
        CouponApi.deleteShopCoupon(shopCouponId);

        //商家删除满减
        DiscountApi.delete(discountId, true);
        //删除商品
        ProductApi.delete(productId, true);
        //删除运费模板
        TransportApi.deleteTransport(TransportApi.infoTransport(true).get(0).getTransportId(), true);

        //运行后验证数据是否正确
        TimeUnit.SECONDS.sleep(2L);
        Assert.assertEquals(ShopWalletApi.getMongoShopWalletLogBO(orderNumberList.get(0), true).size(), 3);
        OrderDetailVO orderDetailVO = ShopWalletApi.getOrderDetailVO(orderNumberList.get(0), refundId, true);
        WalletAssert.shopOrderDetailAssert(orderDetailVO.getOrderItemDetailList().get(0), 18800L, 5000L, 0L, 10816L, 2984L, 0L, 150L, 1.99, 159L,
                1000L, 2640L, 300L, 300L, 5000L, null, null, -4560L, 5000L, 1, 1);
        WalletAssert.shopOrderFreightAssert(orderDetailVO, 800L, 0L, 800L);
    }

    @Test(description = "多优惠金额叠加虚拟订单", dataProvider = "virtualProduct")
    public void discountAmountTestWithVirtualProduct(Long productId) throws InterruptedException {
        //新建满减活动
        List<DiscountItemDTO> discountItemDTOList = Arrays.asList(DiscountData.getDiscountItemDTO(10000L,1000L), DiscountData.getDiscountItemDTO(10100L, 5000L));
        List<Long> productIds = Collections.singletonList(productId);
        DiscountApi.save(DiscountData.getDiscount(0, 0, discountItemDTOList, 50000L, 1, productIds, 1), true);
        //获取满减活动id
        Long discountId = DiscountApi.getDiscountPage(true).get(0).getDiscountId();

        //新建店铺代金券
        CouponApi.saveShopCoupon(CouponData.getCouponDTO(1, 0, 1, 1000L, 300L, null, 2, 10, 100, 1, productIds));
        //获取店铺优惠券id
        Long shopCouponId = CouponApi.getShopCouponPage().get(0).getCouponId();
        //用户领取店铺优惠券
        CouponApi.receive(shopCouponId);

        //新建平台代金券
        CouponApi.savePlatformCoupon(CouponData.getCouponDTO(1, 0, 1, 1000L, 300L, null, 2, 10, 100, 0, productIds));
        //获取优惠券id
        Long platformCouponId = CouponApi.getPlatformCouponPage().get(0).getCouponId();
        //用户领取优惠券
        CouponApi.receive(platformCouponId);

        //新增打8折权益
        Long discountUserRightsId = UserRightsApi.save(UserRightsDtoData.getDiscounttUserRightsDTO(80));
        //新增包邮权益
        Long freeFeeUserRightsId = UserRightsApi.save(UserRightsDtoData.getFreeFeeUserRightsDTO());
        //用户会员等级添加包邮和打8折权益
        UserLevelApi.update(UserLevelDtoData.getUserLevelDTO(UserApi.getUserInfo().getUserLevelId(), Arrays.asList(discountUserRightsId, freeFeeUserRightsId)));

        //修改积分配置，每15积分抵扣一元，最大使用积分比例100%
        ScoreConfigApi.update(ScoreConfigDtoData.getScoreConfigDTO(15L, 100D));

        OrderDTO orderDTO = OrderDtoData.getOrderDtoData(productId, 1);
        //用户使用优惠券
        orderDTO.setCouponIds(Arrays.asList(CouponApi.getUserCouponPage().get(0).getCouponUserId(), CouponApi.getUserCouponPage().get(1).getCouponUserId()));
        //使用150积分
        orderDTO.setIsScorePay(1);
        orderDTO.setUserUseScore(150L);
        //确认订单
        MyOrderApi.confirm(orderDTO);
        //用户提交订单
        List<Long> orderNumberList = MyOrderApi.submit(SubmitOrderDtoData.getSubmitOrderDtoData(productId));

        //商家修改订单金额为50元
        TimeUnit.SECONDS.sleep(2L);
        OrderApi.changeOrderAmount(OrderAdminDtoData.getOrderAdminDto(orderNumberList.get(0), 5000L, 0L));

        //根据订单id支付订单
        PayApi.orderPay(orderNumberList);
        TimeUnit.SECONDS.sleep(2L);
        //对订单进行退款
        Long refundId = OrderRefund.virtualOrderRefund(orderNumberList.get(0));
        TimeUnit.SECONDS.sleep(2L);

        //删除会员权益
        UserRightsApi.delete(discountUserRightsId);
        UserRightsApi.delete(freeFeeUserRightsId);

        //用户删除领取的店铺优惠券
        CouponApi.deleteUserCoupon(CouponApi.getUserCouponPage().get(0).getCouponUserId());

        //根据平台优惠券id获取优惠券信息
        CouponVO platformCouponVO = CouponApi.getPlatformCouponInfo(platformCouponId);
        //修改平台优惠券为暂不投放
        CouponApi.updatePlatformCoupon(CouponData.getUpdateCouponDTO(platformCouponVO));
        //删除平台代金券券
        CouponApi.deletePlatformCoupon(platformCouponId);

        //根据店铺优惠券id获取店铺优惠券信息
        CouponVO shopCouponVO = CouponApi.getShopCouponInfo(shopCouponId);
        //修改店铺优惠券为暂不投放
        CouponApi.updateShopCoupon(CouponData.getUpdateCouponDTO(shopCouponVO));
        //删除店铺代金券
        CouponApi.deleteShopCoupon(shopCouponId);

        //商家删除满减
        DiscountApi.delete(discountId, true);
        //删除商品
        ProductApi.delete(productId, true);

        //运行后验证数据是否正确
        TimeUnit.SECONDS.sleep(2L);
        Assert.assertEquals(ShopWalletApi.getMongoShopWalletLogBO(orderNumberList.get(0), true).size(), 2);
        OrderDetailVO orderDetailVO = ShopWalletApi.getOrderDetailVO(orderNumberList.get(0), refundId, true);
        WalletAssert.shopOrderDetailAssert(orderDetailVO.getOrderItemDetailList().get(0), 18800L, 5000L, 0L, 10816L, 2984L, 0L, 150L, 1.99, 159L,
                1000L, 2640L, 300L, 300L, 5000L, null, null, -4560L, 5000L, 1, 1);
        WalletAssert.shopOrderFreightAssert(orderDetailVO, 0L, 0L, 0L);
    }

    @Test(description = "多优惠金额叠加预售订单", dataProvider = "depositPreSaleProduct")
    public void discountAmountTestWithDepositPreSaleProduct(Long productId) throws InterruptedException {
        //新建满减活动
        List<DiscountItemDTO> discountItemDTOList = Arrays.asList(DiscountData.getDiscountItemDTO(10000L,1000L), DiscountData.getDiscountItemDTO(10100L, 5000L));
        List<Long> productIds = Collections.singletonList(productId);
        DiscountApi.save(DiscountData.getDiscount(0, 0, discountItemDTOList, 50000L, 1, productIds, 1), true);
        //获取满减活动id
        Long discountId = DiscountApi.getDiscountPage(true).get(0).getDiscountId();

        //新建店铺代金券
        CouponApi.saveShopCoupon(CouponData.getCouponDTO(1, 0, 1, 1000L, 300L, null, 2, 10, 100, 1, productIds));
        //获取店铺优惠券id
        Long shopCouponId = CouponApi.getShopCouponPage().get(0).getCouponId();
        //用户领取店铺优惠券
        CouponApi.receive(shopCouponId);

        //新建平台代金券
        CouponApi.savePlatformCoupon(CouponData.getCouponDTO(1, 0, 1, 1000L, 300L, null, 2, 10, 100, 0, productIds));
        //获取优惠券id
        Long platformCouponId = CouponApi.getPlatformCouponPage().get(0).getCouponId();
        //用户领取优惠券
        CouponApi.receive(platformCouponId);

        //新增打8折权益
        Long discountUserRightsId = UserRightsApi.save(UserRightsDtoData.getDiscounttUserRightsDTO(80));
        //新增包邮权益
        Long freeFeeUserRightsId = UserRightsApi.save(UserRightsDtoData.getFreeFeeUserRightsDTO());
        //用户会员等级添加包邮和打8折权益
        UserLevelApi.update(UserLevelDtoData.getUserLevelDTO(UserApi.getUserInfo().getUserLevelId(), Arrays.asList(discountUserRightsId, freeFeeUserRightsId)));

        OrderDTO orderDTO = OrderDtoData.getOrderDtoData(productId, 1);
        //用户使用优惠券
        orderDTO.setCouponIds(Arrays.asList(CouponApi.getUserCouponPage().get(0).getCouponUserId(), CouponApi.getUserCouponPage().get(1).getCouponUserId()));
        //确认订单
        MyOrderApi.confirm(orderDTO);
        //用户提交订单
        List<Long> orderNumberList = MyOrderApi.submit(SubmitOrderDtoData.getSubmitOrderDtoData(productId));

        //商家修改订单金额为50元
        OrderApi.changeOrderAmount(OrderAdminDtoData.getOrderAdminDto(orderNumberList.get(0), 5000L, 0L));

        //根据订单id支付订单
        PayApi.orderPay(orderNumberList);
        TimeUnit.SECONDS.sleep(2L);
        PayApi.orderPayBalance(orderNumberList.get(0));
        //对订单进行退款
        Long refundId = OrderRefund.realOrderRefund(orderNumberList.get(0));
        TimeUnit.SECONDS.sleep(2L);

        //删除会员权益
        UserRightsApi.delete(discountUserRightsId);
        UserRightsApi.delete(freeFeeUserRightsId);

        //用户删除领取的店铺优惠券
        CouponApi.deleteUserCoupon(CouponApi.getUserCouponPage().get(0).getCouponUserId());

        //根据平台优惠券id获取优惠券信息
        CouponVO platformCouponVO = CouponApi.getPlatformCouponInfo(platformCouponId);
        //修改平台优惠券为暂不投放
        CouponApi.updatePlatformCoupon(CouponData.getUpdateCouponDTO(platformCouponVO));
        //删除平台代金券券
        CouponApi.deletePlatformCoupon(platformCouponId);

        //根据店铺优惠券id获取店铺优惠券信息
        CouponVO shopCouponVO = CouponApi.getShopCouponInfo(shopCouponId);
        //修改店铺优惠券为暂不投放
        CouponApi.updateShopCoupon(CouponData.getUpdateCouponDTO(shopCouponVO));
        //删除店铺代金券
        CouponApi.deleteShopCoupon(shopCouponId);

        //商家删除满减
        DiscountApi.delete(discountId, true);
        //删除商品
        ProductApi.delete(productId, true);
        //删除运费模板
        TransportApi.deleteTransport(TransportApi.infoTransport(true).get(0).getTransportId(), true);

        //运行后验证数据是否正确
        TimeUnit.SECONDS.sleep(2L);
        Assert.assertEquals(ShopWalletApi.getMongoShopWalletLogBO(orderNumberList.get(0), true).size(), 3);
        OrderDetailVO orderDetailVO = ShopWalletApi.getOrderDetailVO(orderNumberList.get(0), refundId, true);
        WalletAssert.shopOrderDetailAssert(orderDetailVO.getOrderItemDetailList().get(0), 18800L, 5800L, 0L, 12802L, 198L, 0L, 0L, 1.99, 119L,
                0L, 0L, 300L, 300L, 5000L, null, null, -6400L, 5800L, 1, 1);
        WalletAssert.shopOrderFreightAssert(orderDetailVO, 800L, 0L, 800L);
    }

    @Test(description = "多优惠金额叠加供应商订单", dataProvider = "supplierProduct")
    public void discountAmountTestWithSupplierProduct(Long productId, Long supplierProductId) throws InterruptedException {
        //新建满减活动
        List<DiscountItemDTO> discountItemDTOList = Arrays.asList(DiscountData.getDiscountItemDTO(10000L,1000L), DiscountData.getDiscountItemDTO(10100L, 5000L));
        List<Long> productIds = Collections.singletonList(productId);
        DiscountApi.save(DiscountData.getDiscount(0, 0, discountItemDTOList, 50000L, 1, productIds, 1), true);
        //获取满减活动id
        Long discountId = DiscountApi.getDiscountPage(true).get(0).getDiscountId();

        //新建店铺代金券
        CouponApi.saveShopCoupon(CouponData.getCouponDTO(1, 0, 1, 1000L, 300L, null, 2, 10, 100, 1, productIds));
        //获取店铺优惠券id
        Long shopCouponId = CouponApi.getShopCouponPage().get(0).getCouponId();
        //用户领取店铺优惠券
        CouponApi.receive(shopCouponId);

        //新建平台代金券
        CouponApi.savePlatformCoupon(CouponData.getCouponDTO(1, 0, 1, 1000L, 300L, null, 2, 10, 100, 0, productIds));
        //获取优惠券id
        Long platformCouponId = CouponApi.getPlatformCouponPage().get(0).getCouponId();
        //用户领取优惠券
        CouponApi.receive(platformCouponId);

        //新增打8折权益
        Long discountUserRightsId = UserRightsApi.save(UserRightsDtoData.getDiscounttUserRightsDTO(80));
        //新增包邮权益
        Long freeFeeUserRightsId = UserRightsApi.save(UserRightsDtoData.getFreeFeeUserRightsDTO());
        //用户会员等级添加包邮和打8折权益
        UserLevelApi.update(UserLevelDtoData.getUserLevelDTO(UserApi.getUserInfo().getUserLevelId(), Arrays.asList(discountUserRightsId, freeFeeUserRightsId)));

        //修改积分配置，每15积分抵扣一元，最大使用积分比例100%
        ScoreConfigApi.update(ScoreConfigDtoData.getScoreConfigDTO(15L ,100D));

        OrderDTO orderDTO = OrderDtoData.getOrderDtoData(productId, 1);
        //用户使用优惠券
        orderDTO.setCouponIds(Arrays.asList(CouponApi.getUserCouponPage().get(0).getCouponUserId(), CouponApi.getUserCouponPage().get(1).getCouponUserId()));
        //使用150积分
        orderDTO.setIsScorePay(1);
        orderDTO.setUserUseScore(150L);
        //确认订单
        MyOrderApi.confirm(orderDTO);
        //用户提交订单
        List<Long> orderNumberList = MyOrderApi.submit(SubmitOrderDtoData.getSubmitOrderDtoData(productId));

        //商家修改订单金额为50元
        OrderApi.changeOrderAmount(OrderAdminDtoData.getOrderAdminDto(orderNumberList.get(0), 5000L, 0L));

        //根据订单id支付订单
        PayApi.orderPay(orderNumberList);
        TimeUnit.SECONDS.sleep(2L);
        //对订单进行退款
        Long refundId = OrderRefund.supplierOrderRefund(orderNumberList.get(0));
        TimeUnit.SECONDS.sleep(2L);

        //删除会员权益
        UserRightsApi.delete(discountUserRightsId);
        UserRightsApi.delete(freeFeeUserRightsId);

        //用户删除领取的店铺优惠券
        CouponApi.deleteUserCoupon(CouponApi.getUserCouponPage().get(0).getCouponUserId());

        //根据平台优惠券id获取优惠券信息
        CouponVO platformCouponVO = CouponApi.getPlatformCouponInfo(platformCouponId);
        //修改平台优惠券为暂不投放
        CouponApi.updatePlatformCoupon(CouponData.getUpdateCouponDTO(platformCouponVO));
        //删除平台代金券券
        CouponApi.deletePlatformCoupon(platformCouponId);

        //根据店铺优惠券id获取店铺优惠券信息
        CouponVO shopCouponVO = CouponApi.getShopCouponInfo(shopCouponId);
        //修改店铺优惠券为暂不投放
        CouponApi.updateShopCoupon(CouponData.getUpdateCouponDTO(shopCouponVO));
        //删除店铺代金券
        CouponApi.deleteShopCoupon(shopCouponId);

        //商家删除满减
        DiscountApi.delete(discountId, true);
        //删除商品
        ProductApi.delete(productId, true);
        SupplierProductApi.delete(supplierProductId, true);

        //运行后验证数据是否正确
        TimeUnit.SECONDS.sleep(2L);
        Assert.assertEquals(ShopWalletApi.getMongoShopWalletLogBO(orderNumberList.get(0), true).size(), 2);
        OrderDetailVO orderDetailVO = ShopWalletApi.getOrderDetailVO(orderNumberList.get(0), refundId, true);
        WalletAssert.shopOrderDetailAssert(orderDetailVO.getOrderItemDetailList().get(0), 18800L, 5000L, 6600L, 10816L, 2984L, 0L, 150L, 1.99, 28L,
                1000L, 2640L, 300L, 300L, 5000L, null, null, -4560L, 5000L, 1, 1);
    }
}
