order_detail.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package dao
  2. import (
  3. "context"
  4. "database/sql"
  5. "encoding/json"
  6. "go-common/app/common/openplatform/encoding"
  7. "go-common/app/service/openplatform/ticket-sales/api/grpc/type"
  8. rpc "go-common/app/service/openplatform/ticket-sales/api/grpc/v1"
  9. "go-common/library/log"
  10. )
  11. const (
  12. // 更新购买人信息
  13. _updateDetailBuyer = "update order_detail set buyer = ?,tel = ?,personal_id = ? where order_id = ?"
  14. // 更新配送信息
  15. _updateDetailDelivery = "update order_detail set deliver_detail = ? where order_id = ?"
  16. )
  17. //UpdateDetailBuyer 更新购买人信息
  18. func (d *Dao) UpdateDetailBuyer(c context.Context, req *rpc.UpBuyerRequest) (num int64, err error) {
  19. var res sql.Result
  20. PersonIDEnc, _ := encoding.Encrypt(req.Buyers.PersonalID, d.c.Encrypt)
  21. TelEnc, _ := encoding.Encrypt(req.Buyers.Tel, d.c.Encrypt)
  22. if res, err = d.db.Exec(c, _updateDetailBuyer, req.Buyers.Name, TelEnc, string(PersonIDEnc), req.OrderID); err != nil {
  23. log.Warn("更新订单详情%d失败", req.OrderID)
  24. return
  25. }
  26. return res.RowsAffected()
  27. }
  28. //UpdateDetailDelivery 更新配送信息
  29. func (d *Dao) UpdateDetailDelivery(c context.Context, arg *_type.OrderDeliver, orderID int64) (num int64, err error) {
  30. var res sql.Result
  31. arg.Tel, _ = encoding.Encrypt(arg.Tel, d.c.Encrypt)
  32. DeliverDetail, err := json.Marshal(arg)
  33. if err != nil {
  34. log.Warn("更新订单详情%d失败", orderID)
  35. }
  36. if res, err = d.db.Exec(c, _updateDetailDelivery, string(DeliverDetail), orderID); err != nil {
  37. log.Warn("更新订单详情%d失败", orderID)
  38. return
  39. }
  40. return res.RowsAffected()
  41. }