package com.icloud.server.scala.goods

import com.fasterxml.jackson.annotation.{JsonAutoDetect, JsonProperty}
import com.icloud.server.scala.engine.service.GoodsPayService
import com.icloud.server.scala.shiro.UserRepository
import com.icloud.server.utils.IdWorker
import com.icloud.server.web.JsonResult
import io.swagger.annotations._
import lombok.{AllArgsConstructor, Data, NoArgsConstructor}
import org.hibernate.annotations.{CreationTimestamp, UpdateTimestamp}
import org.springframework.data.domain.{PageRequest, Pageable, Sort}
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 springfox.documentation.annotations.ApiIgnore

import java.util
import java.util.Date
import javax.annotation.Resource
import javax.persistence._
import scala.annotation.meta.field
import scala.beans.BeanProperty
import scala.jdk.CollectionConverters._
//import collection.JavaConverters._
//import scala.collection.JavaConversions._
//asJava
//import scala.collection.JavaConverters._


@Api(tags = Array("商品橱柜和商品支付链接"), value = "API", hidden = true)
@RestController
@RequestMapping(Array("/goods/"))
@CrossOrigin
class GoodsController {

  @Resource
  @BeanProperty
  var gr: GoodsRepository = _
  @Resource
  @BeanProperty
  var gr1: GoodsRepository1 = _

  @Resource
  @BeanProperty
  var gpgr: GoodsPackageRepository = _

  @Resource
  @BeanProperty
  var gpr: GoodspayRepository = _
  @Resource
  @BeanProperty
  var gpr1: GoodspayRepository1 = _

  @Resource
  @BeanProperty
  var gpdr: GoodspayditchRepository = _
  @Resource
  @BeanProperty
  var ur: UserRepository = _
  @Resource
  @BeanProperty var goodspayservice: GoodsPayService = _




  /**
   * @Description:复制商品链接
   * @Author: yangs
   * @Date: 2022-07-13 16:41
   *
   *
   * */
  def getgoodslink(): Unit = {

  }

  //单个查询
  @ApiOperation(value = "商品橱柜里模糊搜索---模糊查询名字", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "name", value = "商品名", required = true, dataType = "String")
  ))
  @PostMapping(Array("findbylikename"))
  @ResponseBody
  def findbylikename(@RequestParam uid: Long, @RequestParam name: String,@RequestParam page:Int, @RequestParam size:Int): JsonResult = {
    //查询多少条

    val request :Pageable= PageRequest.of(page-1, size, Sort.Direction.DESC, "goodsid")
    val count1 = gr.countBySubject(name)

    val count = gr.countBySubjectLikeAndStatusAndParentAndUseridOrderByGoodsid("%" + name + "%", 0, 1, uid)
    val list = gr.findBySubjectLikeAndStatusAndParentAndUseridOrderByGoodsidDesc("%" + name + "%", 0, 1, uid,request)

    new JsonResult(new Findbylikename(count,list))
  }

  @ApiOperation(value = "更新商品橱柜信息", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "req", value = "更新商品信息", required = true, dataType = "UpdateGoodsReq")
  ))
  @PostMapping(Array("updategoods"))
  @ResponseBody
  def updupdate_goodsate(@RequestBody req: UpdateGoodsReq): JsonResult = {

    if (req.parent == 0) {
      req.sub.map(x => {

        gpgr.save(new GoodsPackage().toEntity(req.goods_package_id, req.goodsid, x, null, req.status))
        gr.save(new Goods().toEntity(req.goodsid, req.tenantid, req.uid, req.subject,
          req.shortname, req.picurl, req.body, req.price, req.markingprice, "0", req.status, req.parent, req.free, req.goods_package_id.toString))
      })

    } else {
      gr.save(new Goods().toEntity1(req.goodsid, req.tenantid, req.uid, req.subject,
        req.shortname, req.picurl, req.body, req.price, req.markingprice, "0", req.status, req.parent, req.free))
    }
    goodspayservice.lading()
    new JsonResult("ok")
  }



  @ApiOperation(value = "创建商品橱柜商品", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "req", value = "实体类", required = true, dataType = "CreateGoodsReq")
  ))
  @PostMapping(Array("creategoods"))
  @ResponseBody
  def createGoods(@RequestBody req: CreateGoodsReq): JsonResult = {
    val goodsid = new IdWorker().nextId()
    val goodspackageid = new IdWorker().nextId()
    if (req.parent == 0) {
      req.sub.map(x => {
        gpgr.save(new GoodsPackage().toEntity(goodspackageid, goodsid, x, null, 0))
      })
      gr.save(new Goods().toEntity(goodsid, req.tenantid, req.uid, req.subject,
        req.shortname, req.picurl, req.body, req.price, req.markingprice, "0", 0, req.parent, req.free, goodspackageid.toString))
    } else {
      gr.save(new Goods().toEntity1(goodsid, req.tenantid, req.uid, req.subject,
        req.shortname, req.picurl, req.body, req.price, req.markingprice, "0", 0, req.parent, req.free))
    }
    new JsonResult("ok")
  }

  @ApiOperation(value = "创建商品链接", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "goodspay", value = "实体类", required = true, dataType = "GoodspayCase")
  ))
  @PostMapping(Array("creategoodspay"))
  @ResponseBody
  def createGoodspay(@RequestBody goodspay: GoodspayCase): JsonResult = {
    var goodspayidss = new IdWorker().nextId()
    goodspay.goodspayditch.map(x => {
      x.goodspayid = goodspayidss
      x.goodsid=goodspay.goodsid
      createGoodspayditch(x)
    })

    gpr.save(new Goodspay().toEntity(goodspayidss, goodspay.goodsid, goodspay.paymentmodel,
      goodspay.payment, goodspay.fullphone, goodspay.expiremodel, goodspay.expireendtime,
      goodspay.expiremillisecond, goodspay.remark, 0, // ditchid,
      goodspay.subject,
      goodspay.uid, goodspay.starttime, goodspay.shortname))
    goodspayservice.lading()
    new JsonResult("ok")
  }

