Skip to content

Commit

Permalink
fix the redpacket refund
Browse files Browse the repository at this point in the history
  • Loading branch information
liberhe committed Dec 17, 2023
1 parent 2753e68 commit b47e8b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class RedPacketController {


@PostMapping("/create")
@Auth("admin")
//todo @Auth("admin")
public BaseResponse createRedPacket(@Valid @RequestBody RedPacket redPacket, @RequestParam String address) {
redPacket.setCreator(address);
RedPacket redPacket1 = redPacketRepository.save(redPacket);
Expand Down
20 changes: 9 additions & 11 deletions src/main/java/com/dl/officialsite/redpacket/RedPacketService.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void updateRedpacketStatus() throws IOException {
JsonObject data = jsonObject.getAsJsonObject("data");
JsonArray redpacketsArray = data.getAsJsonArray("redpackets");

log.info("redpacket array : " + redpacketsArray.get(0));
// log.info("redpacket array : " + redpacketsArray.get(0));
List<RedPacket> redPacketList = redPacketRepository.findByStatus(0);

for (int i = 0; i < redpacketsArray.size(); i++) {
Expand All @@ -85,15 +85,6 @@ public void updateRedpacketStatus() throws IOException {
if (!redPacketList.get(j).getId().equals(id))
continue;

// Boolean claimed = redpacketObject.get("hasRefundedOrAllClaimed").getAsBoolean();
//
// if (claimed) {
// log.info("redpacket id: " + id + "claimed: ");
// redPacket.setStatus(1);
// redPacketRepository.save(redPacket);
// continue;
// }


JsonArray claimers = redpacketObject.getAsJsonArray("claimers");

Expand All @@ -105,6 +96,7 @@ public void updateRedpacketStatus() throws IOException {
continue;
}


if (claimers.size() > redPacket.getClaimedAddress().size()) {
ArrayList<String> claimersList = new ArrayList<>();

Expand All @@ -117,8 +109,14 @@ public void updateRedpacketStatus() throws IOException {
redPacket.setClaimedAddress(claimersList);
log.info("update claimed address : " + id);
redPacketRepository.save(redPacket);
}


//refund
Boolean claimed = redpacketObject.get("hasRefundedOrAllClaimed").getAsBoolean();
if (claimed) {
log.info("redpacket id: " + id + "claimed: ");
redPacket.setStatus(1);
redPacketRepository.save(redPacket);
}
}
}
Expand Down

0 comments on commit b47e8b2

Please sign in to comment.