记得上下班打卡 | git大法好,push需谨慎

Commit 7ed61cae authored by wangyifan's avatar wangyifan

退款申请拒绝后再次申请提示“不可退款”修复;发起方不返回字段修复

parent 6bee1ba0
......@@ -756,8 +756,14 @@ public class GoblinOrderAppServiceImpl implements IGoblinOrderAppService {
List<String> backOrderList = redisUtils.getBackOrderByOrderId(orderId);
for (String backOrderId : backOrderList) {
GoblinBackOrderVo vo = redisUtils.getBackOrderVo(backOrderId);
if (vo == null) {
continue;
}
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(vo.getOrderId());
vo.setPayType(orderVo.getPayType());
if (orderVo != null) {
vo.setPayType(orderVo.getPayType());
}
vo.setOperationType(GoblinRefundHelper.resolveBackOrderOperationType(vo));
vos.add(vo);
}
return ResponseDto.success(vos);
......
......@@ -3,7 +3,9 @@ package com.liquidnet.service.goblin.service.impl.helper;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.HttpUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.vo.GoblinBackOrderSkuVo;
import com.liquidnet.service.goblin.dto.vo.GoblinBackOrderVo;
import com.liquidnet.service.goblin.dto.vo.GoblinOrderSkuVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreOrderVo;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
......@@ -73,6 +75,23 @@ public class GoblinRefundHelper {
return orderSkuVo.getStatus() == 3 || orderSkuVo.getStatus() == 4;
}
/**
* 推断退款单发起方:优先读已存储值;历史数据无 operationType 时按 describes/reason 兜底。
*/
public static Integer resolveBackOrderOperationType(GoblinBackOrderVo backOrderVo) {
if (backOrderVo == null) {
return GoblinStatusConst.Type.OPERATION_TYPE_1.getValue();
}
if (backOrderVo.getOperationType() != null) {
return backOrderVo.getOperationType();
}
if ("店铺退款".equals(backOrderVo.getDescribes())
|| GoblinStatusConst.Type.BACK_REASON_TYPE_8.getDesc().equals(backOrderVo.getReason())) {
return GoblinStatusConst.Type.OPERATION_TYPE_2.getValue();
}
return GoblinStatusConst.Type.OPERATION_TYPE_1.getValue();
}
public String initRefund(GoblinStoreOrderVo orderVo, BigDecimal price, String refundCode) {
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
params.add("code", orderVo.getPayCode());
......
......@@ -246,6 +246,9 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer
}
}
}
// 拒绝退款后恢复子单状态(61 -> 2/3/4),否则再次发起退款会因 canRefund 校验失败
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(backOrderVo.getOrderId());
LinkedList<Object[]> orderSkuStatusSql = restoreOrderSkuStatusOnRefundRefused(backOrderVo, orderVo, now);
backOrderVo.setStatus(GoblinStatusConst.Status.ORDER_BACK_STATUS_3.getValue());
backOrderVo.setRefuseAt(nowStr);
backOrderVo.setRefuseSize(backOrderVo.getRefuseSize() == null ? 1 : backOrderVo.getRefuseSize() + 1);
......@@ -259,21 +262,33 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer
//mongo
mongoUtils.updateGoblinBackOrderVo(backOrderId, backOrderVo);
//mysql
queueUtils.sendMsgByRedis(
MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.get("goblin_order.store.backOrderStatus",
backOrderVo.getStatus(), backOrderVo.getAuditAt(), backOrderVo.getRefuseSize(), now,
backOrderId, now, now
)
);
//添加日志
queueUtils.sendMsgByRedis(
MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.get("goblin_order.store.refundLog",
backOrderLog.getBackOrderLogId(), backOrderLog.getBackOrderId(), backOrderLog.getOperationType(),
backOrderLog.getMessage(), backOrderLog.getOperationName(), backOrderLog.getStatus(), now
)
);
LinkedList<String> sqls = CollectionUtil.linkedListString();
LinkedList<Object[]> backOrderStatusSql = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> refundLogSql = CollectionUtil.linkedListObjectArr();
sqls.add(SqlMapping.get("goblin_order.store.backOrderStatus"));
backOrderStatusSql.add(new Object[]{
backOrderVo.getStatus(), backOrderVo.getAuditAt(), backOrderVo.getRefuseSize(), now,
backOrderId, now, now
});
if (!orderSkuStatusSql.isEmpty()) {
sqls.add(SqlMapping.get("goblin_order.store.orderSkuStatus"));
}
sqls.add(SqlMapping.get("goblin_order.store.refundLog"));
refundLogSql.add(new Object[]{
backOrderLog.getBackOrderLogId(), backOrderLog.getBackOrderId(), backOrderLog.getOperationType(),
backOrderLog.getMessage(), backOrderLog.getOperationName(), backOrderLog.getStatus(), now
});
if (orderSkuStatusSql.isEmpty()) {
queueUtils.sendMsgByRedis(
MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.gets(sqls, backOrderStatusSql, refundLogSql)
);
} else {
queueUtils.sendMsgByRedis(
MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.gets(sqls, backOrderStatusSql, orderSkuStatusSql, refundLogSql)
);
}
return ResponseDto.success();
}
......@@ -572,8 +587,7 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer
} else if (StringUtil.isNotBlank(item.getRefuseAt())) {
vo.setProcessedAt(item.getRefuseAt());
}
Integer operationType = resolveBackOrderOperationType(item);
vo.setOperationType(operationType);
vo.setOperationType(GoblinRefundHelper.resolveBackOrderOperationType(item));
if (StringUtil.isNotBlank(item.getOrderId())) {
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(item.getOrderId());
if (orderVo != null) {
......@@ -587,15 +601,59 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer
return vo;
}
private Integer resolveBackOrderOperationType(GoblinBackOrderVo item) {
if (item.getOperationType() != null) {
return item.getOperationType();
private LinkedList<Object[]> restoreOrderSkuStatusOnRefundRefused(GoblinBackOrderVo backOrderVo,
GoblinStoreOrderVo orderVo,
LocalDateTime now) {
LinkedList<Object[]> orderSkuStatusSql = CollectionUtil.linkedListObjectArr();
if (backOrderVo == null || orderVo == null || backOrderVo.getBackOrderSkuVos() == null) {
return orderSkuStatusSql;
}
if ("店铺退款".equals(item.getDescribes())
|| GoblinStatusConst.Type.BACK_REASON_TYPE_8.getDesc().equals(item.getReason())) {
return GoblinStatusConst.Type.OPERATION_TYPE_2.getValue();
for (GoblinBackOrderSkuVo backOrderSkuVo : backOrderVo.getBackOrderSkuVos()) {
GoblinOrderSkuVo orderSkuVo = redisUtils.getGoblinOrderSkuVo(backOrderSkuVo.getOrderSkuId());
if (orderSkuVo == null) {
continue;
}
if (!Integer.valueOf(GoblinStatusConst.Status.ORDER_STATUS_61.getValue()).equals(orderSkuVo.getStatus())) {
continue;
}
orderSkuVo.setStatus(resolveSkuRollbackStatus(orderVo, orderSkuVo.getOrderSkuId()));
redisUtils.setGoblinOrderSku(orderSkuVo.getOrderSkuId(), orderSkuVo);
mongoUtils.updateGoblinOrderSkuVo(orderSkuVo.getOrderSkuId(), orderSkuVo);
orderSkuStatusSql.add(new Object[]{
orderSkuVo.getStatus(), now,
orderSkuVo.getOrderSkuId(), now, now
});
}
return GoblinStatusConst.Type.OPERATION_TYPE_1.getValue();
return orderSkuStatusSql;
}
private int resolveSkuRollbackStatus(GoblinStoreOrderVo orderVo, String orderSkuId) {
int orderStatus = orderVo.getStatus();
if (orderStatus == GoblinStatusConst.Status.ORDER_STATUS_2.getValue()) {
return isSkuShipped(orderVo.getOrderId(), orderSkuId)
? GoblinStatusConst.Status.ORDER_STATUS_3.getValue()
: GoblinStatusConst.Status.ORDER_STATUS_2.getValue();
}
if (orderStatus == GoblinStatusConst.Status.ORDER_STATUS_3.getValue()) {
return GoblinStatusConst.Status.ORDER_STATUS_3.getValue();
}
if (orderStatus == GoblinStatusConst.Status.ORDER_STATUS_4.getValue()) {
return GoblinStatusConst.Status.ORDER_STATUS_4.getValue();
}
return orderStatus;
}
private boolean isSkuShipped(String orderId, String orderSkuId) {
List<GoblinMailVo> mails = redisUtils.getGoblinMail(orderId);
if (mails == null || mails.isEmpty()) {
return false;
}
for (GoblinMailVo mail : mails) {
if (mail.getOrderSkuVoIds() != null && mail.getOrderSkuVoIds().contains(orderSkuId)) {
return true;
}
}
return false;
}
private GoblinBackOrderLog initBackLog(String orderId, String uid, LocalDateTime now) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment