package com.icloud.server.scala.pay

import com.fasterxml.jackson.annotation.JsonProperty
import com.icloud.server.scala.goods.GoodspayditchCase
import com.icloud.server.web.err.{ErrorCode, GlobalErrorCodeConstants, ServerException, ServiceException}
import com.icloud.server.web.json.JsonResult
import io.swagger.annotations._
import lombok.{AllArgsConstructor, Data, NoArgsConstructor}
import org.springframework.data.jpa.repository.{JpaRepository, JpaSpecificationExecutor}
import org.springframework.data.repository.{CrudRepository, PagingAndSortingRepository}
import org.springframework.stereotype.Repository
import org.springframework.web.bind.annotation._

import java.util
import java.util.{Optional, Set}
import javax.annotation.Resource
import javax.persistence._
import scala.annotation.meta.field
import scala.beans.BeanProperty
import scala.jdk.CollectionConverters._

/** 用户版本
 *
 * @Author : yang
 * @Date : 2022-07-07 6:40 PM
 * @Version : 2.1.2
 */
@Api(tags = Array("支付渠道"), value = "API")
@RestController
@RequestMapping(Array("/pay/"))
@CrossOrigin
class PayController {
  @Resource
  @BeanProperty
  var upr: UserpayRepository = _
  @Resource
  @BeanProperty
  var ar1: Alipay1Repository = _
  @Resource
  @BeanProperty
  var wr1: Wxpay1Repository = _

