test(firstleg): bind channel change hash to full payload
This commit is contained in:
+1
@@ -159,6 +159,7 @@ public class OrderChannelChangePricingService {
|
|||||||
try {
|
try {
|
||||||
String value = request.tenantId() + ":" + request.orderId() + ":" + request.orderVersion() + ":"
|
String value = request.tenantId() + ":" + request.orderId() + ":" + request.orderVersion() + ":"
|
||||||
+ request.originWarehouseId() + ":" + request.channelCode().trim().toUpperCase() + ":"
|
+ request.originWarehouseId() + ":" + request.channelCode().trim().toUpperCase() + ":"
|
||||||
|
+ request.channelName().trim() + ":"
|
||||||
+ request.destinationType() + ":" + request.destinationWarehouseId() + ":"
|
+ request.destinationType() + ":" + request.destinationWarehouseId() + ":"
|
||||||
+ request.destinationCode() + ":" + request.pricingTaxMode();
|
+ request.destinationCode() + ":" + request.pricingTaxMode();
|
||||||
return HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256")
|
return HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256")
|
||||||
|
|||||||
+16
@@ -96,6 +96,22 @@ class OrderChannelChangePricingServiceTest {
|
|||||||
verify(repository, never()).applyOrderChannelChange(any(), any(), any());
|
verify(repository, never()).applyOrderChannelChange(any(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void sameOrderVersionRejectsDifferentChannelNamePayload() {
|
||||||
|
InboundPricingEntity inbound = inbound("UNPRICED");
|
||||||
|
InboundPricingIdempotencyEntity token = token(4L, "COMPLETED");
|
||||||
|
token.setRequestHash(requestHash(request(4)));
|
||||||
|
when(repository.findInboundByOrderForUpdate(10001L, 77L)).thenReturn(inbound);
|
||||||
|
when(repository.findIdempotency(10001L, 0L, "ORDER_CHANNEL_CHANGE", "77:4")).thenReturn(token);
|
||||||
|
Request changedName = new Request(10001L, 77L, 4L, 9L, "MATSON_NEW", "伪造名称",
|
||||||
|
"FBA", 501L, "ONT8", "TAX_INCLUDED");
|
||||||
|
|
||||||
|
assertThatThrownBy(() -> service.apply(changedName))
|
||||||
|
.isInstanceOf(BizException.class)
|
||||||
|
.hasMessageContaining("同一订单版本已用于不同渠道变更");
|
||||||
|
verify(estimator, never()).estimate(any());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void rejectsOlderOrderVersionAfterNewerVersionWasApplied() {
|
void rejectsOlderOrderVersionAfterNewerVersionWasApplied() {
|
||||||
InboundPricingEntity inbound = inbound("UNPRICED");
|
InboundPricingEntity inbound = inbound("UNPRICED");
|
||||||
|
|||||||
Reference in New Issue
Block a user