|
|
@@ -22,7 +22,7 @@ func AddResourceSpecification(doerId int64, req models.ResourceSpecificationReq) |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func UpdateResourceSpecification(doerId int64, specId int64, req models.ResourceSpecificationReq) *response.BizError { |
|
|
|
func UpdateSpecUnitPrice(doerId int64, specId int64, unitPrice int) *response.BizError { |
|
|
|
oldSpec, err := models.GetResourceSpecification(&models.ResourceSpecification{ID: specId}) |
|
|
|
if err != nil { |
|
|
|
return response.NewBizError(err) |
|
|
@@ -30,14 +30,12 @@ func UpdateResourceSpecification(doerId int64, specId int64, req models.Resource |
|
|
|
if oldSpec == nil { |
|
|
|
return response.SPECIFICATION_NOT_EXIST |
|
|
|
} |
|
|
|
n, err := models.UpdateResourceSpecificationById(specId, models.ResourceSpecification{ |
|
|
|
UnitPrice: req.UnitPrice, |
|
|
|
}) |
|
|
|
err = models.UpdateSpecUnitPriceById(specId, unitPrice) |
|
|
|
if err != nil { |
|
|
|
return response.NewBizError(err) |
|
|
|
} |
|
|
|
|
|
|
|
if n > 0 { |
|
|
|
if oldSpec.UnitPrice != unitPrice { |
|
|
|
newSpec, _ := models.GetResourceSpecification(&models.ResourceSpecification{ID: specId}) |
|
|
|
AddSpecOperateLog(doerId, "edit", newSpec, oldSpec, fmt.Sprintf("修改单价从%d积分到%d积分", oldSpec.UnitPrice, newSpec.UnitPrice)) |
|
|
|
} |
|
|
@@ -134,7 +132,7 @@ func GetResourceSpecificationScenes(specId int64) ([]models.ResourceSceneBriefRe |
|
|
|
return r, nil |
|
|
|
} |
|
|
|
|
|
|
|
func ResourceSpecOnShelf(doerId int64, id int64, req models.ResourceSpecificationReq) *response.BizError { |
|
|
|
func ResourceSpecOnShelf(doerId int64, id int64, unitPrice int) *response.BizError { |
|
|
|
spec, err := models.GetResourceSpecification(&models.ResourceSpecification{ID: id}) |
|
|
|
if err != nil { |
|
|
|
return response.NewBizError(err) |
|
|
@@ -146,13 +144,11 @@ func ResourceSpecOnShelf(doerId int64, id int64, req models.ResourceSpecificatio |
|
|
|
return response.RESOURCE_QUEUE_NOT_AVAILABLE |
|
|
|
} |
|
|
|
|
|
|
|
n, err := models.ResourceSpecOnShelf(id, models.ResourceSpecification{ |
|
|
|
UnitPrice: req.UnitPrice, |
|
|
|
}) |
|
|
|
err = models.ResourceSpecOnShelf(id, unitPrice) |
|
|
|
if err != nil { |
|
|
|
return response.NewBizError(err) |
|
|
|
} |
|
|
|
if n > 0 { |
|
|
|
if spec.UnitPrice != unitPrice { |
|
|
|
newSpec, _ := models.GetResourceSpecification(&models.ResourceSpecification{ID: id}) |
|
|
|
AddSpecOperateLog(doerId, "on-shelf", newSpec, spec, fmt.Sprintf("修改单价从%d积分到%d积分", spec.UnitPrice, newSpec.UnitPrice)) |
|
|
|
} |
|
|
|