merchant_data_api_price_list.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package accounting
  4. import (
  5. "context"
  6. "gd_management/apis"
  7. "gd_management/common.in/utils"
  8. "gd_management/errors"
  9. "github.com/astaxie/beego/orm"
  10. "go.uber.org/zap"
  11. )
  12. func MerchantDataApiPriceList(ctx context.Context, req *apis.MerchantDataApiPriceListReq, reply *apis.MerchantDataApiPriceListReply) error {
  13. if req.MerchantId == 0 {
  14. return errors.ArgsError
  15. }
  16. o := orm.NewOrm()
  17. _, err := o.Raw("select t1.id as merchant_data_api_id,t1.unit_price,t1.merchant_id,t1.alias,t3.data_api_name as merchant_data_api_name from t_gd_merchant_data_api as t1 left join t_gd_data_api_query_type as t2 on t1.query_type_id=t2.id left join t_gd_data_api as t3 on t3.id=t2.data_api_id where t1.merchant_id=?", req.MerchantId).QueryRows(&reply.List)
  18. if err != nil {
  19. l.Error("func",
  20. zap.String("call", "MerchantDataApiPriceList"),
  21. zap.String("args", utils.MarshalJsonString(req)),
  22. zap.String("error", err.Error()))
  23. return errors.DataBaseError
  24. }
  25. for index, _ := range reply.List {
  26. if reply.List[index].Alias != "" {
  27. reply.List[index].MerchantDataApiName = reply.List[index].Alias
  28. }
  29. }
  30. // select t1.id,t1.unit_price,t1.merchant_id,t1.alias,t3.data_api_name from t_gd_merchant_data_api as t1 left join t_gd_data_api_query_type as t2 on t1.query_type_id=t2.id left join t_gd_data_api as t3 on t3.id=t2.data_api_id
  31. return nil
  32. }