//  @ApiOperation(value = "更新商品链接---已经弃用用1.0.2", notes = "")
//  @ApiImplicitParams(Array(
//    new ApiImplicitParam(name = "uppay", value = "实体类", required = true, dataType = "UpGoodspayReq")
//  ))
//  @PostMapping(Array("updategoodspay"))
//  @ResponseBody
//  def UpdateGoodspay(@RequestBody uppay: UpGoodspayReq): JsonResult = {
//    //    var goodspayidss = new IdWorker().nextId()
////    uppay.upgoodspayditchreq.map(x => {
////      //      x.goodspayid = goodspayidss
////      upGoodspayditch(x)
////    })
////
////    gpr.save(new Goodspay().toEntity(uppay.id, uppay.goodsid, uppay.paymentmodel,
////      uppay.payment, uppay.fullphone, uppay.expiremodel, uppay.expireendtime,
////      uppay.expiremillisecond, uppay.remark, uppay.status, // ditchid,
////      uppay.subject,
////      uppay.uid, uppay.starttime, uppay.shortname))
//    new JsonResult("ok")
//  }
/**
 * @Description:更新渠道信息
 * @Author: yang
 * @Date: 2022-07-19 11:23
 *
 * @param gd
 *
 **/
  def upGoodspayditch(gd: UpGoodspayditchReq,  goodsid: Long, goodspayid: Long): Unit = {
    //    删除渠道信息
    val goodspayditch = gpdr.findByIdAndStatus(gd.id, 0)
    if(goodspayditch==null) throw new RuntimeException("请刷新页面,再更新")

    goodspayditch.setStatus(1)
    gpdr.save(goodspayditch)
    //新建渠道信息
    createGoodspayditch(GoodspayditchCase(goodsid,goodspayid,gd.payname,gd.optpay,gd.random.toString,gd.appointpay,0))
  }
