package com.czg.account.dto.shopuser;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author yjjie
 * @date 2026/1/28 11:30
 */
@Data
public class ShopUserExportDTO {

    /**
     * 主店铺Id
     */
    @ExcelIgnore
    private Long mainShopId;

    @ExcelProperty("手机号")
    private String phone;

    @ExcelProperty("会员生日")
    private String birthDay;

    @ExcelProperty("用户昵称")
    private String nickName;

    @ExcelIgnore
    private Integer status;
    @ExcelProperty("会员状态")
    private String statusRemark;

    @ExcelIgnore
    private Integer isVip;
    @ExcelProperty("是否会员")
    private String vipRemark;

    @ExcelProperty("会员编号")
    private String code;

    @ExcelProperty("余额")
    private BigDecimal amount;

    @ExcelProperty("充值次数")
    private Integer rechargeCount;

    @ExcelProperty("消费累计")
    private BigDecimal consumeAmount;

    @ExcelProperty("消费次数")
    private Integer consumeCount;

    @ExcelProperty("经验值")
    private Long experience;

    @ExcelIgnore
    private String distributionShops;
    @ExcelProperty("是否分销员")
    private String distributionShopsRemark;

    @ExcelProperty("优惠券数量")
    private Long couponNum;

    @ExcelProperty("订单数量")
    private Long orderNumber;

    @ExcelProperty("充值金额")
    private BigDecimal rechargeAmount;

    @ExcelProperty("会员等级")
    private String memberLevelName;

    @ExcelProperty("下一级会员等级")
    private String nextMemberLevelName;

    @ExcelProperty("升级所需经验值")
    private Long nextExperience;

    @ExcelProperty("积分余额")
    private Long pointBalance;

    @ExcelProperty("加入会员时间")
    private LocalDateTime joinTime;

    @ExcelProperty("创建时间")
    private LocalDateTime createTime;

    public String getVipRemark() {
        if (isVip == null || isVip == 0) {
            return "否";
        }
        return "是";
    }

    public String getStatusRemark() {
        if (status == null || status == 0) {
            return "禁用";
        }
        return "正常";
    }

    public String getDistributionShopsRemark() {
        if (StrUtil.isBlank(distributionShops)) {
            return "否";
        }

        if (distributionShops.contains(mainShopId + "_1")) {
            return "是";
        }

        return "否";
    }
}