  @ApiOperation(value = "在支付配制中查询支付宝的详情", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "uid", value = "支付实体类", required = true, dataType = "String")
  ))
  @PostMapping(Array("findAli1"))
  @ResponseBody
  def findAli1(uid: String): JsonResult = {
    var alipays = ar1.findByUseridAndStatus(uid, 0)
    alipays=if(!alipays.isEmpty){
      alipays.asScala.filter(x=>{
        x.alipaypublickey=x.alipaypublickey
        x.privatekey=xxx(x.privatekey)
        x.appid=x.appid
        true
      }).reverse.asJava
    }else null

    new JsonResult(alipays)
  }

  @ApiOperation(value = "在支付配制中查询微信渠道信息", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "uid", value = "支付实体类", required = true, dataType = "String")
  ))
  @PostMapping(Array("findWX1"))
  @ResponseBody
  def findWx1(uid: String): JsonResult = {
    var wxpays = wr1.findByUseridAndStatus(uid, 0)
    wxpays=if(!wxpays.isEmpty) {
      wxpays.asScala.filter(x=>{
        x.appid=x.appid
        x.mchid=x.mchid
        x.mchkey=xxx(x.mchkey)
        true
      }).reverse.asJava
    }else null


    new JsonResult(wxpays)
  }


  @ApiOperation(value = "查询支付宝渠道信息", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "uid", value = "支付实体类", required = true, dataType = "String")
  ))
  @PostMapping(Array("findAli"))
  @ResponseBody
  def findAli(uid: String): JsonResult = {
    var alipays = ar1.findByUseridAndStatus(uid, 0)
    alipays=if(!alipays.isEmpty){
      alipays.asScala.filter(x=>{
        x.alipaypublickey=x.alipaypublickey
        x.privatekey=xxx(x.privatekey)
        x.appid=x.appid
      true
      }).asJava
      //util.List[Alipay1]
    }else new util.ArrayList[Alipay1]()
    val alipay = new Alipay1()
    alipay.setId(0)
    alipay.setName("默认")
    alipay.setPaytype(1)
    alipays.add(alipay)
    val res = alipays.asScala.reverse.asJava

    new JsonResult(res)
  }

  @ApiOperation(value = "查询微信渠道信息", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "uid", value = "支付实体类", required = true, dataType = "String")
  ))
  @PostMapping(Array("findWX"))
  @ResponseBody
  def findWx(uid: String): JsonResult = {
    var wxpays = wr1.findByUseridAndStatus(uid, 0)
    wxpays=if(!wxpays.isEmpty) {
      wxpays.asScala.filter(x=>{
        x.appid=x.appid
        x.mchid=x.mchid
        x.mchkey=xxx(x.mchkey)
        true
      }).asJava
    }else new util.ArrayList[Wxpay1]()
    // @(ApiModelProperty@field)(position = 1, example = "1232", value = "goodsid") @JsonProperty("goodsid") goodsid: Long,
    //                              @ApiIgnore() @(ApiModelProperty@field)(position = 1, example = "1232", value = "goodspayid") @JsonProperty("goodspayid") var goodspayid: Long,
    //                              @(ApiModelProperty@field)(position = 1, example = "1232", value = "payname") @JsonProperty("payname") payname: String,
    //                              @(ApiModelProperty@field)(position = 1, example = "1232", value = "optpay") @JsonProperty("optpay") optpay: Long,
    //                              @(ApiModelProperty@field)(position = 1, example = "1232", value = "random") @JsonProperty("random") random: String,
    //                              @(ApiModelProperty@field)(position = 1, example = "1232", value = "appointpay") @JsonProperty("appointpay") appointpay: Long,
    //                              @(ApiModelProperty@field)(position = 1, example = "1232", value = "status") @JsonProperty("status") status: Int)
//   wxpays.asScala.map(x=>{
//
//   })
//    new GoodspayditchCase()

    val wxpay = new Wxpay1()
    wxpay.setId(0)
    wxpay.setName("默认")
    wxpay.setPaytype(1)
    wxpays.add(wxpay)
    val res = wxpays.asScala.reverse.asJava
    new JsonResult(res)
  }


  @ApiOperation(value = "创建支付宝支付渠道", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "req", value = "支付实体类", required = true, dataType = "CreateAliReq")
  ))
  @PostMapping(Array("createali"))
  @ResponseBody
  def createali(@RequestBody req: CreateAliReq): JsonResult = {
    //    println(s"uid = ${req.uid}")
    //    println(s"appid = ${req.appid}")
    //    println(s"name = ${req.name}")
    //    println(s"privatekey = ${req.privatekey}")
    //    println(s"alipaypublickey = ${req.alipaypublickey}")
    //    println(s"req.paytype = ${req.paytype}")
    ar1.save(new Alipay1().toEntity(req.name, req.appid, req.privatekey, req.alipaypublickey, 0, 1, 500000L, req.uid, req.paytype, 0))
    new JsonResult("ok")
  }

  @ApiOperation(value = "创建微信支付渠道", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "req", value = "支付实体类", required = true, dataType = "CreateWxReq")
  ))
  @PostMapping(Array("createwx"))
  @ResponseBody
  def createwx(@RequestBody req: CreateWxReq): JsonResult = {

    wr1.save(new Wxpay1().toEntity(req.name, req.appid, req.mchid, req.mchkey, 0, 1, 500000L, req.uid, req.paytype, 0))

    new JsonResult("ok")
  }

  @ApiOperation(value = "查询所有支付渠道信息", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "uid", value = "支付实体类", required = true, dataType = "String")
  ))
  @PostMapping(Array("findaliall"))
  @ResponseBody
  def select(uid: Int): JsonResult = {
    val userpay = upr.findByIdAndDfe(uid, 0)

    val pays = new util.ArrayList[FindAllPayRes]()
    val ali = new util.ArrayList[SelectPayRes]()
    val wx = new util.ArrayList[SelectPayRes]()
    var alistatus=0
    var wxstatus=0
    if (!userpay.alipay.isEmpty) {

      userpay.alipay.asScala.map(x => {
        ali.add(new SelectPayRes(x.id, x.paytype, x.name, x.amount, xxxappid(x.appid) , xxx(x.privatekey),
          xxx(x.alipaypublickey), null, x.status,
          null, null, x.weight))
      })
//       alistatus = userpay.alipay.asScala.filter(y => {
//        y.paystatus !=0
//      }).maxBy(z=>{z.paystatus}).status
      alistatus = userpay.alipay.asScala.maxBy(z=>{z.paystatus}).status

//      if (!ali1.isEmpty) {
//      ali1.maxBy(z=>{z.paystatus})
//      }
    }

    if (!userpay.wxpay.isEmpty) {
      userpay.wxpay.asScala.map(x => {
        wx.add(new SelectPayRes(x.id, x.paytype, x.name, x.amount, x.appid, null,
          null, null, x.status,
          x.mchid, xxx(x.mchkey), x.weight))
      })
      wxstatus = userpay.wxpay.asScala.maxBy(z=>{z.paystatus}).status
    }
    //    al.asScala.sortBy(x=>{x.id})
    pays.add(new FindAllPayRes("1",wxstatus.toString,wx.size().toString,wx.asScala.toArray))
    pays.add(new FindAllPayRes("2",alistatus.toString,ali.size().toString,ali.asScala.toArray))

    new JsonResult(pays)
  }

  @ApiOperation(value = "查询支付宝渠道信息", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "uid", value = "支付实体类", required = true, dataType = "String")
  ))
  @PostMapping(Array("findalipay"))
  @ResponseBody
  def findalipay(uid: Int): JsonResult = {

    val userpay = upr.findByIdAndDfe(uid, 0)
    val ali = new util.ArrayList[SelectPayRes]()

    if (!userpay.alipay.isEmpty) {

      userpay.alipay.asScala.map(x => {
        ali.add(new SelectPayRes(x.id, x.paytype, x.name, x.amount,x.appid, xxx(x.privatekey),
          x.alipaypublickey, null, x.status,
          null, null, x.weight))
      })
    }
    new JsonResult(ali)
  }

  def xxxappid(str:String): String ={
    if(str==null||str.size<4)null else str.substring(0,3)+"*****"+ str.substring(str.size-3)
  }
  def xxx(str:String): String ={
//    if(str==null||str.size<15)null else str.substring(0,4)+"*****"+ str.substring(str.size-5)
    if(str==null||str.size<15)null else "********"
  }
  @ApiOperation(value = "查询微信渠道信息", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "uid", value = "支付实体类", required = true, dataType = "String")
  ))
  @PostMapping(Array("findwxpay"))
  @ResponseBody
  def findwxpay(uid: Int): JsonResult = {

    val userpay = upr.findByIdAndDfe(uid, 0)
    val wx = new util.ArrayList[SelectPayRes]()

    if (!userpay.wxpay.isEmpty) {
      userpay.wxpay.asScala.map(x => {
        wx.add(new SelectPayRes(x.id, x.paytype, x.name, x.amount, xxxappid(x.appid), null,
          null, null, x.status,
          xxx(x.mchid), xxx(x.mchkey), x.weight))
      })
    }

    new JsonResult(wx)
  }

  @ApiOperation(value = "更新支付宝渠道信息", notes = "不更新的字段,传null")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "req", value = "支付实体类", required = true, dataType = "UpdateAliReq")
  ))
  @PostMapping(Array("updateali"))
  @ResponseBody
  def updateali(@RequestBody req: UpdateAliReq): JsonResult = {

    if (req.id == null) {throw new ServiceException(GlobalErrorCodeConstants.BAD_REQUEST)}
    val ali = ar1.findById(req.id).orElseGet(null)
    if(ali!=null){
      if(req.name!=null)ali.setName(req.name)
      if(req.appid!=null)ali.setAppid(req.appid)
      if(req.privatekey!=null)ali.setPrivatekey(req.privatekey)
      if(req.alipaypublickey!=null)ali.setAlipaypublickey(req.alipaypublickey)
      if(req.paystate!=null)ali.setPaystate(req.paystate)
      if(req.weight!=null)ali.setWeight(req.weight)
      if(req.amount!=null)ali.setAmount(req.amount)
      ar1.save(ali)

    }
    new JsonResult("ok")
  }

  @ApiOperation(value = "更新微信渠道信息", notes = "不更新的字段,传null")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "req", value = "支付实体类", required = true, dataType = "UpdateWxReq")
  ))
  @PostMapping(Array("updatewx"))
  @ResponseBody
  def updatewx(@RequestBody req: UpdateWxReq): JsonResult = {

    if (req.id == null) throw new ServiceException(GlobalErrorCodeConstants.BAD_REQUEST)

    val wxpay = wr1.findById(req.id).orElseGet(null)
    if(wxpay!=null){
      if(req.name!=null)wxpay.setName(req.name)
      if(req.appid!=null)wxpay.setAppid(req.appid)
      if(req.mchid!=null)wxpay.setMchid(req.mchid)
      if(req.mchkey!=null)wxpay.setMchkey(req.mchkey)
      if(req.paystate!=null)wxpay.setPaystate(req.paystate)
      if(req.weight!=null)wxpay.setWeight(req.weight)
      if(req.amount!=null)wxpay.setAmount(req.amount)
      wr1.save(wxpay)
    }
    new JsonResult()
  }

  @ApiOperation(value = "禁用支付宝渠道信息", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "req", value = "删除支付实体类", required = true, dataType = "DelPayReq")
  ))
  @PostMapping(Array("DisableAli"))
  @ResponseBody
  def disable_ali(@RequestBody req:DelPayReq): JsonResult ={

    val ali = ar1.findById(req.payid).orElseGet(null)
    if (ali!=null) {
      ali.paystate=if(ali.paystate ==1) 0 else 1
      ar1.save(ali)
    }
    new JsonResult("ok")
  }
  @ApiOperation(value = "禁用微信渠道信息", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "req", value = "删除支付实体类", required = true, dataType = "DelPayReq")
  ))
  @PostMapping(Array("DisableWx"))
  @ResponseBody
  def disable_wx(@RequestBody req:DelPayReq): JsonResult ={
    val wxpay = wr1.findById(req.payid).orElseGet(null)
    if (wxpay!=null) {
      wxpay.paystate=if(wxpay.paystate ==1) 0 else 1
      wr1.save(wxpay)
    }
    new JsonResult("ok")
  }

  @ApiOperation(value = "删除支付宝渠道信息", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "req", value = "删除支付实体类", required = true, dataType = "DelPayReq")
  ))
  @PostMapping(Array("delali"))
  @ResponseBody
  def del_ali(@RequestBody req:DelPayReq): JsonResult ={

    val ali = ar1.findById(req.payid).orElseGet(null)
    if (ali!=null) {
      ali.status = 1
      ar1.save(ali)
    }
    new JsonResult("ok")
  }
  @ApiOperation(value = "删除微信渠道信息", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "req", value = "删除支付实体类", required = true, dataType = "DelPayReq")
  ))
  @PostMapping(Array("delwx"))
  @ResponseBody
  def del_wx(@RequestBody req:DelPayReq): JsonResult ={
    val wxpay = wr1.findById(req.payid).orElseGet(null)
    if (wxpay!=null) {
      wxpay.status = 1
      wr1.save(wxpay)
    }
    new JsonResult("ok")
  }


  //  @ApiOperation( value = "更新支付宝渠道信息", notes = "" )
  //  @ApiImplicitParams( Array(
  //    new ApiImplicitParam( name = "req", value = "支付实体类", required = true, dataType = "Tt" )
  //  ) )
  //  @PostMapping( Array( "ttt" ) )
  //  def ttt(@RequestBody req:Tt): JsonResult ={
  //    println(s"Tt = ${Tt}")
  //    new JsonResult("ok")
  //  }




}

