添加相关逻辑,修改相关bug

pull/540/head
wangshengcai 2025-01-11 11:33:24 +08:00
parent 37630ba845
commit 4467b44d2f
15 changed files with 318 additions and 90 deletions

View File

@ -72,6 +72,13 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-xnlmp</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.20</version>
</dependency>
</dependencies>
<build>

View File

@ -14,4 +14,10 @@ public class XnlMpConstant {
public static final Long COLLECT_TYPE_PRODUCT = 1L;
public static final Long COLLECT_TYPE_SPECIALIST = 2L;
public static final Long COLLECT_TYPE_CONTENT = 3L;
//充值
public static final Integer RECORD_TYPE_RECHARGE = 1;
//消费
public static final Integer RECORD_TYPE_CONSUMPTION = 2;
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.web.controller.system;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@ -8,8 +9,10 @@ import com.ruoyi.system.domain.param.UserInfoParam;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.*;
import com.ruoyi.xnlmp.domain.MpMembershipLevel;
import com.ruoyi.xnlmp.domain.MpRechargeConsumptionRecord;
import com.ruoyi.xnlmp.domain.vo.SysUserVO;
import com.ruoyi.xnlmp.service.IMpMembershipLevelService;
import com.ruoyi.xnlmp.service.IMpRechargeConsumptionRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ArrayUtils;
@ -76,6 +79,9 @@ public class SysUserController extends BaseController {
@Autowired
private IMpMembershipLevelService mpMembershipLevelService;
@Autowired
private IMpRechargeConsumptionRecordService rechargeConsumptionRecordServiceImpl;
@RequiresPermissions("system:user:view")
@GetMapping()
@ -371,9 +377,13 @@ public class SysUserController extends BaseController {
Subject subject = SecurityUtils.getSubject();
SysUser principal = (SysUser) subject.getPrincipal();
SysUser sysUser = userService.selectUserById(principal.getUserId());
MpRechargeConsumptionRecord rechargeConsumptionRecord = new MpRechargeConsumptionRecord();
rechargeConsumptionRecord.setUserId(sysUser.getUserId());
rechargeConsumptionRecord = rechargeConsumptionRecordServiceImpl.selectMpRechargeConsumptionRecordByUserId(rechargeConsumptionRecord);
SysUserVO vo = new SysUserVO();
BeanUtils.copyProperties(sysUser,vo);
vo.setMpMembershipLevel(Objects.nonNull(vo.getMembershipLevelId())?mpMembershipLevelService.selectMpMembershipLevelById(Long.valueOf(vo.getMembershipLevelId())): null);
vo.setAccountBalance(Objects.nonNull(rechargeConsumptionRecord)?rechargeConsumptionRecord.getBalance(): new BigDecimal(0));
return success(vo);
}

View File

@ -0,0 +1,40 @@
package com.ruoyi.web.controller.xnlmp;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.Map;
@Api(tags = "基本信息")
@Controller
@RequestMapping("/xnlmp/basicInfo")
public class BasicInformationController extends BaseController {
@Value("${xnlmp.basicInfo.tel}")
public String tel;
@Value("${xnlmp.basicInfo.payment}")
public Boolean isPayment;
@Value("${xnlmp.basicInfo.query}")
public Boolean isQuery;
@ApiOperation(value = "查询")
@GetMapping()
@ResponseBody
public AjaxResult details() {
Map<String, Object> map = new HashMap<>();
map.put("tel",tel);
map.put("isPayment",isPayment);
map.put("isQuery",isQuery);
return success(map);
}
}

View File

@ -2,6 +2,9 @@ package com.ruoyi.web.controller.xnlmp;
import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
@ -27,6 +30,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
* @author ruoyi
* @date 2024-12-14
*/
@Api(tags = "会员等级")
@Controller
@RequestMapping("/xnlmp/level")
public class MpMembershipLevelController extends BaseController
@ -127,13 +131,13 @@ public class MpMembershipLevelController extends BaseController
return toAjax(mpMembershipLevelService.deleteMpMembershipLevelByIds(ids));
}
@RequiresPermissions("xnlmp:level:mpList")
@PostMapping("/mpList")
@ApiOperation(value = "会员等级列表")
@GetMapping("/mpList")
@ResponseBody
public TableDataInfo mpList(@RequestBody MpMembershipLevel mpMembershipLevel)
public TableDataInfo mpList()
{
startPage();
List<MpMembershipLevel> list = mpMembershipLevelService.selectMpMembershipLevelList(mpMembershipLevel);
List<MpMembershipLevel> list = mpMembershipLevelService.selectMpMembershipLevelList(null);
return getDataTable(list);
}
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.web.controller.xnlmp;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@ -7,11 +8,15 @@ import java.util.stream.Collectors;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.constant.XnlMpConstant;
import com.ruoyi.xnlmp.domain.MpProductInfo;
import com.ruoyi.xnlmp.domain.vo.MpRechargeConsumptionRecordVO;
import com.ruoyi.xnlmp.service.IMpProductInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@ -45,6 +50,11 @@ public class MpRechargeConsumptionRecordController extends BaseController {
private IMpRechargeConsumptionRecordService mpRechargeConsumptionRecordService;
@Autowired
private ISysUserService userService;
@Autowired
private IMpProductInfoService mpProductInfoServiceImpl;
@RequiresPermissions("xnlmp:record:view")
@GetMapping()
public String record() {
@ -136,15 +146,29 @@ public class MpRechargeConsumptionRecordController extends BaseController {
/**
*
*/
@PostMapping("/mpList")
@GetMapping("/mpList")
@ApiOperation("我的消费记录")
@ResponseBody
public TableDataInfo mpList(MpRechargeConsumptionRecord mpRechargeConsumptionRecord) {
public TableDataInfo mpList() {
MpRechargeConsumptionRecord mpRechargeConsumptionRecord = new MpRechargeConsumptionRecord();
Subject subject = SecurityUtils.getSubject();
SysUser principal = (SysUser) subject.getPrincipal();
mpRechargeConsumptionRecord.setUserId(principal.getUserId());
startPage();
List<MpRechargeConsumptionRecord> list = mpRechargeConsumptionRecordService.selectMpRechargeConsumptionRecordList(mpRechargeConsumptionRecord);
return getDataTable(list);
List< MpRechargeConsumptionRecordVO> vos = new ArrayList<>();
list.forEach(x -> {
MpRechargeConsumptionRecordVO vo = new MpRechargeConsumptionRecordVO();
BeanUtils.copyProperties(x,vo);
if(XnlMpConstant.RECORD_TYPE_RECHARGE.intValue() == x.getType().intValue()) {
vo.setProductInfoName("会员充值");
}else {
MpProductInfo mpProductInfo = mpProductInfoServiceImpl.selectMpProductInfoById(x.getProductInfoId());
vo.setProductInfoName(mpProductInfo.getName());
}
vos.add(vo);
});
return getDataTable(vos);
}
}

View File

@ -0,0 +1,72 @@
package utils;
/**
*
*
* @author lihu
* @date 20250103 13:58
*/
import java.util.Random;
/**
* IP
*
* @author Liyh
*/
public class RandomIpUtil {
/**
* IP
* <p>
*
* 127.xxx.xxx.xxx loopback 127.0.0.1
* 192.168.xxx.xxx private (site local address)访
* 10.xxx.xxx.xxx 172.16.xxx.xxx 172.31.xxx.xxx 访
* 169.254.xxx.xxx (link local IP)
* 224.xxx.xxx.xxx 239.xxx.xxx.xxx
* 255.255.255.255 广
* IPv4
* </p>
*/
public static String getRandomIp() {
// 指定 IP 范围
int[][] range = {
{607649792, 608174079}, // 36.56.0.0-36.63.255.255
{1038614528, 1039007743}, // 61.232.0.0-61.237.255.255
{1783627776, 1784676351}, // 106.80.0.0-106.95.255.255
{2035023872, 2035154943}, // 121.76.0.0-121.77.255.255
{2078801920, 2079064063}, // 123.232.0.0-123.235.255.255
{-1950089216, -1948778497}, // 139.196.0.0-139.215.255.255
{-1425539072, -1425014785}, // 171.8.0.0-171.15.255.255
{-1236271104, -1235419137}, // 182.80.0.0-182.92.255.255
{-770113536, -768606209}, // 210.25.0.0-210.47.255.255
{-569376768, -564133889}, // 222.16.0.0-222.95.255.255
};
Random random = new Random();
int index = random.nextInt(10);
String ip = num2ip(range[index][0] + random.nextInt(range[index][1] - range[index][0]));
return ip;
}
/**
* IP
*/
public static String num2ip(int ip) {
int[] b = new int[4];
b[0] = (ip >> 24) & 0xff;
b[1] = (ip >> 16) & 0xff;
b[2] = (ip >> 8) & 0xff;
b[3] = ip & 0xff;
// 拼接 IP
String result = b[0] + "." + b[1] + "." + b[2] + "." + b[3];
return result;
}
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
String randomIp = getRandomIp();
System.out.println(randomIp);
}
}
}

View File

@ -0,0 +1,7 @@
package vo;
import java.net.HttpCookie;
public class MyHttpCookie {
}

View File

@ -1,9 +1,13 @@
package com.ruoyi.xnlmp.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
@ -11,113 +15,60 @@ import com.ruoyi.common.core.domain.BaseEntity;
/**
* mp_recharge_consumption_record
*
*
* @author ruoyi
* @date 2024-12-14
*/
@Data
@ToString
@ApiModel(value = "充值、消费记录对象")
public class MpRechargeConsumptionRecord extends BaseEntity
{
public class MpRechargeConsumptionRecord extends BaseEntity {
private static final long serialVersionUID = 1L;
/** $column.columnComment */
/**
* $column.columnComment
*/
private Long id;
/** 金额 */
/**
*
*/
@Excel(name = "金额")
@ApiModelProperty("金额")
private BigDecimal amount;
/** 1:充值2消费 */
@ApiModelProperty("产品id")
private Long productInfoId;
@ApiModelProperty("产品名称")
private String productInfoName;
/**
* 1:2
*/
@Excel(name = "1:充值2消费")
@ApiModelProperty("1:充值2消费")
private Integer type;
/** 用户id */
/**
* id
*/
@Excel(name = "用户id")
@ApiModelProperty("用户id")
private Long userId;
/** 当前余额 */
/**
*
*/
@Excel(name = "当前余额")
@ApiModelProperty("当前余额")
private BigDecimal balance;
/** 版本号 */
/**
*
*/
@Excel(name = "版本号")
private Long version;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setAmount(BigDecimal amount)
{
this.amount = amount;
}
public BigDecimal getAmount()
{
return amount;
}
public void setType(Integer type)
{
this.type = type;
}
public Integer getType()
{
return type;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setBalance(BigDecimal balance)
{
this.balance = balance;
}
public BigDecimal getBalance()
{
return balance;
}
public void setVersion(Long version)
{
this.version = version;
}
public Long getVersion()
{
return version;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("amount", getAmount())
.append("type", getType())
.append("userId", getUserId())
.append("balance", getBalance())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("version", getVersion())
.toString();
}
}

View File

@ -0,0 +1,69 @@
package com.ruoyi.xnlmp.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
import java.util.Date;
/**
* mp_recharge_consumption_record
*
* @author ruoyi
* @date 2024-12-14
*/
@Data
@ToString
@ApiModel(value = "充值、消费记录对象")
public class MpRechargeConsumptionRecordVO {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
private Long id;
/**
*
*/
@Excel(name = "金额")
@ApiModelProperty("金额")
private BigDecimal amount;
@ApiModelProperty("产品id")
private Long productInfoId;
@ApiModelProperty("产品名称")
private String productInfoName;
/**
* 1:2
*/
@Excel(name = "1:充值2消费")
@ApiModelProperty("1:充值2消费")
private Integer type;
/**
* id
*/
@Excel(name = "用户id")
@ApiModelProperty("用户id")
private Long userId;
/**
*
*/
@Excel(name = "当前余额")
@ApiModelProperty("当前余额")
private BigDecimal balance;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}

View File

@ -9,6 +9,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;
import java.math.BigDecimal;
/**
* sys_user
*
@ -52,6 +54,10 @@ public class SysUserVO extends BaseEntity {
@ApiModelProperty("身份证号")
private String iDNumber;
@ApiModelProperty("账号余额")
private BigDecimal accountBalance;
/**
*
*/
@ -245,4 +251,12 @@ public class SysUserVO extends BaseEntity {
public void setMpMembershipLevel(MpMembershipLevel mpMembershipLevel) {
this.mpMembershipLevel = mpMembershipLevel;
}
public BigDecimal getAccountBalance() {
return accountBalance;
}
public void setAccountBalance(BigDecimal accountBalance) {
this.accountBalance = accountBalance;
}
}

View File

@ -27,6 +27,8 @@ public interface MpRechargeConsumptionRecordMapper
*/
public List<MpRechargeConsumptionRecord> selectMpRechargeConsumptionRecordList(MpRechargeConsumptionRecord mpRechargeConsumptionRecord);
public MpRechargeConsumptionRecord selectMpRechargeConsumptionRecordByUserId(MpRechargeConsumptionRecord mpRechargeConsumptionRecord);
/**
*
*

View File

@ -27,6 +27,8 @@ public interface IMpRechargeConsumptionRecordService
*/
public List<MpRechargeConsumptionRecord> selectMpRechargeConsumptionRecordList(MpRechargeConsumptionRecord mpRechargeConsumptionRecord);
MpRechargeConsumptionRecord selectMpRechargeConsumptionRecordByUserId(MpRechargeConsumptionRecord mpRechargeConsumptionRecord);
/**
*
*

View File

@ -45,6 +45,12 @@ public class MpRechargeConsumptionRecordServiceImpl implements IMpRechargeConsum
return mpRechargeConsumptionRecordMapper.selectMpRechargeConsumptionRecordList(mpRechargeConsumptionRecord);
}
@Override
public MpRechargeConsumptionRecord selectMpRechargeConsumptionRecordByUserId(MpRechargeConsumptionRecord mpRechargeConsumptionRecord) {
return mpRechargeConsumptionRecordMapper.selectMpRechargeConsumptionRecordByUserId(mpRechargeConsumptionRecord);
}
/**
*
*

View File

@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="MpRechargeConsumptionRecord" id="MpRechargeConsumptionRecordResult">
<result property="id" column="id" />
<result property="amount" column="amount" />
<result property="productInfoId" column="product_info_id" />
<result property="type" column="type" />
<result property="userId" column="user_id" />
<result property="balance" column="balance" />
@ -16,18 +17,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectMpRechargeConsumptionRecordVo">
select id, amount, type, user_id, balance, create_time, update_time, version from mp_recharge_consumption_record
select id, amount,product_info_id, type, user_id, balance, create_time, update_time, version from mp_recharge_consumption_record
</sql>
<select id="selectMpRechargeConsumptionRecordList" parameterType="MpRechargeConsumptionRecord" resultMap="MpRechargeConsumptionRecordResult">
<include refid="selectMpRechargeConsumptionRecordVo"/>
<where>
<if test="amount != null "> and amount = #{amount}</if>
<if test="productInfoId != null "> and product_info_id, = #{productInfoId}</if>
<if test="type != null "> and type = #{type}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="balance != null "> and balance = #{balance}</if>
<if test="version != null "> and version = #{version}</if>
</where>
order by create_time desc
</select>
<select id="selectMpRechargeConsumptionRecordByUserId" parameterType="MpRechargeConsumptionRecord" resultMap="MpRechargeConsumptionRecordResult">
<include refid="selectMpRechargeConsumptionRecordVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
</where>
order by create_time desc limit 1
</select>
<select id="selectMpRechargeConsumptionRecordById" parameterType="Long" resultMap="MpRechargeConsumptionRecordResult">
@ -40,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="amount != null">amount,</if>
<if test="productInfoId != null">product_info_id,</if>
<if test="type != null">type,</if>
<if test="userId != null">user_id,</if>
<if test="balance != null">balance,</if>
@ -50,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="amount != null">#{amount},</if>
<if test="productInfoId != null">#{productInfoId},</if>
<if test="type != null">#{type},</if>
<if test="userId != null">#{userId},</if>
<if test="balance != null">#{balance},</if>
@ -63,6 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update mp_recharge_consumption_record
<trim prefix="SET" suffixOverrides=",">
<if test="amount != null">amount = #{amount},</if>
<if test="productInfoId != null">product_info_id = #{productInfoId},</if>
<if test="type != null">type = #{type},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="balance != null">balance = #{balance},</if>