//id: Long, goodsid: Long, goodspayid: Long, payname: String, optpay: Long, random: String, appointpay: Long, status: Int
  def createGoodspayditch(gd: GoodspayditchCase): Long = {
    val id = new IdWorker().nextId()
    gpdr.save(new Goodspayditch().toEntity(id, gd.goodsid, gd.goodspayid, gd.payname, gd.optpay, gd.random, gd.appointpay, gd.status))
    id
  }


  @ApiOperation(value = "搜索商品橱柜里所有商品", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "uid", value = "用户名", required = true, dataType = "String")
  ))
  @PostMapping(Array("select"))
  @ResponseBody
  def select(uid: Long,strtus:Int,@RequestParam page:Int, @RequestParam size:Int): JsonResult = {
    val request :Pageable= PageRequest.of(page-1, size, Sort.Direction.DESC, "goodsid")

    val (count,goodses) = if(strtus==3){
      (gr1. countByUserid(uid),
      gr1.findByUseridOrderByGoodsidDesc(uid,request))
    }else{
      (gr1.countByUseridAndStatus(uid, strtus),
      gr1.findByUseridAndStatusOrderByGoodsidDesc(uid, strtus,request))
    }


    new JsonResult( new SelectALl(count,goodses))
  }

  @ApiOperation(value = "查所有商品的链接", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "uid", value = "用户名", required = true, dataType = "String")
  ))
  @PostMapping(Array("findgoodspays"))
  @ResponseBody
  def findgoodspay(uid: String,@RequestParam page:Int, @RequestParam size:Int): JsonResult = {
    val request :Pageable= PageRequest.of(page-1, size, Sort.Direction.DESC, "id")
    val goodses = gpr1.findByStatusAndUseridOrderByIdDesc(0, uid,request)
   var value= goodses.asScala.filter(x=>{
      x.goodspayditch=x.goodspayditch.asScala.filter(_.status==0).asJava
      true
    }).toList.asJava
    new JsonResult(value)
  }

  @ApiOperation(value = "商品链接查询---模糊检索查询名字", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "uid", value = "uid", required = true, dataType = "String"),
    new ApiImplicitParam(name = "subject", value = "商品名", required = true, dataType = "String")
  ))
  @PostMapping(Array("findBysub"))
  @ResponseBody
  def select(uid: Long, subject: String): JsonResult = {
    val goodses = gpr1.findBySubjectLikeAndStatusAndUseridOrderByIdDesc(subject, 0, uid)
    val username = ur.findById(uid.toInt).username
    if (!goodses.isEmpty) {
      goodses.asScala.map(x => {
        x.username = username
      })
    }
    new JsonResult(goodses)
  }

  @ApiOperation(value = "删除商品链接----1.0.2", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "uid", value = "用户名", required = true, dataType = "Long"),
    new ApiImplicitParam(name = "goodspayid", value = "商品橱窗id", required = true, dataType = "Long")
  ))
  @PostMapping(Array("delectgoodpay"))
  @ResponseBody
  def delectgoodpay(uid: Long, goodspayid: Long): JsonResult = {
    val goodspay = gpr.findByIdAndUseridAndStatus(goodspayid, uid, 0)
    goodspay.setStatus(1)
    gpr.save(goodspay)
    new JsonResult("ok")
  }


  @PostMapping(Array("updategoodpay33"))
  @ResponseBody
  def updategoodpay2(@RequestBody uppay: UpGoodspayReq ): JsonResult = {
    val goodspay = gpr.findByIdAndUseridAndStatus(uppay.id, uppay.uid, 0)
    goodspay
    new JsonResult()
  }
  @ApiOperation(value = "更新商品链接---1.0.2", notes = "")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "uppay", value = "实体类", required = true, dataType = "UpGoodspayReq")
  ))
  @PostMapping(Array("updategoodspay"))
  @ResponseBody
  def updategoodspay(@RequestBody uppay: UpGoodspayReq): JsonResult = {

    var goodspay = gpr.findByIdAndUseridAndStatus(uppay.id, uppay.uid, 0)
    goodspay.expiremodel=uppay.expiremodel.toString
    goodspay.setExpiremodel(uppay.expiremodel.toString)
  goodspay.setPayment(uppay.payment)
  goodspay.setExpireendtime(uppay.expireendtime)
  goodspay.setRemark(uppay.remark)
  goodspay.setGoodsid(uppay.goodsid)
  goodspay.setFullphone(uppay.fullphone.toString)
    goodspay.setPaymentmodel(uppay.paymentmodel)
    goodspay.setShortname(uppay.shortname)
    goodspay.setSubject(uppay.subject)
    goodspay.setStarttime(uppay.starttime)
    gpr.save(goodspay)

    uppay.upgoodspayditchreq.map(x => {
//      x.goodspayid = uppay.goodsid
//      x.goodsid=uppay.goodsid
      upGoodspayditch(x,uppay.goodsid,uppay.id)
    })
    goodspayservice.lading()
    new JsonResult("ok")
  }

}

