order_action.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // /订单操作表
  7. type CygxOrderAction struct {
  8. ActionId int `orm:"column(action_id);pk";comment:"动作id"`
  9. Action string `comment:"动作内容"`
  10. OrderStatus int `comment:"订单状态,0:已取消、1:待支付、2:已支付、3:已退款"`
  11. OrderStatusText string `comment:"订单状态名称"`
  12. OrderCode string `comment:"订单编号"`
  13. UserId int `comment:"用户ID"`
  14. Mobile string `comment:"手机号"`
  15. Email string `comment:"邮箱"`
  16. CompanyId int `comment:"公司ID"`
  17. CompanyName string `comment:"公司名称"`
  18. RealName string `comment:"用户实际名称"`
  19. SellerName string `comment:"所属销售"`
  20. CreateTime time.Time `comment:"创建时间"`
  21. ModifyTime time.Time `comment:"修改时间"`
  22. RegisterPlatform int `comment:"来源 1小程序,2:网页"`
  23. AdminId int `comment:"管理员ID"`
  24. AdminName string `comment:"管理员姓名"`
  25. }
  26. func AddCygxOrderRefundRevoke(item *CygxOrderAction) (err error) {
  27. to := orm.NewOrmUsingDB("hz_cygx")
  28. o, err := to.Begin()
  29. if err != nil {
  30. return
  31. }
  32. defer func() {
  33. if err != nil {
  34. _ = o.Rollback()
  35. } else {
  36. _ = o.Commit()
  37. }
  38. }()
  39. updateParams := make(map[string]interface{})
  40. updateParams["OrderStatus"] = 6 //退款关闭
  41. ptrStructOrTableName := "cygx_order"
  42. whereParam := map[string]interface{}{"order_code": item.OrderCode}
  43. qs := o.QueryTable(ptrStructOrTableName)
  44. for expr, exprV := range whereParam {
  45. qs = qs.Filter(expr, exprV)
  46. }
  47. _, err = qs.Update(updateParams)
  48. if err != nil {
  49. return
  50. }
  51. _, err = o.Insert(item)
  52. return
  53. }
  54. //// 添加CygxOrderRefund
  55. //func AddCygxOrderRefundRevoke(item *CygxOrderRefund) (err error) {
  56. // to := orm.NewOrmUsingDB("hz_cygx")
  57. // o, err := to.Begin()
  58. // if err != nil {
  59. // return
  60. // }
  61. // defer func() {
  62. // if err != nil {
  63. // _ = o.Rollback()
  64. // } else {
  65. // _ = o.Commit()
  66. // }
  67. // }()
  68. // updateParams := make(map[string]interface{})
  69. // updateParams["OrderStatus"] = 3
  70. // updateParams["RefundMoney"] = item.RefundMoney
  71. // updateParams["RefundRemark"] = item.Remark
  72. // updateParams["RefundTime"] = time.Now()
  73. // ptrStructOrTableName := "cygx_order"
  74. // whereParam := map[string]interface{}{"order_code": item.OrderCode}
  75. // qs := o.QueryTable(ptrStructOrTableName)
  76. // for expr, exprV := range whereParam {
  77. // qs = qs.Filter(expr, exprV)
  78. // }
  79. // _, err = qs.Update(updateParams)
  80. // if err != nil {
  81. // return
  82. // }
  83. // _, err = o.Insert(item)
  84. // return
  85. //}