增加支付方式配置
This commit is contained in:
parent
3fc536eb1c
commit
763f340709
|
|
@ -2,8 +2,9 @@ package com.mdd.admin.controller.setting;
|
||||||
|
|
||||||
|
|
||||||
import com.mdd.admin.service.ISettingPaymentService;
|
import com.mdd.admin.service.ISettingPaymentService;
|
||||||
import com.mdd.admin.validate.setting.SettingPaymentValidate;
|
import com.mdd.admin.validate.setting.SettingPayConfigValidate;
|
||||||
import com.mdd.common.aop.NotLogin;
|
import com.mdd.admin.validate.setting.SettingPayMethodValidate;
|
||||||
|
import com.mdd.admin.vo.setting.SettingPaymentMethodVo;
|
||||||
import com.mdd.common.core.AjaxResult;
|
import com.mdd.common.core.AjaxResult;
|
||||||
import com.mdd.common.entity.setting.DevPayConfig;
|
import com.mdd.common.entity.setting.DevPayConfig;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
|
@ -22,23 +23,31 @@ public class SettingPaymentController {
|
||||||
@Resource
|
@Resource
|
||||||
ISettingPaymentService iSettingPaymentService;
|
ISettingPaymentService iSettingPaymentService;
|
||||||
|
|
||||||
public AjaxResult<Object> method() {
|
@GetMapping("/method")
|
||||||
return AjaxResult.success();
|
@ApiOperation(value="支付方式列表")
|
||||||
|
public AjaxResult<List<List<SettingPaymentMethodVo>>> method() {
|
||||||
|
List<List<SettingPaymentMethodVo>> list = iSettingPaymentService.method();
|
||||||
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotLogin
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@ApiOperation(value="支付渠道列表")
|
@ApiOperation(value="支付配置列表")
|
||||||
public AjaxResult<Object> list() {
|
public AjaxResult<Object> list() {
|
||||||
List<DevPayConfig> list = iSettingPaymentService.list();
|
List<DevPayConfig> list = iSettingPaymentService.list();
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotLogin
|
@PostMapping("/editConfig")
|
||||||
@PostMapping("/edit")
|
@ApiOperation(value="支付配置编辑")
|
||||||
@ApiOperation(value="支付渠道编辑")
|
public AjaxResult<Object> editConfig(@Validated @RequestBody SettingPayConfigValidate configValidate) {
|
||||||
public AjaxResult<Object> edit(@Validated @RequestBody SettingPaymentValidate paymentValidate) {
|
iSettingPaymentService.editConfig(configValidate);
|
||||||
iSettingPaymentService.edit(paymentValidate);
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/editMethod")
|
||||||
|
@ApiOperation(value="支付方式编辑")
|
||||||
|
public AjaxResult<Object> editMethod(@Validated @RequestBody SettingPayMethodValidate methodValidate) {
|
||||||
|
iSettingPaymentService.editMethod(methodValidate);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.mdd.admin.service;
|
package com.mdd.admin.service;
|
||||||
|
|
||||||
import com.mdd.admin.validate.setting.SettingPaymentValidate;
|
import com.mdd.admin.validate.setting.SettingPayConfigValidate;
|
||||||
|
import com.mdd.admin.validate.setting.SettingPayMethodValidate;
|
||||||
|
import com.mdd.admin.vo.setting.SettingPaymentMethodVo;
|
||||||
import com.mdd.common.entity.setting.DevPayConfig;
|
import com.mdd.common.entity.setting.DevPayConfig;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -10,8 +12,12 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface ISettingPaymentService {
|
public interface ISettingPaymentService {
|
||||||
|
|
||||||
|
List<List<SettingPaymentMethodVo>> method();
|
||||||
|
|
||||||
List<DevPayConfig> list();
|
List<DevPayConfig> list();
|
||||||
|
|
||||||
void edit(SettingPaymentValidate paymentValidate);
|
void editConfig(SettingPayConfigValidate configValidate);
|
||||||
|
|
||||||
|
void editMethod(SettingPayMethodValidate methodValidate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,24 @@ package com.mdd.admin.service.impl;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.mdd.admin.service.ISettingPaymentService;
|
import com.mdd.admin.service.ISettingPaymentService;
|
||||||
import com.mdd.admin.validate.setting.SettingPaymentValidate;
|
import com.mdd.admin.validate.setting.SettingPayConfigValidate;
|
||||||
|
import com.mdd.admin.validate.setting.SettingPayMethodValidate;
|
||||||
|
import com.mdd.admin.vo.setting.SettingPaymentMethodVo;
|
||||||
import com.mdd.common.entity.setting.DevPayConfig;
|
import com.mdd.common.entity.setting.DevPayConfig;
|
||||||
|
import com.mdd.common.entity.setting.DevPayWay;
|
||||||
import com.mdd.common.mapper.setting.DevPayConfigMapper;
|
import com.mdd.common.mapper.setting.DevPayConfigMapper;
|
||||||
|
import com.mdd.common.mapper.setting.DevPayWayMapper;
|
||||||
import com.mdd.common.util.MapUtils;
|
import com.mdd.common.util.MapUtils;
|
||||||
import com.mdd.common.util.UrlUtils;
|
import com.mdd.common.util.UrlUtils;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -24,6 +32,53 @@ public class SettingPaymentServiceImpl implements ISettingPaymentService {
|
||||||
@Resource
|
@Resource
|
||||||
DevPayConfigMapper devPayConfigMapper;
|
DevPayConfigMapper devPayConfigMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
DevPayWayMapper devPayWayMapper;
|
||||||
|
|
||||||
|
public List<List<SettingPaymentMethodVo>> method() {
|
||||||
|
List<DevPayWay> lists = devPayWayMapper.selectList(null);
|
||||||
|
|
||||||
|
List<List<SettingPaymentMethodVo>> result = new LinkedList<>();
|
||||||
|
List<SettingPaymentMethodVo> mnp = new LinkedList<>();
|
||||||
|
List<SettingPaymentMethodVo> oa = new LinkedList<>();
|
||||||
|
List<SettingPaymentMethodVo> h5 = new LinkedList<>();
|
||||||
|
|
||||||
|
for (DevPayWay devPayWay : lists) {
|
||||||
|
DevPayConfig devPayConfig = devPayConfigMapper.selectOne(
|
||||||
|
new QueryWrapper<DevPayConfig>()
|
||||||
|
.eq("id", devPayWay.getPayConfigId())
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
SettingPaymentMethodVo vo = new SettingPaymentMethodVo();
|
||||||
|
BeanUtils.copyProperties(devPayWay, vo);
|
||||||
|
vo.setName(devPayConfig.getName());
|
||||||
|
vo.setIcon(UrlUtils.toAbsoluteUrl(devPayConfig.getIcon()));
|
||||||
|
|
||||||
|
switch (devPayWay.getScene()) {
|
||||||
|
case 1: // 微信小程序
|
||||||
|
mnp.add(vo);
|
||||||
|
break;
|
||||||
|
case 2: // 微信公众号
|
||||||
|
oa.add(vo);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
h5.add(vo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.add(mnp);
|
||||||
|
result.add(oa);
|
||||||
|
result.add(h5);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付配置列表
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return List<DevPayConfig>
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<DevPayConfig> list() {
|
public List<DevPayConfig> list() {
|
||||||
List<DevPayConfig> devPayConfigs = devPayConfigMapper.selectList(
|
List<DevPayConfig> devPayConfigs = devPayConfigMapper.selectList(
|
||||||
|
|
@ -38,22 +93,46 @@ public class SettingPaymentServiceImpl implements ISettingPaymentService {
|
||||||
return devPayConfigs;
|
return devPayConfigs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付配置编辑
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @param configValidate 参数
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void edit(SettingPaymentValidate paymentValidate) {
|
public void editConfig(SettingPayConfigValidate configValidate) {
|
||||||
DevPayConfig devPayConfig = devPayConfigMapper.selectOne(
|
DevPayConfig devPayConfig = devPayConfigMapper.selectOne(
|
||||||
new QueryWrapper<DevPayConfig>()
|
new QueryWrapper<DevPayConfig>()
|
||||||
.eq("id", paymentValidate.getId())
|
.eq("id", configValidate.getId())
|
||||||
.last("limit 1"));
|
.last("limit 1"));
|
||||||
|
|
||||||
Assert.notNull(devPayConfig, "数据不存在!");
|
Assert.notNull(devPayConfig, "数据不存在!");
|
||||||
|
|
||||||
devPayConfig.setName(paymentValidate.getName());
|
devPayConfig.setName(configValidate.getName());
|
||||||
devPayConfig.setIcon(UrlUtils.toRelativeUrl(paymentValidate.getIcon()));
|
devPayConfig.setIcon(UrlUtils.toRelativeUrl(configValidate.getIcon()));
|
||||||
devPayConfig.setSort(paymentValidate.getSort());
|
devPayConfig.setSort(configValidate.getSort());
|
||||||
devPayConfig.setRemark(paymentValidate.getRemark());
|
devPayConfig.setRemark(configValidate.getRemark());
|
||||||
devPayConfig.setParams(JSON.toJSONString(paymentValidate.getParams()));
|
if (devPayConfig.getWay().equals(1)) {
|
||||||
|
devPayConfig.setParams("{}");
|
||||||
|
} else {
|
||||||
|
devPayConfig.setParams(JSON.toJSONString(configValidate.getParams()));
|
||||||
|
}
|
||||||
devPayConfigMapper.updateById(devPayConfig);
|
devPayConfigMapper.updateById(devPayConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void editMethod(SettingPayMethodValidate methodValidate) {
|
||||||
|
List<List<SettingPaymentMethodVo>> data = methodValidate.getData();
|
||||||
|
|
||||||
|
for (List<SettingPaymentMethodVo> list : data) {
|
||||||
|
for (SettingPaymentMethodVo vo : list) {
|
||||||
|
DevPayWay way = new DevPayWay();
|
||||||
|
way.setIsDefault(vo.getIsDefault());
|
||||||
|
way.setStatus(vo.getStatus());
|
||||||
|
devPayWayMapper.update(way, new QueryWrapper<DevPayWay>().eq("id", vo.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import java.util.Map;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ApiModel("支付渠道设置参数")
|
@ApiModel("支付渠道设置参数")
|
||||||
public class SettingPaymentValidate {
|
public class SettingPayConfigValidate {
|
||||||
|
|
||||||
@IDMust(message = "id参数必传且需大于0")
|
@IDMust(message = "id参数必传且需大于0")
|
||||||
@ApiModelProperty(value = "ID", required = true)
|
@ApiModelProperty(value = "ID", required = true)
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.mdd.admin.validate.setting;
|
||||||
|
|
||||||
|
import com.mdd.admin.vo.setting.SettingPaymentMethodVo;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("支付方式设置参数")
|
||||||
|
public class SettingPayMethodValidate {
|
||||||
|
|
||||||
|
List<List<SettingPaymentMethodVo>> data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.mdd.admin.vo.setting;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SettingPaymentMethodVo {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
private Integer isDefault;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -6,9 +6,11 @@ import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ApiModel("支付配置实体")
|
@ApiModel("支付配置实体")
|
||||||
public class DevPayConfig {
|
public class DevPayConfig implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.mdd.common.entity.setting;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("支付方式实体")
|
||||||
|
public class DevPayWay implements Serializable {
|
||||||
|
|
||||||
|
@TableId(value="id", type= IdType.AUTO)
|
||||||
|
@ApiModelProperty("ID")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty("支付配置ID")
|
||||||
|
private Integer payConfigId;
|
||||||
|
|
||||||
|
@ApiModelProperty("场景编码: [1=微信小程序, 2=微信公众号, 3=H5, 4=PC, 5=APP]")
|
||||||
|
private Integer scene;
|
||||||
|
|
||||||
|
@ApiModelProperty("默认支付: [0=否的, 1=是的]")
|
||||||
|
private Integer isDefault;
|
||||||
|
|
||||||
|
@ApiModelProperty("方式状态: [0=关闭, 1=开启]")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.mdd.common.mapper.setting;
|
||||||
|
|
||||||
|
import com.mdd.common.core.basics.IBaseMapper;
|
||||||
|
import com.mdd.common.entity.setting.DevPayWay;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付方式Mapper
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DevPayWayMapper extends IBaseMapper<DevPayWay> {
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue