커미션, 정산, 정산완료, 모델 수정 및 사이트 계좌 리스트 모델 수정

This commit is contained in:
byung eun park 2019-10-04 22:25:49 +09:00
parent 38b39255bf
commit 0d01d3b2e0
19 changed files with 250 additions and 101 deletions

View File

@ -6,8 +6,8 @@ import com.totopia.server.modules.game.entity.SportsEntity;
import com.totopia.server.modules.game.repository.LeagueRepository; import com.totopia.server.modules.game.repository.LeagueRepository;
import com.totopia.server.modules.game.repository.SportsRepository; import com.totopia.server.modules.game.repository.SportsRepository;
import com.totopia.server.modules.game.type.SportsName; import com.totopia.server.modules.game.type.SportsName;
import com.totopia.server.modules.site.entity.BankInfoEntity; import com.totopia.server.modules.site.entity.BankAccountsEntity;
import com.totopia.server.modules.site.repository.BankInfoRepository; import com.totopia.server.modules.site.repository.BankAccountsRepository;
import com.totopia.server.modules.user.entity.GradeEntity; import com.totopia.server.modules.user.entity.GradeEntity;
import com.totopia.server.modules.user.entity.RoleEntity; import com.totopia.server.modules.user.entity.RoleEntity;
import com.totopia.server.modules.user.entity.UserEntity; import com.totopia.server.modules.user.entity.UserEntity;
@ -54,7 +54,7 @@ public class DbInitializer implements CommandLineRunner {
LeagueRepository leagueRepository; LeagueRepository leagueRepository;
@Autowired @Autowired
BankInfoRepository bankInfoRepository; BankAccountsRepository bankInfoRepository;
@Override @Override
public void run(String... strings) throws Exception { public void run(String... strings) throws Exception {
@ -414,9 +414,9 @@ public class DbInitializer implements CommandLineRunner {
} }
private void initDbBankInfo() { private void initDbBankInfo() {
BankInfoEntity bankInfoEntity; BankAccountsEntity bankInfoEntity;
bankInfoEntity = BankInfoEntity.builder() bankInfoEntity = BankAccountsEntity.builder()
.name("국민은행") .name("국민은행")
.number("11111-11-11111") .number("11111-11-11111")
.holder("테스트1") .holder("테스트1")
@ -424,7 +424,7 @@ public class DbInitializer implements CommandLineRunner {
.build(); .build();
bankInfoRepository.save(bankInfoEntity); bankInfoRepository.save(bankInfoEntity);
bankInfoEntity = BankInfoEntity.builder() bankInfoEntity = BankAccountsEntity.builder()
.name("우리은행") .name("우리은행")
.number("22222-22-22222") .number("22222-22-22222")
.holder("테스트2") .holder("테스트2")
@ -432,7 +432,7 @@ public class DbInitializer implements CommandLineRunner {
.build(); .build();
bankInfoRepository.save(bankInfoEntity); bankInfoRepository.save(bankInfoEntity);
bankInfoEntity = BankInfoEntity.builder() bankInfoEntity = BankAccountsEntity.builder()
.name("기업은행") .name("기업은행")
.number("33333-33-33333") .number("33333-33-33333")
.holder("테스트3") .holder("테스트3")
@ -440,7 +440,7 @@ public class DbInitializer implements CommandLineRunner {
.build(); .build();
bankInfoRepository.save(bankInfoEntity); bankInfoRepository.save(bankInfoEntity);
bankInfoEntity = BankInfoEntity.builder() bankInfoEntity = BankAccountsEntity.builder()
.name("신한은행") .name("신한은행")
.number("44444-44-444444") .number("44444-44-444444")
.holder("테스트4") .holder("테스트4")
@ -448,7 +448,7 @@ public class DbInitializer implements CommandLineRunner {
.build(); .build();
bankInfoRepository.save(bankInfoEntity); bankInfoRepository.save(bankInfoEntity);
bankInfoEntity = BankInfoEntity.builder() bankInfoEntity = BankAccountsEntity.builder()
.name("국민은행") .name("국민은행")
.number("55555-55-55555") .number("55555-55-55555")
.holder("테스트5") .holder("테스트5")

View File

@ -1,9 +1,8 @@
package com.totopia.server.modules.site.controller; package com.totopia.server.modules.site.controller;
import com.totopia.server.commons.data.payload.ApiResponse; import com.totopia.server.commons.data.payload.ApiResponse;
import com.totopia.server.modules.game.entity.LeagueEntity; import com.totopia.server.modules.site.entity.BankAccountsEntity;
import com.totopia.server.modules.site.entity.BankInfoEntity; import com.totopia.server.modules.site.service.BankAccountsService;
import com.totopia.server.modules.site.service.BankInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -17,38 +16,38 @@ import javax.validation.Valid;
import java.util.List; import java.util.List;
@RestController @RestController
public class BankInfoController { public class BankAccountsController {
@Autowired @Autowired
BankInfoService bankInfoService; BankAccountsService bankAccountsService;
@GetMapping(value = "/bank_info") @GetMapping(value = "/bank_info")
public Page<BankInfoEntity> all( public Page<BankAccountsEntity> all(
@SortDefault.SortDefaults({ @SortDefault.SortDefaults({
@SortDefault( @SortDefault(
sort = "id", sort = "id",
direction = Sort.Direction.ASC) }) direction = Sort.Direction.ASC) })
Pageable pageable) { Pageable pageable) {
return this.bankInfoService.getAllBankInfo(pageable); return this.bankAccountsService.getAllBankInfo(pageable);
} }
@GetMapping(value = "/bank_info/test") @GetMapping(value = "/bank_info/test")
public List<BankInfoEntity> allTest() { public List<BankAccountsEntity> allTest() {
return this.bankInfoService.getAllBankInfoTest(); return this.bankAccountsService.getAllBankInfoTest();
} }
@PostMapping(value = "/bank_info") @PostMapping(value = "/bank_info")
@ResponseStatus(code = HttpStatus.CREATED) @ResponseStatus(code = HttpStatus.CREATED)
public ResponseEntity<?> save(@Valid @RequestBody BankInfoEntity bankInfoEntity) throws Exception{ public ResponseEntity<?> save(@Valid @RequestBody BankAccountsEntity bankInfoEntity) throws Exception{
this.bankInfoService.save(bankInfoEntity); this.bankAccountsService.save(bankInfoEntity);
return ResponseEntity.ok().body(new ApiResponse(true, "BankInfo registered successfully")); return ResponseEntity.ok().body(new ApiResponse(true, "BankInfo registered successfully"));
} }
@PutMapping(value = "/bank_info/{bankInfoId}") @PutMapping(value = "/bank_info/{bankInfoId}")
public ResponseEntity<?> updateLeague(@PathVariable Long bankInfoId, BankInfoEntity bankInfoEntity) throws Exception { public ResponseEntity<?> updateLeague(@PathVariable Long bankInfoId, BankAccountsEntity bankInfoEntity) throws Exception {
BankInfoEntity leagueEntity1 = this.bankInfoService.modify(bankInfoEntity); BankAccountsEntity leagueEntity1 = this.bankAccountsService.modify(bankInfoEntity);
return ResponseEntity.ok(leagueEntity1); return ResponseEntity.ok(leagueEntity1);
} }
} }

View File

@ -14,10 +14,10 @@ import javax.persistence.*;
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Builder @Builder
public class BankInfoEntity extends DateAuditEntity { public class BankAccountsEntity extends DateAuditEntity {
@Id @Id
@GeneratedValue(generator = "bank_info_generator") @GeneratedValue(generator = "bank_accounts_generator")
@SequenceGenerator(name = "bank_info_generator", sequenceName = "bank_info_sequence", initialValue = 1) @SequenceGenerator(name = "bank_accounts_generator", sequenceName = "bank_accounts_sequence", initialValue = 1)
private Short id; private Short id;
@Basic @Basic

View File

@ -0,0 +1,7 @@
package com.totopia.server.modules.site.repository;
import com.totopia.server.modules.site.entity.BankAccountsEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface BankAccountsRepository extends JpaRepository<BankAccountsEntity, Short> {
}

View File

@ -1,7 +0,0 @@
package com.totopia.server.modules.site.repository;
import com.totopia.server.modules.site.entity.BankInfoEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface BankInfoRepository extends JpaRepository<BankInfoEntity, Short> {
}

View File

@ -0,0 +1,54 @@
package com.totopia.server.modules.site.service;
import com.totopia.server.commons.exception.ResourceNotFoundException;
import com.totopia.server.modules.site.entity.BankAccountsEntity;
import com.totopia.server.modules.site.repository.BankAccountsRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class BankAccountsService {
@Autowired
BankAccountsRepository bankAccountsRepository;
public BankAccountsEntity save(BankAccountsEntity entity) {
return this.bankAccountsRepository.save(entity);
}
public BankAccountsEntity modify(BankAccountsEntity entity) {
if(entity == null || entity.getId() == 0) {
log.error("id is not null");
}
return this.bankAccountsRepository.save(entity);
}
public Short removeById(Short bankInfoId) {
return bankAccountsRepository.findById(bankInfoId).map(bankInfo -> {
bankAccountsRepository.delete(bankInfo);
return bankInfoId;
}).orElseThrow(() -> new ResourceNotFoundException("BankInfoEntity", "bankInfoId", bankInfoId));
}
public Page<BankAccountsEntity> getAllBankInfo(Pageable pageable) {
return this.bankAccountsRepository.findAll(pageable);
}
public List<BankAccountsEntity> getAllBankInfoTest() {
return this.bankAccountsRepository.findAll();
}
public BankAccountsEntity getBankInfoById(Short bankInfoId) {
return this.bankAccountsRepository.findById(bankInfoId).orElseThrow(null);
}
}

View File

@ -1,54 +0,0 @@
package com.totopia.server.modules.site.service;
import com.totopia.server.commons.exception.ResourceNotFoundException;
import com.totopia.server.modules.site.entity.BankInfoEntity;
import com.totopia.server.modules.site.repository.BankInfoRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class BankInfoService {
@Autowired
BankInfoRepository bankInfoRepository;
public BankInfoEntity save(BankInfoEntity entity) {
return this.bankInfoRepository.save(entity);
}
public BankInfoEntity modify(BankInfoEntity entity) {
if(entity == null || entity.getId() == 0) {
log.error("id is not null");
}
return this.bankInfoRepository.save(entity);
}
public Short removeById(Short bankInfoId) {
return bankInfoRepository.findById(bankInfoId).map(bankInfo -> {
bankInfoRepository.delete(bankInfo);
return bankInfoId;
}).orElseThrow(() -> new ResourceNotFoundException("BankInfoEntity", "bankInfoId", bankInfoId));
}
public Page<BankInfoEntity> getAllBankInfo(Pageable pageable) {
return this.bankInfoRepository.findAll(pageable);
}
public List<BankInfoEntity> getAllBankInfoTest() {
return this.bankInfoRepository.findAll();
}
public BankInfoEntity getBankInfoById(Short bankInfoId) {
return this.bankInfoRepository.findById(bankInfoId).orElseThrow(null);
}
}

View File

@ -1,6 +1,6 @@
package com.totopia.server.modules.user.entity; package com.totopia.server.modules.user.entity;
import com.totopia.server.commons.data.entity.UserDateAuditEntity; import com.totopia.server.commons.data.entity.DateAuditEntity;
import com.totopia.server.modules.user.type.StatusName; import com.totopia.server.modules.user.type.StatusName;
import lombok.*; import lombok.*;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
@ -14,7 +14,7 @@ import javax.persistence.*;
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Builder @Builder
public class BankEntity extends UserDateAuditEntity { public class BankEntity extends DateAuditEntity {
private static final long serialVersionUID = -8628291684559836128L; private static final long serialVersionUID = -8628291684559836128L;
@ -24,7 +24,7 @@ public class BankEntity extends UserDateAuditEntity {
private Long id; private Long id;
@Basic @Basic
@Column(name = "userId", nullable = false) @Column(name = "user_id", nullable = false)
private Long userId; private Long userId;
@Basic @Basic

View File

@ -0,0 +1,54 @@
package com.totopia.server.modules.user.entity;
import com.totopia.server.commons.data.entity.UserDateAuditEntity;
import com.totopia.server.modules.user.type.CommissionName;
import lombok.*;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
@Entity(name = "commission")
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Builder
public class CommissionEntity extends UserDateAuditEntity {
@Id
@GeneratedValue(generator = "commission_generator")
@SequenceGenerator(name = "commission_generator", sequenceName = "commission_sequence", initialValue = 1)
private Long id;
@Basic
@Column(name = "user_id", nullable = false)
private Long userId;
@Basic
@Column(name = "banking_fees", nullable = false)
private Float bankingFees;
@Basic
@Column(name = "sports_fees", nullable = false)
private Float sportsFees;
@Basic
@Column(name = "mini_game_fees", nullable = false, length = 100)
private Float miniGameFees;
@Basic
@Column(name = "rotus_fees", nullable = false, length = 100)
private Float rotusFees;
@Basic
@Column(name = "sports_raffle_fees", nullable = false, length = 100)
private Float sportsRaffleFees;
@Basic
@Column(name = "mini_game_raffle_fees", nullable = false, length = 100)
private String miniGameRaffleFees;
@Enumerated(EnumType.STRING)
@Column(name = "type", length = 60)
private CommissionName type;
}

View File

@ -23,6 +23,15 @@ public class ConnectHistoryEntity extends DateAuditEntity implements Serializabl
private Long id; private Long id;
@Basic @Basic
@Column(name = "activation", nullable = true, length = 100) @Column(name = "user_id", nullable = false)
private Long userId;
@Basic
@Column(name = "ip", nullable = true, length = 100)
private String ip; private String ip;
@Basic
@Column(name = "location", nullable = true, length = 100)
private String location;
} }

View File

@ -24,18 +24,23 @@ public class DepositEntity extends DateAuditEntity implements Serializable {
@SequenceGenerator(name = "deposit_generator", sequenceName = "deposit_sequence", initialValue = 1) @SequenceGenerator(name = "deposit_generator", sequenceName = "deposit_sequence", initialValue = 1)
private Long id; private Long id;
@Basic
@Column(name = "price", nullable = false) @Column(name = "price", nullable = false)
private Integer price; private Integer price;
@Column(name = "approve_id", nullable = false) @Basic
private Long approve; @Column(name = "approve_user_id", nullable = false)
private Long approveUser;
@Basic
@Column(name = "bank_id", nullable = false) @Column(name = "bank_id", nullable = false)
private Long bank; private Long bank;
@Basic
@Column(name = "bank_account", nullable = false) @Column(name = "bank_account", nullable = false)
private Short bankAccount; private Short bankAccount;
@Basic
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@Column(name = "status", length = 60) @Column(name = "status", length = 60)
private BankingName status; private BankingName status;

View File

@ -0,0 +1,31 @@
package com.totopia.server.modules.user.entity;
import com.totopia.server.commons.data.entity.UserDateAuditEntity;
import lombok.*;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
@Entity(name = "pay_done")
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Builder
@AttributeOverrides({
@AttributeOverride(name = "createdAt", column = @Column(name = "payments_date")),
@AttributeOverride(name = "createdBy", column = @Column(name = "approve_user_id")),
})
public class PayDoneEntity extends UserDateAuditEntity {
@Id
@GeneratedValue(generator = "pay_done_generator")
@SequenceGenerator(name = "pay_done_generator", sequenceName = "pay_done_sequence", initialValue = 1)
private Long id;
@Basic
@Column(name = "settle_user_id", nullable = false)
private Long settleUser;
}

View File

@ -0,0 +1,41 @@
package com.totopia.server.modules.user.entity;
import com.totopia.server.commons.data.entity.UserDateAuditEntity;
import com.totopia.server.modules.user.type.BankingName;
import lombok.*;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
@Entity(name = "pay")
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Builder
public class PayEntity extends UserDateAuditEntity {
@Id
@GeneratedValue(generator = "pay_generator")
@SequenceGenerator(name = "pay_generator", sequenceName = "pay_sequence", initialValue = 1)
private Long id;
@Basic
@Column(name = "belong_user_id", nullable = false)
private Long belongUser;
@Basic
@Column(name = "banking_user_id", nullable = false)
private Long bankingUser;
@Basic
@Column(name = "price", nullable = false)
private Integer price;
@Basic
@Enumerated(EnumType.STRING)
@Column(name = "banking_type", length = 60)
private BankingName bankingType;
}

View File

@ -23,18 +23,23 @@ public class WithdrawEntity extends DateAuditEntity implements Serializable {
@SequenceGenerator(name = "withdraw_generator", sequenceName = "withdraw_sequence", initialValue = 1) @SequenceGenerator(name = "withdraw_generator", sequenceName = "withdraw_sequence", initialValue = 1)
private Long id; private Long id;
@Basic
@Column(name = "price", nullable = false) @Column(name = "price", nullable = false)
private Integer price; private Integer price;
@Column(name = "approve_id", nullable = false) @Basic
private Long approve; @Column(name = "approve_user_id", nullable = false)
private Long approveUser;
@Basic
@Column(name = "bank_id", nullable = false) @Column(name = "bank_id", nullable = false)
private Long bank; private Long bank;
@Basic
@Column(name = "bank_account", nullable = false) @Column(name = "bank_account", nullable = false)
private Short bankAccount; private Short bankAccount;
@Basic
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@Column(name = "status", length = 60) @Column(name = "status", length = 60)
private BankingName status; private BankingName status;

View File

@ -1,5 +1,5 @@
package com.totopia.server.modules.user.type; package com.totopia.server.modules.user.type;
public enum BankingName { public enum BankingName {
BANKING_WAITING, BANKING_HOLD, BANKING_COMPLETE BANKING_WAITING, BANKING_HOLD, BANKING_COMPLETE, BANKING_DEPOSIT, BANKING_WITHDRAW
} }

View File

@ -0,0 +1,7 @@
package com.totopia.server.modules.user.type;
public enum CommissionName {
COMMISSION_BANKING, // 충환 방식
COMMISSION_BETTING, // 베팅 방식
COMMISSION_RAFFLE // 낙첨 방식
}

View File

@ -1,20 +1,18 @@
package com.totopia.server.modules.site.service; package com.totopia.server.modules.site.service;
import com.totopia.server.modules.site.repository.BankInfoRepository; import com.totopia.server.modules.site.repository.BankAccountsRepository;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.*;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest @SpringBootTest
public class BankInfoServiceTest { public class BankInfoServiceTest {
@Autowired @Autowired
BankInfoRepository bankInfoRepository; BankAccountsRepository bankAccountsRepository;
@Test @Test

View File

@ -41,7 +41,7 @@ public class DepositRepositoryTest {
DepositEntity en = DepositEntity.builder() DepositEntity en = DepositEntity.builder()
.price(10000) .price(10000)
.bankAccount((short) 1) .bankAccount((short) 1)
.approve(accounts.get(0).getId()) .approveUser(accounts.get(0).getId())
.bank(accounts.get(2).getId()) .bank(accounts.get(2).getId())
.status(BankingName.BANKING_WAITING) .status(BankingName.BANKING_WAITING)

View File

@ -38,7 +38,7 @@ public class WithdrawRepositoryTest {
WithdrawEntity en = WithdrawEntity.builder() WithdrawEntity en = WithdrawEntity.builder()
.price(10000) .price(10000)
.bankAccount((short) 2) .bankAccount((short) 2)
.approve(accounts.get(0).getId()) .approveUser(accounts.get(0).getId())
.bank(accounts.get(2).getId()) .bank(accounts.get(2).getId())
.status(BankingName.BANKING_WAITING) .status(BankingName.BANKING_WAITING)
.build(); .build();