package com.icloud.server.scala.engine.contect

import com.fasterxml.jackson.annotation.JsonProperty
import com.icloud.server.payutils.enums.PayTypeEnum
import io.swagger.annotations.{ApiModel, ApiModelProperty}

import scala.annotation.meta.field
import scala.beans.BeanProperty
@ApiModel(description = "获取支付链接---通用版本1.0.2版本--风控版本")
case class PayRequest (@(ApiModelProperty@field)(position = 1, example = "1232", value = "paytype") @JsonProperty("paytype") paytype: Int,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "studentid") @JsonProperty("studentid") studentid: String,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "ditch") @JsonProperty("ditch") ditch: String,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "goodsid") @JsonProperty("goodsid") goodsid: Long,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "phone") @JsonProperty("phone") phone: String,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "openid") @JsonProperty("openid") openid: String,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "nickname") @JsonProperty("nickname") nickname: String,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "headimgurl") @JsonProperty("headimgurl") headimgurl: String,
                      ){

def toRequest(ip:String): PayType ={
  if(paytype==1){
    new PayType(PayTypeEnum.WXPAY,studentid,  ditch, goodsid, phone,ip, openid,nickname,headimgurl)
  }else if(paytype==2){
    new PayType(PayTypeEnum.ALIPAY,studentid,  ditch, goodsid, phone,ip,openid,nickname,headimgurl)
  }else { //3
    new PayType(PayTypeEnum.WXJSPAY,studentid,  ditch, goodsid, phone,ip, openid,nickname,headimgurl)

  }
}
}

case class PayType( @BeanProperty paytypeenum:PayTypeEnum,
                    @BeanProperty studentid: String,
                    @BeanProperty ditch: String,
                    @BeanProperty goodsid: Long,
                    @BeanProperty phone: String,
                    @BeanProperty ip: String,
                     @BeanProperty openid: String,
                    @BeanProperty nickname: String,
                      @BeanProperty headimgurl: String,
                  )