@Repository trait GoodsRepository extends CrudRepository[Goods, Long] with JpaSpecificationExecutor[Goods] with JpaRepository[Goods, Long] with PagingAndSortingRepository[Goods, Long] {

  def findByUseridAndStatus(userid: Long, status: Int): java.util.List[Goods]

  def findByGoodsidAndAndStatus(goodsid: Long, status: Int): Goods
  def countBySubject(subject: String): Long

  //  def findBySubjectLikeAndStatusAndParentOrderByGoodsid(subject: String,status:Int,parent: Int) :util.List[Goods]
  def countBySubjectLikeAndStatusAndParentAndUseridOrderByGoodsid(subject: String, status: Int, parent: Int, userid: Long): Long
  def findBySubjectLikeAndStatusAndParentAndUseridOrderByGoodsidDesc(subject: String, status: Int, parent: Int, userid: Long,pageable: Pageable): java.util.List[Goods]

  def findBySubjectLike(subject: String): java.util.List[Goods]

}

@Repository trait GoodsRepository1 extends CrudRepository[Goods2, Long] with JpaSpecificationExecutor[Goods2] with JpaRepository[Goods2, Long] with PagingAndSortingRepository[Goods2, Long] {



  def countByUseridAndStatus(userid: Long, status: Int): Long

  def findByUseridAndStatusOrderByGoodsidDesc(userid: Long, status: Int,pageable: Pageable): java.util.List[Goods2]

  def countByUserid(userid: Long): Long
  def findByUseridOrderByGoodsidDesc(userid: Long,pageable: Pageable): java.util.List[Goods2]

  def findByGoodsidAndAndStatus(goodsid: Long, status: Int): Goods2
}

@Data
@Entity
@Table(name = "goods")
@NoArgsConstructor
@AllArgsConstructor
class Goods extends Serializable {
  @Id
  @BeanProperty
  @Column(name = "goods_id")
  var goodsid: Long = _
  @BeanProperty
  @Column(name = "tenant_id")
  var tenantid: Long = _
  @BeanProperty
  @Column(name = "user_id")
  var userid: Long = _
  @BeanProperty
  @Column(name = "full_phone")
  var fullphone: String = _
  @BeanProperty
  @Column var subject: String = _
  @BeanProperty
  @Column var free: String = _
  @BeanProperty
  @Column(name = "short_name")
  var shortname: String = _
  @BeanProperty
  @Column(name = "pic_url")
  var picurl: String = _
  @BeanProperty
  @Column
  var body: String = _
  @BeanProperty
  @Column
  var price: Long = _

  @BeanProperty
  @Column
  var sellcount: Long = _
  @BeanProperty
  @Column
  var sellamount: Long = _


  @BeanProperty
  @Column(name = "marking_price")
  var markingprice: Long = _
  @BeanProperty
  @Column(name = "selling_model")
  var sellingmodel: String = _
  @BeanProperty
  @Column var status: Int = _
  @BeanProperty
  @Column var parent: Int = _
  @CreationTimestamp
  @BeanProperty
  @Column var CREATETIME: Date = _
  @UpdateTimestamp
  @BeanProperty
  @Column var UPDATETIME: Date = _

  @BeanProperty
  @Column(name = "goods_package_id")
  var goodspackageid: String = _


  def toEntity(goodsid: Long, tenantid: Long, userid: Long, subject: String, shortname: String, picurl: String,
               body: String, price: Long, markingprice: Long, sellingmodel: String,
               status: Int, parent: Int, free: String, goodspackageid: String): Goods = {
    this.goodsid = goodsid
    this.goodspackageid = goodspackageid
    this.tenantid = tenantid
    this.userid = userid
    this.subject = subject
    this.shortname = shortname
    this.picurl = picurl
    this.body = body
    this.price = price
    this.markingprice = markingprice
    this.sellingmodel = sellingmodel
    this.status = status
    this.parent = parent
    this.free = free
    this
  }

