package com.cyksj.model.views;

import com.ejlchina.searcher.bean.DbField;
import com.ejlchina.searcher.bean.DbIgnore;
import com.ejlchina.searcher.bean.SearchBean;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 项目名: yhlxj2
 * 文件名: UserMirrorShopView
 * 创建者: JavaZou
 * 创建时间:2024/10/21 18:22
 */
@Getter
@Setter
@SearchBean(tables = "user_mirror_shop ys left join user_mirror_shop_order_relate omr on omr.mp_id = ys.id" +
		" left join order_don od on od.id = omr.order_id and od.status not in ('noPayment', 'close') :time:",
		groupBy = "ys.id,ys.user_id,ys.custom_id,ys.status,ys.remark,ys.created_time,ys.update_time")
public class UserMirrorShopView {

	@DbField("ys.id")
	private Long id;

	/**
	 * 店铺名
	 */
	@DbField("ys.name")
	private String name;

	@DbField("ys.user_id")
	private Long userId;

	@DbIgnore
	private String businessName;

	@DbIgnore
	private String nickname;

	@DbField("count(od.id)")
	private Integer orders;

	@DbField("ys.custom_id")
	private String customId;

	/**
	 * 分销人数
	 * 其中拉新用户购买一单又退款，且无后续下单动作的不算分销用户，不统计在此字段内
	 */
	@DbIgnore
	private Integer distributeUserNum;

	/**
	 * 邀请人数
	 */
	@DbField("select count(*) from user_mirror_shop_user_distribute_shared where shop_user_id = ys.user_id")
	private Integer inviteNum;

	/**
	 * 分销订单金额(无需产生积分)
	 */
	@DbField("(ifnull(sum(od.money),0) - ifnull(sum(od.refund_money),0))")
	private BigDecimal distributeOrdersMoney;

	/**
	 * 销量最高的产品
	 */
	@DbIgnore
	private String goodsTitle;

	@DbField("ys.status")
	private Boolean status;

	@DbField("ys.remark")
	private String remark;

	@DbField("ys.contact")
	private String contact;

	@DbField("ys.qr_code")
	private String qrCode;

	@DbField("ys.created_time")
	private Date createdTime;

	@DbField("ys.update_time")
	private Date updateTime;

	/**
	 * 加盟提成
	 */
	@DbIgnore
	private BigDecimal joinFeeTaskMoney;

	@DbIgnore
	private BigDecimal availableMoney;

	@DbIgnore
	private BigDecimal gotMoney;
}