@Repository trait UserpayRepository extends CrudRepository[Userpay, Integer] with JpaSpecificationExecutor[Userpay] with JpaRepository[Userpay, Integer] with PagingAndSortingRepository[Userpay, Integer] {
  def findByIdAndDfe(id: Int, dfe: Int): Userpay

  //  def findByUsernameAndDfe (username: java.lang.String,dfe:Int): Userpay
}

@Entity
@Table(name = "sys_user") class Userpay extends Serializable {
  @Id
  //  @GeneratedValue( strategy = GenerationType.IDENTITY )
  @BeanProperty
  @Column(name = "user_id")
  var id: Int = _

  @BeanProperty
  @Column(name = "delete_flg")
  var dfe: Int = _
  @BeanProperty //  @JsonIgnore
  @OneToMany(mappedBy = "userpay", cascade = Array(CascadeType.ALL), fetch = FetchType.EAGER) //targetEntity=classOf[UserRole] ,,fetch = FetchType.EAGER targetEntity=classOf[UserRole] ,
  var alipay: Set[Alipay] = _
  @BeanProperty //  @JsonIgnore
  @OneToMany(mappedBy = "userpay", cascade = Array(CascadeType.ALL), fetch = FetchType.EAGER) //targetEntity=classOf[UserRole] ,,fetch = FetchType.EAGER targetEntity=classOf[UserRole] ,
  var wxpay: Set[Wxpay] = _
}


