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

Commit 7ed61cae authored by wangyifan's avatar wangyifan

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

parent 6bee1ba0
...@@ -756,8 +756,14 @@ public class GoblinOrderAppServiceImpl implements IGoblinOrderAppService { ...@@ -756,8 +756,14 @@ public class GoblinOrderAppServiceImpl implements IGoblinOrderAppService {
List<String> backOrderList = redisUtils.getBackOrderByOrderId(orderId); List<String> backOrderList = redisUtils.getBackOrderByOrderId(orderId);
for (String backOrderId : backOrderList) { for (String backOrderId : backOrderList) {
GoblinBackOrderVo vo = redisUtils.getBackOrderVo(backOrderId); GoblinBackOrderVo vo = redisUtils.getBackOrderVo(backOrderId);
if (vo == null) {
continue;
}
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(vo.getOrderId()); GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(vo.getOrderId());
if (orderVo != null) {
vo.setPayType(orderVo.getPayType()); vo.setPayType(orderVo.getPayType());
}
vo.setOperationType(GoblinRefundHelper.resolveBackOrderOperationType(vo));
vos.add(vo); vos.add(vo);
} }
return ResponseDto.success(vos); return ResponseDto.success(vos);
......
...@@ -3,7 +3,9 @@ package com.liquidnet.service.goblin.service.impl.helper; ...@@ -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.CollectionUtil;
import com.liquidnet.commons.lang.util.HttpUtil; import com.liquidnet.commons.lang.util.HttpUtil;
import com.liquidnet.commons.lang.util.JsonUtils; 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.GoblinBackOrderSkuVo;
import com.liquidnet.service.goblin.dto.vo.GoblinBackOrderVo;
import com.liquidnet.service.goblin.dto.vo.GoblinOrderSkuVo; import com.liquidnet.service.goblin.dto.vo.GoblinOrderSkuVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreOrderVo; import com.liquidnet.service.goblin.dto.vo.GoblinStoreOrderVo;
import com.liquidnet.service.goblin.util.GoblinRedisUtils; import com.liquidnet.service.goblin.util.GoblinRedisUtils;
...@@ -73,6 +75,23 @@ public class GoblinRefundHelper { ...@@ -73,6 +75,23 @@ public class GoblinRefundHelper {
return orderSkuVo.getStatus() == 3 || orderSkuVo.getStatus() == 4; 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) { public String initRefund(GoblinStoreOrderVo orderVo, BigDecimal price, String refundCode) {
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString(); MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
params.add("code", orderVo.getPayCode()); params.add("code", orderVo.getPayCode());
......
...@@ -246,6 +246,9 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer ...@@ -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.setStatus(GoblinStatusConst.Status.ORDER_BACK_STATUS_3.getValue());
backOrderVo.setRefuseAt(nowStr); backOrderVo.setRefuseAt(nowStr);
backOrderVo.setRefuseSize(backOrderVo.getRefuseSize() == null ? 1 : backOrderVo.getRefuseSize() + 1); backOrderVo.setRefuseSize(backOrderVo.getRefuseSize() == null ? 1 : backOrderVo.getRefuseSize() + 1);
...@@ -259,21 +262,33 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer ...@@ -259,21 +262,33 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer
//mongo //mongo
mongoUtils.updateGoblinBackOrderVo(backOrderId, backOrderVo); mongoUtils.updateGoblinBackOrderVo(backOrderId, backOrderVo);
//mysql //mysql
queueUtils.sendMsgByRedis( LinkedList<String> sqls = CollectionUtil.linkedListString();
MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(), LinkedList<Object[]> backOrderStatusSql = CollectionUtil.linkedListObjectArr();
SqlMapping.get("goblin_order.store.backOrderStatus", LinkedList<Object[]> refundLogSql = CollectionUtil.linkedListObjectArr();
sqls.add(SqlMapping.get("goblin_order.store.backOrderStatus"));
backOrderStatusSql.add(new Object[]{
backOrderVo.getStatus(), backOrderVo.getAuditAt(), backOrderVo.getRefuseSize(), now, backOrderVo.getStatus(), backOrderVo.getAuditAt(), backOrderVo.getRefuseSize(), now,
backOrderId, now, 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( queueUtils.sendMsgByRedis(
MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(), MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.get("goblin_order.store.refundLog", SqlMapping.gets(sqls, backOrderStatusSql, orderSkuStatusSql, refundLogSql)
backOrderLog.getBackOrderLogId(), backOrderLog.getBackOrderId(), backOrderLog.getOperationType(),
backOrderLog.getMessage(), backOrderLog.getOperationName(), backOrderLog.getStatus(), now
)
); );
}
return ResponseDto.success(); return ResponseDto.success();
} }
...@@ -572,8 +587,7 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer ...@@ -572,8 +587,7 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer
} else if (StringUtil.isNotBlank(item.getRefuseAt())) { } else if (StringUtil.isNotBlank(item.getRefuseAt())) {
vo.setProcessedAt(item.getRefuseAt()); vo.setProcessedAt(item.getRefuseAt());
} }
Integer operationType = resolveBackOrderOperationType(item); vo.setOperationType(GoblinRefundHelper.resolveBackOrderOperationType(item));
vo.setOperationType(operationType);
if (StringUtil.isNotBlank(item.getOrderId())) { if (StringUtil.isNotBlank(item.getOrderId())) {
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(item.getOrderId()); GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(item.getOrderId());
if (orderVo != null) { if (orderVo != null) {
...@@ -587,15 +601,59 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer ...@@ -587,15 +601,59 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer
return vo; return vo;
} }
private Integer resolveBackOrderOperationType(GoblinBackOrderVo item) { private LinkedList<Object[]> restoreOrderSkuStatusOnRefundRefused(GoblinBackOrderVo backOrderVo,
if (item.getOperationType() != null) { GoblinStoreOrderVo orderVo,
return item.getOperationType(); LocalDateTime now) {
LinkedList<Object[]> orderSkuStatusSql = CollectionUtil.linkedListObjectArr();
if (backOrderVo == null || orderVo == null || backOrderVo.getBackOrderSkuVos() == null) {
return orderSkuStatusSql;
}
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 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;
} }
if ("店铺退款".equals(item.getDescribes())
|| GoblinStatusConst.Type.BACK_REASON_TYPE_8.getDesc().equals(item.getReason())) {
return GoblinStatusConst.Type.OPERATION_TYPE_2.getValue();
} }
return GoblinStatusConst.Type.OPERATION_TYPE_1.getValue(); return false;
} }
private GoblinBackOrderLog initBackLog(String orderId, String uid, LocalDateTime now) { 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