袁野 1 month ago
parent 7ed2fa80f5
commit 9a57d7b571
  1. 2
      order/src/main/java/com/order/controller/business/BsOrderMeiTuanController.java
  2. 57
      order/src/main/java/com/order/controller/notify/MeiTuanController.java
  3. 14
      service/src/main/java/com/hfkj/service/order/BsOrderRefundService.java
  4. 17
      service/src/main/java/com/hfkj/service/order/OrderCancelService.java
  5. 83
      service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java
  6. 2
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java

@ -39,7 +39,7 @@ public class BsOrderMeiTuanController {
try { try {
// 查询配置的平台服务费 // 查询配置的平台服务费
SecConfig config = secConfigService.queryDetail(platformCode); SecConfig config = secConfigService.queryDetail(platformCode);
BigDecimal servicePrice = new BigDecimal(0); BigDecimal servicePrice;
if (config == null) { if (config == null) {
log.error("orderMeiTuan -> servicePrice() error!"); log.error("orderMeiTuan -> servicePrice() error!");

@ -7,8 +7,11 @@ import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.OrderUtil; import com.hfkj.common.utils.OrderUtil;
import com.hfkj.config.CommonSysConst; import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.BsOrderMeituan; import com.hfkj.entity.BsOrderMeituan;
import com.hfkj.entity.BsOrderRefund;
import com.hfkj.meituan.MeiTuanService; import com.hfkj.meituan.MeiTuanService;
import com.hfkj.service.goods.BsOrderMeiTuanService; import com.hfkj.service.goods.BsOrderMeiTuanService;
import com.hfkj.service.order.BsOrderRefundService;
import com.hfkj.service.order.BsOrderService;
import com.hfkj.sysenum.order.OrderChildStatusEnum; import com.hfkj.sysenum.order.OrderChildStatusEnum;
import com.meituan.sqt.utils.EncryptUtil; import com.meituan.sqt.utils.EncryptUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -32,6 +35,10 @@ public class MeiTuanController {
@Resource @Resource
private BsOrderMeiTuanService bsOrderMeiTuanService; private BsOrderMeiTuanService bsOrderMeiTuanService;
@Resource
private BsOrderRefundService orderRefundService;
@Resource
private BsOrderService orderService;
private static Logger log = LoggerFactory.getLogger(MeiTuanService.class); private static Logger log = LoggerFactory.getLogger(MeiTuanService.class);
@ -115,6 +122,55 @@ public class MeiTuanController {
} }
// 退款 // 退款
if (Objects.equals(jsonObject.getString("method"), "trade.third.refund")) { if (Objects.equals(jsonObject.getString("method"), "trade.third.refund")) {
BsOrderRefund orderRefund = orderRefundService.meiTuanRefund(
jsonObject.getString("tradeRefundNo") ,
jsonObject.getString("tradeNo") ,
jsonObject.getBigDecimal("refundAmount") ,
"美团退款"
);
// 美团退款订单
JSONObject object = new JSONObject();
object.put("thirdRefundNo" , orderRefund.getRefundOrderNo());
log.info("美团关闭订单-参数: {}", object);
JSONObject data = new JSONObject();
data.put("status", 0);
data.put("msg", "成功");
data.put("data", EncryptUtil.aesEncrypt(object.toJSONString() , CommonSysConst.getSysConfig().getMtSecretKey()));
log.info("============回调任务End=============");
return data;
}
// 交易关单
if (Objects.equals(jsonObject.getString("method"), "trade.third.pay.close")) {
BsOrderMeituan orderMeiTuan = bsOrderMeiTuanService.findOrderMeiTuanByTradeNo(jsonObject.getString("tradeNo"));
if (orderMeiTuan != null) {
if (orderMeiTuan.getStatus() == OrderChildStatusEnum.status1.getCode() || orderMeiTuan.getStatus() == OrderChildStatusEnum.status5.getCode()) {
if (orderMeiTuan.getOrderNo() == null) {
orderMeiTuan.setCancelTime(new Date());
orderMeiTuan.setStatus(OrderChildStatusEnum.status5.getCode());
bsOrderMeiTuanService.update(orderMeiTuan);
} else {
orderService.cancel(orderMeiTuan.getOrderNo(), false);
}
// 美团查询订单
JSONObject object = new JSONObject();
object.put("tradeNo" , orderMeiTuan.getTradeNo());
object.put("thirdTradeNo" , orderMeiTuan.getThirdTradeNo());
log.info("美团关闭订单-参数: {}", object);
JSONObject data = new JSONObject();
data.put("status", 0);
data.put("msg", "成功");
data.put("data", EncryptUtil.aesEncrypt(object.toJSONString() , CommonSysConst.getSysConfig().getMtSecretKey()));
log.info("============回调任务End=============");
return data;
}
}
return null; return null;
} }
if (Objects.equals(jsonObject.getString("method"), "trade.third.pay.query")) { if (Objects.equals(jsonObject.getString("method"), "trade.third.pay.query")) {
@ -128,7 +184,6 @@ public class MeiTuanController {
object.put("tradeTime" , "1970-01-01 00:00:00"); object.put("tradeTime" , "1970-01-01 00:00:00");
} else { } else {
object.put("tradeTime" , orderMeiTuan.getPayTime()); object.put("tradeTime" , orderMeiTuan.getPayTime());
} }
object.put("tradeAmount" , orderMeiTuan.getTradeAmount()); object.put("tradeAmount" , orderMeiTuan.getTradeAmount());
object.put("payStatus" , MeiTuanService.payStatus(orderMeiTuan.getStatus())); object.put("payStatus" , MeiTuanService.payStatus(orderMeiTuan.getStatus()));

@ -44,13 +44,14 @@ public interface BsOrderRefundService {
/** /**
* @MethodName meiTuanRefund * @MethodName meiTuanRefund
* @Description: 美团退款 * @Description: 美团退款
* @param childOrderNo * @param tradeRefundNo
* @param remark * @param remark
* @param refundPrice
* @return: com.hfkj.entity.BsOrderRefund * @return: com.hfkj.entity.BsOrderRefund
* @Author: Sum1Dream * @Author: Sum1Dream
* @Date: 2024/9/18 下午4:33 * @Date: 2024/9/18 下午4:33
*/ */
BsOrderRefund meiTuanRefund(String childOrderNo, String tradeNo , BigDecimal refundPrice, String remark); BsOrderRefund meiTuanRefund(String tradeRefundNo, String tradeNo , BigDecimal refundPrice, String remark);
/** /**
* 查询退款 * 查询退款
@ -58,6 +59,15 @@ public interface BsOrderRefundService {
* @return * @return
*/ */
BsOrderRefund getRefund(String refundOrderNo); BsOrderRefund getRefund(String refundOrderNo);
/**
* @MethodName getRefundByTradeRefundNo
* @Description:
* @param tradeRefundNo
* @return: com.hfkj.entity.BsOrderRefund
* @Author: Sum1Dream
* @Date: 2024/9/23 上午11:16
*/
BsOrderRefund getRefundByTradeRefundNo(String tradeRefundNo);
/** /**
* 查询退款列表 * 查询退款列表
* @param param * @param param

@ -3,10 +3,12 @@ package com.hfkj.service.order;
import com.hfkj.common.utils.RedisUtil; import com.hfkj.common.utils.RedisUtil;
import com.hfkj.entity.BsOrderChild; import com.hfkj.entity.BsOrderChild;
import com.hfkj.entity.BsOrderCoupon; import com.hfkj.entity.BsOrderCoupon;
import com.hfkj.entity.BsOrderMeituan;
import com.hfkj.entity.GoodsMsg; import com.hfkj.entity.GoodsMsg;
import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderChildModel;
import com.hfkj.model.order.OrderModel; import com.hfkj.model.order.OrderModel;
import com.hfkj.service.coupon.BsOrderCouponService; import com.hfkj.service.coupon.BsOrderCouponService;
import com.hfkj.service.goods.BsOrderMeiTuanService;
import com.hfkj.service.goods.GoodsMsgService; import com.hfkj.service.goods.GoodsMsgService;
import com.hfkj.service.goods.GoodsSpecsService; import com.hfkj.service.goods.GoodsSpecsService;
import com.hfkj.sysenum.order.OrderChildProductTypeEnum; import com.hfkj.sysenum.order.OrderChildProductTypeEnum;
@ -44,6 +46,8 @@ public class OrderCancelService {
private GoodsMsgService goodsMsgService; private GoodsMsgService goodsMsgService;
@Resource @Resource
private GoodsSpecsService goodsSpecsService; private GoodsSpecsService goodsSpecsService;
@Resource
private BsOrderMeiTuanService bsOrderMeiTuanService;
/** /**
* 订单业务处理 * 订单业务处理
* @param order * @param order
@ -55,6 +59,9 @@ public class OrderCancelService {
if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type2.getCode())) { if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type2.getCode())) {
product(childOrder); product(childOrder);
} }
if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type5.getCode())) {
meituan(childOrder);
}
} }
} }
@ -79,5 +86,15 @@ public class OrderCancelService {
} }
} }
// 美团订单取消
public void meituan(OrderChildModel orderChild) {
// 查询产品
BsOrderMeituan orderMeiTuan = bsOrderMeiTuanService.findOrderMeiTuan(orderChild.getChildOrderNo());
orderMeiTuan.setCancelTime(new Date());
orderMeiTuan.setStatus(OrderChildStatusEnum.status5.getCode());
bsOrderMeiTuanService.update(orderMeiTuan);
}
} }

@ -12,6 +12,7 @@ import com.hfkj.entity.*;
import com.hfkj.mer.BsMerPayConfigService; import com.hfkj.mer.BsMerPayConfigService;
import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderChildModel;
import com.hfkj.model.order.OrderModel; import com.hfkj.model.order.OrderModel;
import com.hfkj.service.goods.BsOrderMeiTuanService;
import com.hfkj.service.hlt.HltCardRefundService; import com.hfkj.service.hlt.HltCardRefundService;
import com.hfkj.service.hlt.HuiLianTongUnionCardService; import com.hfkj.service.hlt.HuiLianTongUnionCardService;
import com.hfkj.service.order.BsOrderChildService; import com.hfkj.service.order.BsOrderChildService;
@ -35,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -60,6 +62,8 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
private HltCardRefundService hltCardRefundService; private HltCardRefundService hltCardRefundService;
@Resource @Resource
private OrderRefundSuccessService orderRefundSuccessService; private OrderRefundSuccessService orderRefundSuccessService;
@Resource
private BsOrderMeiTuanService orderMeiTuanService;
@Override @Override
public void editData(BsOrderRefund data) { public void editData(BsOrderRefund data) {
data.setUpdateTime(new Date()); data.setUpdateTime(new Date());
@ -248,16 +252,31 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class}) @Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class})
public BsOrderRefund meiTuanRefund(String childOrderNo, String tradeNo , BigDecimal refundPrice, String remark) { public BsOrderRefund meiTuanRefund(String tradeRefundNo, String tradeNo , BigDecimal refundPrice, String remark) {
// 查询退款订
BsOrderRefund bsOrderRefund = getRefundByTradeRefundNo(tradeRefundNo);
if (bsOrderRefund != null) {
return bsOrderRefund;
}
// 查询业务订单
BsOrderMeituan orderMeiTuan = orderMeiTuanService.findOrderMeiTuanByTradeNo(tradeNo);
if (orderMeiTuan == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的业务订单");
}
// 查询子订单 // 查询子订单
OrderChildModel orderChild = orderChildService.getDetail(childOrderNo); OrderChildModel orderChild = orderChildService.getDetail(orderMeiTuan.getChildOrderNo());
if (orderChild == null) { if (orderChild == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的子订单"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的子订单");
} }
// if (productCount > orderChild.getSurplusRefundCount()) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!退货数量超过子订单可退数量"); if (orderChild.getStatus() != OrderChildStatusEnum.status2.getCode()) {
// } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态不支持退款!");
}
// 查询交易订单 // 查询交易订单
BsOrder order = orderService.getOrder(orderChild.getOrderNo()); BsOrder order = orderService.getOrder(orderChild.getOrderNo());
if (order == null) { if (order == null) {
@ -276,20 +295,35 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
orderRefund.setRefundPayChannel(order.getPayChannel()); orderRefund.setRefundPayChannel(order.getPayChannel());
orderRefund.setReufndPayType(order.getPayType()); orderRefund.setReufndPayType(order.getPayType());
// if (orderChild.getSurplusRefundCount().equals(productCount)) { // 是否全额退款
// // 全部退款 if (orderMeiTuan.getTradeAmount().equals(refundPrice)) {
// orderRefund.setRefundPrice(orderChild.getSurplusRefundPrice()); // 全部退款
// orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral()); orderRefund.setRefundPrice(orderChild.getSurplusRefundPrice());
// } else { orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral());
// // 部分退款 } else {
// // 计算单价 // 部分退款
// BigDecimal unitPrice = orderChild.getSurplusRefundPrice().divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2); // 计算部分退款比例
// BigDecimal unitPriceIntegral = new BigDecimal(orderChild.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100")) BigDecimal proportion = orderChild.getProductTotalPrice().divide(refundPrice, 2, RoundingMode.DOWN);
// .divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2); // 退积分
// Long unitPriceIntegral = new BigDecimal(orderChild.getIntegralDiscountPrice()).multiply(proportion).longValue();
// orderRefund.setRefundPrice(unitPrice.multiply(new BigDecimal(productCount.toString()))); // 退金额
// orderRefund.setRefundIntegral(unitPriceIntegral.multiply(new BigDecimal("100")).longValue()); BigDecimal price = orderChild.getProductActualPrice().multiply(proportion);
// }
// 插入退款积分
if (unitPriceIntegral > orderChild.getSurplusRefundIntegral()) {
orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral());
} else {
orderRefund.setRefundIntegral(unitPriceIntegral);
}
// 插入退款金额
if (price.compareTo(orderChild.getSurplusRefundPrice()) > 0) {
orderRefund.setRefundPrice(orderChild.getSurplusRefundPrice());
} else {
orderRefund.setRefundPrice(price);
}
}
if (orderRefund.getRefundIntegral() > 0L) { if (orderRefund.getRefundIntegral() > 0L) {
@ -358,6 +392,17 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
return null; return null;
} }
@Override
public BsOrderRefund getRefundByTradeRefundNo(String tradeRefundNo) {
BsOrderRefundExample example = new BsOrderRefundExample();
example.createCriteria().andTradeRefundNoEqualTo(tradeRefundNo);
List<BsOrderRefund> list = orderRefundMapper.selectByExample(example);
if (!list.isEmpty()){
return list.get(0);
}
return null;
}
@Override @Override
public List<BsOrderRefund> getRefundList(Map<String, Object> param) { public List<BsOrderRefund> getRefundList(Map<String, Object> param) {
BsOrderRefundExample example = new BsOrderRefundExample(); BsOrderRefundExample example = new BsOrderRefundExample();

@ -524,7 +524,7 @@ public class BsOrderServiceImpl implements BsOrderService {
// 删除缓存 // 删除缓存
cacheDelete(order.getOrderNo()); cacheDelete(order.getOrderNo());
// 处理业务 // 处理业务
//orderPaySuccessService.orderBusHandle(order); orderPaySuccessService.orderBusHandle(order);
} }
@Override @Override

Loading…
Cancel
Save