Commit 41ee7950 by 郑勇

feat: [none] 首页奖券包

parent a818edca
......@@ -67,6 +67,8 @@ import java.util.Random;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import static com.pcloud.book.util.common.ThreadPoolUtils.RMALL_SIGN_IN;
@Component("giftCouponPackageBiz")
......@@ -679,11 +681,22 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
}
List<Long> packageIds = list.stream().map(a -> a.getId()).distinct().collect(Collectors.toList());
List<Long> receivedIds= ListUtils.isEmpty(packageIds) ? new ArrayList<>() : giftReceiveDao.getReceivedIds(packageIds,wechatUserId);
List<GiftReceiveDTO> listReceived=giftReceiveDao.getReceivedCount(packageIds,wechatUserId);
Map<Long, GiftReceiveDTO> receiveDTOMap = CollectionUtil.isEmpty(listReceived) ? new HashMap<>() : listReceived.stream().collect(Collectors.toMap(a -> a.getGiftPackageId(), Function.identity()));
for (GiftPackageDTO giftPackageDTO : list) {
giftPackageDTO.setHasReceived(false);
if(!ListUtils.isEmpty(receivedIds) && receivedIds.contains(giftPackageDTO.getId())){
giftPackageDTO.setHasReceived(true);
}
giftPackageDTO.setReceiveNum(0);
giftPackageDTO.setFailureNum(0);
if(CollectionUtil.isNotEmpty(receiveDTOMap) && receiveDTOMap.containsKey(giftPackageDTO.getId())){
GiftReceiveDTO giftReceiveDTO1 = receiveDTOMap.get(giftPackageDTO.getId());
if(null!=giftReceiveDTO1){
giftPackageDTO.setReceiveNum(giftReceiveDTO1.getReceiveNum());
giftPackageDTO.setFailureNum(giftReceiveDTO1.getFailureNum());
}
}
giftPackageDTO.setDesc(StringUtils.isEmpty(giftPackageDTO.getResourceDesc()) ? new ArrayList<>() : Arrays.stream(giftPackageDTO.getResourceDesc().split(",")).collect(Collectors.toList()));
}
}
......
......@@ -39,4 +39,6 @@ public interface GiftReceiveDao extends BaseDao<GiftReceive> {
Integer getGiftAllReceiveCount(Long wechatUserId);
List<Long> getReceivedIds(List<Long> packageIds, Long wechatUserId);
List<GiftReceiveDTO> getReceivedCount(List<Long> packageIds, Long wechatUserId);
}
\ No newline at end of file
......@@ -83,4 +83,12 @@ public class GiftReceiveDaoImpl extends BaseDaoImpl<GiftReceive> implements Gift
map.put("giftPackageIds",packageIds);
return super.getSqlSession().selectList(super.getStatement("getReceivedIds"), map);
}
@Override
public List<GiftReceiveDTO> getReceivedCount(List<Long> packageIds, Long wechatUserId) {
Map<String,Object> map=new HashMap<>();
map.put("wechatUserId",wechatUserId);
map.put("giftPackageIds",packageIds);
return super.getSqlSession().selectList(super.getStatement("getReceivedCount"), map);
}
}
......@@ -62,6 +62,11 @@ public class GiftPackageDTO{
private Integer receiveNum;
/**
* 失效/已使用总数
*/
private Integer failureNum;
/**
* 未使用数量
*/
private Integer notUsedNum;
......
......@@ -24,5 +24,10 @@ public class GiftReceiveDTO {
*/
private Long receiveId;
/**
* 失效/已使用总数
*/
private Integer failureNum;
}
\ No newline at end of file
......@@ -234,4 +234,21 @@
</foreach>
</select>
<select id="getReceivedCount" parameterType="map" resultType="com.pcloud.book.giftcoupon.dto.GiftReceiveDTO">
select
gift_package_id giftPackageId,
count(1) receiveNum,
sum(if((a.use_time is not null or now() > b.valid_date_end),1,0)) failureNum
from gift_receive a
LEFT JOIN gift_coupon_package b
on a.gift_package_id=b.id
where
a.wechat_user_id=#{wechatUserId}
and a.gift_package_id in
<foreach collection="giftPackageIds" item="item" index="index" open="(" separator="," close=")">
${item}
</foreach>
GROUP BY a.gift_package_id;
</select>
</mapper>
\ No newline at end of file
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