yshop1.6.3新增微信退款及其模板消息,后台新增支付证书配置,修复手机端管理端拒绝退款bug
This commit is contained in:
@ -141,8 +141,6 @@ public class ShoperController extends BaseController {
|
|||||||
@PostMapping("/admin/order/refund")
|
@PostMapping("/admin/order/refund")
|
||||||
@ApiOperation(value = "订单退款",notes = "订单退款")
|
@ApiOperation(value = "订单退款",notes = "订单退款")
|
||||||
public ApiResult<Object> orderRefund(@Validated @RequestBody OrderRefundParam param){
|
public ApiResult<Object> orderRefund(@Validated @RequestBody OrderRefundParam param){
|
||||||
//if(ObjectUtil.isNotNull(param)) return ApiResult.fail("演示环境禁止操作");
|
|
||||||
int uid = SecurityUtils.getUserId().intValue();
|
|
||||||
|
|
||||||
storeOrderService.orderRefund(param);
|
storeOrderService.orderRefund(param);
|
||||||
|
|
||||||
@ -157,7 +155,6 @@ public class ShoperController extends BaseController {
|
|||||||
@ApiOperation(value = "chart统计",notes = "chart统计")
|
@ApiOperation(value = "chart统计",notes = "chart统计")
|
||||||
public ApiResult<Object> chartCount(@RequestParam(value = "cate",defaultValue = "1") int cate,
|
public ApiResult<Object> chartCount(@RequestParam(value = "cate",defaultValue = "1") int cate,
|
||||||
@RequestParam(value = "type",defaultValue = "1") int type){
|
@RequestParam(value = "type",defaultValue = "1") int type){
|
||||||
int uid = SecurityUtils.getUserId().intValue();
|
|
||||||
|
|
||||||
return ApiResult.ok(storeOrderService.chartCount(cate,type));
|
return ApiResult.ok(storeOrderService.chartCount(cate,type));
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import javax.validation.constraints.NotNull;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName OrderPriceParam
|
* @ClassName OrderRefundParam
|
||||||
* @Author hupeng <610796224@qq.com>
|
* @Author hupeng <610796224@qq.com>
|
||||||
* @Date 2019/11/26
|
* @Date 2019/11/26
|
||||||
**/
|
**/
|
||||||
|
@ -32,9 +32,6 @@ import java.util.Map;
|
|||||||
* @author hupeng
|
* @author hupeng
|
||||||
* @since 2019-10-27
|
* @since 2019-10-27
|
||||||
*/
|
*/
|
||||||
//@WebService(serviceName = "YxStoreOrderService",
|
|
||||||
// targetNamespace = "http://service.order.modules.yixiang.co"
|
|
||||||
//)
|
|
||||||
public interface YxStoreOrderService extends BaseService<YxStoreOrder> {
|
public interface YxStoreOrderService extends BaseService<YxStoreOrder> {
|
||||||
|
|
||||||
Map<String,Object> chartCount(int cate,int type);
|
Map<String,Object> chartCount(int cate,int type);
|
||||||
|
@ -57,6 +57,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||||
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
||||||
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
import com.github.binarywang.wxpay.config.WxPayConfig;
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
@ -168,8 +169,6 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
|||||||
private AlipayService alipayService;
|
private AlipayService alipayService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单退款
|
* 订单退款
|
||||||
* @param param
|
* @param param
|
||||||
@ -188,10 +187,18 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
|||||||
YxStoreOrder storeOrder = new YxStoreOrder();
|
YxStoreOrder storeOrder = new YxStoreOrder();
|
||||||
//修改状态
|
//修改状态
|
||||||
storeOrder.setId(orderQueryVo.getId());
|
storeOrder.setId(orderQueryVo.getId());
|
||||||
|
|
||||||
|
if(param.getType() == 2){
|
||||||
|
storeOrder.setRefundStatus(0);
|
||||||
|
yxStoreOrderMapper.updateById(storeOrder);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据支付类型不同退款不同
|
||||||
|
if(orderQueryVo.getPayType().equals("yue")){
|
||||||
storeOrder.setRefundStatus(2);
|
storeOrder.setRefundStatus(2);
|
||||||
storeOrder.setRefundPrice(BigDecimal.valueOf(param.getPrice()));
|
storeOrder.setRefundPrice(BigDecimal.valueOf(param.getPrice()));
|
||||||
yxStoreOrderMapper.updateById(storeOrder);
|
yxStoreOrderMapper.updateById(storeOrder);
|
||||||
|
|
||||||
//退款到余额
|
//退款到余额
|
||||||
userService.incMoney(orderQueryVo.getUid(),param.getPrice());
|
userService.incMoney(orderQueryVo.getUid(),param.getPrice());
|
||||||
|
|
||||||
@ -212,6 +219,60 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
|||||||
|
|
||||||
|
|
||||||
orderStatusService.create(orderQueryVo.getId(),"order_edit","退款给用户:"+param.getPrice() +"元");
|
orderStatusService.create(orderQueryVo.getId(),"order_edit","退款给用户:"+param.getPrice() +"元");
|
||||||
|
}else{
|
||||||
|
String apiUrl = RedisUtil.get("api_url");
|
||||||
|
if(StrUtil.isBlank(apiUrl)) throw new ErrorRequestException("请配置api地址");
|
||||||
|
//读取redis配置
|
||||||
|
String appId = RedisUtil.get("wxpay_appId");
|
||||||
|
String mchId = RedisUtil.get("wxpay_mchId");
|
||||||
|
String mchKey = RedisUtil.get("wxpay_mchKey");
|
||||||
|
String keyPath = RedisUtil.get("wxpay_keyPath");
|
||||||
|
|
||||||
|
if(StrUtil.isBlank(appId) || StrUtil.isBlank(mchId) || StrUtil.isBlank(mchKey)){
|
||||||
|
throw new ErrorRequestException("请配置微信支付");
|
||||||
|
}
|
||||||
|
if(StrUtil.isBlank(keyPath)){
|
||||||
|
throw new ErrorRequestException("请配置微信支付证书");
|
||||||
|
}
|
||||||
|
WxPayRefundRequest wxPayRefundRequest = new WxPayRefundRequest();
|
||||||
|
BigDecimal bigDecimal = new BigDecimal("100");
|
||||||
|
wxPayRefundRequest.setTotalFee(bigDecimal.multiply(orderQueryVo.getPayPrice()).intValue());//订单总金额
|
||||||
|
wxPayRefundRequest.setOutTradeNo(param.getOrderId());
|
||||||
|
wxPayRefundRequest.setOutRefundNo(param.getOrderId());
|
||||||
|
wxPayRefundRequest.setRefundFee(bigDecimal.multiply(orderQueryVo.getPayPrice()).intValue());//退款金额
|
||||||
|
wxPayRefundRequest.setOpUserId(mchId); //操作人默认商户号当前
|
||||||
|
wxPayRefundRequest.setNotifyUrl(apiUrl+"/api/notify/refund");
|
||||||
|
|
||||||
|
WxPayConfig wxPayConfig = new WxPayConfig();
|
||||||
|
wxPayConfig.setAppId(appId);
|
||||||
|
wxPayConfig.setMchId(mchId);
|
||||||
|
wxPayConfig.setMchKey(mchKey);
|
||||||
|
wxPayConfig.setKeyPath(keyPath);
|
||||||
|
wxPayService.setConfig(wxPayConfig);
|
||||||
|
try {
|
||||||
|
wxPayService.refund(wxPayRefundRequest);
|
||||||
|
} catch (WxPayException e) {
|
||||||
|
log.info("refund-error:{}",e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//模板消息通知
|
||||||
|
String siteUrl = RedisUtil.get("site_url");
|
||||||
|
YxWechatUserQueryVo wechatUser = wechatUserService.getYxWechatUserById(orderQueryVo.getUid());
|
||||||
|
if(ObjectUtil.isNotNull(wechatUser)){
|
||||||
|
YxWechatTemplate WechatTemplate = yxWechatTemplateService.getOne(
|
||||||
|
new QueryWrapper<YxWechatTemplate>().eq("tempkey","OPENTM410119152"));
|
||||||
|
Map<String,String> map = new HashMap<>();
|
||||||
|
map.put("first","您在yshop的订单退款申请被通过,钱款将很快还至您的支付账户。");
|
||||||
|
map.put("keyword1",orderQueryVo.getOrderId());//订单号
|
||||||
|
map.put("keyword2",orderQueryVo.getPayPrice().toString());
|
||||||
|
map.put("keyword3",OrderUtil.stampToDate(orderQueryVo.getAddTime().toString()));
|
||||||
|
map.put("remark","yshop电商系统为你服务!");
|
||||||
|
templateMessageService.sendWxMpTemplateMessage( wechatUser.getOpenid()
|
||||||
|
,WechatTemplate.getTempid(),
|
||||||
|
siteUrl+"/order/detail/"+orderQueryVo.getOrderId(),map);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +113,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
.antMatchers("/wechat/auth").anonymous()
|
.antMatchers("/wechat/auth").anonymous()
|
||||||
.antMatchers("/share").anonymous()
|
.antMatchers("/share").anonymous()
|
||||||
.antMatchers("/wechat/notify").anonymous()
|
.antMatchers("/wechat/notify").anonymous()
|
||||||
|
.antMatchers("/notify/refund").anonymous()
|
||||||
.antMatchers("/wechat/serve").anonymous()
|
.antMatchers("/wechat/serve").anonymous()
|
||||||
.antMatchers("/logistics").anonymous()
|
.antMatchers("/logistics").anonymous()
|
||||||
.antMatchers("/seckill/index").anonymous()
|
.antMatchers("/seckill/index").anonymous()
|
||||||
|
@ -34,7 +34,9 @@ public class JobTimer {
|
|||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
Map<String,Object> job = blockingQueue.take();
|
Map<String,Object> job = blockingQueue.take();
|
||||||
|
if(job != null){
|
||||||
executorService.execute(new ExecutorTask(job));
|
executorService.execute(new ExecutorTask(job));
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
try {
|
try {
|
||||||
|
@ -6,6 +6,8 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import co.yixiang.common.api.ApiCode;
|
import co.yixiang.common.api.ApiCode;
|
||||||
import co.yixiang.common.api.ApiResult;
|
import co.yixiang.common.api.ApiResult;
|
||||||
import co.yixiang.common.web.controller.BaseController;
|
import co.yixiang.common.web.controller.BaseController;
|
||||||
|
import co.yixiang.modules.manage.web.param.OrderRefundParam;
|
||||||
|
import co.yixiang.modules.order.entity.YxStoreOrder;
|
||||||
import co.yixiang.modules.order.service.YxStoreOrderService;
|
import co.yixiang.modules.order.service.YxStoreOrderService;
|
||||||
import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
||||||
import co.yixiang.modules.security.security.JwtUser;
|
import co.yixiang.modules.security.security.JwtUser;
|
||||||
@ -21,6 +23,7 @@ import co.yixiang.utils.EncryptUtils;
|
|||||||
import co.yixiang.utils.OrderUtil;
|
import co.yixiang.utils.OrderUtil;
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
||||||
|
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
import com.vdurmont.emoji.EmojiParser;
|
import com.vdurmont.emoji.EmojiParser;
|
||||||
@ -245,6 +248,36 @@ public class WechatController extends BaseController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信退款回调
|
||||||
|
* @param xmlData
|
||||||
|
* @return
|
||||||
|
* @throws WxPayException
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "退款回调通知处理",notes = "退款回调通知处理")
|
||||||
|
@PostMapping("/notify/refund")
|
||||||
|
public String parseRefundNotifyResult(@RequestBody String xmlData) {
|
||||||
|
try {
|
||||||
|
WxPayRefundNotifyResult result = wxPayService.parseRefundNotifyResult(xmlData);
|
||||||
|
String orderId = result.getReqInfo().getOutTradeNo();
|
||||||
|
Integer refundFee = result.getReqInfo().getRefundFee()/100;
|
||||||
|
YxStoreOrderQueryVo orderInfo = orderService.getOrderInfo(orderId,0);
|
||||||
|
if(orderInfo.getRefundStatus() == 2){
|
||||||
|
return WxPayNotifyResponse.success("处理成功!");
|
||||||
|
}
|
||||||
|
YxStoreOrder storeOrder = new YxStoreOrder();
|
||||||
|
//修改状态
|
||||||
|
storeOrder.setId(orderInfo.getId());
|
||||||
|
storeOrder.setRefundStatus(2);
|
||||||
|
storeOrder.setRefundPrice(BigDecimal.valueOf(refundFee));
|
||||||
|
orderService.updateById(storeOrder);
|
||||||
|
return WxPayNotifyResponse.success("处理成功!");
|
||||||
|
} catch (WxPayException e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return WxPayNotifyResponse.fail(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信验证消息
|
* 微信验证消息
|
||||||
|
@ -36,7 +36,6 @@ spring:
|
|||||||
web-stat-filter:
|
web-stat-filter:
|
||||||
url-pattern: /*
|
url-pattern: /*
|
||||||
exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
|
exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
|
||||||
connection-init-sqls: set names utf8mb4
|
|
||||||
|
|
||||||
#配置 Jpa
|
#配置 Jpa
|
||||||
jpa:
|
jpa:
|
||||||
|
@ -187,6 +187,24 @@ public class YxStoreOrderController {
|
|||||||
@PreAuthorize("hasAnyRole('ADMIN','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
|
@PreAuthorize("hasAnyRole('ADMIN','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
|
||||||
public ResponseEntity refund(@Validated @RequestBody YxStoreOrder resources){
|
public ResponseEntity refund(@Validated @RequestBody YxStoreOrder resources){
|
||||||
yxStoreOrderService.refund(resources);
|
yxStoreOrderService.refund(resources);
|
||||||
|
|
||||||
|
//模板消息通知
|
||||||
|
String siteUrl = RedisUtil.get("site_url");
|
||||||
|
YxWechatUserDTO wechatUser = wechatUserService.findById(resources.getUid());
|
||||||
|
if(ObjectUtil.isNotNull(wechatUser)){
|
||||||
|
YxWechatTemplate WechatTemplate = yxWechatTemplateService
|
||||||
|
.findByTempkey("OPENTM410119152");
|
||||||
|
Map<String,String> map = new HashMap<>();
|
||||||
|
map.put("first","您在yshop的订单退款申请被通过,钱款将很快还至您的支付账户。");
|
||||||
|
map.put("keyword1",resources.getOrderId());//订单号
|
||||||
|
map.put("keyword2",resources.getPayPrice().toString());
|
||||||
|
map.put("keyword3",OrderUtil.stampToDate(resources.getAddTime().toString()));
|
||||||
|
map.put("remark","yshop电商系统为你服务!");
|
||||||
|
templateMessageService.sendWxMpTemplateMessage( wechatUser.getOpenid()
|
||||||
|
,WechatTemplate.getTempid(),
|
||||||
|
siteUrl+"/order/detail/"+resources.getOrderId(),map);
|
||||||
|
}
|
||||||
|
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,10 @@ package co.yixiang.modules.shop.service.impl;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import co.yixiang.exception.BadRequestException;
|
import co.yixiang.exception.BadRequestException;
|
||||||
import co.yixiang.exception.EntityExistException;
|
import co.yixiang.exception.EntityExistException;
|
||||||
|
import co.yixiang.exception.ErrorRequestException;
|
||||||
import co.yixiang.modules.activity.domain.YxStorePink;
|
import co.yixiang.modules.activity.domain.YxStorePink;
|
||||||
import co.yixiang.modules.activity.repository.YxStorePinkRepository;
|
import co.yixiang.modules.activity.repository.YxStorePinkRepository;
|
||||||
import co.yixiang.modules.activity.service.YxStorePinkService;
|
import co.yixiang.modules.activity.service.YxStorePinkService;
|
||||||
@ -21,15 +23,22 @@ import co.yixiang.modules.shop.service.dto.*;
|
|||||||
import co.yixiang.modules.shop.service.mapper.YxStoreOrderMapper;
|
import co.yixiang.modules.shop.service.mapper.YxStoreOrderMapper;
|
||||||
import co.yixiang.utils.OrderUtil;
|
import co.yixiang.utils.OrderUtil;
|
||||||
import co.yixiang.utils.QueryHelp;
|
import co.yixiang.utils.QueryHelp;
|
||||||
|
import co.yixiang.utils.RedisUtil;
|
||||||
import co.yixiang.utils.ValidationUtil;
|
import co.yixiang.utils.ValidationUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import co.yixiang.modules.shop.domain.StoreOrderCartInfo;
|
import co.yixiang.modules.shop.domain.StoreOrderCartInfo;
|
||||||
import co.yixiang.modules.shop.repository.YxStoreOrderCartInfoRepository;
|
import co.yixiang.modules.shop.repository.YxStoreOrderCartInfoRepository;
|
||||||
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
||||||
|
import com.github.binarywang.wxpay.config.WxPayConfig;
|
||||||
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -39,6 +48,7 @@ import org.springframework.data.domain.Pageable;
|
|||||||
* @author hupeng
|
* @author hupeng
|
||||||
* @date 2019-10-14
|
* @date 2019-10-14
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||||
public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||||
@ -67,6 +77,9 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private YxStorePinkRepository storePinkRepository;
|
private YxStorePinkRepository storePinkRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WxPayService wxPayService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrderTimeDataDTO getOrderTimeData() {
|
public OrderTimeDataDTO getOrderTimeData() {
|
||||||
int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date()));
|
int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date()));
|
||||||
@ -112,6 +125,7 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
|||||||
throw new BadRequestException("请输入退款金额");
|
throw new BadRequestException("请输入退款金额");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(resources.getPayType().equals("yue")){
|
||||||
//修改状态
|
//修改状态
|
||||||
resources.setRefundStatus(2);
|
resources.setRefundStatus(2);
|
||||||
resources.setRefundPrice(resources.getPayPrice());
|
resources.setRefundPrice(resources.getPayPrice());
|
||||||
@ -145,6 +159,44 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
|||||||
storeOrderStatus.setChangeTime(OrderUtil.getSecondTimestampTwo());
|
storeOrderStatus.setChangeTime(OrderUtil.getSecondTimestampTwo());
|
||||||
|
|
||||||
yxStoreOrderStatusService.create(storeOrderStatus);
|
yxStoreOrderStatusService.create(storeOrderStatus);
|
||||||
|
}else{
|
||||||
|
String apiUrl = RedisUtil.get("api_url");
|
||||||
|
if(StrUtil.isBlank(apiUrl)) throw new BadRequestException("请配置api地址");
|
||||||
|
//读取redis配置
|
||||||
|
String appId = RedisUtil.get("wxpay_appId");
|
||||||
|
String mchId = RedisUtil.get("wxpay_mchId");
|
||||||
|
String mchKey = RedisUtil.get("wxpay_mchKey");
|
||||||
|
String keyPath = RedisUtil.get("wxpay_keyPath");
|
||||||
|
|
||||||
|
if(StrUtil.isBlank(appId) || StrUtil.isBlank(mchId) || StrUtil.isBlank(mchKey)){
|
||||||
|
throw new BadRequestException("请配置微信支付");
|
||||||
|
}
|
||||||
|
if(StrUtil.isBlank(keyPath)){
|
||||||
|
throw new BadRequestException("请配置微信支付证书");
|
||||||
|
}
|
||||||
|
WxPayRefundRequest wxPayRefundRequest = new WxPayRefundRequest();
|
||||||
|
BigDecimal bigDecimal = new BigDecimal("100");
|
||||||
|
wxPayRefundRequest.setTotalFee(bigDecimal.multiply(resources.getPayPrice()).intValue());//订单总金额
|
||||||
|
wxPayRefundRequest.setOutTradeNo(resources.getOrderId());
|
||||||
|
wxPayRefundRequest.setOutRefundNo(resources.getOrderId());
|
||||||
|
wxPayRefundRequest.setRefundFee(bigDecimal.multiply(resources.getPayPrice()).intValue());//退款金额
|
||||||
|
wxPayRefundRequest.setOpUserId(mchId); //操作人默认商户号当前
|
||||||
|
wxPayRefundRequest.setNotifyUrl(apiUrl+"/api/notify/refund");
|
||||||
|
|
||||||
|
WxPayConfig wxPayConfig = new WxPayConfig();
|
||||||
|
wxPayConfig.setAppId(appId);
|
||||||
|
wxPayConfig.setMchId(mchId);
|
||||||
|
wxPayConfig.setMchKey(mchKey);
|
||||||
|
wxPayConfig.setKeyPath(keyPath);
|
||||||
|
wxPayService.setConfig(wxPayConfig);
|
||||||
|
try {
|
||||||
|
wxPayService.refund(wxPayRefundRequest);
|
||||||
|
} catch (WxPayException e) {
|
||||||
|
log.info("refund-error:{}",e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,4 +85,4 @@ file:
|
|||||||
# 文件大小 /M
|
# 文件大小 /M
|
||||||
maxSize: 100
|
maxSize: 100
|
||||||
avatarMaxSize: 5
|
avatarMaxSize: 5
|
||||||
localUrl: http://localhost:8000
|
localUrl: https://yshopapi.dayouqiantu.cn
|
Reference in New Issue
Block a user