feat(gao): point redemption in product stock list and detail
This commit is contained in:
@@ -21,6 +21,9 @@ public interface GaoPointRedemptionMapper extends BaseMapper<GaoPointRedemption,
|
||||
/// 按门店和 ID 查询兑换单
|
||||
GaoPointRedemption selectByStoreIdAndId(@Param("storeId") String storeId, @Param("id") String id);
|
||||
|
||||
/// 按 ID 列表查询兑换单
|
||||
List<GaoPointRedemption> selectByIdList(@Param("idList") List<String> idList);
|
||||
|
||||
/// 锁定兑换单
|
||||
GaoPointRedemption selectForUpdate(@Param("id") String id);
|
||||
|
||||
|
||||
+23
-3
@@ -4,8 +4,10 @@ import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoOrderFulfillment;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoPointRedemption;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoProductStockRecord;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoOrderFulfillmentMapper;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoPointRedemptionMapper;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoProductStockRecordMapper;
|
||||
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoProductStockRecordService;
|
||||
@@ -36,6 +38,7 @@ public class GaoProductStockRecordServiceImplement extends AbstractEntityService
|
||||
|
||||
private final GaoProductStockRecordMapper mapper;
|
||||
private final GaoOrderFulfillmentMapper orderFulfillmentMapper;
|
||||
private final GaoPointRedemptionMapper pointRedemptionMapper;
|
||||
private final AttachmentService attachmentService;
|
||||
private final GaoCustomerService customerService;
|
||||
private final UserService userService;
|
||||
@@ -158,8 +161,16 @@ public class GaoProductStockRecordServiceImplement extends AbstractEntityService
|
||||
Map<String, GaoOrderFulfillment> fulfillmentMap = fulfillmentIdList.isEmpty()
|
||||
? Map.of() : orderFulfillmentMapper.selectByIdList(fulfillmentIdList).stream()
|
||||
.collect(Collectors.toMap(GaoOrderFulfillment::getId, item -> item));
|
||||
List<String> redemptionIdList = recordList.stream()
|
||||
.filter(record -> record.getOperationType() == GaoProductStockRecord.OperationType.POINT_REDEMPTION_OUT
|
||||
&& record.getBizType() == GaoProductStockRecord.BizType.POINT_REDEMPTION)
|
||||
.map(GaoProductStockRecord::getBizId)
|
||||
.filter(value -> value != null && !value.isBlank()).distinct().toList();
|
||||
Map<String, GaoPointRedemption> redemptionMap = redemptionIdList.isEmpty()
|
||||
? Map.of() : pointRedemptionMapper.selectByIdList(redemptionIdList).stream()
|
||||
.collect(Collectors.toMap(GaoPointRedemption::getId, item -> item));
|
||||
List<String> customerIdList = recordList.stream()
|
||||
.map(record -> getCustomerId(record, fulfillmentMap))
|
||||
.map(record -> getCustomerId(record, fulfillmentMap, redemptionMap))
|
||||
.filter(value -> value != null && !value.isBlank())
|
||||
.distinct()
|
||||
.toList();
|
||||
@@ -173,7 +184,7 @@ public class GaoProductStockRecordServiceImplement extends AbstractEntityService
|
||||
operator.setAttachmentList(userAvatarMap.getOrDefault(operator.getId(), List.of()));
|
||||
}
|
||||
record.setOperator(operator);
|
||||
String customerId = getCustomerId(record, fulfillmentMap);
|
||||
String customerId = getCustomerId(record, fulfillmentMap, redemptionMap);
|
||||
if (TimiJava.isEmpty(customerId)) {
|
||||
continue;
|
||||
}
|
||||
@@ -185,7 +196,16 @@ public class GaoProductStockRecordServiceImplement extends AbstractEntityService
|
||||
}
|
||||
}
|
||||
|
||||
private String getCustomerId(GaoProductStockRecord record, Map<String, GaoOrderFulfillment> fulfillmentMap) {
|
||||
private String getCustomerId(GaoProductStockRecord record, Map<String, GaoOrderFulfillment> fulfillmentMap,
|
||||
Map<String, GaoPointRedemption> redemptionMap) {
|
||||
if (TimiJava.isEmpty(record.getBizId())) {
|
||||
return null;
|
||||
}
|
||||
if (record.getOperationType() == GaoProductStockRecord.OperationType.POINT_REDEMPTION_OUT
|
||||
&& record.getBizType() == GaoProductStockRecord.BizType.POINT_REDEMPTION) {
|
||||
GaoPointRedemption redemption = redemptionMap.get(record.getBizId());
|
||||
return redemption == null ? null : redemption.getCustomerId();
|
||||
}
|
||||
if (record.getBizType() != GaoProductStockRecord.BizType.ORDER_FULFILLMENT) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user