package org.springblade.yeePay.entity.saas;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springblade.yeePay.common.YeepayApiConstant;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;

@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@ApiModel("付款码支付入参")
public class AggpayPayDto {
	/**
	 * 发起方商户编号。
	 * 标准商户收付款方案中此参数与收款商户编号一致；
	 * 平台商户收付款方案中此参数为平台商商户编号；
	 * 服务商解决方案中，①标准商户收款时，该参数为标准商户商编 ②平台商收款或平台商入驻商户收款时，该参数为平台商商编。
	 */
	@NotBlank
	@ApiModelProperty(value = "发起方商户编号", required = true)
	private String parentMerchantNo;

	@NotBlank
	@ApiModelProperty(value = "商户编号。收单主体商编，平台商或服务商下的子商户，普通特约商户", required = true)
	private String merchantNo;

	@ApiModelProperty(value = "商户收款请求号。商户系统内部生成的订单号，需要保持在同一个商户下唯一")
	private String orderId;

	@ApiModelProperty(value = "订单金额。业务上是必须参数，单位： 元， 两位小数， 最低 0.01")
	private BigDecimal orderAmount;

	@ApiModelProperty(value = "订单截止时间。格式yyyy-MM-dd HH:mm:ss不传默认一天")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private String expiredTime;

	@ApiModelProperty(value = "业务上是必须参数，支付成功服务器回调地址：支付成功通知、超时通知、失败通知。")
	private String notifyUrl;

	@ApiModelProperty(value = "自定义对账备注。商户可以自定义自身业务需要使用的字段： 如对账时定义该订单应属的会计科目")
	private String memo;

	@ApiModelProperty(value = "商品名称")
	private String goodsName;

	/**
	 * 分账订单标记
	 * DELAY_SETTLE:需要分账
	 * REAL_TIME:不需要分账
	 */
	@ApiModelProperty(value = "分账订单标记")
	private YeepayApiConstant.fundProcessType fundProcessType;

	/**
	 * 支付方式类型
	 * MERCHANT_SCAN:付款码支付
	 */
	@NotBlank
	@ApiModelProperty(value = "支付方式类型", required = true)
	private YeepayApiConstant.payWayType payWay;

	/**
	 * 渠道类型
	 * WECHAT:微信
	 * ALIPAY:支付宝
	 * UNIONPAY:银联云闪付
	 * APPLEPAY:苹果闪付
	 */
	@NotBlank
	@ApiModelProperty(value = "渠道类型", required = true)
	private YeepayApiConstant.channelType channel;

	/**
	 * 场景
	 * OFFLINE:线下
	 * 渠道类型为银联时，不必传
	 */
	@ApiModelProperty(value = "场景")
	private YeepayApiConstant.sceneType scene;

	@NotBlank
	@ApiModelProperty(value = "获取的用户授权码(ApplePay对应paymentToken解密后的emvData)", required = true)
	private String authCode;

	@ApiModelProperty(value = "微信公众号ID。如需获取付款用户的用户ID时需要传入")
	private String appId;

	@NotBlank
	@ApiModelProperty(value = "用户真实IP地址", required = true)
	private String userIp;

	@NotBlank
	@ApiModelProperty(value = "终端号id", required = true)
	private String terminalId;

	@ApiModelProperty(value = "商家终端场景信息")
	private TerminalSceneInfo terminalSceneInfo;

	@ApiModelProperty(value = "渠道指定支付信息。支持花呗分期")
	private ChannelSpecifiedInfo channelSpecifiedInfo;

