/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.pay.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.gson.Gson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springblade.common.enums.PayType; import org.springblade.modules.pay.entity.PaymentInfoEntity; import org.springblade.modules.pay.mapper.PaymentInfoMapper; import org.springblade.modules.pay.vo.PaymentInfoVO; import org.springblade.modules.pay.service.IPaymentInfoService; import org.springblade.core.mp.base.BaseServiceImpl; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import java.util.HashMap; import java.util.Map; /** * 支付信息 服务实现类 * * @author BladeX * @since 2024-04-07 */ @Service public class PaymentInfoServiceImpl extends ServiceImpl implements IPaymentInfoService { private static Logger logger = LoggerFactory.getLogger(PaymentInfoServiceImpl.class); @Override public IPage selectPaymentInfoPage(IPage page, PaymentInfoVO paymentInfo) { return page.setRecords(baseMapper.selectPaymentInfoPage(page, paymentInfo)); } /** * 记录支付日志 * @param plainText */ @Override public void createPaymentInfo(String plainText) { logger.info("记录支付日志"); Gson gson = new Gson(); HashMap plainTextMap = gson.fromJson(plainText, HashMap.class); //订单号 String orderNo = (String)plainTextMap.get("out_trade_no"); //业务编号 String transactionId = (String)plainTextMap.get("transaction_id"); //支付类型 String tradeType = (String)plainTextMap.get("trade_type"); //交易状态 String tradeState = (String)plainTextMap.get("trade_state"); //用户实际支付金额 Map amount = (Map)plainTextMap.get("amount"); Integer payerTotal = ((Double) amount.get("payer_total")).intValue(); PaymentInfoEntity paymentInfo = new PaymentInfoEntity(); paymentInfo.setOrderNo(orderNo); paymentInfo.setPaymentType(PayType.WXPAY.getType()); paymentInfo.setTransactionId(transactionId); paymentInfo.setTradeType(tradeType); paymentInfo.setTradeState(tradeState); paymentInfo.setPayerTotal(payerTotal); paymentInfo.setContent(plainText); baseMapper.insert(paymentInfo); } }