处理支付日志相关功能
This commit is contained in:
parent
d8c4799028
commit
9a6f8128ac
|
|
@ -70,9 +70,6 @@ public enum ClientEnum {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取状态码
|
||||
*
|
||||
|
|
|
|||
|
|
@ -40,4 +40,20 @@ public enum LogMoneyEnum {
|
|||
return this.msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据编码获取Msg
|
||||
*
|
||||
* @author fzr
|
||||
* @param code 类型
|
||||
* @return String
|
||||
*/
|
||||
public static String getMsgByCode(Integer code){
|
||||
for(ClientEnum enumItem: ClientEnum.values()) {
|
||||
if (enumItem.getCode() == code) {
|
||||
return enumItem.getMsg();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package com.mdd.front.controller;
|
||||
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.front.service.ILogsService;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.vo.LogRecordDataVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/logs")
|
||||
@Api(tags = "日志管理")
|
||||
public class LogsController {
|
||||
|
||||
@Resource
|
||||
ILogsService iLogsService;
|
||||
|
||||
@GetMapping("/userMoney")
|
||||
@ApiOperation("用户金额变动日志")
|
||||
public AjaxResult<Object> userMoney(@Validated PageValidate pageValidate,
|
||||
@RequestParam(defaultValue = "0") Integer type) {
|
||||
|
||||
PageResult<LogRecordDataVo> list = iLogsService.userMoney(pageValidate, type);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import com.mdd.front.LikeFrontThreadLocal;
|
|||
import com.mdd.front.service.IRechargeService;
|
||||
import com.mdd.front.validate.RechargeValidate;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.vo.RechargeRecordVo;
|
||||
import com.mdd.front.vo.LogRecordDataVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -28,7 +28,7 @@ public class RechargeController {
|
|||
public AjaxResult<Object> record(@Validated PageValidate pageValidate) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
|
||||
PageResult<RechargeRecordVo> list = iRechargeService.record(userId, pageValidate);
|
||||
PageResult<LogRecordDataVo> list = iRechargeService.record(userId, pageValidate);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,5 +113,4 @@ public class UserController {
|
|||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.mdd.front.service;
|
||||
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.vo.LogRecordDataVo;
|
||||
|
||||
/**
|
||||
* 日志接口服务类
|
||||
*/
|
||||
public interface ILogsService {
|
||||
|
||||
PageResult<LogRecordDataVo> userMoney(PageValidate pageValidate, Integer type);
|
||||
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package com.mdd.front.service;
|
|||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.front.validate.RechargeValidate;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.vo.RechargeRecordVo;
|
||||
import com.mdd.front.vo.LogRecordDataVo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ public interface IRechargeService {
|
|||
* @param pageValidate 分页参数
|
||||
* @return PageResult<RechargeRecordVo>
|
||||
*/
|
||||
PageResult<RechargeRecordVo> record(Integer userId, PageValidate pageValidate);
|
||||
PageResult<LogRecordDataVo> record(Integer userId, PageValidate pageValidate);
|
||||
|
||||
/**
|
||||
* 充值下单
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ public class ArticleServiceImpl implements IArticleService {
|
|||
}
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
package com.mdd.front.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.LogMoney;
|
||||
import com.mdd.common.entity.article.Article;
|
||||
import com.mdd.common.enums.LogMoneyEnum;
|
||||
import com.mdd.common.mapper.LogMoneyMapper;
|
||||
import com.mdd.common.util.TimeUtils;
|
||||
import com.mdd.common.util.UrlUtils;
|
||||
import com.mdd.front.service.ILogsService;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.vo.LogRecordDataVo;
|
||||
import com.mdd.front.vo.article.ArticleListedVo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class LogsServiceImpl implements ILogsService {
|
||||
|
||||
@Resource
|
||||
LogMoneyMapper logMoneyMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<LogRecordDataVo> userMoney(PageValidate pageValidate, Integer type) {
|
||||
Integer pageNo = pageValidate.getPageNo();
|
||||
Integer pageSize = pageValidate.getPageSize();
|
||||
|
||||
QueryWrapper<LogMoney> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("id");
|
||||
if (type > 0) {
|
||||
queryWrapper.eq("action", type);
|
||||
}
|
||||
|
||||
IPage<LogMoney> iPage = logMoneyMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
|
||||
List<LogRecordDataVo> list = new LinkedList<>();
|
||||
for (LogMoney logMoney : iPage.getRecords()) {
|
||||
LogRecordDataVo vo = new LogRecordDataVo();
|
||||
|
||||
vo.setId(logMoney.getId());
|
||||
vo.setAction(logMoney.getAction());
|
||||
vo.setOrderAmount(logMoney.getChangeAmount());
|
||||
vo.setTips(LogMoneyEnum.getMsgByCode(logMoney.getChangeType()));
|
||||
vo.setCreateTime(TimeUtils.timestampToDate(vo.getCreateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -8,11 +8,10 @@ import com.mdd.common.entity.RechargeOrder;
|
|||
import com.mdd.common.enums.PaymentEnum;
|
||||
import com.mdd.common.mapper.RechargeOrderMapper;
|
||||
import com.mdd.common.util.TimeUtils;
|
||||
import com.mdd.common.util.ToolUtils;
|
||||
import com.mdd.front.service.IRechargeService;
|
||||
import com.mdd.front.validate.RechargeValidate;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.vo.RechargeRecordVo;
|
||||
import com.mdd.front.vo.LogRecordDataVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -39,7 +38,7 @@ public class RechargeServiceImpl implements IRechargeService {
|
|||
* @return PageResult<RechargeRecordVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<RechargeRecordVo> record(Integer userId, PageValidate pageValidate) {
|
||||
public PageResult<LogRecordDataVo> record(Integer userId, PageValidate pageValidate) {
|
||||
Integer pageNo = pageValidate.getPageNo();
|
||||
Integer pageSize = pageValidate.getPageSize();
|
||||
|
||||
|
|
@ -50,12 +49,13 @@ public class RechargeServiceImpl implements IRechargeService {
|
|||
|
||||
IPage<RechargeOrder> iPage = rechargeOrderMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
|
||||
List<RechargeRecordVo> list = new LinkedList<>();
|
||||
List<LogRecordDataVo> list = new LinkedList<>();
|
||||
for (RechargeOrder rechargeOrder : iPage.getRecords()) {
|
||||
RechargeRecordVo vo = new RechargeRecordVo();
|
||||
LogRecordDataVo vo = new LogRecordDataVo();
|
||||
vo.setId(rechargeOrder.getId());
|
||||
vo.setAction(1);
|
||||
vo.setOrderAmount(rechargeOrder.getOrderAmount());
|
||||
vo.setPayTime(TimeUtils.timestampToDate(rechargeOrder.getPayTime()));
|
||||
vo.setCreateTime(TimeUtils.timestampToDate(rechargeOrder.getPayTime()));
|
||||
vo.setTips("充值" + vo.getOrderAmount() + "元");
|
||||
list.add(vo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package com.mdd.front.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "日志记录Vo")
|
||||
public class LogRecordDataVo implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "金额")
|
||||
private BigDecimal orderAmount;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String tips;
|
||||
|
||||
@ApiModelProperty(value = "操作")
|
||||
private Integer action;
|
||||
|
||||
@ApiModelProperty(value = "时间")
|
||||
private String createTime;
|
||||
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
package com.mdd.front.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "充值记录Vo")
|
||||
public class RechargeRecordVo implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "订单ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "充值金额")
|
||||
private BigDecimal orderAmount;
|
||||
|
||||
@ApiModelProperty(value = "充值描述")
|
||||
private String tips;
|
||||
|
||||
@ApiModelProperty(value = "充值时间")
|
||||
private String payTime;
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue