feat: 账单、充值和套餐记录
This commit is contained in:
@@ -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<UBill> list = uBillService.list();
|
||||
List<UBillUserVo> list = uBillService.getBillByUser();
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(UBill uBill) {
|
||||
List<UBill> 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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<Object> loginUser = SecurityUtils.getLoginUser();
|
||||
List<UOrder> list = uOrderService.list(Wrappers.<UOrder>lambdaQuery()
|
||||
.eq(UOrder::getUserId, loginUser.getUserid()).eq(UOrder::getType, 1)
|
||||
.orderByDesc(UOrder::getCreateTime));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/packagePage")
|
||||
public TableDataInfo packagePage() {
|
||||
startPage();
|
||||
LoginUser<Object> loginUser = SecurityUtils.getLoginUser();
|
||||
List<UOrder> list = uOrderService.list(Wrappers.<UOrder>lambdaQuery()
|
||||
.eq(UOrder::getUserId, loginUser.getUserid()).eq(UOrder::getType, 0)
|
||||
.orderByDesc(UOrder::getCreateTime));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(UOrder uOrder) {
|
||||
List<UOrder> list = uOrderService.list();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -12,5 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* @since 2025-01-06
|
||||
*/
|
||||
public interface UBillMapper extends BaseMapper<UBill> {
|
||||
|
||||
List<UBillUserVo> getBillByUser(@Param("userId") Long userId);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +16,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface IUBillService extends IService<UBill> {
|
||||
|
||||
List<UBillUserVo> getBillByUser();
|
||||
|
||||
}
|
||||
|
||||
@@ -120,7 +120,8 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> 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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -17,4 +22,9 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class UBillServiceImpl extends ServiceImpl<UBillMapper, UBill> implements IUBillService {
|
||||
|
||||
@Override
|
||||
public List<UBillUserVo> getBillByUser() {
|
||||
LoginUser<Object> loginUser = SecurityUtils.getLoginUser();
|
||||
return this.baseMapper.getBillByUser(loginUser.getUserid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,19 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.wfc.user.mapper.UBillMapper">
|
||||
|
||||
<select id="getBillByUser" resultType="org.wfc.user.domain.vo.UBillUserVo">
|
||||
SELECT
|
||||
b.id,
|
||||
h.start_time,
|
||||
h.end_time,
|
||||
h.traffic_up + h.traffic_down traffic,
|
||||
b.amount,
|
||||
b.create_time,
|
||||
b.`status`
|
||||
FROM
|
||||
u_bill b
|
||||
LEFT JOIN u_cdr_history h ON h.id = b.cdr_history_id
|
||||
AND h.del_flag = 0
|
||||
AND b.user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user