@Data
@Entity
@Table(name = "alipay")
@NoArgsConstructor
@AllArgsConstructor
class Alipay {
  @Id
  @BeanProperty
  @Column
  var id: Long = _
  @BeanProperty
  @Column var name: String = _
  @BeanProperty
  @Column(name = "app_id")
  var appid: String = _
  @BeanProperty
  @Column(name = "private_key")
  var privatekey: String = _
  @BeanProperty
  @Column(name = "alipay_publickey")
  var alipaypublickey: String = _
  @BeanProperty
  @Column(name = "paystatus")
  var paystatus: Int = _
  @BeanProperty
  @Column var status: Int = _
  @BeanProperty
  @Column
  var weight: Int = _
  @BeanProperty
  @Column
  var amount: Long = _
  @BeanProperty
  @Column(name = "pay_type")
  var paytype: Int = _

  @ManyToOne //(fetch=FetchType.EAGER)//fetch=FetchType.LAZY
  @JoinColumn(name = "user_id") var userpay: Userpay = _
}


@Data
@Entity
@Table(name = "wxpay")
@NoArgsConstructor
@AllArgsConstructor
class Wxpay {
  @Id
  @BeanProperty
  @Column
  var id: Long = _
  @BeanProperty
  @Column var name: String = _
  @BeanProperty
  @Column(name = "app_id")
  var appid: String = _
  @BeanProperty
  @Column(name = "mch_id")
  var mchid: String = _
  @BeanProperty
  @Column(name = "mch_key")
  var mchkey: String = _
  @BeanProperty
  @Column(name = "paystatus")
  var paystatus: Int = _
  @BeanProperty
  @Column
  var weight: Int = _
  @BeanProperty
  @Column
  var amount: Long = _
  @BeanProperty
  @Column var status: Int = _
  @BeanProperty
  @Column(name = "pay_type")
  var paytype: Int = _
  @ManyToOne //(fetch=FetchType.EAGER)//fetch=FetchType.LAZY
  @JoinColumn(name = "user_id") var userpay: Userpay = _

}


