转换价格金额元->分

This commit is contained in:
sxu 2025-07-04 13:59:09 +08:00
parent 4fe5bf5c20
commit 8f2c2adfc9
1 changed files with 6 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package com.bonus.canteen.core.cook.service.impl;
import java.util.List;
import java.util.Objects;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
@ -71,6 +73,8 @@ public class CookMaterialServiceImpl implements ICookMaterialService {
if (cookMaterialMapper.checkIsExistByName(cookMaterial.getMaterialName(), null) > 0) {
throw new ServiceException("该原料名称已存在");
}
cookMaterial.setSalePrice(Objects.isNull(cookMaterial.getSalePrice()) ? 0L : cookMaterial.getSalePrice() * 100);
cookMaterial.setUnitPrice(Objects.isNull(cookMaterial.getUnitPrice()) ? 0L : cookMaterial.getUnitPrice() * 100);
return cookMaterialMapper.insertCookMaterial(cookMaterial);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
@ -108,6 +112,8 @@ public class CookMaterialServiceImpl implements ICookMaterialService {
if (cookMaterialMapper.checkIsExistByName(cookMaterial.getMaterialName(), cookMaterial.getMaterialId()) > 0) {
throw new ServiceException("该原料名称已存在");
}
cookMaterial.setSalePrice(Objects.isNull(cookMaterial.getSalePrice()) ? 0L : cookMaterial.getSalePrice() * 100);
cookMaterial.setUnitPrice(Objects.isNull(cookMaterial.getUnitPrice()) ? 0L : cookMaterial.getUnitPrice() * 100);
return cookMaterialMapper.updateCookMaterial(cookMaterial);
} catch (Exception e) {
throw new ServiceException(e.getMessage());