package com.wzj.soopin.order.domain.bo;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wzj.soopin.order.domain.entity.WechatPaymentHistory;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;

@Data
@Schema(description = "微信订单表 查询 对象")
public class WechatPaymentHistoryBo {
    @Schema(description = "payment_id 精确匹配")
    private String paymentId;

    @Schema(description = "用户 ID 精确匹配")
    private Long memberId;

    @Schema(description = "OPENID 精确匹配")
    private String openid;

    @Schema(description = "真实姓名，提现需要 精确匹配")
    private String realNameLike;

    @Schema(description = "标题|商品名称 精确匹配")
    private String title;

    @Schema(description = "订单号 支付时是payId 其他为orderId 精确匹配")
    private Long orderId;

    @Schema(description = "金额，单位分 精确匹配")
    private BigDecimal money;

    @Schema(description = "交易类型（1为支付  2为提现  3为退款） 精确匹配")
    private Integer opType;

    @Schema(description = "状态（0：未完成交易   1：完成关键交易） 精确匹配")
    private Integer paymentStatus;

    @Schema(description = "附加数据 精确匹配")
    private String attach;

    @Schema(description = "响应内容 精确匹配")
    private String responseBody;

    public Wrapper<WechatPaymentHistory> toWrapper() {
        return new LambdaQueryWrapper<WechatPaymentHistory>()
            .eq(paymentId != null && !paymentId.isEmpty(), WechatPaymentHistory::getPaymentId, paymentId)
            .eq(memberId != null, WechatPaymentHistory::getMemberId, memberId)
            .eq(openid != null && !openid.isEmpty(), WechatPaymentHistory::getOpenid, openid)
            .like(realNameLike != null && !realNameLike.isEmpty(), WechatPaymentHistory::getRealName, realNameLike)
            .eq(title != null && !title.isEmpty(), WechatPaymentHistory::getTitle, title)
            .eq(orderId != null, WechatPaymentHistory::getOrderId, orderId)
            .eq(money != null, WechatPaymentHistory::getMoney, money)
            .eq(opType != null, WechatPaymentHistory::getOpType, opType)
            .eq(paymentStatus != null, WechatPaymentHistory::getPaymentStatus, paymentStatus)
            .eq(attach != null && !attach.isEmpty(), WechatPaymentHistory::getAttach, attach)
            .eq(responseBody != null && !responseBody.isEmpty(), WechatPaymentHistory::getResponseBody, responseBody);
    }
}