@Repository trait Alipay1Repository extends CrudRepository[Alipay1, Long] with JpaSpecificationExecutor[Alipay1] with JpaRepository[Alipay1, Long] with PagingAndSortingRepository[Alipay1, Long] {
  def findByUseridAndStatus(userid: String, status: Int): util.List[Alipay1]

  // override def findById(id: Long ):Alipay1
  override def findById(id: Long): Optional[Alipay1]

}

@Data
@Entity
@Table(name = "alipay")
@NoArgsConstructor
@AllArgsConstructor
class Alipay1 {
  @Id
  @BeanProperty
  @Column
  var id: Long = _
  @BeanProperty
  @Column var name: String = _
  @BeanProperty
  @Column(name = "app_id")
  var appid: String = _
  @BeanProperty
  @Column(name = "private_key")
  var privatekey: String = _
  @BeanProperty
  @Column(name = "alipay_publickey")
  var alipaypublickey: String = _
  @BeanProperty
  @Column(name = "paystatus")
  var paystate: Int = _
  @BeanProperty
  @Column var status: Int = _
  @BeanProperty
  @Column
  var weight: Int = _
  @BeanProperty
  @Column
  var amount: Long = _
  //  @transient
  @BeanProperty
  @Column(name = "pay_type")
  var paytype: Int = _
  @BeanProperty
  @Column(name = "user_id")
  var userid: String = _

