Browse Source

修改最新需求

master
panxiaohe 2 years ago
parent
commit
26d91c79e9
  1. 9
      cereshop-app/src/main/java/com/shop/cereshop/app/controller/extend/XsPayController.java
  2. 30
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/xs/service/impl/XsPayServiceImpl.java
  3. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/service/pay/CerePayLogService.java
  4. 12
      cereshop-app/src/main/java/com/shop/cereshop/app/service/pay/impl/CerePayLogServiceImpl.java
  5. 3
      cereshop-business/src/main/java/com/shop/cereshop/business/controller/XsPayController.java
  6. 32
      cereshop-business/src/main/java/com/shop/cereshop/business/pay/xs/service/impl/XsPayServiceImpl.java
  7. 4
      cereshop-business/src/main/java/com/shop/cereshop/business/service/after/impl/CereOrderAfterServiceImpl.java
  8. 4
      cereshop-business/src/main/java/com/shop/cereshop/business/service/order/impl/CereShopOrderServiceImpl.java
  9. 148
      cereshop-business/src/main/resources/mybatis/mapper/log/HuaxunService.xml

9
cereshop-app/src/main/java/com/shop/cereshop/app/controller/extend/XsPayController.java

@ -50,7 +50,7 @@ public class XsPayController {
* @throws Exception
*/
@PostMapping("pay/notify")
public void payNotify(@RequestParam(name = "msg") String msg) throws Exception {
public String payNotify(@RequestParam(name = "msg") String msg) throws Exception {
try {
XsCallBackRequestVo xsCallBackRequestVo = xsPayService.parseCallBackRequestVo(msg);
String status = xsCallBackRequestVo.getContent().getString("status");
@ -90,6 +90,7 @@ public class XsPayController {
} catch (Exception e) {
e.printStackTrace();
}
return "success";
}
/**
@ -97,7 +98,7 @@ public class XsPayController {
* @throws Exception
*/
@PostMapping("pay/baoguannotify")
public void payBaoGuanNotify(@RequestParam(name = "msg") String msg) throws Exception {
public String payBaoGuanNotify(@RequestParam(name = "msg") String msg) throws Exception {
try {
XsCallBackRequestVo xsCallBackRequestVo = xsPayService.parseCallBackRequestVo(msg);
log.info(new Gson().toJson(xsCallBackRequestVo));
@ -116,6 +117,7 @@ public class XsPayController {
} catch (Exception e) {
e.printStackTrace();
}
return "success";
}
/**
@ -123,7 +125,8 @@ public class XsPayController {
* @throws Exception
*/
@PostMapping("refund/notify")
public void refundNotify(@RequestParam(name = "msg") String msg) throws Exception {
public String refundNotify(@RequestParam(name = "msg") String msg) throws Exception {
log.info("----refundNotify:" + msg);
return "success";
}
}

30
cereshop-app/src/main/java/com/shop/cereshop/app/pay/xs/service/impl/XsPayServiceImpl.java

@ -17,12 +17,14 @@ import com.shop.cereshop.app.pay.xs.service.XsPayService;
import com.shop.cereshop.app.pay.xs.utils.CommonUtils;
import com.shop.cereshop.app.pay.xs.utils.HttpUtils;
import com.shop.cereshop.app.service.buyer.CereBuyerUserService;
import com.shop.cereshop.app.service.pay.CerePayLogService;
import com.shop.cereshop.commons.config.XspayConfig;
import com.shop.cereshop.commons.constant.XsPayEnum;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.order.CereOrderParent;
import com.shop.cereshop.commons.domain.order.CereOrderProduct;
import com.shop.cereshop.commons.domain.order.CereShopOrder;
import com.shop.cereshop.commons.domain.pay.CerePayLog;
import com.shop.cereshop.commons.domain.shop.CereShopCrossDetail;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.EmptyUtils;
@ -55,6 +57,9 @@ public class XsPayServiceImpl implements XsPayService {
@Autowired
private CereShopCrossDetailDAO cereShopCrossDetailDAO;
@Autowired
private CerePayLogService cerePayLogService;
//支付申请服务代码 serCode
private static final String PAY_SER_CODE = "101005";
@ -518,12 +523,25 @@ public class XsPayServiceImpl implements XsPayService {
try {
//解析响应报文并验签
CommonUtils.verifySignRespMsg(BAOGUAN_SER_CODE,respMsg);
// LinkedHashMap<String,String> responseMap = JSONObject.parseObject(respMsg,new TypeReference<LinkedHashMap<String,String>>(){}, Feature.OrderedField );
// String resMsg = responseMap.get("msg");
// String responeMsg = new String(Base64.getDecoder().decode(resMsg));
// JSONObject jsonObject = JSONObject.parseObject(responeMsg);
// String qrCodeUrl = jsonObject.getJSONObject("content").getJSONObject("payInfo").getString("qrCodeUrl");
// qrCodeUrl = new URIBuilder(qrCodeUrl).getQueryParams().get(0).getValue();
LinkedHashMap<String,String> responseMap = JSONObject.parseObject(respMsg,new TypeReference<LinkedHashMap<String,String>>(){}, Feature.OrderedField );
String resMsg = responseMap.get("msg");
String responeMsg = new String(Base64.getDecoder().decode(resMsg));
JSONObject jsonObject = JSONObject.parseObject(responeMsg);
String respOrderDetailsStr = jsonObject.getJSONObject("content").getString("respOrderDetails");
if(StringUtils.isNotBlank(respOrderDetailsStr)){
JSONArray respOrderDetails = JSONObject.parseArray(respOrderDetailsStr);
for (int i = 0; i < respOrderDetails.size(); i++) {
JSONObject respOrderDetail = respOrderDetails.getJSONObject(i);
String subOrderNo = respOrderDetail.getString("subOrderNo");
String subPayTransactionNo = respOrderDetail.getString("subPayTransactionNo");
CerePayLog cerePayLog = cerePayLogService.selectByOrderFormid(subOrderNo);
if(cerePayLog != null){
cerePayLog.setTransactionId(subPayTransactionNo);
cerePayLogService.update(cerePayLog);
}
}
}
} catch (CoBusinessException e) {
throw e;
} catch (Exception e) {

2
cereshop-app/src/main/java/com/shop/cereshop/app/service/pay/CerePayLogService.java

@ -9,4 +9,6 @@ import com.shop.cereshop.commons.domain.pay.CerePayLog;
public interface CerePayLogService {
void insert(CerePayLog payLog) throws Exception;
void update(CerePayLog payLog) throws Exception;
CerePayLog selectByOrderFormid(String orderFormid);
}

12
cereshop-app/src/main/java/com/shop/cereshop/app/service/pay/impl/CerePayLogServiceImpl.java

@ -5,6 +5,7 @@
*/
package com.shop.cereshop.app.service.pay.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.shop.cereshop.app.dao.pay.CerePayLogDAO;
import com.shop.cereshop.app.service.pay.CerePayLogService;
import com.shop.cereshop.commons.domain.pay.CerePayLog;
@ -21,4 +22,15 @@ public class CerePayLogServiceImpl implements CerePayLogService {
public void insert(CerePayLog payLog) throws Exception {
cerePayLogDAO.insert(payLog);
}
@Override
public void update(CerePayLog payLog) throws Exception {
cerePayLogDAO.updateByPrimaryKey(payLog);
}
@Override
public CerePayLog selectByOrderFormid(String orderFormid){
return cerePayLogDAO.selectOne(Wrappers.<CerePayLog>lambdaQuery()
.eq(CerePayLog::getOrderFormid, orderFormid));
}
}

3
cereshop-business/src/main/java/com/shop/cereshop/business/controller/XsPayController.java

@ -81,7 +81,7 @@ public class XsPayController {
* @throws Exception
*/
@PostMapping("refund/notify")
public void refundNotify(@RequestParam(name = "msg") String msg) throws Exception {
public String refundNotify(@RequestParam(name = "msg") String msg) throws Exception {
log.info("refundNotify msg:" + msg);
try {
XsCallBackRequestVo xsCallBackRequestVo = xsPayService.parseCallBackRequestVo(msg);
@ -106,6 +106,7 @@ public class XsPayController {
} catch (Exception e) {
e.printStackTrace();
}
return "success";
//
}
}

32
cereshop-business/src/main/java/com/shop/cereshop/business/pay/xs/service/impl/XsPayServiceImpl.java

@ -13,6 +13,7 @@ import com.shop.cereshop.business.pay.xs.utils.CommonUtils;
import com.shop.cereshop.business.pay.xs.utils.HttpUtils;
import com.shop.cereshop.business.service.order.CereShopOrderService;
import com.shop.cereshop.commons.config.XspayConfig;
import com.shop.cereshop.commons.constant.WxPayEnum;
import com.shop.cereshop.commons.constant.XsPayEnum;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.EmptyUtils;
@ -24,6 +25,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Base64;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@ -66,19 +68,23 @@ public class XsPayServiceImpl implements XsPayService {
JSONObject content = jsonObject.getJSONObject("content");
String status = content.getString("status");
//2成功 3失败
if(StringUtils.equals(status, "0")) {
String merOrderId = content.getString("merOrderId");
String oldMmerOrderId = content.getString("oldMerOrderId");
String dealId = content.getString("refundOrderNo");
String[] split = oldMmerOrderId.split("-");
if (!EmptyUtils.isEmpty(split)) {
String orderFormId = split[0];
if (!EmptyUtils.isEmpty(orderFormId)) {
//处理支付成功后的其他逻辑
cereShopOrderService.handleRefundWxLog(orderFormId, dealId, merOrderId);
}
}
if(StringUtils.equals(status, "1")) {
Map<String, String> result = new HashMap<>();
result.put("return_msg", WxPayEnum.REFUND_SUCCESS.getCode());
result.put("return_code", WxPayEnum.REFUND_OK.getCode());
return result;
// String merOrderId = content.getString("merOrderId");
// String oldMmerOrderId = content.getString("oldMerOrderId");
// String dealId = content.getString("refundOrderNo");
//
// String[] split = oldMmerOrderId.split("-");
// if (!EmptyUtils.isEmpty(split)) {
// String orderFormId = split[0];
// if (!EmptyUtils.isEmpty(orderFormId)) {
// //处理支付成功后的其他逻辑
// cereShopOrderService.handleRefundWxLog(orderFormId, dealId, merOrderId);
// }
// }
}
} catch (CoBusinessException e) {
if(StringUtils.equals(e.getCode(), "0005")){

4
cereshop-business/src/main/java/com/shop/cereshop/business/service/after/impl/CereOrderAfterServiceImpl.java

@ -199,7 +199,7 @@ public class CereOrderAfterServiceImpl implements CereOrderAfterService {
if(resultMap.get("return_msg").equals(WxPayEnum.REFUND_SUCCESS.getCode())&&
resultMap.get("return_code").equals(WxPayEnum.REFUND_OK.getCode())){
//退款成功 支付宝的退款是立即退款的需要同步处理
if (Arrays.asList(IntegerEnum.ORDER_PAY_ALI.getCode(),
if (Arrays.asList(IntegerEnum.ORDER_PAY_ALI.getCode(),IntegerEnum.ORDER_PAY_XS.getCode(),
IntegerEnum.ORDER_PAY_HUABEI.getCode()).contains(order.getPaymentMode())) {
//内部调用不会执行事务所以通过springUtil获取service对象
CereOrderAfterService afterService = SpringUtil.getBean(CereOrderAfterService.class);
@ -337,7 +337,7 @@ public class CereOrderAfterServiceImpl implements CereOrderAfterService {
if(resultMap.get("return_msg").equals(WxPayEnum.REFUND_SUCCESS.getCode())&&
resultMap.get("return_code").equals(WxPayEnum.REFUND_OK.getCode())){
//退款成功 支付宝的退款是立即退款的需要同步处理
if (Arrays.asList(IntegerEnum.ORDER_PAY_ALI.getCode(),
if (Arrays.asList(IntegerEnum.ORDER_PAY_ALI.getCode(),IntegerEnum.ORDER_PAY_XS.getCode(),
IntegerEnum.ORDER_PAY_HUABEI.getCode()).contains(order.getPaymentMode())) {
//内部调用不会执行事务所以通过springUtil获取service对象
CereOrderAfterService afterService = SpringUtil.getBean(CereOrderAfterService.class);

4
cereshop-business/src/main/java/com/shop/cereshop/business/service/order/impl/CereShopOrderServiceImpl.java

@ -359,12 +359,12 @@ public class CereShopOrderServiceImpl implements CereShopOrderService {
//微信支付没通,暂时直接处理业务
// handleRefundTestWxLog(order.getOrderFormid(),refund.getTransactionId(),refund.getOutTradeNo());
PayService payService = PayFactory.getPayService(refund.getPaymentMode());
Map<String, String> resultMap = payService.orderRefund(refund.getOrderFormid(), refund.getTransactionId(), refund.getOutRefundNo(), refund.getTotalFee(), refund.getTotalFee());
Map<String, String> resultMap = payService.orderRefund(refund.getOutTradeNo(), refund.getTransactionId(), refund.getOutRefundNo(), refund.getTotalFee(), refund.getTotalFee());
if(!EmptyUtils.isEmpty(resultMap)){
if(resultMap.get("return_msg").equals(WxPayEnum.REFUND_SUCCESS.getCode())&&
resultMap.get("return_code").equals(WxPayEnum.REFUND_OK.getCode())){
//退款成功 支付宝的退款是立即退款的需要同步处理
if (Arrays.asList(IntegerEnum.ORDER_PAY_ALI.getCode(),
if (Arrays.asList(IntegerEnum.ORDER_PAY_ALI.getCode(),IntegerEnum.ORDER_PAY_XS.getCode(),
IntegerEnum.ORDER_PAY_HUABEI.getCode()).contains(order.getPaymentMode())) {
//内部调用不会执行事务所以通过springUtil获取service对象
CereShopOrderService cereShopOrderService = SpringUtil.getBean(CereShopOrderService.class);

148
cereshop-business/src/main/resources/mybatis/mapper/log/HuaxunService.xml

@ -1,148 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shop.cereshop.business.dao.log.CerePlatformWebLogDAO">
<resultMap id="BaseResultMap" type="com.shop.cereshop.commons.domain.log.CerePlatformWebLog">
<id column="web_log_id" jdbcType="BIGINT" property="webLogId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="url" jdbcType="VARCHAR" property="url" />
<result column="params" jdbcType="VARCHAR" property="params" />
<result column="type" jdbcType="BIT" property="type" />
<result column="ip" jdbcType="VARCHAR" property="ip" />
<result column="ip_source" jdbcType="VARCHAR" property="ipSource" />
<result column="describe" jdbcType="VARCHAR" property="describe" />
<result column="browser_name" jdbcType="VARCHAR" property="browserName" />
<result column="time" jdbcType="INTEGER" property="time" />
<result column="create_time" jdbcType="VARCHAR" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
web_log_id, `name`, url, params, `type`, ip, ip_source, `describe`, browser_name,
`time`, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from cere_platform_web_log
where web_log_id = #{webLogId,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from cere_platform_web_log
where web_log_id = #{webLogId,jdbcType=BIGINT}
</delete>
<insert id="insertSelective" keyColumn="web_log_id" keyProperty="webLogId" parameterType="com.shop.cereshop.commons.domain.log.CerePlatformWebLog" useGeneratedKeys="true">
insert into cere_platform_web_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">
`name`,
</if>
<if test="url != null">
url,
</if>
<if test="params != null">
params,
</if>
<if test="type != null">
`type`,
</if>
<if test="ip != null">
ip,
</if>
<if test="ipSource != null">
ip_source,
</if>
<if test="describe != null">
`describe`,
</if>
<if test="browserName != null">
browser_name,
</if>
<if test="time != null">
`time`,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="url != null">
#{url,jdbcType=VARCHAR},
</if>
<if test="params != null">
#{params,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=BIT},
</if>
<if test="ip != null">
#{ip,jdbcType=VARCHAR},
</if>
<if test="ipSource != null">
#{ipSource,jdbcType=VARCHAR},
</if>
<if test="describe != null">
#{describe,jdbcType=VARCHAR},
</if>
<if test="browserName != null">
#{browserName,jdbcType=VARCHAR},
</if>
<if test="time != null">
#{time,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.shop.cereshop.commons.domain.log.CerePlatformWebLog">
update cere_platform_web_log
<set>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="url != null">
url = #{url,jdbcType=VARCHAR},
</if>
<if test="params != null">
params = #{params,jdbcType=VARCHAR},
</if>
<if test="type != null">
`type` = #{type,jdbcType=BIT},
</if>
<if test="ip != null">
ip = #{ip,jdbcType=VARCHAR},
</if>
<if test="ipSource != null">
ip_source = #{ipSource,jdbcType=VARCHAR},
</if>
<if test="describe != null">
`describe` = #{describe,jdbcType=VARCHAR},
</if>
<if test="browserName != null">
browser_name = #{browserName,jdbcType=VARCHAR},
</if>
<if test="time != null">
`time` = #{time,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=VARCHAR},
</if>
</set>
where web_log_id = #{webLogId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.shop.cereshop.commons.domain.log.CerePlatformWebLog">
update cere_platform_web_log
set `name` = #{name,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR},
params = #{params,jdbcType=VARCHAR},
`type` = #{type,jdbcType=BIT},
ip = #{ip,jdbcType=VARCHAR},
ip_source = #{ipSource,jdbcType=VARCHAR},
`describe` = #{describe,jdbcType=VARCHAR},
browser_name = #{browserName,jdbcType=VARCHAR},
`time` = #{time,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=VARCHAR}
where web_log_id = #{webLogId,jdbcType=BIGINT}
</update>
</mapper>
Loading…
Cancel
Save