	/**
	 * 微信
	 * {"goodsTag":"全场券订单优惠标识","costPrice":"单品券-订单原价","receiptId":"单品券-商品小票",
	 * "goodsDetail":[
	 * {"quantity":1,"goodsId":"商品编码","price":"2.1","goodsName":"商品名称","wxpayGoodsId":"渠道侧商品编码"},
	 * {"quantity":2,"goodsId":"商品编码","price":"2.2","goodsName":"商品名称","wxpayGoodsId":"渠道侧商品编码"}
	 * ]}
	 * 银联云闪付
	 * [{"channelGoodsId":"商品编号","goodsName":"商品名称","price":1,"quantity":1,"category":"商品类目","addnInfo":"附加信息"},
	 * {"channelGoodsId":"商品编号","goodsName":"商品名称","price":1,"quantity":1,"category":"商品类目","addnInfo":"附加信息"}]
	 */
	@ApiModelProperty(value = "渠道优惠信息。订单需参与渠道指定优惠时传入，如微信单品券")
	private String channelPromotionInfo;

	@ApiModelProperty(value = "限制付款人信息。特殊行业需要支付实名场景下使用，如保险的特殊险种需要付款人和投保人实名条件下可以使用")
	private IdentityInfo identityInfo;

	@ApiModelProperty(value = "是否限制贷记卡")
	private YeepayApiConstant.limitCredit limitCredit;

	@ApiModelProperty(value = "下单接口返回的token如果商户使用先下单再支付模式，请传入下单接口返回的token")
	private String token;

	/**
	 * 易宝订单号
	 * 如果商户使用先下单再支付模式，请传入下单接口返回的易宝订单号
	 * 同时传入易宝订单号和token，将以易宝订单号为准
	 */
	@ApiModelProperty(value = "易宝订单号")
	private String uniqueOrderNo;

	@ApiModelProperty(value = "清算成功服务器回调地址，不传则不通知")
	private String csUrl;

	@ApiModelProperty(value = "ApplePay支付密码，免密情况下可不填，对应paymentToken解密后的encryptedPINData")
	private String encryptedPINData;

	@ApiModelProperty(value = "卡号，ApplePay对应paymentToken解密后的emvData")
	private String payerAccountNo;

	/**
	 * 合作银行信息：
	 * JSON字符串；已获批开通账户通的平台商可传入此字段，否则请勿传值
	 * accountProvider:合作银行
	 * token:商户与银行约定令牌
	 */
	@ApiModelProperty(value = "合作银行信息")
	private AccountLinkInfo accountLinkInfo;

}

@Data
@Builder
@ApiModel("商家终端场景信息")
@NoArgsConstructor
@AllArgsConstructor
class TerminalSceneInfo {

	@ApiModelProperty(value = "门店id")
	private String storeId;

	@ApiModelProperty(value = "门店名称")
	private String storeName;

	@ApiModelProperty(value = "商户操作员编号")
	private String operatorId;

	@ApiModelProperty(value = "支付宝的店铺编号")
	private String alipayStoreId;

	@ApiModelProperty(value = "门店行政区划码")
	private String areaCode;

	@ApiModelProperty(value = "门店详细地址")
	private String address;
}

@Data
@Builder
@ApiModel("渠道指定支付信息。支持花呗分期")
@NoArgsConstructor
@AllArgsConstructor
class ChannelSpecifiedInfo {

	@ApiModelProperty(value = "花呗分期数量")
	private Integer hbFqNum;

	@ApiModelProperty(value = "花呗分期卖家百分比")
	private Integer hbFqSellerPercent;

	@ApiModelProperty(value = "")
	private String sysServiceProviderId;
}

@Data
@Builder
@ApiModel("限制付款人信息")
@NoArgsConstructor
@AllArgsConstructor
class IdentityInfo {

	@ApiModelProperty("身份验证类型")
	private String identityVerifyType;

	@ApiModelProperty("付款人类型")
	private String payerIdType;

	@ApiModelProperty("付款人数量")
	private String payerNumber;

	@ApiModelProperty("付款人名")
	private String payerName;

	@ApiModelProperty("付款人手机")
	private String payerPhone;
}

@Data
@Builder
@ApiModel("合作银行信息")
@NoArgsConstructor
@AllArgsConstructor
class AccountLinkInfo{

	@ApiModelProperty("合作银行")
	private String accountProvider;

	@ApiModelProperty("商户与银行约定令牌")
	private String token;
}
