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

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

View File

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

View File

@ -14,10 +14,10 @@ import javax.persistence.*;
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Builder
public class BankInfoEntity extends DateAuditEntity {
public class BankAccountsEntity extends DateAuditEntity {
@Id
@GeneratedValue(generator = "bank_info_generator")
@SequenceGenerator(name = "bank_info_generator", sequenceName = "bank_info_sequence", initialValue = 1)
@GeneratedValue(generator = "bank_accounts_generator")
@SequenceGenerator(name = "bank_accounts_generator", sequenceName = "bank_accounts_sequence", initialValue = 1)
private Short id;
@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;
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 lombok.*;
import lombok.experimental.SuperBuilder;
@ -14,7 +14,7 @@ import javax.persistence.*;
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Builder
public class BankEntity extends UserDateAuditEntity {
public class BankEntity extends DateAuditEntity {
private static final long serialVersionUID = -8628291684559836128L;
@ -24,7 +24,7 @@ public class BankEntity extends UserDateAuditEntity {
private Long id;
@Basic
@Column(name = "userId", nullable = false)
@Column(name = "user_id", nullable = false)
private Long userId;
@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;
@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;
@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)
private Long id;
@Basic
@Column(name = "price", nullable = false)
private Integer price;
@Column(name = "approve_id", nullable = false)
private Long approve;
@Basic
@Column(name = "approve_user_id", nullable = false)
private Long approveUser;
@Basic
@Column(name = "bank_id", nullable = false)
private Long bank;
@Basic
@Column(name = "bank_account", nullable = false)
private Short bankAccount;
@Basic
@Enumerated(EnumType.STRING)
@Column(name = "status", length = 60)
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)
private Long id;
@Basic
@Column(name = "price", nullable = false)
private Integer price;
@Column(name = "approve_id", nullable = false)
private Long approve;
@Basic
@Column(name = "approve_user_id", nullable = false)
private Long approveUser;
@Basic
@Column(name = "bank_id", nullable = false)
private Long bank;
@Basic
@Column(name = "bank_account", nullable = false)
private Short bankAccount;
@Basic
@Enumerated(EnumType.STRING)
@Column(name = "status", length = 60)
private BankingName status;

View File

@ -1,5 +1,5 @@
package com.totopia.server.modules.user.type;
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;
import com.totopia.server.modules.site.repository.BankInfoRepository;
import com.totopia.server.modules.site.repository.BankAccountsRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest
public class BankInfoServiceTest {
@Autowired
BankInfoRepository bankInfoRepository;
BankAccountsRepository bankAccountsRepository;
@Test

View File

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

View File

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