update 集团

This commit is contained in:
2024-01-18 16:38:18 +08:00
parent 63ae3c8ab7
commit e291e53f13
2 changed files with 27 additions and 1 deletions

View File

@@ -23,6 +23,8 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
/**
@@ -69,6 +71,11 @@ public class MemberGroupServiceImpl implements MemberGroupService {
if (CollectionUtils.isEmpty(resultList)) {
return Lists.newArrayList();
}
for (MemberGroupVO memberGroupVO : resultList) {
BigDecimal discount = memberGroupVO.getDiscount();
// 返回给前端乘以10
memberGroupVO.setDiscount(discount.multiply(BigDecimal.TEN));
}
return resultList;
}
@@ -89,9 +96,24 @@ public class MemberGroupServiceImpl implements MemberGroupService {
} catch (Exception e) {
}
if (isBetween(memberGroup.getDiscount())) {
// 入库除以10
memberGroup.setDiscount(memberGroup.getDiscount().divide(BigDecimal.TEN, 2, RoundingMode.DOWN));
}
return memberGroupMapper.insertMemberGroup(memberGroup);
}
private boolean isBetween(BigDecimal price){
BigDecimal start = BigDecimal.ZERO;
BigDecimal end = BigDecimal.TEN;
return isBetween(price, start, end);
}
private boolean isBetween(BigDecimal price, BigDecimal start, BigDecimal end){
return price.compareTo(start) > 0 && price.compareTo(end) < 0;
}
// 生成编号
private String generateGroupCode() {
while (true) {

View File

@@ -104,7 +104,11 @@
<dict-tag :options="dict.type.group_type" :value="scope.row.groupType" />
</template>
</el-table-column>
<el-table-column label="折扣率" align="center" prop="discount" />
<el-table-column label="折扣率" align="center" prop="discount" >
<template slot-scope="scope">
<span>{{ scope.row.discount }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"