orde.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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:已退款"`
  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 `description:"退款时间"`
  54. RefundRemark string `description:"退款原因说明"`
  55. OrderStatus int `comment:"订单状态,0:已取消、1:待支付、2:已支付、3:已退款"`
  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. CreateTime time.Time `comment:"创建时间"`
  68. ModifyTime time.Time `comment:"修改时间"`
  69. RegisterPlatform int `comment:"来源 1小程序,2:网页"`
  70. }
  71. func GetCygxOrderList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxOrderResp, err error) {
  72. o := orm.NewOrmUsingDB("hz_cygx")
  73. sql := `SELECT *
  74. FROM
  75. cygx_order
  76. WHERE 1 = 1 ` + condition
  77. sql += ` LIMIT ?,? `
  78. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  79. return
  80. }
  81. // 获取数量
  82. func GetCygxOrderCount(condition string, pars []interface{}) (count int, err error) {
  83. o := orm.NewOrmUsingDB("hz_cygx")
  84. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_order WHERE 1= 1 ` + condition
  85. err = o.Raw(sqlCount, pars).QueryRow(&count)
  86. return
  87. }
  88. // 根据订单编号获取订单详情
  89. func GetCygxOrderDetailByOrderCode(orderCode string) (item *CygxOrderResp, err error) {
  90. o := orm.NewOrmUsingDB("hz_cygx")
  91. sql := `SELECT * FROM cygx_order WHERE order_code = ? `
  92. err = o.Raw(sql, orderCode).QueryRow(&item)
  93. return
  94. }
  95. type OrderListResp struct {
  96. OrderCode string `comment:"订单编号"`
  97. UserId int `comment:"用户ID"`
  98. Mobile string `comment:"手机号"`
  99. Email string `comment:"邮箱"`
  100. CompanyId int `comment:"公司ID"`
  101. CompanyName string `comment:"公司名称"`
  102. RealName string `comment:"用户实际名称"`
  103. SellerName string `comment:"所属销售"`
  104. OrderMoney float64 `comment:"订单总价"`
  105. CreateTime string `comment:"创建时间"`
  106. SourceId int `comment:"来源ID"`
  107. Source string `comment:"来源\n报告 :article\n活动 :activity"`
  108. SourceTitle string `comment:"来源名称,活动或者报告标题"`
  109. OrderStatus int `comment:"订单状态码"`
  110. OrderStatusText string `comment:"订单状态描述"`
  111. StartDate string `comment:"开始日期"`
  112. EndDate string `comment:"结束日期"`
  113. InviteName string `description:"邀请人"`
  114. PayTime string `comment:"订单付款时间"`
  115. RefundTime string `comment:"订单退款时间"`
  116. RefundRemark string `description:"退款原因说明"`
  117. PaymentProject string `comment:"付款项目"`
  118. HttpUrl string `description:"跳转地址"`
  119. }
  120. type UserOrderListResp struct {
  121. Paging *paging.PagingItem `description:"分页数据"`
  122. List []*OrderListResp
  123. }