orde.go 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type CygxOrder struct {
  8. OrderId int `orm:"column(order_id);pk";comment:"订单id"`
  9. OrderCode string `comment:"订单编号"`
  10. OutTradeCode string `comment:"外部交易号"`
  11. PaymentType int `comment:"支付类型。支付类型。取值范围:1微信小程序,2微信扫码支付,3微信H5支付。"`
  12. GoodsName string `comment:"商品名称"`
  13. GoodsId int `comment:"商品ID"`
  14. BuyerInvoice string `comment:"买家发票信息"`
  15. GoodsMoney float64 `comment:"商品总价"`
  16. OrderMoney float64 `comment:"订单总价"`
  17. Point int `comment:"订单消耗积分"`
  18. PointMoney float64 `comment:"订单消耗积分抵多少钱"`
  19. PayMoney float64 `comment:"订单实付金额"`
  20. RefundMoney float64 `comment:"订单退款金额"`
  21. RefundTime time.Time `description:"退款时间"`
  22. RefundRemark string `description:"退款原因说明"`
  23. OrderStatus int `comment:"订单状态,0:已取消、1:待支付、2:已支付、3:退款成功、4:退款处理中、5:退款异常、6:退款关闭"`
  24. PayTime time.Time `comment:"订单付款时间"`
  25. SourceId int `comment:"来源ID"`
  26. Source string `comment:"来源\n报告 :article\n活动 :activity"`
  27. SourceTitle string `comment:"来源名称,活动或者报告标题"`
  28. UserId int `comment:"用户ID"`
  29. Mobile string `comment:"手机号"`
  30. Email string `comment:"邮箱"`
  31. CompanyId int `comment:"公司ID"`
  32. CompanyName string `comment:"公司名称"`
  33. RealName string `comment:"用户实际名称"`
  34. SellerName string `comment:"所属销售"`
  35. CreateTime time.Time `comment:"创建时间"`
  36. ModifyTime time.Time `comment:"修改时间"`
  37. RegisterPlatform int `comment:"来源 1小程序,2:网页"`
  38. }
  39. type CygxOrderResp struct {
  40. OrderId int `orm:"column(order_id);pk";comment:"订单id"`
  41. OrderCode string `comment:"订单编号"`
  42. OutTradeNo string `comment:"【商户订单号】 商户系统内部订单号"`
  43. OutTradeCode string `comment:"外部交易号"`
  44. PaymentType int `comment:"支付类型。取值范围:1微信支付,2支付宝支付。"`
  45. TradeType string `comment:"交易类型,枚举值:JSAPI:公众号支付 、 NATIVE:扫码支付 、 App:App支付 、 MICROPAY:付款码支付 、 MWEB:H5支付 、 FACEPAY:刷脸支付"`
  46. GoodsName string `comment:"商品名称"`
  47. GoodsId int `comment:"商品ID"`
  48. BuyerInvoice string `comment:"买家发票信息"`
  49. GoodsMoney float64 `comment:"商品总价"`
  50. OrderMoney float64 `comment:"订单总价"`
  51. Point int `comment:"订单消耗积分"`
  52. PointMoney float64 `comment:"订单消耗积分抵多少钱"`
  53. PayMoney float64 `comment:"订单实付金额"`
  54. RefundMoney float64 `comment:"订单退款金额"`
  55. RefundTime time.Time `comment:"退款时间"`
  56. RefundRemark string `comment:"退款原因说明"`
  57. OrderStatus int `comment:"订单状态,0:已取消、1:待支付、2:已支付、3:退款成功、4:退款处理中、5:退款异常、6:退款关闭"`
  58. PayTime time.Time `comment:"订单付款时间"`
  59. SourceId int `comment:"来源ID"`
  60. Source string `comment:"来源\n报告 :article\n活动 :activity"`
  61. SourceTitle string `comment:"来源名称,活动或者报告标题"`
  62. UserId int `comment:"用户ID"`
  63. Mobile string `comment:"手机号"`
  64. Email string `comment:"邮箱"`
  65. CompanyId int `comment:"公司ID"`
  66. CompanyName string `comment:"公司名称"`
  67. RealName string `comment:"用户实际名称"`
  68. SellerName string `comment:"所属销售"`
  69. StartDate time.Time `comment:"开始日期"`
  70. EndDate time.Time `comment:"结束日期"`
  71. CreateTime time.Time `comment:"创建时间"`
  72. ModifyTime time.Time `comment:"修改时间"`
  73. RegisterPlatform int `comment:"来源 1小程序,2:网页"`
  74. ShareId int `comment:"分享人ID"`
  75. ShareName string `comment:"分享人姓名"`
  76. }
  77. func GetCygxOrderList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxOrderResp, err error) {
  78. o := orm.NewOrmUsingDB("hz_cygx")
  79. sql := `SELECT *
  80. FROM
  81. cygx_order
  82. WHERE 1 = 1 ` + condition
  83. sql += ` LIMIT ?,? `
  84. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  85. return
  86. }
  87. // 获取数量
  88. func GetCygxOrderCount(condition string, pars []interface{}) (count int, err error) {
  89. o := orm.NewOrmUsingDB("hz_cygx")
  90. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_order WHERE 1= 1 ` + condition
  91. err = o.Raw(sqlCount, pars).QueryRow(&count)
  92. return
  93. }
  94. // 根据订单编号获取订单详情
  95. func GetCygxOrderDetailByOrderCode(orderCode string) (item *CygxOrderResp, err error) {
  96. o := orm.NewOrmUsingDB("hz_cygx")
  97. sql := `SELECT * FROM cygx_order WHERE order_code = ? `
  98. err = o.Raw(sql, orderCode).QueryRow(&item)
  99. return
  100. }
  101. type OrderListResp struct {
  102. OrderCode string `comment:"订单编号"`
  103. UserId int `comment:"用户ID"`
  104. Mobile string `comment:"手机号"`
  105. Email string `comment:"邮箱"`
  106. CompanyId int `comment:"公司ID"`
  107. CompanyName string `comment:"公司名称"`
  108. RealName string `comment:"用户实际名称"`
  109. SellerName string `comment:"所属销售"`
  110. OrderMoney float64 `comment:"订单总价"`
  111. CreateTime string `comment:"创建时间"`
  112. SourceId int `comment:"来源ID"`
  113. Source string `comment:"来源\n报告 :article\n活动 :activity"`
  114. SourceTitle string `comment:"来源名称,活动或者报告标题"`
  115. OrderStatus int `comment:"订单状态码"`
  116. OrderStatusText string `comment:"订单状态描述"`
  117. PaymentTypeText string `comment:"支付类型。取值范围:1微信小程序,2微信扫码支付,3微信H5支付。"`
  118. StartDate string `comment:"开始日期"`
  119. EndDate string `comment:"结束日期"`
  120. InviteName string `description:"邀请人"`
  121. PayTime string `comment:"订单付款时间"`
  122. RefundTime string `comment:"订单退款时间"`
  123. RefundRemark string `description:"退款原因说明"`
  124. PaymentProject string `comment:"付款项目"`
  125. HttpUrl string `description:"跳转地址"`
  126. }
  127. type UserOrderListResp struct {
  128. Paging *paging.PagingItem `description:"分页数据"`
  129. List []*OrderListResp
  130. }