  def toEntity1(goodsid: Long, tenantid: Long, userid: Long, subject: String, shortname: String, picurl: String,
                body: String, price: Long, markingprice: Long, sellingmodel: String,
                status: Int, parent: Int, free: String): Goods = {
    this.goodsid = goodsid
    this.tenantid = tenantid
    this.userid = userid
    this.subject = subject
    this.shortname = shortname
    this.picurl = picurl
    this.body = body
    this.price = price
    this.markingprice = markingprice
    this.sellingmodel = sellingmodel
    this.status = status
    this.parent = parent
    this.free = free
    this
  }
}


@Repository trait GoodspayRepository extends CrudRepository[Goodspay, Long] with JpaSpecificationExecutor[Goodspay] with JpaRepository[Goodspay, Long] with PagingAndSortingRepository[Goodspay, Long] {

  def findByIdAndStatus(id: Long, status: Int): Goodspay

  def findByIdAndUseridAndStatus(id: Long, userid: Long, status: Int): Goodspay

  def findBySubjectLikeAndStatusAndUseridOrderByGoodsid(subject: String, status: Int, userid: Long): util.List[Goodspay]

}


@Data
@Entity
@Table(name = "goods_pay")
@NoArgsConstructor
@AllArgsConstructor
class Goodspay extends Serializable {
  //  @GeneratedValue( strategy = GenerationType.IDENTITY )
  @Id
  @BeanProperty
  @Column(name = "id")
  var id: Long = _


  @BeanProperty
  @Column(name = "user_id")
  var userid: Long = _
  @BeanProperty
  @Column
  var subject: String = _
  @BeanProperty
  @Column(name = "short_name")
  var shortname: String = _
  @BeanProperty
  @Column(name = "goods_id")
  var goodsid: Long = _
  //    @BeanProperty
  //    @Column(name = "ditch_id")
  //    var ditchid: Long = _
  @BeanProperty
  @Column(name = "payment_model")
  var paymentmodel: Int = _
  @BeanProperty
  @Column(name = "payment")
  var payment: Long = _
  @BeanProperty
  @Column(name = "full_phone")
  var fullphone: String = _
  @BeanProperty
  @Column(name = "expire_model")
  var expiremodel: String = _
  @BeanProperty
  @Column(name = "expire_endtime")
  var expireendtime: Date = _
  @BeanProperty
  @Column
  var starttime: Date = _
  @BeanProperty
  @Column(name = "expire_millisecond")
  var expiremillisecond: Long = _
  @BeanProperty
  @Column
  var remark: String = _
  @BeanProperty
  @Column var status: Int = _
  @CreationTimestamp
  @BeanProperty
  @Column var CREATETIME: Date = _
  @UpdateTimestamp
  @BeanProperty
  @Column var UPDATETIME: Date = _



  //  @BeanProperty
  //  @JoinColumn( name = "ditch_id" )
  //  @OneToOne( fetch = FetchType.EAGER, cascade = Array( CascadeType.ALL ) ) var goodspayditch: Goodspayditch = _

  def toEntity(id: Long, goodsid: Long, paymentmodel: Int, payment: Long,
               fullphone: String, expiremodel: String, expireendtime: Date,
               expiremillisecond: Long, remark: String, status: Int, //ditchid: Long,
               subject: String, userid: Long, starttime: Date, shortname: String
              ): Goodspay = {
    this.id = id
    this.goodsid = goodsid
    this.paymentmodel = paymentmodel
    this.payment = payment
    this.fullphone = fullphone
    this.expiremodel = expiremodel
    this.expireendtime = expireendtime
    this.expiremillisecond = expiremillisecond
    this.remark = remark
    this.status = status
    //        this.ditchid = ditchid
    this.subject = subject
    this.userid = userid
    this.starttime = starttime
    this.shortname = shortname
    this
  }

}


