瀏覽代碼

fix(设备计费单价): int改为float64

likai 4 年之前
父節點
當前提交
624d3d1ba1

+ 2 - 2
handler/equipment.go

@@ -326,10 +326,10 @@ func (e *Equipment) UpdateUnitfPrice(ctx context.Context, req *equipment2.Instru
 		return err
 	}
 	g.Log().Info("Received Equipment.UpdateUnitfPrice request @ " + tenant)
-	if strconv.Itoa(req.InstrumentId) == "" || strconv.Itoa(req.UnitCount) == "" {
+	if req.InstrumentId == 0 || req.UnitCount < 0 {
 		return errors.New("请输入完成参数!")
 	}
-	err = equipment.NewSrv(tenant).UpdateUnitfPrice(req.InstrumentId, req.UnitCount)
+	err = equipment.NewSrv(tenant).UpdateUnitPrice(req.InstrumentId, req.UnitCount)
 	_, err, code, msg := myerrors.CheckError(err)
 	rsp.Code = code
 	rsp.Msg = msg

+ 1 - 1
model/consequent/internal/consequent.go

@@ -21,7 +21,7 @@ type Consequent struct {
 	Code        string      `orm:"Code"        json:"code"`        // 成果编号
 	OwnersId    string      `orm:"OwnersId"    json:"ownersId"`    // 获得者
 	OwnersName  string      `orm:"OwnersName"  json:"ownersName"`  // 获得者名称
-	MediaIds    string      `orm:"MediaIds" 	json:"media_ids"`     // 成果附件Id
+	MediaIds    string      `orm:"MediaIds"    json:"media_ids"`     // 成果附件Id
 	PublishTime *gtime.Time `orm:"PublishTime" json:"publishTime"` // 获得时间
 	ProjectId   int         `orm:"ProjectId"   json:"projectId"`   // 项目ID
 	ProjectName string      `orm:"ProjectName" json:"projectName"` // 项目名称

+ 4 - 4
model/equipment/instrument.go

@@ -16,7 +16,7 @@ type Instrument internal2.Instrument
 // 设备Id、计费单价
 type InstrumentId struct {
 	InstrumentId int `json:"instrument_id"` // 设备Id
-	UnitCount    int `json:"unit_count"`    // 计费单价
+	UnitCount    float64 `json:"unit_count"`    // 计费单价
 	Rate         int `json:"rate"`          // 优惠比例
 }
 type InstrumentEntity struct {
@@ -30,10 +30,10 @@ type SearchEntity struct {
 	InstrType               int         `orm:"InstrType"               json:"instr_type"`                 // 设备类别
 	InstrTypeStr            string      `orm:"-"                       json:"-"           excel:"设备类别"`   // 设备类别
 	Brand                   string      `orm:"Brand"                   json:"brand"       excel:"设备品牌"`   // 设备品牌
-	Belongs                 int         `orm:"Belongs"  			   json:"belongs"`                             // 设备所属 1内部 2外部
-	BelongsName             string      `orm:"BelongsName"      	   json:"belongs_name"`                  // 设备所属名称
+	Belongs                 int         `orm:"Belongs"                 json:"belongs"`                             // 设备所属 1内部 2外部
+	BelongsName             string      `orm:"BelongsName"             json:"belongs_name"`                  // 设备所属名称
 	Rate                    int         `orm:"Rate"                    json:"rate"`                       // 优惠比例
-	UnitCount               int         `orm:"UnitCount"               json:"unit_count"`                 // 计费单价
+	UnitCount               float64     `orm:"UnitCount"               json:"unit_count"`                 // 计费单价
 	FactoryNum              string      `orm:"FactoryNum"              json:"factory_num" excel:"出厂编号"`   // 出厂编号
 	Status                  int         `orm:"Status"                  json:"status"`                     // 设备状态
 	StatusStr               string      `orm:"-"                       json:"-"           excel:"设备状态"`   // 设备状态 string

+ 1 - 1
model/equipment/internal/instrument.go

@@ -25,7 +25,7 @@ type Instrument struct {
 	Belongs                 int         `orm:"Belongs"                 json:"belongs"`                 // 设备所属 1内部 2外部
 	BelongsName             int         `orm:"BelongsName"             json:"belongsName"`             // 设备所属名称
 	Rate                    int         `orm:"Rate"                    json:"rate"`                    // 优惠比例
-	UnitCount               int         `orm:"UnitCount"               json:"unitCount"`               // 计费单价
+	UnitCount               float64     `orm:"UnitCount"               json:"unitCount"`               // 计费单价
 	CountType               string      `orm:"-"                       json:"countType"`               // 计费方式
 	Location                string      `orm:"Location"                json:"location"`                // 设备所在位置
 	Remark                  string      `orm:"Remark"                  json:"remark"`                  // 备注

+ 2 - 2
service/equipment/equipment.go

@@ -287,8 +287,8 @@ func (s Service) GetUnitCount(instrumentId int) (rspInfo []equipment2.Instrument
 }
 
 // UpdateUnifPrice 更新计费价格
-func (s Service) UpdateUnitfPrice(instrumentId, unitCount int) error {
-	_, err := s.Dao.DB.Model("Instrument").Update("unitCount = "+strconv.Itoa(unitCount), "Id = "+
+func (s Service) UpdateUnitPrice(instrumentId int, unitCount float64) error {
+	_, err := s.Dao.DB.Model("Instrument").Update(fmt.Sprintf("unitCount=%v", unitCount), "Id = "+
 		strconv.Itoa(instrumentId))
 	if err != nil {
 		return err