|
|
@ -41,6 +41,7 @@ import com.ruoyi.applet.utils.WechatRefundUtil; |
|
|
|
import com.ruoyi.common.constant.Constants; |
|
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
|
import com.ruoyi.common.core.redis.RedisService; |
|
|
|
import com.ruoyi.common.utils.IDGenerator; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.ruoyi.common.utils.spring.SpringUtils; |
|
|
|
import com.ruoyi.framework.config.LocalDataUtil; |
|
|
@ -430,8 +431,7 @@ public class IApiMallOrderServiceImpl implements IApiMallOrderService { |
|
|
|
refundHistory.setCreateTime(LocalDateTime.now()); |
|
|
|
refundHistory.setUpdateTime(LocalDateTime.now()); |
|
|
|
|
|
|
|
// 这里需要注入WechatPaymentHistoryMapper,暂时注释 |
|
|
|
// wechatPaymentHistoryMapper.insert(refundHistory); |
|
|
|
wechatPaymentHistoryMapper.insert(refundHistory); |
|
|
|
log.info("退款历史记录已创建:{}", refundHistory); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("记录退款历史失败", e); |
|
|
@ -462,26 +462,34 @@ public class IApiMallOrderServiceImpl implements IApiMallOrderService { |
|
|
|
QueryWrapper<MemberWechat> memberWechatQw = new QueryWrapper<>(); |
|
|
|
memberWechatQw.eq("member_id", req.getMemberId()); |
|
|
|
MemberWechat memberWechat = memberWechatMapper.selectOne(memberWechatQw); |
|
|
|
if (memberWechat == null || StrUtil.isBlank(memberWechat.getOpenid())){ |
|
|
|
if (memberWechat == null || StrUtil.isBlank(memberWechat.getRoutineOpenid())){ |
|
|
|
throw new RuntimeException("获取用户openId失败"); |
|
|
|
} |
|
|
|
|
|
|
|
Order order = orderList.get(0); |
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<OrderItem> orderItemQw = new QueryWrapper<>(); |
|
|
|
orderItemQw.eq("order_id", orderList.get(0).getId()); |
|
|
|
orderItemQw.eq("order_id", order.getId()); |
|
|
|
List<OrderItem> orderItemList = orderItemMapper.selectList(orderItemQw); |
|
|
|
String orderDesc = orderItemList.get(0).getProductName().substring(0, Math.min(40, orderItemList.get(0).getProductName().length())); |
|
|
|
//保存微信支付历史 |
|
|
|
LocalDateTime optDate = LocalDateTime.now(); |
|
|
|
QueryWrapper<WechatPaymentHistory> wxPaymentQw = new QueryWrapper<>(); |
|
|
|
wxPaymentQw.eq("order_id", orderList.get(0).getPayId()); |
|
|
|
wxPaymentQw.eq("order_id", order.getPayId()); |
|
|
|
wxPaymentQw.eq("op_type", Constants.PaymentOpType.PAY); |
|
|
|
WechatPaymentHistory wechatPaymentHistory = wechatPaymentHistoryMapper.selectOne(wxPaymentQw); |
|
|
|
if (wechatPaymentHistory == null){ |
|
|
|
wechatPaymentHistory = new WechatPaymentHistory(); |
|
|
|
wechatPaymentHistory.setOrderId(orderList.get(0).getPayId()); |
|
|
|
// WechatPaymentHistory wechatPaymentHistory = wechatPaymentHistoryMapper.selectOne(wxPaymentQw); |
|
|
|
// if (wechatPaymentHistory == null){ |
|
|
|
|
|
|
|
Long payId = IDGenerator.generateId(); |
|
|
|
|
|
|
|
WechatPaymentHistory wechatPaymentHistory = new WechatPaymentHistory(); |
|
|
|
wechatPaymentHistory.setId(payId); |
|
|
|
wechatPaymentHistory.setOrderId(order.getId()); |
|
|
|
wechatPaymentHistory.setMemberId(req.getMemberId()); |
|
|
|
wechatPaymentHistory.setOpenid(memberWechat.getOpenid()); |
|
|
|
wechatPaymentHistory.setOpenid(memberWechat.getRoutineOpenid()); |
|
|
|
wechatPaymentHistory.setTitle(orderItemList.get(0).getProductName()); |
|
|
|
wechatPaymentHistory.setMoney(orderList.get(0).getPayAmount()); |
|
|
|
wechatPaymentHistory.setMoney(order.getPayAmount()); |
|
|
|
wechatPaymentHistory.setOpType(Constants.PaymentOpType.PAY); |
|
|
|
wechatPaymentHistory.setPaymentStatus(0); |
|
|
|
wechatPaymentHistory.setCreateBy(req.getMemberId()); |
|
|
@ -489,10 +497,16 @@ public class IApiMallOrderServiceImpl implements IApiMallOrderService { |
|
|
|
wechatPaymentHistory.setUpdateBy(req.getMemberId()); |
|
|
|
wechatPaymentHistory.setUpdateTime(optDate); |
|
|
|
wechatPaymentHistoryMapper.insert(wechatPaymentHistory); |
|
|
|
}else { |
|
|
|
wechatPaymentHistory.setMoney(orderList.get(0).getPayAmount()); |
|
|
|
wechatPaymentHistoryMapper.updateById(wechatPaymentHistory); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
req.setPayId(payId); |
|
|
|
order.setPayId(payId); |
|
|
|
orderMapper.updateById(order); |
|
|
|
|
|
|
|
// }else { |
|
|
|
// wechatPaymentHistory.setMoney(order.getPayAmount()); |
|
|
|
// wechatPaymentHistoryMapper.updateById(wechatPaymentHistory); |
|
|
|
// } |
|
|
|
//请开启微信支付 wechat.enabled=true |
|
|
|
//调用wx的jsapi拿prepayId,返回签名等信息 |
|
|
|
String openId = memberWechat.getOpenid(); |
|
|
|