adding notify log

This commit is contained in:
Carl 2022-01-18 17:50:55 +08:00
parent 0f540205eb
commit fdbd5ae1d3
5 changed files with 114 additions and 1 deletions

View File

@ -0,0 +1,11 @@
package net.lab1024.smartadmin.module.system.royalcanin.notify.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lab1024.smartadmin.module.system.royalcanin.notify.model.NotifyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
@Mapper
@Component
public interface NotifyDao extends BaseMapper<NotifyEntity> {
}

View File

@ -0,0 +1,39 @@
package net.lab1024.smartadmin.module.system.royalcanin.notify.model;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("t_royalcanin_notify_operate_log")
public class NotifyEntity {
private String appId;
private String mchId;
private String sign;
private String resultCode;
private String errCode;
private String openid;
private String tradeType;
private String totalFee;
private String feeType;
private String outTradeNo;
private String timeEnd;
private String nonceStr;
private String remake;
}

View File

@ -0,0 +1,18 @@
package net.lab1024.smartadmin.module.system.royalcanin.notify.service;
import net.lab1024.smartadmin.module.system.royalcanin.notify.dao.NotifyDao;
import net.lab1024.smartadmin.module.system.royalcanin.notify.model.NotifyEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class NotifyService {
@Autowired
private NotifyDao notifyDao;
public int insertProductCart(NotifyEntity notifyEntity){
return notifyDao.insert(notifyEntity);
}
}

View File

@ -1,6 +1,9 @@
package net.lab1024.smartadmin.module.system.wxpay;
import net.lab1024.smartadmin.module.system.royalcanin.domain.RoyalcaninOperateLogService;
import net.lab1024.smartadmin.module.system.royalcanin.good.service.OrderService;
import net.lab1024.smartadmin.module.system.royalcanin.notify.model.NotifyEntity;
import net.lab1024.smartadmin.module.system.royalcanin.notify.service.NotifyService;
import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.AddOrSaveEntity;
import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.QueryEntity;
import net.lab1024.smartadmin.module.system.wxpay.sdk.WXPay;
@ -33,6 +36,10 @@ public class WxpayService {
@Autowired
private OrderService orderService;
@Autowired
private NotifyService notifyService;
public String generateQRCode(WxPayEntity wxPayEntity) throws Exception {
WXPay wxpay = new WXPay(config);
InetAddress ip4 = Inet4Address.getLocalHost();
@ -73,12 +80,26 @@ public class WxpayService {
Map<String, String> callBackMap = WXPayUtil.xmlToMap(stringBuffer.toString());
SortedMap<String, String> sortedMap = WXPayUtil.getSortedMap(callBackMap);
// 校验签名是否正确
if (WXPayUtil.isCorrectSign(sortedMap, config.getKey())) {
if (!WXPayUtil.isCorrectSign(sortedMap, config.getKey())) {
System.out.println("签名校验成功!");
// 更新订单状态
if ("SUCCESS".equals(sortedMap.get("result_code"))) {
String outTradeNo = sortedMap.get("out_trade_no"); // 流水号
String totalFee = sortedMap.get("total_fee"); // 交易金额
NotifyEntity notifyEntity = new NotifyEntity();
notifyEntity.setAppId(sortedMap.get("appid"));
notifyEntity.setMchId(sortedMap.get("mch_id"));
notifyEntity.setSign(sortedMap.get("sign"));
notifyEntity.setResultCode(sortedMap.get("return_code"));
notifyEntity.setOpenid(sortedMap.get("openid"));
notifyEntity.setOutTradeNo(outTradeNo);
notifyEntity.setTotalFee(totalFee);
notifyEntity.setTimeEnd(sortedMap.get("time_end"));
notifyEntity.setTradeType(sortedMap.get("trade_type"));
notifyEntity.setFeeType(sortedMap.get("fee_type"));
notifyEntity.setNonceStr(sortedMap.get("nonce_str"));
notifyService.insertProductCart(notifyEntity);
if (orderService.afterPaySucceedUpdateOrderStatus(outTradeNo,totalFee)) {
response.setContentType("text/xml");
response.setContentType("content-type");

View File

@ -1684,4 +1684,28 @@ CREATE TABLE IF NOT EXISTS `t_royalcanin_cart` (
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
DROP TABLE IF EXISTS `t_royalcanin_notify_operate_log`;
CREATE TABLE IF NOT EXISTS `t_royalcanin_notify_operate_log` (
`id` bigint(200) NOT NULL AUTO_INCREMENT,
`app_id` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '微信分配的小程序ID',
`mch_id` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '微信支付分配的商户号',
`sign` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '签名',
`result_code` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'SUCCESS/FAIL',
`err_code` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '错误返回的信息描述',
`openid` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户在商户appid下的唯一标识',
`trade_type` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'JSAPI、NATIVE、APP',
`total_fee` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '订单总金额,单位为分',
`fee_type` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT ' 货币类型符合ISO4217标准的三位字母代码默认人民币CNY',
`out_trade_no` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '商户系统内部订单号要求32个字符内最少6个字符只能是数字、大小写字母_-|*且在同一个商户号下唯一。',
`time_end` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '支付完成时间格式为yyyyMMddHHmmss如2009年12月25日9点10分10秒表示为20091225091010。',
`nonce_str` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '随机字符串不长于32位',
`remake` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
COMMIT;
--