@Repository trait GoodsPackageRepository extends CrudRepository[GoodsPackage, Long] with JpaSpecificationExecutor[GoodsPackage] with JpaRepository[GoodsPackage, Long] with PagingAndSortingRepository[GoodsPackage, Long] {
  def findByGoodsidAndStatus(goodsid: Long, status: Int): java.util.List[GoodsPackage]

}


@Data
@Entity
@Table(name = "goods_package")
@NoArgsConstructor
@AllArgsConstructor
class GoodsPackage extends Serializable {
  //  @GeneratedValue( strategy = GenerationType.IDENTITY )
  @Id
  @BeanProperty
  @Column(name = "id")
  var id: Long = _

  @BeanProperty
  @Column(name = "goods_id")
  var goodsid: Long = _
  @BeanProperty
  @Column(name = "sub_goods_id")
  var subgoodsid: Long = _

  @BeanProperty
  @Column
  var remark: String = _
  @BeanProperty
  @Column var status: Int = _
  @CreationTimestamp
  @BeanProperty
  @Column var CREATETIME: Date = _
  @UpdateTimestamp
  @BeanProperty
  @Column var UPDATETIME: Date = _

  def toEntity(id: Long, goodsid: Long, subgoodsid: Long, remark: String, status: Int): GoodsPackage = {
    this.id = id
    this.goodsid = goodsid
    this.subgoodsid = subgoodsid
    this.remark = remark
    this.status = status
    this
  }

}

@Repository trait GoodspayditchRepository extends CrudRepository[Goodspayditch, Long] with JpaSpecificationExecutor[Goodspayditch] with JpaRepository[Goodspayditch, Long] with PagingAndSortingRepository[Goodspayditch, Long] {
  def findByIdAndStatus(id: Long, status: Int): Goodspayditch

}


@Data
@Entity
@Table(name = "goods_pay_ditch")
@NoArgsConstructor
@AllArgsConstructor
class Goodspayditch extends Serializable {
  @Id
  @BeanProperty
  @Column(name = "ditch_id")
  var id: Long = _

  @BeanProperty
  @Column(name = "goods_id")
  var goodsid: Long = _

  @BeanProperty
  @Column(name = "goods_pay_id")
  var goodspayid: Long = _
  @BeanProperty
  @Column(name = "pay_name")
  var payname: String = _
  @BeanProperty
  @Column(name = "opt_pay")
  var optpay: Long = _
  @BeanProperty
  @Column(name = "random")
  var random: String = _
  @BeanProperty
  @Column(name = "appoint_pay")
  var appointpay: Long = _

  @BeanProperty
  @Column var status: Int = _
  @CreationTimestamp
  @BeanProperty
  @Column var CREATETIME: Date = _
  @UpdateTimestamp
  @BeanProperty
  @Column var UPDATETIME: Date = _

  def toEntity(id: Long, goodsid: Long, goodspayid: Long, payname: String, optpay: Long, random: String, appointpay: Long, status: Int): Goodspayditch = {
    this.id = id
    this.goodsid = goodsid
    this.goodspayid = goodspayid
    this.payname = payname
    this.optpay = optpay
    this.random = random
    this.appointpay = appointpay
    this.status = status
    this
  }

}

// @BeanProperty var goodsids: List[String]
//@Data
case class CreateGoodsReq(
                           @JsonProperty("tenantid") tenantid: Long,
                           @JsonProperty("uid") uid: Long,
                           @JsonProperty("subject") subject: String,
                           @JsonProperty("shortname") shortname: String,
                           @JsonProperty("picurl") picurl: String,
                           @JsonProperty("body") body: String,
                           @JsonProperty("price") price: Long,
                           @JsonProperty("markingprice") markingprice: Long,
                           @JsonProperty("parent") parent: Int,
                           @JsonProperty("free") free: String,
                           @JsonProperty("sub") sub: Array[Long])
//case class CreateSubGoodsReq(@BeanProperty var goodsid: util.List[String])


