diff --git a/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/UBillRuleController.java b/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/UBillRuleController.java new file mode 100644 index 0000000..b22b1eb --- /dev/null +++ b/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/UBillRuleController.java @@ -0,0 +1,69 @@ +package org.wfc.system.controller; + +import cn.hutool.core.collection.CollUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.wfc.common.core.web.controller.BaseController; +import org.wfc.common.core.web.domain.AjaxResult; +import org.wfc.common.core.web.page.TableDataInfo; +import org.wfc.system.domain.UBillRule; +import org.wfc.system.service.IUBillRuleService; + +import java.util.List; + +/** + *

+ * 用户平台-计费规则表 前端控制器 + *

+ * + * @author sys + * @since 2025-01-07 + */ +@RestController +@RequestMapping("/billRule") +public class UBillRuleController extends BaseController { + + @Autowired + private IUBillRuleService uBillRuleService; + + @GetMapping("/page") + public TableDataInfo page(UBillRule uBillRule) { + startPage(); + List list = uBillRuleService.list(); + return getDataTable(list); + } + + @GetMapping("/list") + public AjaxResult list(UBillRule uBillRule) { + List list = uBillRuleService.list(); + return success(list); + } + + @GetMapping(value = "/{id}") + public AjaxResult getById(@PathVariable("id") Long id) { + return success(uBillRuleService.getById(id)); + } + + @PostMapping + public AjaxResult add(@RequestBody UBillRule uBillRule) { + return toAjax(uBillRuleService.save(uBillRule)); + } + + @PutMapping + public AjaxResult edit(@RequestBody UBillRule uBillRule) { + return toAjax(uBillRuleService.updateById(uBillRule)); + } + + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(uBillRuleService.removeByIds(CollUtil.newArrayList(ids))); + } + +} diff --git a/wfc-modules/wfc-system/src/main/java/org/wfc/system/domain/UBillRule.java b/wfc-modules/wfc-system/src/main/java/org/wfc/system/domain/UBillRule.java new file mode 100644 index 0000000..922883f --- /dev/null +++ b/wfc-modules/wfc-system/src/main/java/org/wfc/system/domain/UBillRule.java @@ -0,0 +1,38 @@ +package org.wfc.system.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.math.BigDecimal; +import org.wfc.common.mybatis.domain.BaseData; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; + +/** + *

+ * 用户平台-计费规则表 + *

+ * + * @author sys + * @since 2025-01-07 + */ +@Getter +@Setter +@TableName("u_bill_rule") +@Schema(name = "UBillRule", description = "用户平台-计费规则表") +public class UBillRule extends BaseData { + + private static final long serialVersionUID = 1L; + + @Schema(description = "价格") + private BigDecimal price; + + @Schema(description = "流量") + private Long traffic; + + @Schema(description = "单位") + private Integer unit; + + @Schema(description = "是否启用") + private Boolean enable; +} diff --git a/wfc-modules/wfc-system/src/main/java/org/wfc/system/mapper/UBillRuleMapper.java b/wfc-modules/wfc-system/src/main/java/org/wfc/system/mapper/UBillRuleMapper.java new file mode 100644 index 0000000..e0d91b4 --- /dev/null +++ b/wfc-modules/wfc-system/src/main/java/org/wfc/system/mapper/UBillRuleMapper.java @@ -0,0 +1,18 @@ +package org.wfc.system.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; +import org.wfc.system.domain.UBillRule; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 用户平台-计费规则表 Mapper 接口 + *

+ * + * @author sys + * @since 2025-01-07 + */ +@DS("user") +public interface UBillRuleMapper extends BaseMapper { + +} diff --git a/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/IUBillRuleService.java b/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/IUBillRuleService.java new file mode 100644 index 0000000..c1f1d08 --- /dev/null +++ b/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/IUBillRuleService.java @@ -0,0 +1,16 @@ +package org.wfc.system.service; + +import org.wfc.system.domain.UBillRule; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 用户平台-计费规则表 服务类 + *

+ * + * @author sys + * @since 2025-01-07 + */ +public interface IUBillRuleService extends IService { + +} diff --git a/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/impl/UBillRuleServiceImpl.java b/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/impl/UBillRuleServiceImpl.java new file mode 100644 index 0000000..aecf53b --- /dev/null +++ b/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/impl/UBillRuleServiceImpl.java @@ -0,0 +1,20 @@ +package org.wfc.system.service.impl; + +import org.wfc.system.domain.UBillRule; +import org.wfc.system.mapper.UBillRuleMapper; +import org.wfc.system.service.IUBillRuleService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 用户平台-计费规则表 服务实现类 + *

+ * + * @author sys + * @since 2025-01-07 + */ +@Service +public class UBillRuleServiceImpl extends ServiceImpl implements IUBillRuleService { + +} diff --git a/wfc-modules/wfc-system/src/main/resources/mapper/system/UBillRuleMapper.xml b/wfc-modules/wfc-system/src/main/resources/mapper/system/UBillRuleMapper.xml new file mode 100644 index 0000000..c752439 --- /dev/null +++ b/wfc-modules/wfc-system/src/main/resources/mapper/system/UBillRuleMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java index da0eef4..77d81d7 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java @@ -248,9 +248,9 @@ public class UAccountServiceImpl extends ServiceImpl i BigDecimal balanceUsed = Optional.of(account.getBalanceUsed()).orElse(BigDecimal.ZERO); BigDecimal balance = Optional.of(dashboardVo.getBalance()).orElse(BigDecimal.ZERO); if (balance.compareTo(balanceUsed) >= 0) { - dashboardVo.setBalance(BigDecimal.ZERO); - } else { dashboardVo.setBalance(balance.subtract(balanceUsed)); + } else { + dashboardVo.setBalance(BigDecimal.ZERO); } } return dashboardVo;