order_set_price.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package user_merchant
  2. import (
  3. "context"
  4. "gd_management/apis"
  5. "gd_management/common.in/storage"
  6. "gd_management/common.in/utils"
  7. "gd_management/errors"
  8. "fmt"
  9. "github.com/astaxie/beego/orm"
  10. "go.uber.org/zap"
  11. )
  12. func ManagementSetMerchantOrderPrice(ctx context.Context, req *apis.ManagementSetMerchantOrderPriceReq, reply *apis.ManagementSetMerchantOrderPriceReply) (err error) {
  13. task := func(o orm.Ormer) error {
  14. _, err := o.Raw("update t_gd_data_api_order set goods_price=? where id=?", req.Price, req.OrderId).Exec()
  15. if err != nil {
  16. l.Error("mysql",
  17. zap.String("sql", "update t_gd_data_api_order set goods_price=?where id=?"),
  18. zap.String("fields", fmt.Sprintf("goods_price:%f id:%d", req.Price, req.OrderId)),
  19. zap.String("error", err.Error()))
  20. if err == orm.ErrNoRows {
  21. return errors.DataBaseNoRecord
  22. }
  23. return errors.DataBaseError
  24. }
  25. return nil
  26. }
  27. tasks := []storage.DbaTasker{}
  28. tasks = append(tasks, storage.GenerateDbaTask(task))
  29. storage.ExecTrans(tasks...)
  30. l.Debug(utils.MarshalJsonString(req, reply))
  31. return nil
  32. }