model.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package model
  2. import (
  3. "fmt"
  4. "strings"
  5. "go-common/library/time"
  6. )
  7. //Order...主订单表状态
  8. const (
  9. OrderPaid = 2
  10. OrderRefunded = 3
  11. OrderRefundPartly = 2
  12. OrderRefundedAll = 4
  13. )
  14. //DistOrder...分销订单表状态
  15. const (
  16. DistOrderNormal = 1
  17. DistOrderRefunded = 2
  18. DistOrderPartlyRefunded = 3
  19. )
  20. // SpecsSeparator sku 规格分隔符
  21. const SpecsSeparator = "_"
  22. //OrderInfo 订单同步字段
  23. type OrderInfo struct {
  24. Oid uint64 `json:"oid"`
  25. CmAmount uint64 `json:"cm_amount"`
  26. CmMethod int64 `json:"cm_method"`
  27. CmPrice uint64 `json:"cm_price"`
  28. Duid uint64 `json:"duid"`
  29. Stat int64 `json:"status"`
  30. Pid uint64 `json:"pid"`
  31. Count uint64 `json:"count"`
  32. Sid uint64 `json:"sid"`
  33. Type int64 `json:"type"`
  34. PayAmount uint64 `json:"pay_amount"`
  35. Serial string `json:"serial_num"`
  36. Ctime time.Time `json:"ctime"`
  37. Mtime time.Time `json:"mtime"`
  38. }
  39. //OrderStockCnt 订单库存
  40. type OrderStockCnt struct {
  41. OrderID int64
  42. Count int64
  43. }
  44. //SkuCnt sku库存
  45. type SkuCnt struct {
  46. SkuID int64
  47. Count int64
  48. }
  49. //Batch 批量库存操作
  50. type Batch struct {
  51. ScreenID int64 // 场次 ID
  52. TicketPriceID int64 // 票价 ID 就是 sku_stock SKUID
  53. SkAlert int64 // 库存预警数
  54. TotalStock int64 // 总库存数
  55. }
  56. //Specs 生成库存规格
  57. func (b *Batch) Specs() (s string) {
  58. s = fmt.Sprintf("%d%s%d", b.ScreenID, SpecsSeparator, b.TicketPriceID)
  59. return
  60. }
  61. //InsPlHlds insert语句占位符
  62. func InsPlHlds(colCnt int, rowCnt int) string {
  63. hLen := colCnt*2 + 2
  64. h := make([]byte, hLen)
  65. h[0] = '('
  66. h[hLen-2] = ')'
  67. h[hLen-1] = ','
  68. copy(h[1:], []byte(strings.Repeat(",?", colCnt)[1:]))
  69. bPlHlds := make([]byte, hLen*rowCnt-1)
  70. j := 0
  71. for i := 0; i < rowCnt; i++ {
  72. copy(bPlHlds[j:], h)
  73. j += hLen
  74. }
  75. return string(bPlHlds)
  76. }