orde.go 6.7 KB

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