  def toEntity(name: String, appid: String, privatekey: String, alipaypublickey: String, paystate: Int, weight: Int, amount: Long, userid: String, paytype: Int, status: Int): Alipay1 = {
    this.name = name
    this.appid = appid
    this.privatekey = privatekey
    this.alipaypublickey = alipaypublickey
    this.paystate = paystate
    this.weight = weight
    this.amount = amount
    this.userid = userid
    this.paytype = paytype
    this.status = status

    this
  }

  def UpEntity(id: Long, name: String, appid: String, privatekey: String, alipaypublickey: String, paystate: Int, weight: Int, amount: Long, userid: String, paytype: Int, status: Int): Alipay1 = {
    val ali = toEntity(name, appid, privatekey, alipaypublickey, paystate, weight, amount, userid, paytype, status)
    ali.setId(id)
    ali
  }
}

@Repository trait Wxpay1Repository extends CrudRepository[Wxpay1, Long] with JpaSpecificationExecutor[Long] with JpaRepository[Wxpay1, Long] with PagingAndSortingRepository[Wxpay1, Long] {
  def findByUseridAndStatus(userid: String, status: Int): util.List[Wxpay1]

}

@Data
@Entity
@Table(name = "wxpay")
@NoArgsConstructor
@AllArgsConstructor
class Wxpay1 {
  @Id
  @BeanProperty
  @Column
  var id: Long = _
  @BeanProperty
  @Column var name: String = _
  @BeanProperty
  @Column(name = "app_id")
  var appid: String = _
  @BeanProperty
  @Column(name = "mch_id")
  var mchid: String = _
  @BeanProperty
  @Column(name = "mch_key")
  var mchkey: String = _
  @BeanProperty
  @Column(name = "paystatus")
  var paystate: Int = _
  @BeanProperty
  @Column
  var weight: Int = _
  @BeanProperty
  @Column
  var amount: Long = _
  @BeanProperty
  @Column var status: Int = _
  @BeanProperty
  @Column(name = "user_id")
  var userid: String = _
  @BeanProperty
  @Column(name = "pay_type")
  var paytype: Int = _

  def toEntity(name: String, appid: String, mchid: String, mchkey: String, paystate: Int, weight: Int, amount: Long, userid: String, paytype: Int, status: Int): Wxpay1 = {
    this.name = name
    this.appid = appid
    this.mchid = mchid
    this.mchkey = mchkey
    this.paystate = paystate
    this.weight = weight
    this.amount = amount
    this.amount = amount
    this.userid = userid
    this.paytype = paytype
    this.status = status
    this
  }

  def UpEntity(id: Long, name: String, appid: String, mchid: String, mchkey: String, paystate: Int, weight: Int, amount: Long, userid: String, paytype: Int, status: Int): Wxpay1 = {
    val wx = toEntity(name: String, appid: String, mchid: String, mchkey: String, paystate, weight, amount, userid, paytype, status)
    wx.setId(id)
    wx
  }

}
@ApiModel(description = "创建微信支付渠道")
case class CreateAliReq(@(ApiModelProperty@field)(position = 1, example = "1232", value = "uid") @JsonProperty("uid") uid: String,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "name") @JsonProperty("name") name: String,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "appid") @JsonProperty("appid") appid: String,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "密钥") @JsonProperty("privatekey") privatekey: String,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "alipaypublickey") @JsonProperty("alipaypublickey") alipaypublickey: String,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "paytype") @JsonProperty("paytype") paytype: Int,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "server_url") @JsonProperty("server_url") server_url: String)