case class UpdateGoodsReq(@JsonProperty("goodsid") goodsid: Long,
                          @JsonProperty("tenantid") tenantid: Long,
                          @JsonProperty("uid") uid: Long,
                          @JsonProperty("goods_package_id") goods_package_id: Long,
                          @JsonProperty("subject") subject: String,
                          @JsonProperty("shortname") shortname: String,
                          @JsonProperty("picurl") picurl: String,
                          @JsonProperty("body") body: String,
                          @JsonProperty("price") price: Long,
                          @JsonProperty("markingprice") markingprice: Long,
                          @JsonProperty("status") status: Int,
                          @JsonProperty("parent") parent: Int,
                          @JsonProperty("free") free: String,
                          @JsonProperty("sub") sub: Array[Long])

@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
@ApiModel(description = "表名描述")
case class UpGoodsReq1(@(ApiModelProperty@field)(position = 1, example = "1232", value = "用户id") @JsonProperty("uid") uid: Long,
                       @(ApiModelProperty@field)(position = 1, example = "1232", value = "图片URL") @JsonProperty("picurl") picurl: String)

//case class UpGoodsReq1(  @JsonProperty("uid")  uid: Long, @JsonProperty("picurl") picurl: String)
//case class CreateSubGoodsReq1(@BeanProperty var goodsid: util.List[String])
//
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
case class aa(uid: Long, picurl: String)

case class GoodspayCase(@JsonProperty("goodsid") goodsid: Long,
                        @JsonProperty("paymentmodel") paymentmodel: Int,
                        @JsonProperty("payment") payment: Long,
                        @JsonProperty("fullphone") fullphone: String,
                        @JsonProperty("expiremodel") expiremodel: String,
                        @JsonProperty("expireendtime") expireendtime: Date,
                        @JsonProperty("expiremillisecond") expiremillisecond: Long,
                        @JsonProperty("starttime") starttime: Date,
                        @JsonProperty("subject") subject: String,
                        @JsonProperty("uid") uid: Long,
                        @JsonProperty("shortname") shortname: String,
                        @JsonProperty("remark") remark: String,
                        @JsonProperty("goodspayditch") goodspayditch: Array[GoodspayditchCase])

@ApiModel(description = "创建商品橱窗")
case class GoodspayditchCase(
                              @(ApiModelProperty@field)(position = 1, example = "1232", value = "goodsid") @JsonProperty("goodsid") var 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)

@ApiModel(description = "更新商品橱窗")
case class UpGoodspayReq(
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "id") @JsonProperty("id") id: Long,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "goodsid") @JsonProperty("goodsid") goodsid: Long,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "paymentmodel") @JsonProperty("paymentmodel") paymentmodel: Int,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "payment") @JsonProperty("payment") payment: Long,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "fullphone") @JsonProperty("fullphone") fullphone: Int,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "expiremodel") @JsonProperty("expiremodel") expiremodel: Int,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "expireendtime") @JsonProperty("expireendtime") expireendtime: Date,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "expiremillisecond") @JsonProperty("expiremillisecond") expiremillisecond: Long,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "starttime") @JsonProperty("starttime") starttime: Date,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "subject") @JsonProperty("subject") subject: String,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "uid") @JsonProperty("uid") uid: Long,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "status") @JsonProperty("status") status: Int,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "shortname") @JsonProperty("shortname") shortname: String,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "remark") @JsonProperty("remark") remark: String,
                          @(ApiModelProperty@field)(position = 1, example = "1232", value = "goodspayditch") @JsonProperty("goodspayditch") upgoodspayditchreq: Array[UpGoodspayditchReq])

@ApiModel(description = "更新商品橱窗渠道")
case class UpGoodspayditchReq(

                               @(ApiModelProperty@field)(position = 1, example = "1232", value = "id") @JsonProperty("id") var id: 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: Int,
                               @(ApiModelProperty@field)(position = 1, example = "1232", value = "appointpay") @JsonProperty("appointpay") appointpay: Long
                               //                              @(ApiModelProperty@field)(position = 4, example = "1232", value = "status") @JsonProperty("status") status: Int

                             )
case class Findbylikename(@BeanProperty count:Long, @BeanProperty goods:util.List[Goods])
case class SelectALl(@BeanProperty count:Long, @BeanProperty goods:util.List[Goods2])