diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UBillController.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UBillController.java index 162cd92..ee417b4 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UBillController.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UBillController.java @@ -1,19 +1,12 @@ package org.wfc.user.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.user.domain.UBill; +import org.wfc.user.domain.vo.UBillUserVo; import org.wfc.user.service.IUBillService; import java.util.List; @@ -27,43 +20,17 @@ import java.util.List; * @since 2025-01-06 */ @RestController -@RequestMapping("/user/uBill") +@RequestMapping("/bill") public class UBillController extends BaseController { @Autowired private IUBillService uBillService; @GetMapping("/page") - public TableDataInfo page(UBill uBill) { + public TableDataInfo page() { startPage(); - List list = uBillService.list(); + List list = uBillService.getBillByUser(); return getDataTable(list); } - @GetMapping("/list") - public AjaxResult list(UBill uBill) { - List list = uBillService.list(); - return success(list); - } - - @GetMapping(value = "/{id}") - public AjaxResult getById(@PathVariable("id") Long id) { - return success(uBillService.getById(id)); - } - - @PostMapping - public AjaxResult add(@RequestBody UBill uBill) { - return toAjax(uBillService.save(uBill)); - } - - @PutMapping - public AjaxResult edit(@RequestBody UBill uBill) { - return toAjax(uBillService.updateById(uBill)); - } - - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) { - return toAjax(uBillService.removeByIds(CollUtil.newArrayList(ids))); - } - } diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UOrderController.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UOrderController.java index 12aac4e..0e0c39b 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UOrderController.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UOrderController.java @@ -1,6 +1,7 @@ package org.wfc.user.controller; import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -10,9 +11,11 @@ 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.domain.LoginUser; 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.common.security.utils.SecurityUtils; import org.wfc.user.domain.UOrder; import org.wfc.user.service.IUOrderService; @@ -40,6 +43,26 @@ public class UOrderController extends BaseController { return getDataTable(list); } + @GetMapping("/rechargePage") + public TableDataInfo rechargePage() { + startPage(); + LoginUser loginUser = SecurityUtils.getLoginUser(); + List list = uOrderService.list(Wrappers.lambdaQuery() + .eq(UOrder::getUserId, loginUser.getUserid()).eq(UOrder::getType, 1) + .orderByDesc(UOrder::getCreateTime)); + return getDataTable(list); + } + + @GetMapping("/packagePage") + public TableDataInfo packagePage() { + startPage(); + LoginUser loginUser = SecurityUtils.getLoginUser(); + List list = uOrderService.list(Wrappers.lambdaQuery() + .eq(UOrder::getUserId, loginUser.getUserid()).eq(UOrder::getType, 0) + .orderByDesc(UOrder::getCreateTime)); + return getDataTable(list); + } + @GetMapping("/list") public AjaxResult list(UOrder uOrder) { List list = uOrderService.list(); diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/domain/vo/UBillUserVo.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/domain/vo/UBillUserVo.java new file mode 100644 index 0000000..13de83c --- /dev/null +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/domain/vo/UBillUserVo.java @@ -0,0 +1,35 @@ +package org.wfc.user.domain.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author: cyc + * @since: 2025-01-07 + */ +@Data +public class UBillUserVo { + + @Schema(description = "ID") + private Long id; + + @Schema(description = "开始时间") + private Long startTime; + + @Schema(description = "结束时间") + private Long endTime; + + @Schema(description = "流量") + private Long traffic; + + @Schema(description = "金额") + private BigDecimal amount; + + @Schema(description = "状态") + private Integer status; + + @Schema(description = "创建时间") + private BigDecimal createTime; +} diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/mapper/UBillMapper.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/mapper/UBillMapper.java index 11b4a1b..d0a07e3 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/mapper/UBillMapper.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/mapper/UBillMapper.java @@ -1,7 +1,11 @@ package org.wfc.user.mapper; -import org.wfc.user.domain.UBill; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.wfc.user.domain.UBill; +import org.wfc.user.domain.vo.UBillUserVo; + +import java.util.List; /** *

@@ -12,5 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @since 2025-01-06 */ public interface UBillMapper extends BaseMapper { - + List getBillByUser(@Param("userId") Long userId); } diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUBillService.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUBillService.java index cea4089..574c03a 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUBillService.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/IUBillService.java @@ -1,7 +1,10 @@ package org.wfc.user.service; -import org.wfc.user.domain.UBill; import com.baomidou.mybatisplus.extension.service.IService; +import org.wfc.user.domain.UBill; +import org.wfc.user.domain.vo.UBillUserVo; + +import java.util.List; /** *

@@ -13,4 +16,6 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface IUBillService extends IService { + List getBillByUser(); + } 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 77d81d7..1d26fd0 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 @@ -120,7 +120,8 @@ public class UAccountServiceImpl extends ServiceImpl i for (UCdrLatestHistoryVo historyVo : latestHistoryList) { UBill bill = new UBill(); bill.setUserId(historyVo.getUserId()); - bill.setCdrHistoryId(historyVo.getCdrId()); + bill.setCdrHistoryId(historyVo.getId()); + bill.setStatus(1); BigDecimal total = NumberUtil.div(NumberUtil.add(historyVo.getTrafficDown(), historyVo.getTrafficUp()), 1048576); bill.setAmount(NumberUtil.mul(total, billRule.getPrice())); billMapper.insert(bill); diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UBillServiceImpl.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UBillServiceImpl.java index 983c6e3..8c35169 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UBillServiceImpl.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UBillServiceImpl.java @@ -1,10 +1,15 @@ package org.wfc.user.service.impl; -import org.wfc.user.domain.UBill; -import org.wfc.user.mapper.UBillMapper; -import org.wfc.user.service.IUBillService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.wfc.common.core.domain.LoginUser; +import org.wfc.common.security.utils.SecurityUtils; +import org.wfc.user.domain.UBill; +import org.wfc.user.domain.vo.UBillUserVo; +import org.wfc.user.mapper.UBillMapper; +import org.wfc.user.service.IUBillService; + +import java.util.List; /** *

@@ -17,4 +22,9 @@ import org.springframework.stereotype.Service; @Service public class UBillServiceImpl extends ServiceImpl implements IUBillService { + @Override + public List getBillByUser() { + LoginUser loginUser = SecurityUtils.getLoginUser(); + return this.baseMapper.getBillByUser(loginUser.getUserid()); + } } diff --git a/wfc-modules/wfc-user/src/main/resources/mapper/user/UBillMapper.xml b/wfc-modules/wfc-user/src/main/resources/mapper/user/UBillMapper.xml index d1290f5..2f9db25 100644 --- a/wfc-modules/wfc-user/src/main/resources/mapper/user/UBillMapper.xml +++ b/wfc-modules/wfc-user/src/main/resources/mapper/user/UBillMapper.xml @@ -2,4 +2,19 @@ +