package ink.wgink.module.wechat.pojo.pay.v3.jsapi.pojo;

import ink.wgink.annotation.*;

import java.util.List;

/**
 * @ClassName: PlaceOrderBO
 * @Description: 下单
 * @Author: wanggeng
 * @Date: 2021/8/19 1:52 下午
 * @Version: 1.0
 */
public class PayPlaceOrder {

    @CheckEmptyAnnotation(name = "应用ID")
    private String appid;
    @CheckEmptyAnnotation(name = "直连商户号")
    private String mchid;
    @CheckEmptyAnnotation(name = "商品描述")
    private String description;
    @CheckEmptyAnnotation(name = "商户订单号")
    private String outTradeNo;
    /**
     * 交易结束时间
     */
    private String timeExpire;
    /**
     * 附加数据
     */
    private String attach;
    @CheckEmptyAnnotation(name = "通知地址")
    private String notifyUrl;
    /**
     * 订单优惠标记
     */
    private String goodsTag;
    @CheckNullAnnotation(name = "订单金额")
    @CheckBeanAnnotation
    private Amount amount;
    @CheckNullAnnotation(name = "支付者")
    @CheckBeanAnnotation
    private Payer payer;
    /**
     * 优惠功能
     */
    @CheckBeanAnnotation
    private Detail detail;
    /**
     * 场景信息
     */
    @CheckBeanAnnotation
    private SceneInfo sceneInfo;
    /**
     * 结算信息
     */
    @CheckBeanAnnotation
    private SettleInfo settleInfo;

