增加充值配置功能
This commit is contained in:
parent
a1bd8d56be
commit
a647071d8e
|
|
@ -0,0 +1,36 @@
|
|||
package com.mdd.admin.controller.marketing;
|
||||
|
||||
import com.mdd.admin.service.IMarketingRechargeService;
|
||||
import com.mdd.admin.validate.marketing.MarketingRechargeValidate;
|
||||
import com.mdd.admin.vo.marketing.MarketingRechargeVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/marketing/recharge")
|
||||
@Api("营销充值管理")
|
||||
public class MarketingRechargeController {
|
||||
|
||||
@Resource
|
||||
IMarketingRechargeService iMarketingRechargeService;
|
||||
|
||||
@GetMapping("/detail")
|
||||
@ApiModelProperty(value = "充值配置详情")
|
||||
public AjaxResult<MarketingRechargeVo> detail() {
|
||||
MarketingRechargeVo vo = iMarketingRechargeService.detail();
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
@ApiModelProperty(value = "充值配置保存")
|
||||
public AjaxResult<Object> save(@Validated @RequestBody MarketingRechargeValidate rechargeValidate) {
|
||||
iMarketingRechargeService.save(rechargeValidate);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.mdd.admin.service;
|
||||
|
||||
import com.mdd.admin.validate.marketing.MarketingRechargeValidate;
|
||||
import com.mdd.admin.vo.marketing.MarketingRechargeVo;
|
||||
|
||||
/**
|
||||
* 营销充值服务接口类
|
||||
*/
|
||||
public interface IMarketingRechargeService {
|
||||
|
||||
/**
|
||||
* 充值配置详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return MarketingRechargeVo
|
||||
*/
|
||||
MarketingRechargeVo detail();
|
||||
|
||||
/**
|
||||
* 充值配置保存
|
||||
*
|
||||
* @author fzr
|
||||
* @param rechargeValidate 充值参数
|
||||
*/
|
||||
void save(MarketingRechargeValidate rechargeValidate);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.mdd.admin.service.impl;
|
||||
|
||||
import com.mdd.admin.service.IMarketingRechargeService;
|
||||
import com.mdd.admin.validate.marketing.MarketingRechargeValidate;
|
||||
import com.mdd.admin.vo.marketing.MarketingRechargeVo;
|
||||
import com.mdd.common.util.ConfigUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 营销充值服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class MarketingRechargeServiceImpl implements IMarketingRechargeService {
|
||||
|
||||
/**
|
||||
* 充值配置详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return MarketingRechargeVo
|
||||
*/
|
||||
@Override
|
||||
public MarketingRechargeVo detail() {
|
||||
Map<String, String> config = ConfigUtils.get("recharge");
|
||||
|
||||
MarketingRechargeVo vo = new MarketingRechargeVo();
|
||||
vo.setOpenRecharge(Integer.parseInt(config.getOrDefault("openRecharge", "0")));
|
||||
vo.setMinRechargeMoney(new BigDecimal(config.getOrDefault("minRechargeMoney", "0")));
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值配置保存
|
||||
*
|
||||
* @author fzr
|
||||
* @param rechargeValidate 充值参数
|
||||
*/
|
||||
@Override
|
||||
public void save(MarketingRechargeValidate rechargeValidate) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.mdd.admin.validate.marketing;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@ApiModel("订单搜索参数")
|
||||
public class MarketingRechargeValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull(message = "openRecharge参数缺失")
|
||||
@ApiModelProperty("是否开启充值: 0=否,1=是")
|
||||
private Integer openRecharge;
|
||||
|
||||
@NotNull(message = "minRechargeMoney参数缺失")
|
||||
@ApiModelProperty("最低充值金额")
|
||||
private BigDecimal minRechargeMoney;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.mdd.admin.vo.marketing;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@ApiModel("营销充值Vo")
|
||||
public class MarketingRechargeVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("是否开启充值: 0=否,1=是")
|
||||
private Integer openRecharge;
|
||||
|
||||
@ApiModelProperty("最低充值金额")
|
||||
private BigDecimal minRechargeMoney;
|
||||
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ 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 com.mdd.front.vo.RechargeRecordVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -28,7 +28,7 @@ public class LogsController {
|
|||
public AjaxResult<Object> userMoney(@Validated PageValidate pageValidate,
|
||||
@RequestParam(defaultValue = "0") Integer type) {
|
||||
|
||||
PageResult<LogRecordDataVo> list = iLogsService.userMoney(pageValidate, type);
|
||||
PageResult<RechargeRecordVo> list = iLogsService.userMoney(pageValidate, type);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ 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.LogRecordDataVo;
|
||||
import com.mdd.front.vo.RechargeConfigVo;
|
||||
import com.mdd.front.vo.RechargeRecordVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -23,12 +24,21 @@ public class RechargeController {
|
|||
@Resource
|
||||
IRechargeService iRechargeService;
|
||||
|
||||
@GetMapping("/config")
|
||||
@ApiOperation(value = "充值配置")
|
||||
public AjaxResult<Object> config() {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
|
||||
RechargeConfigVo vo = iRechargeService.config(userId);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
@GetMapping("/record")
|
||||
@ApiOperation(value = "充值记录")
|
||||
public AjaxResult<Object> record(@Validated PageValidate pageValidate) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
|
||||
PageResult<LogRecordDataVo> list = iRechargeService.record(userId, pageValidate);
|
||||
PageResult<RechargeRecordVo> list = iRechargeService.record(userId, pageValidate);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ package com.mdd.front.service;
|
|||
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.vo.LogRecordDataVo;
|
||||
import com.mdd.front.vo.RechargeRecordVo;
|
||||
|
||||
/**
|
||||
* 日志接口服务类
|
||||
*/
|
||||
public interface ILogsService {
|
||||
|
||||
PageResult<LogRecordDataVo> userMoney(PageValidate pageValidate, Integer type);
|
||||
PageResult<RechargeRecordVo> userMoney(PageValidate pageValidate, Integer type);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ 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.LogRecordDataVo;
|
||||
import com.mdd.front.vo.RechargeConfigVo;
|
||||
import com.mdd.front.vo.RechargeRecordVo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -12,14 +13,24 @@ import java.util.Map;
|
|||
*/
|
||||
public interface IRechargeService {
|
||||
|
||||
/**
|
||||
* 充值配置
|
||||
*
|
||||
* @author fzr
|
||||
* @param userId 用户ID
|
||||
* @return RechargeConfigVo
|
||||
*/
|
||||
RechargeConfigVo config(Integer userId);
|
||||
|
||||
/**
|
||||
* 充值记录
|
||||
*
|
||||
* @author fzr
|
||||
* @param userId 用户ID
|
||||
* @param pageValidate 分页参数
|
||||
* @return PageResult<RechargeRecordVo>
|
||||
*/
|
||||
PageResult<LogRecordDataVo> record(Integer userId, PageValidate pageValidate);
|
||||
PageResult<RechargeRecordVo> record(Integer userId, PageValidate pageValidate);
|
||||
|
||||
/**
|
||||
* 充值下单
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import com.mdd.common.mapper.log.LogMoneyMapper;
|
|||
import com.mdd.common.util.TimeUtils;
|
||||
import com.mdd.front.service.ILogsService;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.vo.LogRecordDataVo;
|
||||
import com.mdd.front.vo.RechargeRecordVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -24,7 +24,7 @@ public class LogsServiceImpl implements ILogsService {
|
|||
LogMoneyMapper logMoneyMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<LogRecordDataVo> userMoney(PageValidate pageValidate, Integer type) {
|
||||
public PageResult<RechargeRecordVo> userMoney(PageValidate pageValidate, Integer type) {
|
||||
Integer pageNo = pageValidate.getPageNo();
|
||||
Integer pageSize = pageValidate.getPageSize();
|
||||
|
||||
|
|
@ -36,9 +36,9 @@ public class LogsServiceImpl implements ILogsService {
|
|||
|
||||
IPage<LogMoney> iPage = logMoneyMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
|
||||
List<LogRecordDataVo> list = new LinkedList<>();
|
||||
List<RechargeRecordVo> list = new LinkedList<>();
|
||||
for (LogMoney logMoney : iPage.getRecords()) {
|
||||
LogRecordDataVo vo = new LogRecordDataVo();
|
||||
RechargeRecordVo vo = new RechargeRecordVo();
|
||||
|
||||
vo.setId(logMoney.getId());
|
||||
vo.setAction(logMoney.getAction());
|
||||
|
|
|
|||
|
|
@ -5,16 +5,22 @@ 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.RechargeOrder;
|
||||
import com.mdd.common.entity.user.User;
|
||||
import com.mdd.common.enums.PaymentEnum;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.RechargeOrderMapper;
|
||||
import com.mdd.common.mapper.user.UserMapper;
|
||||
import com.mdd.common.util.ConfigUtils;
|
||||
import com.mdd.common.util.TimeUtils;
|
||||
import com.mdd.front.service.IRechargeService;
|
||||
import com.mdd.front.validate.RechargeValidate;
|
||||
import com.mdd.front.validate.common.PageValidate;
|
||||
import com.mdd.front.vo.LogRecordDataVo;
|
||||
import com.mdd.front.vo.RechargeConfigVo;
|
||||
import com.mdd.front.vo.RechargeRecordVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
|
@ -29,6 +35,28 @@ public class RechargeServiceImpl implements IRechargeService {
|
|||
@Resource
|
||||
RechargeOrderMapper rechargeOrderMapper;
|
||||
|
||||
@Resource
|
||||
UserMapper userMapper;
|
||||
|
||||
/**
|
||||
* 充值配置
|
||||
*
|
||||
* @author fzr
|
||||
* @param userId 用户ID
|
||||
* @return RechargeConfigVo
|
||||
*/
|
||||
@Override
|
||||
public RechargeConfigVo config(Integer userId) {
|
||||
User user = userMapper.selectById(userId);
|
||||
Map<String, String> config = ConfigUtils.get("recharge");
|
||||
|
||||
RechargeConfigVo vo = new RechargeConfigVo();
|
||||
vo.setOpenRecharge(Integer.parseInt(config.getOrDefault("openRecharge", "0")));
|
||||
vo.setMinRechargeMoney(new BigDecimal(config.getOrDefault("minRechargeMoney", "0")));
|
||||
vo.setUserMoney(user.getMoney());
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值记录
|
||||
*
|
||||
|
|
@ -38,7 +66,7 @@ public class RechargeServiceImpl implements IRechargeService {
|
|||
* @return PageResult<RechargeRecordVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<LogRecordDataVo> record(Integer userId, PageValidate pageValidate) {
|
||||
public PageResult<RechargeRecordVo> record(Integer userId, PageValidate pageValidate) {
|
||||
Integer pageNo = pageValidate.getPageNo();
|
||||
Integer pageSize = pageValidate.getPageSize();
|
||||
|
||||
|
|
@ -49,9 +77,9 @@ public class RechargeServiceImpl implements IRechargeService {
|
|||
|
||||
IPage<RechargeOrder> iPage = rechargeOrderMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
|
||||
List<LogRecordDataVo> list = new LinkedList<>();
|
||||
List<RechargeRecordVo> list = new LinkedList<>();
|
||||
for (RechargeOrder rechargeOrder : iPage.getRecords()) {
|
||||
LogRecordDataVo vo = new LogRecordDataVo();
|
||||
RechargeRecordVo vo = new RechargeRecordVo();
|
||||
vo.setId(rechargeOrder.getId());
|
||||
vo.setAction(1);
|
||||
vo.setOrderAmount(rechargeOrder.getOrderAmount());
|
||||
|
|
@ -74,6 +102,15 @@ public class RechargeServiceImpl implements IRechargeService {
|
|||
*/
|
||||
@Override
|
||||
public Map<String, Object> placeOrder(Integer userId, Integer terminal, RechargeValidate rechargeValidate) {
|
||||
RechargeConfigVo config = this.config(userId);
|
||||
if (config.getOpenRecharge().equals(0)) {
|
||||
throw new OperateException("充值功能已关闭");
|
||||
}
|
||||
|
||||
if (rechargeValidate.getOrderAmount().compareTo(config.getMinRechargeMoney()) < 0) {
|
||||
throw new OperateException("充值金额不能少于" + config.getMinRechargeMoney());
|
||||
}
|
||||
|
||||
RechargeOrder order = new RechargeOrder();
|
||||
order.setUserId(userId);
|
||||
order.setOrderTerminal(terminal);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
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 RechargeConfigVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("是否开启充值: 0=否,1=是")
|
||||
private Integer openRecharge;
|
||||
|
||||
@ApiModelProperty("最低充值金额")
|
||||
private BigDecimal minRechargeMoney;
|
||||
|
||||
@ApiModelProperty("用户钱包")
|
||||
private BigDecimal userMoney;
|
||||
|
||||
}
|
||||
|
|
@ -8,8 +8,10 @@ import java.io.Serializable;
|
|||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "日志记录Vo")
|
||||
public class LogRecordDataVo implements Serializable {
|
||||
@ApiModel(value = "充值记录Vo")
|
||||
public class RechargeRecordVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Integer id;
|
||||
Loading…
Reference in New Issue