package com.tmerclub.cloud.systemtest.data.order;

import com.tmerclub.cloud.multishop.mongo.MongoShopWalletLogBO;
import com.tmerclub.cloud.order.vo.OrderDetailVO;
import com.tmerclub.cloud.order.vo.OrderItemDetailVO;
import org.testng.Assert;

/**
 * @author lpj
 */
public class WalletAssert {
    /**
     * 商家店铺结算记录验证
     * @param mongoShopWalletLogBO 店铺结算记录
     * @param amountType 金额类型 0 待结算金额 1 店铺余额 2 冻结金额
     * @param shopIoType 收支类型 0 支出 1 收入
     * @param shopChangeAmount 改变金额
     * @param userAmount 操作金额
     * @param platformAmount 平台优惠金额
     * @param shopReduceAmount 商家优惠金额
     * @param distributionAmount 分销占用金额
     * @param shopPlatformCommission 平台佣金
     * @param reason 资金变化原因 0 用户支付 1 订单结算 2 用户申请退款成功 4 提现申请 5 提现申请被拒绝 6 提现申请通过 9 扣除订单分销金额
     *               11 充值成功 12 扣除订单采购金额 13 商家自行处理采购价差 14 超时未支付尾款
     */
    public static void shopWalletLogAssert(MongoShopWalletLogBO mongoShopWalletLogBO, Integer amountType, Integer shopIoType, Long shopChangeAmount, Long userAmount,
                                    Long platformAmount, Long shopReduceAmount, Long distributionAmount, Long shopPlatformCommission, Integer reason) {
        //金额类型
        Assert.assertEquals(mongoShopWalletLogBO.getAmountType(), amountType);
        //收支类型
        Assert.assertEquals(mongoShopWalletLogBO.getShopIoType(), shopIoType);
        //改变金额
        Assert.assertEquals(mongoShopWalletLogBO.getShopChangeAmount(), shopChangeAmount);
        //操作金额
        Assert.assertEquals(mongoShopWalletLogBO.getUserAmount(), userAmount);
        //平台优惠金额
        Assert.assertEquals(mongoShopWalletLogBO.getPlatformAmount(), platformAmount);
        //商家优惠金额
        Assert.assertEquals(mongoShopWalletLogBO.getShopReduceAmount(), shopReduceAmount);
        //分销占用金额
        Assert.assertEquals(mongoShopWalletLogBO.getDistributionAmount(), distributionAmount);
        //平台佣金
        Assert.assertEquals(mongoShopWalletLogBO.getShopPlatformCommission(), shopPlatformCommission);
        //资金变化原因
        Assert.assertEquals(mongoShopWalletLogBO.getReason(), reason);
    }

    /**
     * 商家结算明细数据验证
     * @param orderItemDetailVO 店铺结算单条数据
     * @param spuTotalAmount 商品总金额
     * @param actualTotal 用户支付金额
     * @param itemPurchaseAmount 供货价
     * @param multiShopReduce 商家优惠金额
     * @param platformShareReduce 平台优惠金额
     * @param distributionAmount 分销金额
     * @param useScore 使用积分
     * @param rate 平台分账
     * @param platformCommission 平台佣金
     * @param scoreAmount 积分抵扣金额
     * @param memberAmount 会员折扣金额
     * @param platformCouponAmount 平台优惠券优惠金额
     * @param shopCouponAmount 店铺优惠券优惠金额
     * @param discountAmount 满减优惠金额
     * @param seckillAmount 秒杀优惠金额
     * @param groupAmount 拼团优惠金额
     * @param shopChangeFreeAmount 商家改价金额
     * @param refundAmount 退款金额
     * @param count 商品数量
     * @param refundCount 退款数量
     */
    public static void shopOrderDetailAssert(OrderItemDetailVO orderItemDetailVO, Long spuTotalAmount, Long actualTotal, Long itemPurchaseAmount, Long multiShopReduce,
                                             Long platformShareReduce, Long distributionAmount, Long useScore, Double rate, Long platformCommission, Long scoreAmount,
                                             Long memberAmount, Long platformCouponAmount, Long shopCouponAmount, Long discountAmount, Long seckillAmount,
                                             Long groupAmount, Long shopChangeFreeAmount, Long refundAmount, Integer count, Integer refundCount) {
        //商品总金额
        Assert.assertEquals(orderItemDetailVO.getSpuTotalAmount(), spuTotalAmount);
        //用户支付金额
        Assert.assertEquals(orderItemDetailVO.getActualTotal(), actualTotal);
        //供货价
        Assert.assertEquals(orderItemDetailVO.getItemPurchaseAmount(), itemPurchaseAmount);
        //商家优惠金额
        Assert.assertEquals(orderItemDetailVO.getMultishopReduce(), multiShopReduce);
        //平台优惠金额
        Assert.assertEquals(orderItemDetailVO.getPlatformShareReduce(), platformShareReduce);
        //分销金额
        Assert.assertEquals(orderItemDetailVO.getDistributionAmount(), distributionAmount);
        //使用积分
        Assert.assertEquals(orderItemDetailVO.getUseScore(), useScore);
        //平台分账
        Assert.assertEquals(orderItemDetailVO.getRate(), rate);
        //平台佣金
        Assert.assertEquals(orderItemDetailVO.getPlatformCommission(), platformCommission);
        //积分抵扣金额
        Assert.assertEquals(orderItemDetailVO.getScoreAmount(), scoreAmount);
        //会员折扣金额
        Assert.assertEquals(orderItemDetailVO.getMemberAmount(), memberAmount);
        //平台优惠券优惠金额
        Assert.assertEquals(orderItemDetailVO.getPlatformCouponAmount(), platformCouponAmount);
        //店铺优惠券优惠金额
        Assert.assertEquals(orderItemDetailVO.getShopCouponAmount(), shopCouponAmount);
        //满减优惠金额
        Assert.assertEquals(orderItemDetailVO.getDiscountAmount(),discountAmount);
        //秒杀优惠金额
        Assert.assertEquals(orderItemDetailVO.getSeckillAmount(), seckillAmount);
        //拼团优惠金额
        Assert.assertEquals(orderItemDetailVO.getGroupAmount(), groupAmount);
        //商家改价金额
        Assert.assertEquals(orderItemDetailVO.getShopChangeFreeAmount(), shopChangeFreeAmount);
        //退款金额
        Assert.assertEquals(orderItemDetailVO.getRefundAmount(), refundAmount);
        //商品数量
        Assert.assertEquals(orderItemDetailVO.getCount(), count);
        //退款数量
        Assert.assertEquals(orderItemDetailVO.getRefundCount(), refundCount);
    }

    /**
     * 商家订单运费验证
     * @param orderDetailVO 订单结算明细
     * @param freightAmount 订单运费
     * @param freeFreightAmount 商家减免运费
     * @param platformFreeFreightAmount 平台减免运费
     */
    public static void shopOrderFreightAssert(OrderDetailVO orderDetailVO, Long freightAmount, Long freeFreightAmount, Long platformFreeFreightAmount) {
        //订单运费
        Assert.assertEquals(orderDetailVO.getFreightAmount(), freightAmount);
        //商家减免运费
        Assert.assertEquals(orderDetailVO.getFreeFreightAmount(), freeFreightAmount);
        //平台减免运费
        Assert.assertEquals(orderDetailVO.getPlatformFreeFreightAmount(), platformFreeFreightAmount);
    }
}
