【admin】新增#备件管理
parent
1f20e73125
commit
7abdb0d1b3
|
@ -1,132 +0,0 @@
|
|||
package com.hcy.admin.config.wxpay;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
||||
import com.hcy.common.entity.pay.DevPay;
|
||||
import com.hcy.common.entity.system.SystemConfig;
|
||||
import com.hcy.common.entity.wxpay.SystemWxPayConfig;
|
||||
import com.hcy.common.enums.OrderPlayTypeEnum;
|
||||
import com.hcy.common.mapper.pay.DevPayMapper;
|
||||
import com.hcy.common.mapper.system.SystemConfigMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author panweiliang
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(WxPayService.class)
|
||||
@AllArgsConstructor
|
||||
public class WxPayConfiguration {
|
||||
|
||||
@Resource
|
||||
private DevPayMapper devPayMapper;
|
||||
|
||||
@Resource
|
||||
private SystemConfigMapper systemConfigMapper;
|
||||
|
||||
@Bean("mpWxPayService")
|
||||
public WxPayService mpWxPayService() {
|
||||
Boolean flag = Boolean.FALSE;
|
||||
WxPayConfig payConfig = new WxPayConfig();
|
||||
DevPay devPay = devPayMapper.getEntityByPayWay(OrderPlayTypeEnum.WECHAT_PAY.getType());
|
||||
String config = devPay.getConfig();
|
||||
SystemWxPayConfig systemWxPayConfig = JSON.parseObject(config, SystemWxPayConfig.class);
|
||||
//payConfig.setAppId(StringUtils.trimToNull(systemWxPayConfig.getAppId()));
|
||||
payConfig.setAppId(StringUtils.trimToNull(this.getAppId("mp_channel")));
|
||||
payConfig.setMchId(StringUtils.trimToNull(systemWxPayConfig.getMchId()));
|
||||
payConfig.setApiV3Key(StringUtils.trimToNull(systemWxPayConfig.getPaySignKey()));
|
||||
if (StringUtils.isNotEmpty(systemWxPayConfig.getApiclientKey())) {
|
||||
payConfig.setPrivateKeyContent(StringUtils.trimToNull(systemWxPayConfig.getApiclientKey()).getBytes());
|
||||
flag = Boolean.TRUE;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(systemWxPayConfig.getApiclientCert())) {
|
||||
payConfig.setPrivateCertContent(StringUtils.trimToNull(systemWxPayConfig.getApiclientCert()).getBytes());
|
||||
flag = Boolean.TRUE;
|
||||
}
|
||||
// 可以指定是否使用沙箱环境
|
||||
payConfig.setUseSandboxEnv(false);
|
||||
WxPayService wxPayService = new WxPayServiceImpl();
|
||||
if (flag) {
|
||||
wxPayService.setConfig(payConfig);
|
||||
}
|
||||
return wxPayService;
|
||||
}
|
||||
|
||||
@Bean("oaWxPayService")
|
||||
public WxPayService oaWxPayService() {
|
||||
Boolean flag = Boolean.FALSE;
|
||||
WxPayConfig payConfig = new WxPayConfig();
|
||||
DevPay devPay = devPayMapper.getEntityByPayWay(OrderPlayTypeEnum.WECHAT_PAY.getType());
|
||||
String config = devPay.getConfig();
|
||||
SystemWxPayConfig systemWxPayConfig = JSON.parseObject(config, SystemWxPayConfig.class);
|
||||
//payConfig.setAppId(StringUtils.trimToNull(systemWxPayConfig.getAppId()));
|
||||
payConfig.setAppId(StringUtils.trimToNull(this.getAppId("oa_channel")));
|
||||
payConfig.setMchId(StringUtils.trimToNull(systemWxPayConfig.getMchId()));
|
||||
payConfig.setApiV3Key(StringUtils.trimToNull(systemWxPayConfig.getPaySignKey()));
|
||||
if (StringUtils.isNotEmpty(systemWxPayConfig.getApiclientKey())) {
|
||||
payConfig.setPrivateKeyContent(StringUtils.trimToNull(systemWxPayConfig.getApiclientKey()).getBytes());
|
||||
flag = Boolean.TRUE;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(systemWxPayConfig.getApiclientCert())) {
|
||||
payConfig.setPrivateCertContent(StringUtils.trimToNull(systemWxPayConfig.getApiclientCert()).getBytes());
|
||||
flag = Boolean.TRUE;
|
||||
}
|
||||
// 可以指定是否使用沙箱环境
|
||||
payConfig.setUseSandboxEnv(false);
|
||||
WxPayService wxPayService = new WxPayServiceImpl();
|
||||
if (flag) {
|
||||
wxPayService.setConfig(payConfig);
|
||||
}
|
||||
return wxPayService;
|
||||
}
|
||||
|
||||
@Bean("h5WxPayService")
|
||||
public WxPayService h5WxPayService() {
|
||||
Boolean flag = Boolean.FALSE;
|
||||
WxPayConfig payConfig = new WxPayConfig();
|
||||
DevPay devPay = devPayMapper.getEntityByPayWay(OrderPlayTypeEnum.WECHAT_PAY.getType());
|
||||
String config = devPay.getConfig();
|
||||
SystemWxPayConfig systemWxPayConfig = JSON.parseObject(config, SystemWxPayConfig.class);
|
||||
//payConfig.setAppId(StringUtils.trimToNull(systemWxPayConfig.getAppId()));
|
||||
payConfig.setAppId(StringUtils.trimToNull(this.getAppId("h5_channel")));
|
||||
payConfig.setMchId(StringUtils.trimToNull(systemWxPayConfig.getMchId()));
|
||||
payConfig.setApiV3Key(StringUtils.trimToNull(systemWxPayConfig.getPaySignKey()));
|
||||
if (StringUtils.isNotEmpty(systemWxPayConfig.getApiclientKey())) {
|
||||
payConfig.setPrivateKeyContent(StringUtils.trimToNull(systemWxPayConfig.getApiclientKey()).getBytes());
|
||||
flag = Boolean.TRUE;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(systemWxPayConfig.getApiclientCert())) {
|
||||
payConfig.setPrivateCertContent(StringUtils.trimToNull(systemWxPayConfig.getApiclientCert()).getBytes());
|
||||
flag = Boolean.TRUE;
|
||||
}
|
||||
// 可以指定是否使用沙箱环境
|
||||
payConfig.setUseSandboxEnv(false);
|
||||
WxPayService wxPayService = new WxPayServiceImpl();
|
||||
if (flag) {
|
||||
wxPayService.setConfig(payConfig);
|
||||
}
|
||||
return wxPayService;
|
||||
}
|
||||
|
||||
private String getAppId(String channel) {
|
||||
List<SystemConfig> configs = systemConfigMapper.getAppId(channel);
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
for (SystemConfig config : configs) {
|
||||
map.put(config.getName(), config.getValue());
|
||||
}
|
||||
return map.getOrDefault("appId", "");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package com.hcy.admin.config.wxpay;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* wxpay pay properties.
|
||||
*
|
||||
* @author panweiliang
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "wx.pay")
|
||||
public class WxPayProperties {
|
||||
/**
|
||||
* 订单支付后回调
|
||||
*/
|
||||
private String orderNotifyUrl;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String orderRefundNotifyUrl;
|
||||
|
||||
/**
|
||||
* 商品描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package com.hcy.admin.controller.pay;
|
||||
|
||||
import com.hcy.admin.config.aop.Log;
|
||||
import com.hcy.admin.service.pay.IDevPayService;
|
||||
import com.hcy.admin.validate.pay.DevPayParam;
|
||||
import com.hcy.admin.vo.pay.DevPayDetailVo;
|
||||
import com.hcy.admin.vo.pay.DevPayListVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付配置管理
|
||||
*/
|
||||
@Api(tags = "支付配置管理")
|
||||
@RestController
|
||||
@RequestMapping("api/pay")
|
||||
public class DevPayController {
|
||||
|
||||
@Resource
|
||||
IDevPayService iDevPayService;
|
||||
|
||||
/**
|
||||
* 支付配置列表
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
@ApiOperation(value = "支付配置管理 - 列表")
|
||||
@GetMapping("/list")
|
||||
public List<DevPayListVo> list() {
|
||||
return iDevPayService.listPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付配置详情
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return Object
|
||||
*/
|
||||
@ApiOperation(value = "支付配置管理 - 详情")
|
||||
@GetMapping("/detail")
|
||||
public DevPayDetailVo detail(@Validated @RequestParam("id") Long id) {
|
||||
return iDevPayService.detail(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付配置编辑
|
||||
*
|
||||
* @param devPayParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@ApiOperation(value = "支付配置管理 - 编辑")
|
||||
@Log(title = "支付配置编辑")
|
||||
@PostMapping("/edit")
|
||||
public void edit(@Validated(value = DevPayParam.update.class) @RequestBody DevPayParam devPayParam) throws Exception {
|
||||
iDevPayService.edit(devPayParam);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package com.hcy.admin.controller.pay;
|
||||
|
||||
import com.hcy.admin.config.aop.Log;
|
||||
import com.hcy.admin.service.way.IDevPayWayService;
|
||||
import com.hcy.admin.validate.way.DevPayWayParam;
|
||||
import com.hcy.admin.vo.way.DevPayWayListVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付方式管理
|
||||
*/
|
||||
@Api(tags = "支付方式管理")
|
||||
@RestController
|
||||
@RequestMapping("api/way")
|
||||
public class DevPayWayController {
|
||||
|
||||
@Resource
|
||||
IDevPayWayService iDevPayWayService;
|
||||
|
||||
/**
|
||||
* 支付方式列表
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
@ApiOperation(value = "支付方式管理 - 列表")
|
||||
@GetMapping("/list")
|
||||
public Map<Long, List<DevPayWayListVo>> list() {
|
||||
return iDevPayWayService.listPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付方式编辑
|
||||
*
|
||||
* @param devPayWayParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@ApiOperation(value = "支付方式管理 - 编辑")
|
||||
@Log(title = "支付方式编辑")
|
||||
@PostMapping("/edit")
|
||||
public void edit(@Validated(value = DevPayWayParam.update.class) @RequestBody List<DevPayWayParam> devPayWayParam) {
|
||||
iDevPayWayService.edit(devPayWayParam);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package com.hcy.admin.controller.sparePart;
|
||||
|
||||
import com.hcy.admin.config.aop.Log;
|
||||
import com.hcy.admin.service.sparePart.ISparePartService;
|
||||
import com.hcy.admin.validate.sparePart.SparePartParam;
|
||||
import com.hcy.admin.validate.common.PageParam;
|
||||
|
||||
import com.hcy.admin.vo.sparePart.SparePartDetailVo;
|
||||
import com.hcy.admin.vo.sparePart.SparePartListVo;
|
||||
import com.hcy.common.core.AjaxResult;
|
||||
import com.hcy.common.core.PageResult;
|
||||
import com.hcy.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 备件信息管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/sparePart")
|
||||
public class SparePartController {
|
||||
|
||||
@Resource
|
||||
ISparePartService iSparePartService;
|
||||
|
||||
/**
|
||||
* 备件信息列表
|
||||
*
|
||||
* @author hcy
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<SparePartListVo> list = iSparePartService.list(pageParam, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
/**
|
||||
* 备件信息详情
|
||||
*
|
||||
* @author hcy
|
||||
* @param id 主键ID
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
SparePartDetailVo detail = iSparePartService.detail(id);
|
||||
return AjaxResult.success(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 备件信息新增
|
||||
*
|
||||
* @author hcy
|
||||
* @param sparePartParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "备件信息新增")
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = SparePartParam.create.class) @RequestBody SparePartParam sparePartParam) {
|
||||
iSparePartService.add(sparePartParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 备件信息编辑
|
||||
*
|
||||
* @author hcy
|
||||
* @param sparePartParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "备件信息编辑")
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = SparePartParam.update.class) @RequestBody SparePartParam sparePartParam) {
|
||||
iSparePartService.edit(sparePartParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 备件信息删除
|
||||
*
|
||||
* @author hcy
|
||||
* @param sparePartParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "备件信息删除")
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = SparePartParam.delete.class) @RequestBody SparePartParam sparePartParam) {
|
||||
iSparePartService.del(sparePartParam.getIds());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package com.hcy.admin.service.pay;
|
||||
|
||||
import com.hcy.admin.validate.pay.DevPayParam;
|
||||
import com.hcy.admin.vo.pay.DevPayDetailVo;
|
||||
import com.hcy.admin.vo.pay.DevPayListVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付配置服务接口类
|
||||
*/
|
||||
public interface IDevPayService {
|
||||
|
||||
/**
|
||||
* 支付配置列表
|
||||
*
|
||||
* @return PageResult<DevPayVo>
|
||||
*/
|
||||
List<DevPayListVo> listPage();
|
||||
|
||||
/**
|
||||
* 支付配置详情
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return DevPay
|
||||
*/
|
||||
DevPayDetailVo detail(Long id);
|
||||
|
||||
/**
|
||||
* 支付配置编辑
|
||||
*
|
||||
* @param devPayParam 参数
|
||||
*/
|
||||
void edit(DevPayParam devPayParam) throws Exception;
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
package com.hcy.admin.service.pay.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.hcy.admin.service.pay.IDevPayService;
|
||||
import com.hcy.admin.validate.pay.DevPayParam;
|
||||
import com.hcy.admin.vo.pay.DevPayConfigVo;
|
||||
import com.hcy.admin.vo.pay.DevPayDetailVo;
|
||||
import com.hcy.admin.vo.pay.DevPayListVo;
|
||||
import com.hcy.common.entity.pay.DevPay;
|
||||
import com.hcy.common.enums.OrderPlayTypeEnum;
|
||||
import com.hcy.common.mapper.pay.DevPayMapper;
|
||||
import com.hcy.common.utils.UrlUtil;
|
||||
import com.hcy.common.utils.YmlUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付配置实现类
|
||||
*/
|
||||
@Service
|
||||
public class DevPayServiceImpl extends ServiceImpl<DevPayMapper, DevPay> implements IDevPayService {
|
||||
|
||||
@Resource
|
||||
DevPayMapper devPayMapper;
|
||||
|
||||
/**
|
||||
* 支付配置列表
|
||||
*
|
||||
* @return PageResult<DevPayListVo>
|
||||
*/
|
||||
@Override
|
||||
public List<DevPayListVo> listPage() {
|
||||
LambdaQueryWrapper<DevPay> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.orderByAsc(DevPay::getId);
|
||||
List<DevPay> list = super.list(lambdaQueryWrapper);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<DevPayListVo> targetList = Lists.newArrayList();
|
||||
Map<Integer, String> map = OrderPlayTypeEnum.getMap();
|
||||
for (DevPay devPay : list) {
|
||||
DevPayListVo vo = new DevPayListVo();
|
||||
BeanUtils.copyProperties(devPay, vo);
|
||||
vo.setPayWayDesc(map.get(devPay.getPayWay()));
|
||||
vo.setImage(UrlUtil.toAbsoluteUrl(devPay.getImage()));
|
||||
targetList.add(vo);
|
||||
}
|
||||
return targetList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付配置详情
|
||||
*
|
||||
* @param id 主键参数
|
||||
* @return DevPay
|
||||
*/
|
||||
@Override
|
||||
public DevPayDetailVo detail(Long id) {
|
||||
DevPay model = devPayMapper.selectOne(
|
||||
new QueryWrapper<DevPay>()
|
||||
.eq("id", id)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在");
|
||||
|
||||
String env = YmlUtil.get("like.production");
|
||||
boolean envStatus = StringUtils.isNotEmpty(env) && env.equals("true");
|
||||
String config = model.getConfig();
|
||||
DevPayConfigVo devPayConfigVo = JSON.parseObject(config, DevPayConfigVo.class);
|
||||
Assert.notNull(devPayConfigVo, "该支付方式配置数据为空");
|
||||
DevPayDetailVo vo = new DevPayDetailVo();
|
||||
BeanUtils.copyProperties(model, vo);
|
||||
devPayConfigVo.setApiclientKey(envStatus ? "******" : devPayConfigVo.getApiclientKey());
|
||||
devPayConfigVo.setApiclientCert(envStatus ? "******" : devPayConfigVo.getApiclientCert());
|
||||
devPayConfigVo.setPaySignKey(envStatus ? "******" : devPayConfigVo.getPaySignKey());
|
||||
devPayConfigVo.setMchId(envStatus ? "******" : devPayConfigVo.getMchId());
|
||||
vo.setConfig(devPayConfigVo);
|
||||
vo.setImage(UrlUtil.toAbsoluteUrl(model.getImage()));
|
||||
vo.setPayWayDesc(OrderPlayTypeEnum.getMap().get(model.getPayWay()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付配置编辑
|
||||
*
|
||||
* @param devPayParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(DevPayParam devPayParam) throws Exception {
|
||||
DevPay model = devPayMapper.selectOne(
|
||||
new QueryWrapper<DevPay>()
|
||||
.eq("id", devPayParam.getId())
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在!");
|
||||
|
||||
model.setId(devPayParam.getId());
|
||||
model.setName(devPayParam.getName());
|
||||
model.setPayWay(devPayParam.getPayWay());
|
||||
String config = JSON.toJSONString(devPayParam.getConfig());
|
||||
model.setConfig(config);
|
||||
model.setImage(UrlUtil.toRelativeUrl(devPayParam.getImage()));
|
||||
model.setSort(devPayParam.getSort());
|
||||
devPayMapper.updateById(model);
|
||||
//wxPayConfigBuilder.buildWxPayClient();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.hcy.admin.service.sparePart;
|
||||
|
||||
import com.hcy.admin.validate.common.PageParam;
|
||||
import com.hcy.admin.validate.sparePart.SparePartParam;
|
||||
import com.hcy.admin.vo.sparePart.SparePartListVo;
|
||||
import com.hcy.admin.vo.sparePart.SparePartDetailVo;
|
||||
import com.hcy.common.core.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 备件信息服务接口类
|
||||
*/
|
||||
public interface ISparePartService {
|
||||
|
||||
/**
|
||||
* 备件信息列表
|
||||
*
|
||||
* @author hcy
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<SparePartVo>
|
||||
*/
|
||||
PageResult<SparePartListVo> list(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 备件信息详情
|
||||
*
|
||||
* @author hcy
|
||||
* @param id 主键ID
|
||||
* @return SparePart
|
||||
*/
|
||||
SparePartDetailVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 备件信息新增
|
||||
*
|
||||
* @author hcy
|
||||
* @param sparePartParam 参数
|
||||
*/
|
||||
void add(SparePartParam sparePartParam);
|
||||
|
||||
/**
|
||||
* 备件信息编辑
|
||||
*
|
||||
* @author hcy
|
||||
* @param sparePartParam 参数
|
||||
*/
|
||||
void edit(SparePartParam sparePartParam);
|
||||
|
||||
/**
|
||||
* 备件信息删除
|
||||
*
|
||||
* @author hcy
|
||||
* @param ids 主键ID
|
||||
*/
|
||||
void del(List<Integer> ids);
|
||||
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
package com.hcy.admin.service.sparePart.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.hcy.admin.service.sparePart.ISparePartService;
|
||||
import com.hcy.admin.validate.common.PageParam;
|
||||
import com.hcy.admin.validate.sparePart.SparePartParam;
|
||||
import com.hcy.admin.vo.sparePart.SparePartListVo;
|
||||
import com.hcy.admin.vo.sparePart.SparePartDetailVo;
|
||||
import com.hcy.common.constant.GlobalConstant;
|
||||
import com.hcy.common.core.PageResult;
|
||||
import com.hcy.common.entity.activity.Activity;
|
||||
import com.hcy.common.entity.sparePart.SparePart;
|
||||
import com.hcy.common.mapper.sparePart.SparePartMapper;
|
||||
import com.hcy.common.utils.TimeUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 备件信息实现类
|
||||
*/
|
||||
@Service
|
||||
public class SparePartServiceImpl implements ISparePartService {
|
||||
|
||||
@Resource
|
||||
SparePartMapper sparePartMapper;
|
||||
|
||||
/**
|
||||
* 备件信息列表
|
||||
*
|
||||
* @author hcy
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<SparePartListVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<SparePartListVo> list(PageParam pageParam, Map<String, String> params) {
|
||||
Integer page = pageParam.getPageNo();
|
||||
Integer limit = pageParam.getPageSize();
|
||||
|
||||
QueryWrapper<SparePart> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("is_delete", 0);
|
||||
queryWrapper.orderByDesc("id");
|
||||
|
||||
sparePartMapper.setSearch(queryWrapper, params, new String[]{
|
||||
"=:sparePartsCode@spare_parts_code:str",
|
||||
"like:sparePartsName@spare_parts_name:str",
|
||||
"=:owningWarehouse@owning_warehouse:long",
|
||||
"=:specificationsModel@specifications_model:str",
|
||||
"=:unit:str",
|
||||
"=:quantity:long",
|
||||
});
|
||||
|
||||
IPage<SparePart> iPage = sparePartMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<SparePartListVo> list = new LinkedList<>();
|
||||
for(SparePart item : iPage.getRecords()) {
|
||||
SparePartListVo vo = new SparePartListVo();
|
||||
BeanUtils.copyProperties(item, vo);
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(item.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(item.getUpdateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 备件信息详情
|
||||
*
|
||||
* @author hcy
|
||||
* @param id 主键参数
|
||||
* @return SparePart
|
||||
*/
|
||||
@Override
|
||||
public SparePartDetailVo detail(Integer id) {
|
||||
SparePart model = sparePartMapper.selectOne(
|
||||
new QueryWrapper<SparePart>()
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在");
|
||||
|
||||
SparePartDetailVo vo = new SparePartDetailVo();
|
||||
BeanUtils.copyProperties(model, vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 备件信息新增
|
||||
*
|
||||
* @author hcy
|
||||
* @param sparePartParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(SparePartParam sparePartParam) {
|
||||
SparePart model = new SparePart();
|
||||
model.setSparePartsCode(sparePartParam.getSparePartsCode());
|
||||
model.setSparePartsName(sparePartParam.getSparePartsName());
|
||||
model.setOwningWarehouse(sparePartParam.getOwningWarehouse());
|
||||
model.setSpecificationsModel(sparePartParam.getSpecificationsModel());
|
||||
model.setUnit(sparePartParam.getUnit());
|
||||
model.setQuantity(sparePartParam.getQuantity());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
sparePartMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 备件信息编辑
|
||||
*
|
||||
* @author hcy
|
||||
* @param sparePartParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(SparePartParam sparePartParam) {
|
||||
SparePart model = sparePartMapper.selectOne(
|
||||
new QueryWrapper<SparePart>()
|
||||
.eq("id", sparePartParam.getId())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在!");
|
||||
|
||||
model.setId(sparePartParam.getId());
|
||||
model.setSparePartsCode(sparePartParam.getSparePartsCode());
|
||||
model.setSparePartsName(sparePartParam.getSparePartsName());
|
||||
model.setOwningWarehouse(sparePartParam.getOwningWarehouse());
|
||||
model.setSpecificationsModel(sparePartParam.getSpecificationsModel());
|
||||
model.setUnit(sparePartParam.getUnit());
|
||||
model.setQuantity(sparePartParam.getQuantity());
|
||||
sparePartMapper.updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 备件信息删除
|
||||
*
|
||||
* @author hcy
|
||||
* @param ids 主键ID
|
||||
*/
|
||||
@Override
|
||||
public void del(List<Integer> ids) {
|
||||
List<SparePart> modelList = sparePartMapper.selectList(
|
||||
new QueryWrapper<SparePart>()
|
||||
.in("id", ids));
|
||||
|
||||
|
||||
Assert.notNull(modelList, "数据不存在!");
|
||||
// GlobalConstant.NOT_DELETE 调用未删除常量
|
||||
// GlobalConstant.DELETE 删除标识
|
||||
|
||||
for (SparePart sparePart : modelList) {
|
||||
sparePart.setIsDelete(GlobalConstant.DELETE);
|
||||
sparePart.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
sparePartMapper.updateById(sparePart);// 进行伪删除 根据id把is_delete修改成1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package com.hcy.admin.service.way;
|
||||
|
||||
import com.hcy.admin.validate.way.DevPayWayParam;
|
||||
import com.hcy.admin.vo.way.DevPayWayListVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付方式服务接口类
|
||||
*/
|
||||
public interface IDevPayWayService {
|
||||
|
||||
/**
|
||||
* 支付方式列表
|
||||
*
|
||||
* @return PageResult<DevPayWayVo>
|
||||
*/
|
||||
Map<Long, List<DevPayWayListVo>> listPage();
|
||||
|
||||
|
||||
/**
|
||||
* 支付方式编辑
|
||||
*
|
||||
* @param devPayWayParam 参数
|
||||
*/
|
||||
void edit(List<DevPayWayParam> devPayWayParam);
|
||||
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
package com.hcy.admin.service.way.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.hcy.admin.service.way.IDevPayWayService;
|
||||
import com.hcy.admin.validate.way.DevPayWayParam;
|
||||
import com.hcy.admin.vo.way.DevPayWayListVo;
|
||||
import com.hcy.common.entity.way.DevPayWay;
|
||||
import com.hcy.common.enums.ClientEnum;
|
||||
import com.hcy.common.enums.OrderPlayTypeEnum;
|
||||
import com.hcy.common.enums.StatusEnum;
|
||||
import com.hcy.common.exception.OperateException;
|
||||
import com.hcy.common.mapper.way.DevPayWayMapper;
|
||||
import com.hcy.common.utils.UrlUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付方式实现类
|
||||
*/
|
||||
@Service
|
||||
public class DevPayWayServiceImpl extends ServiceImpl<DevPayWayMapper, DevPayWay> implements IDevPayWayService {
|
||||
|
||||
@Resource
|
||||
DevPayWayMapper devPayWayMapper;
|
||||
|
||||
/**
|
||||
* 支付方式列表
|
||||
*
|
||||
* @return PageResult<DevPayWayListVo>
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, List<DevPayWayListVo>> listPage() {
|
||||
Map<Integer, String> map = OrderPlayTypeEnum.getMap();
|
||||
Map<Integer, String> clientMap = ClientEnum.getMap();
|
||||
Map<Long, List<DevPayWayListVo>> devPayWayListVoMap = Maps.newHashMap();
|
||||
|
||||
MPJQueryWrapper<DevPayWay> mpjQueryWrapper = new MPJQueryWrapper<DevPayWay>()
|
||||
.selectAll(DevPayWay.class)
|
||||
.select("pay.name as payName, pay.image as payImage, pay.pay_way as payWay")
|
||||
.innerJoin("la_dev_pay pay ON pay.id=t.pay_id")
|
||||
.orderByDesc(Arrays.asList("t.id"));
|
||||
List<DevPayWayListVo> list = devPayWayMapper.selectJoinList(DevPayWayListVo.class, mpjQueryWrapper);
|
||||
|
||||
|
||||
List<DevPayWayListVo> minprogram = new LinkedList<>();
|
||||
List<DevPayWayListVo> officialAccounts = new LinkedList<>();
|
||||
List<DevPayWayListVo> h5 = new LinkedList<>();
|
||||
List<DevPayWayListVo> other = new LinkedList<>();
|
||||
|
||||
//场景:1-微信小程序;2-微信公众号;3-H5;4-PC商城;5-APP;
|
||||
list.forEach(item -> {
|
||||
item.setPayWayDesc(map.get(item.getPayId()));
|
||||
item.setSceneDesc(clientMap.get(item.getScene()));
|
||||
item.setPayImage(UrlUtil.toAbsoluteUrl(item.getPayImage()));
|
||||
Integer scene = item.getScene();
|
||||
switch (scene) {
|
||||
case 1:
|
||||
minprogram.add(item);
|
||||
devPayWayListVoMap.put(item.getId(), minprogram);
|
||||
break;
|
||||
case 2:
|
||||
officialAccounts.add(item);
|
||||
devPayWayListVoMap.put(item.getId(), officialAccounts);
|
||||
break;
|
||||
case 3:
|
||||
h5.add(item);
|
||||
devPayWayListVoMap.put(item.getId(), h5);
|
||||
break;
|
||||
default:
|
||||
other.add(item);
|
||||
devPayWayListVoMap.put(item.getId(), other);
|
||||
break;
|
||||
}
|
||||
});
|
||||
return devPayWayListVoMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付方式编辑
|
||||
*
|
||||
* @param devPayWayParam 参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void edit(List<DevPayWayParam> devPayWayParam) {
|
||||
for (DevPayWayParam payWayParam : devPayWayParam) {
|
||||
DevPayWay model = devPayWayMapper.selectOne(
|
||||
new QueryWrapper<DevPayWay>()
|
||||
.eq("id", payWayParam.getId())
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在!");
|
||||
if (StatusEnum.NOT_ENABLE.getCode() == payWayParam.getStatus()) {
|
||||
throw new OperateException("小程序/公众号默认需要至少开启一个支付状态");
|
||||
}
|
||||
model.setId(payWayParam.getId());
|
||||
model.setScene(payWayParam.getScene());
|
||||
model.setPayId(payWayParam.getPayId());
|
||||
model.setIsDefault(payWayParam.getIsDefault());
|
||||
model.setStatus(payWayParam.getStatus());
|
||||
devPayWayMapper.updateById(model);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.hcy.admin.validate.sparePart;
|
||||
|
||||
|
||||
import com.hcy.common.validator.annotation.IDMust;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import lombok.Data;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 备件信息参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SparePartParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface delete{}
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class})
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "sparePartsCode参数缺失", groups = {create.class, update.class})
|
||||
@Length(max = 255, message = "sparePartsCode参数不能超出255个字符", groups = {create.class, update.class})
|
||||
private String sparePartsCode;
|
||||
|
||||
@NotNull(message = "sparePartsName参数缺失", groups = {create.class, update.class})
|
||||
@Length(max = 255, message = "sparePartsName参数不能超出255个字符", groups = {create.class, update.class})
|
||||
private String sparePartsName;
|
||||
|
||||
@NotNull(message = "owningWarehouse参数缺失", groups = {create.class, update.class})
|
||||
@DecimalMin(value = "0", message = "owningWarehouse参数值不能少于0", groups = {create.class, update.class})
|
||||
private Long owningWarehouse;
|
||||
|
||||
@NotNull(message = "specificationsModel参数缺失", groups = {create.class, update.class})
|
||||
@Length(max = 255, message = "specificationsModel参数不能超出255个字符", groups = {create.class, update.class})
|
||||
private String specificationsModel;
|
||||
|
||||
@NotNull(message = "unit参数缺失", groups = {create.class, update.class})
|
||||
@Length(max = 11, message = "unit参数不能超出11个字符", groups = {create.class, update.class})
|
||||
private String unit;
|
||||
|
||||
@NotNull(message = "quantity参数缺失", groups = {create.class, update.class})
|
||||
@DecimalMin(value = "0", message = "quantity参数值不能少于0", groups = {create.class, update.class})
|
||||
private Long quantity;
|
||||
|
||||
private List<Integer> ids; //备件id集合
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.hcy.admin.vo.sparePart;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* SparePartVo
|
||||
*/
|
||||
@Data
|
||||
public class SparePartDetailVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id; // 主键id
|
||||
private String sparePartsCode; // 备件编码
|
||||
private String sparePartsName; // 备件名称
|
||||
private Long owningWarehouse; // 所属仓库
|
||||
private String specificationsModel; // 规格型号
|
||||
private String unit; // 单位
|
||||
private Long quantity; // 库存数量
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.hcy.admin.vo.sparePart;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* SparePartVo
|
||||
*/
|
||||
@Data
|
||||
public class SparePartListVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id; // 主键id
|
||||
private String sparePartsCode; // 备件编码
|
||||
private String sparePartsName; // 备件名称
|
||||
private Long owningWarehouse; // 所属仓库
|
||||
private String specificationsModel; // 规格型号
|
||||
private String unit; // 单位
|
||||
private Long quantity; // 库存数量
|
||||
private String createTime; // 创建时间
|
||||
private String updateTime; // 更新时间
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ like:
|
|||
spring:
|
||||
# 数据源配置
|
||||
datasource:
|
||||
url: jdbc:mysql://192.168.4.107:3306/homemaking?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
|
||||
url: jdbc:mysql://192.168.4.107:3306/charging_pile?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
|
||||
type: com.zaxxer.hikari.HikariDataSource # 数据源类型
|
||||
driver-class-name: com.mysql.jdbc.Driver # MySql的驱动
|
||||
username: root # 数据库账号
|
||||
|
|
|
@ -6,7 +6,7 @@ like:
|
|||
spring:
|
||||
# 数据源配置
|
||||
datasource:
|
||||
url: jdbc:mysql://192.168.4.107:3306/homemaking?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
|
||||
url: jdbc:mysql://192.168.4.107:3306/charging_pile?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
|
||||
type: com.zaxxer.hikari.HikariDataSource # 数据源类型
|
||||
driver-class-name: com.mysql.jdbc.Driver # MySql的驱动
|
||||
username: root # 数据库账号
|
||||
|
|
|
@ -26,5 +26,4 @@ public class DictData implements Serializable {
|
|||
private Long createTime; // 创建时间
|
||||
private Long updateTime; // 更新时间
|
||||
private Long deleteTime; // 删除时间
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package com.hcy.common.entity.sparePart;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Date;
|
||||
|
||||
/**
|
||||
* 备件信息实体
|
||||
*/
|
||||
@Data
|
||||
public class SparePart implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
private Integer id; // 主键id
|
||||
private String sparePartsCode; // 备件编码
|
||||
private String sparePartsName; // 备件名称
|
||||
private Long owningWarehouse; // 所属仓库
|
||||
private String specificationsModel; // 规格型号
|
||||
private String unit; // 单位
|
||||
private Long quantity; // 库存数量
|
||||
private Integer isDelete; // 是否删除: [0=否, 1=是]
|
||||
private Long createTime; // 创建时间
|
||||
private Long updateTime; // 更新时间
|
||||
private Long deleteTime; // 删除时间
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package com.hcy.common.mapper.pay;
|
||||
|
||||
import com.hcy.common.core.basics.IBaseMapper;
|
||||
import com.hcy.common.entity.pay.DevPay;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
/**
|
||||
* 支付配置Mapper
|
||||
*/
|
||||
@Mapper()
|
||||
@Order(0)
|
||||
public interface DevPayMapper extends IBaseMapper<DevPay> {
|
||||
|
||||
@Select("Select * from la_dev_pay where pay_way = #{payWay} limit 1")
|
||||
DevPay getEntityByPayWay(@Param("payWay") Integer payWay);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.hcy.common.mapper.sparePart;
|
||||
|
||||
|
||||
import com.hcy.common.core.basics.IBaseMapper;
|
||||
import com.hcy.common.entity.sparePart.SparePart;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 备件信息Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface SparePartMapper extends IBaseMapper<SparePart> {
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package com.hcy.front.service.system;
|
||||
|
||||
import com.hcy.front.vo.system.SystemDevPayWayDetailVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付方式服务接口类
|
||||
*/
|
||||
public interface ISystemDevPayWayService {
|
||||
|
||||
/**
|
||||
* 支付方式列表
|
||||
*
|
||||
* @author panweiliang
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> list(Integer scene, Integer orderId, String type);
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package com.hcy.front.service.system.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.hcy.common.entity.order.Order;
|
||||
import com.hcy.common.entity.user.User;
|
||||
import com.hcy.common.entity.way.DevPayWay;
|
||||
import com.hcy.common.enums.OrderStatusEnum;
|
||||
import com.hcy.common.enums.PaymentEnum;
|
||||
import com.hcy.common.mapper.order.OrderMapper;
|
||||
import com.hcy.common.mapper.user.UserMapper;
|
||||
import com.hcy.common.mapper.way.DevPayWayMapper;
|
||||
import com.hcy.common.utils.UrlUtil;
|
||||
import com.hcy.front.FrontThreadLocal;
|
||||
import com.hcy.front.service.system.ISystemDevPayWayService;
|
||||
import com.hcy.front.vo.system.SystemDevPayWayDetailVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付方式实现类
|
||||
*/
|
||||
@Service
|
||||
public class SystemDevPayWayServiceImpl implements ISystemDevPayWayService {
|
||||
|
||||
@Resource
|
||||
DevPayWayMapper devPayWayMapper;
|
||||
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Resource
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
/**
|
||||
* 支付方式列表
|
||||
*
|
||||
* @author panweiliang
|
||||
* @return List<SystemDevPayWayListVo>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> list(Integer scene, Integer orderId, String type) {
|
||||
MPJQueryWrapper<DevPayWay> mpjQueryWrapper = new MPJQueryWrapper<DevPayWay>()
|
||||
.selectAll(DevPayWay.class)
|
||||
.select("pay.name as payName, pay.image as payImage, pay.pay_way as payWay")
|
||||
.innerJoin("la_dev_pay pay ON pay.id=t.pay_id")
|
||||
.eq("t.status", "1")
|
||||
.eq("t.scene", scene)
|
||||
.orderByDesc(Arrays.asList("t.id"));
|
||||
if ("recharge".equals(type)){
|
||||
mpjQueryWrapper.nested( wq -> wq.ne("pay_id",2));
|
||||
}
|
||||
List<SystemDevPayWayDetailVo> list = devPayWayMapper.selectJoinList(SystemDevPayWayDetailVo.class, mpjQueryWrapper);
|
||||
//场景:1-微信小程序;2-微信公众号;3-H5;4-PC商城;5-APP;
|
||||
list.forEach(item -> {
|
||||
item.setPayImage(UrlUtil.toAbsoluteUrl(item.getPayImage()));
|
||||
});
|
||||
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("payWayList", list);
|
||||
|
||||
// 如果是充值订单直接返回支付方式
|
||||
if("recharge".equals(type)){
|
||||
return map;
|
||||
}
|
||||
|
||||
// 获取用户余额信息
|
||||
LambdaQueryWrapper<User> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.select(User::getMoney);
|
||||
lambdaQueryWrapper.eq(User::getId, FrontThreadLocal.getUserId());
|
||||
lambdaQueryWrapper.eq(User::getIsDelete,0);
|
||||
lambdaQueryWrapper.last("limit 1");
|
||||
User user = userMapper.selectOne(lambdaQueryWrapper);
|
||||
//查询预约订单
|
||||
LambdaQueryWrapper<Order> orderLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
orderLambdaQueryWrapper.select(Order::getCancelTime);
|
||||
orderLambdaQueryWrapper.eq(Order::getId,orderId);
|
||||
orderLambdaQueryWrapper.eq(Order::getPayStatus, PaymentEnum.UN_PAID.getCode());
|
||||
orderLambdaQueryWrapper.eq(Order::getOrderStatus, OrderStatusEnum.WAIT_PAY.getStatus());
|
||||
orderLambdaQueryWrapper.eq(Order::getIsDelete,0);
|
||||
orderLambdaQueryWrapper.last("limit 1");
|
||||
Order order = orderMapper.selectOne(orderLambdaQueryWrapper);
|
||||
Assert.notNull(order, "此订单未处于待支付状态!");
|
||||
|
||||
// 预约订单返回余额支付和过期时间
|
||||
map.put("money",user.getMoney());
|
||||
map.put("cancelTime", order.getCancelTime());
|
||||
return map;
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue