future_good_chart_info.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package data_manage
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. // EditFutureGoodChartEnInfoAndEdbEnInfo 更改商品价格曲线英文信息
  7. func EditFutureGoodChartEnInfoAndEdbEnInfo(chartInfoId int, chartNameEn string, edbInfoId int, edbNameEn, edbUnitEn string) (err error) {
  8. o := orm.NewOrmUsingDB("data")
  9. to, err := o.Begin()
  10. if err != nil {
  11. return
  12. }
  13. defer func() {
  14. if err != nil {
  15. _ = to.Rollback()
  16. } else {
  17. _ = to.Commit()
  18. }
  19. }()
  20. sql := ` UPDATE chart_info
  21. SET
  22. chart_name_en =?,
  23. modify_time = NOW()
  24. WHERE chart_info_id = ?`
  25. _, err = to.Raw(sql, chartNameEn, chartInfoId).Exec()
  26. if err != nil {
  27. fmt.Println("UPDATE chart_info Err:", err.Error())
  28. return err
  29. }
  30. var count int
  31. csql := `SELECT COUNT(1) AS count FROM chart_edb_mapping WHERE chart_info_id=? AND edb_info_id=? AND source = 1 `
  32. err = to.Raw(csql, chartInfoId, edbInfoId).QueryRow(&count)
  33. if err != nil {
  34. fmt.Println("QueryRow Err:", err.Error())
  35. return err
  36. }
  37. if count > 0 {
  38. msql := ` UPDATE edb_info
  39. SET edb_name_en = ?,
  40. unit_en = ?,
  41. modify_time = NOW()
  42. WHERE edb_info_id = ? `
  43. _, err = to.Raw(msql, edbNameEn, edbUnitEn, edbInfoId).Exec()
  44. if err != nil {
  45. fmt.Println("edb_info Err:" + err.Error())
  46. return err
  47. }
  48. }
  49. return
  50. }
  51. // EditFutureGoodProfitChartEnInfoAndEdbEnInfo 更改商品利润曲线英文信息
  52. func EditFutureGoodProfitChartEnInfoAndEdbEnInfo(chartInfoId int, chartNameEn string, edbInfoId int, edbNameEn, edbUnitEn, profitNameEn string) (err error) {
  53. o := orm.NewOrmUsingDB("data")
  54. to, err := o.Begin()
  55. if err != nil {
  56. return
  57. }
  58. defer func() {
  59. if err != nil {
  60. _ = to.Rollback()
  61. } else {
  62. _ = to.Commit()
  63. }
  64. }()
  65. sql := ` UPDATE chart_info
  66. SET chart_name_en =?,modify_time = NOW()
  67. WHERE chart_info_id = ?`
  68. _, err = to.Raw(sql, chartNameEn, chartInfoId).Exec()
  69. if err != nil {
  70. fmt.Println("UPDATE chart_info Err:", err.Error())
  71. return
  72. }
  73. // 更改指标英文信息
  74. sql = ` UPDATE edb_info
  75. SET edb_name_en = ?,unit_en = ?,modify_time = NOW()
  76. WHERE edb_info_id = ? `
  77. _, err = to.Raw(sql, edbNameEn, edbUnitEn, edbInfoId).Exec()
  78. if err != nil {
  79. fmt.Println("edb_info Err:" + err.Error())
  80. return
  81. }
  82. // 更改指标英文信息
  83. sql = ` UPDATE chart_info_future_good_profit
  84. SET profit_name_en = ?,modify_time = NOW()
  85. WHERE chart_info_id = ? `
  86. _, err = to.Raw(sql, profitNameEn, chartInfoId).Exec()
  87. if err != nil {
  88. fmt.Println("chart_info_future_good_profit Err:" + err.Error())
  89. return
  90. }
  91. return
  92. }