    public String getAppid() {
        return appid == null ? "" : appid.trim();
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    public String getMchid() {
        return mchid == null ? "" : mchid.trim();
    }

    public void setMchid(String mchid) {
        this.mchid = mchid;
    }

    public String getDescription() {
        return description == null ? "" : description.trim();
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getOutTradeNo() {
        return outTradeNo == null ? "" : outTradeNo.trim();
    }

    public void setOutTradeNo(String outTradeNo) {
        this.outTradeNo = outTradeNo;
    }

    public String getTimeExpire() {
        return timeExpire == null ? "" : timeExpire.trim();
    }

    public void setTimeExpire(String timeExpire) {
        this.timeExpire = timeExpire;
    }

    public String getAttach() {
        return attach == null ? "" : attach.trim();
    }

    public void setAttach(String attach) {
        this.attach = attach;
    }

    public String getNotifyUrl() {
        return notifyUrl == null ? "" : notifyUrl.trim();
    }

    public void setNotifyUrl(String notifyUrl) {
        this.notifyUrl = notifyUrl + "/wechat/pay/notice";
    }

    public String getGoodsTag() {
        return goodsTag == null ? "" : goodsTag.trim();
    }

    public void setGoodsTag(String goodsTag) {
        this.goodsTag = goodsTag;
    }

    public Amount getAmount() {
        return amount;
    }

    public void setAmount(Amount amount) {
        this.amount = amount;
    }

    public Payer getPayer() {
        return payer;
    }

    public void setPayer(Payer payer) {
        this.payer = payer;
    }

    public Detail getDetail() {
        return detail;
    }

    public void setDetail(Detail detail) {
        this.detail = detail;
    }

    public SceneInfo getSceneInfo() {
        return sceneInfo;
    }

    public void setSceneInfo(SceneInfo sceneInfo) {
        this.sceneInfo = sceneInfo;
    }

    public SettleInfo getSettleInfo() {
        return settleInfo;
    }

    public void setSettleInfo(SettleInfo settleInfo) {
        this.settleInfo = settleInfo;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"appid\":\"")
                .append(appid).append('\"');
        sb.append(",\"mchid\":\"")
                .append(mchid).append('\"');
        sb.append(",\"description\":\"")
                .append(description).append('\"');
        sb.append(",\"outTradeNo\":\"")
                .append(outTradeNo).append('\"');
        sb.append(",\"timeExpire\":\"")
                .append(timeExpire).append('\"');
        sb.append(",\"attach\":\"")
                .append(attach).append('\"');
        sb.append(",\"notifyUrl\":\"")
                .append(notifyUrl).append('\"');
        sb.append(",\"goodsTag\":\"")
                .append(goodsTag).append('\"');
        sb.append(",\"amount\":")
                .append(amount);
        sb.append(",\"payer\":")
                .append(payer);
        sb.append(",\"detail\":")
                .append(detail);
        sb.append(",\"sceneInfo\":")
                .append(sceneInfo);
        sb.append(",\"settleInfo\":")
                .append(settleInfo);
        sb.append('}');
        return sb.toString();
    }

    /**
     * 订单金额
     */
    public static class Amount {
        @CheckNumberAnnotation(name = "总金额", min = 0)
        private Integer total;
        /**
         * 货币类型
         */
        private String currency;

        public Integer getTotal() {
            return total == null ? 0 : total;
        }

        public void setTotal(Integer total) {
            this.total = total;
        }

        public String getCurrency() {
            return currency == null ? "" : currency.trim();
        }

        public void setCurrency(String currency) {
            this.currency = currency;
        }

        @Override
        public String toString() {
            final StringBuilder sb = new StringBuilder("{");
            sb.append("\"total\":")
                    .append(total);
            sb.append(",\"currency\":\"")
                    .append(currency).append('\"');
            sb.append('}');
            return sb.toString();
        }
    }

    /**
     * 支付者
     */
    public static class Payer {
        @CheckEmptyAnnotation(name = "用户标识")
        private String openid;

        public String getOpenid() {
            return openid == null ? "" : openid.trim();
        }

        public void setOpenid(String openid) {
            this.openid = openid;
        }

        @Override
        public String toString() {
            final StringBuilder sb = new StringBuilder("{");
            sb.append("\"openid\":\"")
                    .append(openid).append('\"');
            sb.append('}');
            return sb.toString();
        }
    }

    /**
     * 优惠功能
     */
    public static class Detail {
        /**
         * 订单原价
         */
        private Integer costPrice;
        /**
         * 商品小票ID
         */
        private String invoiceId;
        @CheckListBeanAnnotation
        private List<Goods> goodsDetail;

        public Integer getCostPrice() {
            return costPrice == null ? 0 : costPrice;
        }

        public void setCostPrice(Integer costPrice) {
            this.costPrice = costPrice;
        }

        public String getInvoiceId() {
            return invoiceId == null ? "" : invoiceId.trim();
        }

        public void setInvoiceId(String invoiceId) {
            this.invoiceId = invoiceId;
        }

        public List<Goods> getGoodsDetail() {
            return goodsDetail;
        }

        public void setGoodsDetail(List<Goods> goodsDetail) {
            this.goodsDetail = goodsDetail;
        }

        @Override
        public String toString() {
            final StringBuilder sb = new StringBuilder("{");
            sb.append("\"costPrice\":")
                    .append(costPrice);
            sb.append(",\"invoiceId\":\"")
                    .append(invoiceId).append('\"');
            sb.append(",\"goodsDetail\":")
                    .append(goodsDetail);
            sb.append('}');
            return sb.toString();
        }

        public static class Goods {
            @CheckEmptyAnnotation(name = "商户侧商品编码")
            private String merchantGoodsId;
            /**
             * 微信侧商品编码
             */
            private String wechatpayGoodsId;
            /**
             * 商品名称
             */
            private String goodsName;
            @CheckNumberAnnotation(name = "商品数量", min = 0)
            private Integer quantity;
            @CheckNumberAnnotation(name = "商品单价", min = 0)
            private Integer unitPrice;

            public String getMerchantGoodsId() {
                return merchantGoodsId == null ? "" : merchantGoodsId.trim();
            }

            public void setMerchantGoodsId(String merchantGoodsId) {
                this.merchantGoodsId = merchantGoodsId;
            }

            public String getWechatpayGoodsId() {
                return wechatpayGoodsId == null ? "" : wechatpayGoodsId.trim();
            }

            public void setWechatpayGoodsId(String wechatpayGoodsId) {
                this.wechatpayGoodsId = wechatpayGoodsId;
            }

            public String getGoodsName() {
                return goodsName == null ? "" : goodsName.trim();
            }

            public void setGoodsName(String goodsName) {
                this.goodsName = goodsName;
            }

            public Integer getQuantity() {
                return quantity == null ? 0 : quantity;
            }

            public void setQuantity(Integer quantity) {
                this.quantity = quantity;
            }

            public Integer getUnitPrice() {
                return unitPrice == null ? 0 : unitPrice;
            }

            public void setUnitPrice(Integer unitPrice) {
                this.unitPrice = unitPrice;
            }

            @Override
            public String toString() {
                final StringBuilder sb = new StringBuilder("{");
                sb.append("\"merchantGoodsId\":\"")
                        .append(merchantGoodsId).append('\"');
                sb.append(",\"wechatpayGoodsId\":\"")
                        .append(wechatpayGoodsId).append('\"');
                sb.append(",\"goodsName\":\"")
                        .append(goodsName).append('\"');
                sb.append(",\"quantity\":")
                        .append(quantity);
                sb.append(",\"unitPrice\":")
                        .append(unitPrice);
                sb.append('}');
                return sb.toString();
            }
        }
    }

    /**
     * 场景信息
     */
    public static class SceneInfo {
        @CheckEmptyAnnotation(name = "用户终端IP")
        private String payerClientIp;
        /**
         * 商户端设备号
         */
        private String deviceId;
        /**
         * 商户门店信息
         */
        private StoreInfo storeInfo;

        public String getPayerClientIp() {
            return payerClientIp == null ? "" : payerClientIp.trim();
        }

        public void setPayerClientIp(String payerClientIp) {
            this.payerClientIp = payerClientIp;
        }

        public String getDeviceId() {
            return deviceId == null ? "" : deviceId.trim();
        }

        public void setDeviceId(String deviceId) {
            this.deviceId = deviceId;
        }

        public StoreInfo getStoreInfo() {
            return storeInfo;
        }

        public void setStoreInfo(StoreInfo storeInfo) {
            this.storeInfo = storeInfo;
        }

        @Override
        public String toString() {
            final StringBuilder sb = new StringBuilder("{");
            sb.append("\"payerClientIp\":\"")
                    .append(payerClientIp).append('\"');
            sb.append(",\"deviceId\":\"")
                    .append(deviceId).append('\"');
            sb.append(",\"storeInfo\":")
                    .append(storeInfo);
            sb.append('}');
            return sb.toString();
        }

        /**
         * 商户门店信息
         */
        public static class StoreInfo {
            @CheckEmptyAnnotation(name = "门店编号")
            private String id;
            /**
             * 门店名称
             */
            private String name;
            /**
             * 地区编码
             */
            private String areaCode;
            /**
             * 详细地址
             */
            private String address;

            public String getId() {
                return id == null ? "" : id.trim();
            }

            public void setId(String id) {
                this.id = id;
            }

            public String getName() {
                return name == null ? "" : name.trim();
            }

            public void setName(String name) {
                this.name = name;
            }

            public String getAreaCode() {
                return areaCode == null ? "" : areaCode.trim();
            }

            public void setAreaCode(String areaCode) {
                this.areaCode = areaCode;
            }

            public String getAddress() {
                return address == null ? "" : address.trim();
            }

            public void setAddress(String address) {
                this.address = address;
            }

            @Override
            public String toString() {
                final StringBuilder sb = new StringBuilder("{");
                sb.append("\"id\":\"")
                        .append(id).append('\"');
                sb.append(",\"name\":\"")
                        .append(name).append('\"');
                sb.append(",\"areaCode\":\"")
                        .append(areaCode).append('\"');
                sb.append(",\"address\":\"")
                        .append(address).append('\"');
                sb.append('}');
                return sb.toString();
            }
        }
    }

    /**
     * 结算信息
     */
    public static class SettleInfo {
        /**
         * 是否指定分账
         */
        private Boolean profitSharing;

        public Boolean getProfitSharing() {
            return profitSharing;
        }

        public void setProfitSharing(Boolean profitSharing) {
            this.profitSharing = profitSharing;
        }

        @Override
        public String toString() {
            final StringBuilder sb = new StringBuilder("{");
            sb.append("\"profitSharing\":")
                    .append(profitSharing);
            sb.append('}');
            return sb.toString();
        }
    }

}
