rdluck 4 ani în urmă
părinte
comite
b5d5d21621
2 a modificat fișierele cu 55 adăugiri și 25 ștergeri
  1. 36 14
      models/data_source_longzhong.go
  2. 19 11
      services/data_source_longzhong.go

+ 36 - 14
models/data_source_longzhong.go

@@ -219,14 +219,16 @@ func ModifyLongzhonginfoIsNormal(longzhonginfoId int) (err error) {
 }
 
 type LzPriceInfo struct {
-	Standard    string `json:"standard"`
-	ModelName   string `json:"modelName"`
-	Unit        string `json:"unit"`
-	AreaName    string `json:"areaName"`
-	PriceType   string `json:"priceType"`
-	Memo        string `json:"memo"`
-	Id          string `json:"id"`
-	ProductName string `json:"productName"`
+	Standard        string `json:"standard"`
+	ModelName       string `json:"modelName"`
+	Unit            string `json:"unit"`
+	AreaName        string `json:"areaName"`
+	PriceType       string `json:"priceType"`
+	Memo            string `json:"memo"`
+	Id              string `json:"id"`
+	ProductName     string `json:"productName"`
+	MarketName      string `json:"marketName"`
+	ManufactureName string `json:"manufactureName"`
 }
 
 type LzPriceInfoResp struct {
@@ -247,6 +249,8 @@ type Longzhongpriceinfo struct {
 	ProductName          string
 	InfoType             string
 	InfoTypeRemark       string
+	MarketName           string
+	ManufactureName      string
 }
 
 func AddLongzhongpriceinfo(item *Longzhongpriceinfo) (newId int64, err error) {
@@ -270,7 +274,7 @@ func GetLongzhongpriceinfo() (items []*Longzhongpriceinfo, err error) {
 	o := orm.NewOrm()
 	o.Using("edb")
 	sql := `SELECT * FROM longzhongpriceinfo `
-	_,err = o.Raw(sql).QueryRows(&items)
+	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
@@ -308,9 +312,9 @@ func GetLongzhongpricedataCount(unitid, priceDate string) (count int, err error)
 }
 
 type LzPriceData struct {
-	Id         string  `json:"id"`
-	PriceDate  string  `json:"priceDate"`
-	Memo       string  `json:"memo"`
+	Id         string `json:"id"`
+	PriceDate  string `json:"priceDate"`
+	Memo       string `json:"memo"`
 	Price      string `json:"price"`
 	CnyPrice   string `json:"cnyPrice"`
 	ZsyPrice   string `json:"zsyPrice"`
@@ -320,7 +324,7 @@ type LzPriceData struct {
 	RisePrice  string `json:"risePrice"`
 	TonPrice   string `json:"tonPrice"`
 	PriceType  string `json:"priceType"`
-	UpdateDate string  `json:"updateDate"`
+	UpdateDate string `json:"updateDate"`
 }
 
 type LzPriceDataResp struct {
@@ -365,4 +369,22 @@ func GetLongzhongPriceDataById(lzPriceInfoId int) (items []*LongzhongpricedataIt
 	sql := `SELECT * FROM longzhongpricedata WHERE longzhongpriceinfo_id=? ORDER BY price_date DESC `
 	_, err = o.Raw(sql, lzPriceInfoId).QueryRows(&items)
 	return
-}
+}
+
+func ModifyLongzhongpriceinfo(item *Longzhongpriceinfo) (err error) {
+	o := orm.NewOrm()
+	o.Using("edb")
+	sql := `UPDATE  longzhongpriceinfo
+SET
+  standard = ?,
+  model_name = ?,
+  unit= ?,
+  area_name=?,
+  price_type = ?,
+  memo = ?,
+  market_name = ?,
+  manufacture_name = ?
+WHERE price_id = ? `
+	_, err = o.Raw(sql, item.Standard, item.ModelName, item.Unit, item.AreaName, item.PriceType, item.Memo, item.MarketName, item.ManufactureName, item.PriceId).Exec()
+	return
+}

+ 19 - 11
services/data_source_longzhong.go

@@ -672,20 +672,28 @@ func GetLzProductPriceProduct() (err error) {
 				msg = "判断隆众价格指标是否存在失败:err " + err.Error()
 				return err
 			}
+			item := new(models.Longzhongpriceinfo)
+			item.Standard = n.Standard
+			item.ModelName = n.ModelName
+			item.Unit = n.Unit
+			item.AreaName = n.AreaName
+			item.PriceType = n.PriceType
+			item.Memo = n.Memo
+			item.PriceId = n.Id
+			item.ProductName = n.ProductName
+			item.InfoType = k
+			item.InfoTypeRemark = v
+			item.MarketName = n.MarketName
+			item.ManufactureName = n.ManufactureName
 			if count > 0 {
 				fmt.Println("存在", n.ProductName, n.Id)
+				//修改
+				err = models.ModifyLongzhongpriceinfo(item)
+				if err != nil {
+					msg = "修改隆众价格指标失败:err " + err.Error()
+					return err
+				}
 			} else {
-				item := new(models.Longzhongpriceinfo)
-				item.Standard = n.Standard
-				item.ModelName = n.ModelName
-				item.Unit = n.Unit
-				item.AreaName = n.AreaName
-				item.PriceType = n.PriceType
-				item.Memo = n.Memo
-				item.PriceId = n.Id
-				item.ProductName = n.ProductName
-				item.InfoType = k
-				item.InfoTypeRemark = v
 				_, err = models.AddLongzhongpriceinfo(item)
 				if err != nil {
 					msg = "新增隆众价格指标失败:err " + err.Error()