//@Data
//@NoArgsConstructor
//@AllArgsConstructor
@ApiModel(description = "创建微信支付渠道")
case class CreateWxReq(
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "uid") @JsonProperty("uid") uid: String,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "appid") @JsonProperty("appid") appid: String,
                        @(ApiModelProperty@field)(position = 1, example = "test", value = "姓名") @JsonProperty("name") name: String,
                        @(ApiModelProperty@field)(position = 1, example = "12313asd", value = "商户id") @JsonProperty("mchid") mchid: String,
                        @(ApiModelProperty@field)(position = 1, example = "key", value = "微信key") @JsonProperty("mchkey") mchkey: String,
                        @(ApiModelProperty@field)(position = 1, example = "1", value = "支付类型") @JsonProperty("paytype") paytype: Int,
                        @(ApiModelProperty@field)(position = 1, example = "url", value = "url") @JsonProperty("server_url") server_url: String)
@ApiModel(description = "创建微信支付渠道")
case class UpdateAliReq(@(ApiModelProperty@field)(position = 1, example = "1232", value = "uid") @JsonProperty("uid") uid: String,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "id") @JsonProperty("id") id: Long,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "name") @JsonProperty("name") name: String,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "appid") @JsonProperty("appid") appid: String,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "privatekey") @JsonProperty("privatekey") privatekey: String,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "alipaypublickey") @JsonProperty("alipaypublickey") alipaypublickey: String,
                        @(ApiModelProperty@field)(position = 1, example = "1", value = "支付类型") @JsonProperty("paytype") paytype: Int,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "支付状态") @JsonProperty("paystate") paystate: Int,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "金额") @JsonProperty("amount") amount: Long,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "不填") @JsonProperty("server_url") server_url: String,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "权重") @JsonProperty("weight") weight: Int,
                        @(ApiModelProperty@field)(position = 1, example = "1232", value = "状态") @JsonProperty("status") status: Int)
@ApiModel(description = "创建微信支付渠道")
case class UpdateWxReq(@(ApiModelProperty@field)(position = 1, example = "1232", value = "uid") @JsonProperty("uid") uid: String,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "id") @JsonProperty("id") id: Long,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "appid") @JsonProperty("appid") appid: String,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "name") @JsonProperty("name") name: String,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "mchid") @JsonProperty("mchid") mchid: String,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "mchkey") @JsonProperty("mchkey") mchkey: String,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "paytype") @JsonProperty("paytype") paytype: Int,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "server_url") @JsonProperty("server_url") server_url: String,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "paystate") @JsonProperty("paystate") paystate: Int,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "金额") @JsonProperty("amount") amount: Long,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "权重") @JsonProperty("weight") weight: Int,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "状态") @JsonProperty("status") status: Int)


@ApiModel(description = "支付参数")
case class DelPayReq(
                      @(ApiModelProperty@field)(position = 1, example = "1232", value = "权重")@JsonProperty("uid") uid: Long,
                      @(ApiModelProperty@field)(position = 1, example = "1232", value = "权重")@JsonProperty("payid") payid: Long)
case class Tt(@BeanProperty uid: String, @BeanProperty id: String)

//  x.name
//      x.appid
//      x.paytype
//      x.amount
//      x.alipaypublickey
//      x.paystate
//      x.status
//      x.weight
case class SelectPayRes(@BeanProperty id: Long, @BeanProperty paytype: Int, @BeanProperty payname: String, @BeanProperty amount: Long, @BeanProperty appid: String, @BeanProperty privatekey: String,
                        @BeanProperty alipaypublickey: String, @BeanProperty server_url: String, @BeanProperty status: Int,
                        @BeanProperty mchid: String, @BeanProperty mchkey: String, @BeanProperty weight: Int)

case class FindAllPayRes(@BeanProperty payname: String, @BeanProperty paystatus: String, @BeanProperty paycount: String, @BeanProperty payres: Array[SelectPayRes])
