orde.go 6.2 KB

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