From 5b3a5d563e1086fb2edb55f4cc4b7a813d7d1301 Mon Sep 17 00:00:00 2001 From: wgf <121463602@qq.com> Date: Mon, 4 Sep 2023 23:35:05 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=B5=84=E4=BA=A7=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...egesJurisdictionExperimentalSystemDao.java | 7 + .../StudentAccountTradingRecordSheet.java | 7 +- .../com/ibeetl/jlw/enums/AccountTypeEnum.java | 4 +- .../StudentAccountAssetAllocationService.java | 411 ++++++++++++++++-- .../ibeetl/jlw/service/StudentService.java | 8 +- ...JurisdictionExperimentalSystemService.java | 6 + ...udentAccountAssetAllocationController.java | 35 +- ...StudentAccountTradingRecordSheetQuery.java | 7 +- ...sCollegesJurisdictionExperimentalSystem.md | 22 + 9 files changed, 456 insertions(+), 51 deletions(-) diff --git a/web/src/main/java/com/ibeetl/jlw/dao/UniversitiesCollegesJurisdictionExperimentalSystemDao.java b/web/src/main/java/com/ibeetl/jlw/dao/UniversitiesCollegesJurisdictionExperimentalSystemDao.java index 60a395a3..6d01fbea 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/UniversitiesCollegesJurisdictionExperimentalSystemDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/UniversitiesCollegesJurisdictionExperimentalSystemDao.java @@ -44,4 +44,11 @@ public interface UniversitiesCollegesJurisdictionExperimentalSystemDao extends B * @Date: 2023/3/19 23:38 */ List getAllOverdueAuthByBeforeAndAfterDays(@Param("beforeDays") Long beforeDays, @Param("afterDays") Long afterDays, @Param("orgId") Long orgId); + + /** + * 获取不过期应用 + * @param orgId + * @return + */ + List getNotExpireApply( @Param("orgId") Long orgId , @Param("typeId") String typeIds); } \ No newline at end of file diff --git a/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountTradingRecordSheet.java b/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountTradingRecordSheet.java index d5dd07c1..499a2d2f 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountTradingRecordSheet.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountTradingRecordSheet.java @@ -6,6 +6,7 @@ import com.ibeetl.admin.core.util.ValidateConfig; import org.beetl.sql.annotation.entity.AssignID; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; import java.util.Date; /* @@ -23,7 +24,7 @@ public class StudentAccountTradingRecordSheet extends BaseEntity{ //转入金额 - private Long transactionAmount ; + private BigDecimal transactionAmount ; //转入类型 @@ -68,13 +69,13 @@ public class StudentAccountTradingRecordSheet extends BaseEntity{ /**转入金额 *@return */ - public Long getTransactionAmount(){ + public BigDecimal getTransactionAmount(){ return transactionAmount; } /**转入金额 *@param transactionAmount */ - public void setTransactionAmount(Long transactionAmount){ + public void setTransactionAmount(BigDecimal transactionAmount){ this.transactionAmount = transactionAmount; } diff --git a/web/src/main/java/com/ibeetl/jlw/enums/AccountTypeEnum.java b/web/src/main/java/com/ibeetl/jlw/enums/AccountTypeEnum.java index 05f6f014..6663b434 100644 --- a/web/src/main/java/com/ibeetl/jlw/enums/AccountTypeEnum.java +++ b/web/src/main/java/com/ibeetl/jlw/enums/AccountTypeEnum.java @@ -54,9 +54,9 @@ public enum AccountTypeEnum { /**股权投资账户*/ EQUITY_INVESTMENT_ACCOUNT("股权投资账户"), /**量化交易账户(股票基金)*/ - EQUITY_FUND_QUANTITATIVE_TRADING_ACCOUNT("量化交易账户(股票基金)"), + EQUITY_FUND_QUANTITATIVE_TRADING_ACCOUNT("量化交易账户(股票基金)"), /**量化交易账户(期货)*/ - FUTURES_QUANTITATIVE_TRADING_ACCOUNT("量化交易账户(期货)"), + FUTURES_QUANTITATIVE_TRADING_ACCOUNT("量化交易账户(期货)"), /**区块链资产账户*/ BLOCKCHAIN_ASSET_ACCOUNT("区块链资产账户"), /**期权投资账户*/ diff --git a/web/src/main/java/com/ibeetl/jlw/service/StudentAccountAssetAllocationService.java b/web/src/main/java/com/ibeetl/jlw/service/StudentAccountAssetAllocationService.java index 4ee8993e..e4ca5be7 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/StudentAccountAssetAllocationService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/StudentAccountAssetAllocationService.java @@ -1,19 +1,25 @@ package com.ibeetl.jlw.service; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.jwt.JWTUtil; import cn.jlw.util.ToolUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.ibeetl.admin.core.entity.CoreUser; import com.ibeetl.admin.core.service.CoreBaseService; import com.ibeetl.admin.core.util.PlatformException; import com.ibeetl.admin.core.web.JsonResult; import com.ibeetl.admin.core.web.JsonReturnCode; -import com.ibeetl.jlw.dao.StudentAccountAssetAllocationDao; +import com.ibeetl.jlw.dao.*; import com.ibeetl.jlw.entity.*; +import com.ibeetl.jlw.enums.AccountTypeEnum; import com.ibeetl.jlw.web.query.ResourcesApplicationCourseQuery; +import com.ibeetl.jlw.web.query.ResourcesApplicationQuery; import com.ibeetl.jlw.web.query.StudentAccountAssetAllocationQuery; import org.apache.commons.lang3.StringUtils; import org.beetl.sql.core.SqlId; @@ -27,8 +33,7 @@ import javax.validation.constraints.NotBlank; import java.math.BigDecimal; import java.math.RoundingMode; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import static cn.hutool.core.collection.IterUtil.getFirst; import static com.ibeetl.admin.core.util.StreamUtils.listJoin; @@ -42,40 +47,57 @@ import static java.util.Collections.emptyList; @Service @Transactional @Validated -public class StudentAccountAssetAllocationService extends CoreBaseService{ +public class StudentAccountAssetAllocationService extends CoreBaseService { - @Autowired private StudentAccountAssetAllocationDao studentAccountAssetAllocationDao; - @Autowired private LoginTodoService loginTodoService; - @Autowired private ResourcesApplicationService resourcesApplicationService; + @Autowired + private StudentAccountAssetAllocationDao studentAccountAssetAllocationDao; + @Autowired + private LoginTodoService loginTodoService; + @Autowired + private ResourcesApplicationService resourcesApplicationService; @Autowired private ResourcesApplicationCourseService resourcesApplicationCourseService; @Autowired private CourseInfoService courseInfoService; - public PageQueryqueryByCondition(PageQuery query){ - PageQuery ret = studentAccountAssetAllocationDao.queryByCondition(query); + + @Autowired + private UniversitiesCollegesDao universitiesCollegesDao; + + @Autowired + private UniversitiesCollegesJurisdictionExperimentalSystemDao universitiesCollegesJurisdictionExperimentalSystemDao; + + @Autowired + private ResourcesApplicationDao resourcesApplicationDao; + + @Autowired + private StudentAccountTradingRecordSheetDao studentAccountTradingRecordSheetDao; + + + public PageQuery queryByCondition(PageQuery query) { + PageQuery ret = studentAccountAssetAllocationDao.queryByCondition(query); queryListAfter(ret.getList()); return ret; } - public PageQueryqueryByConditionQuery(PageQuery query){ - PageQuery ret = studentAccountAssetAllocationDao.queryByConditionQuery(query); + public PageQuery queryByConditionQuery(PageQuery query) { + PageQuery ret = studentAccountAssetAllocationDao.queryByConditionQuery(query); queryListAfter(ret.getList()); return ret; } - public void deleteByList(List list){ + public void deleteByList(List list) { String ids = ""; ToolUtils.deleteNullList(list); - for(int i=0;null != list && i studentAccountAssetAllocationList = new ArrayList<>(); try { @@ -91,11 +113,12 @@ public class StudentAccountAssetAllocationService extends CoreBaseService0){ - for(int i=0;i 0) { + for (int i = 0; i < studentAccountAssetAllocationList.size(); i++) { StudentAccountAssetAllocation studentAccountAssetAllocation = studentAccountAssetAllocationList.get(i); studentAccountAssetAllocation.setUserId(studentAccountAssetAllocationQuery.getUserId()); studentAccountAssetAllocation.setOrgId(studentAccountAssetAllocationQuery.getOrgId()); @@ -105,7 +128,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService 0; - if(!flag){ + if (!flag) { msg = "更新指定参数失败"; } - }else{ + } else { msg = "指定参数为空"; } return msg; } - public List getValues (Object paras){ + public List getValues(Object paras) { return sqlManager.select(SqlId.of("jlw.studentAccountAssetAllocation.getStudentAccountAssetAllocationValues"), StudentAccountAssetAllocation.class, paras); } - public List getValuesByQuery (StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery){ + public List getValuesByQuery(StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery) { return studentAccountAssetAllocationDao.getValuesByQuery(studentAccountAssetAllocationQuery); } - public List getValuesByQueryNotWithPermission (StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery){ + public List getValuesByQueryNotWithPermission(StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery) { return studentAccountAssetAllocationDao.getValuesByQueryNotWithPermission(studentAccountAssetAllocationQuery); } - public StudentAccountAssetAllocation getInfo (Long id){ + public StudentAccountAssetAllocation getInfo(Long id) { StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery = new StudentAccountAssetAllocationQuery(); studentAccountAssetAllocationQuery.setId(id); List list = studentAccountAssetAllocationDao.getValuesByQuery(studentAccountAssetAllocationQuery); - if(null != list && list.size()>0){ + if (null != list && list.size() > 0) { return list.get(0); - }else{ + } else { return null; } } - public StudentAccountAssetAllocation getInfo (StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery){ + public StudentAccountAssetAllocation getInfo(StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery) { List list = studentAccountAssetAllocationDao.getValuesByQuery(studentAccountAssetAllocationQuery); - if(null != list && list.size()>0){ + if (null != list && list.size() > 0) { return list.get(0); - }else{ + } else { return null; } } @@ -197,8 +220,8 @@ public class StudentAccountAssetAllocationService extends CoreBaseService * 通过token获取资金账户 * - * @param applicationToken token - * @param param 一些参数 + * @param applicationToken token + * @param param 一些参数 * @return {@link List< StudentAccountAssetAllocation>} * @Author: 87966 * @Date: 2023/3/6 16:32 @@ -233,7 +256,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService applications = resourcesApplicationDao.getValuesByQuery(query); + if (CollectionUtil.isNotEmpty(applications)) { + allocation.setApplicationId(applications.get(0).getResourcesApplicationId()); + List experimentalSystems = universitiesCollegesJurisdictionExperimentalSystemDao.getNotExpireApply(orgId, applications.get(0).getResourcesApplicationId().toString()); + allocation.setState(CollectionUtil.isNotEmpty(experimentalSystems) ? 2 : 1); + allocation.setInitialCapital(CollectionUtil.isNotEmpty(experimentalSystems) ? + new BigDecimal(1000000) : BigDecimal.ZERO); + allocation.setAvailableFunds(CollectionUtil.isNotEmpty(experimentalSystems) ? + new BigDecimal(1000000) : BigDecimal.ZERO); + allocation.setInitialInvestmentCapital(CollectionUtil.isNotEmpty(experimentalSystems) ? + new BigDecimal(1000000) : BigDecimal.ZERO); + } + } + } + + + allocation.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId()); + allocation.setName(values[i]); + allocation.setUpdateTime(new Date()); + allocation.setCreateTime(new Date()); + allocation.setIsDel(1); + allocation.setOrgId(orgId); + allocation.setUpdateVersion(-1L); + studentAccountAssetAllocationDao.insert(allocation); + } + } + + /** + * 应用授权后开通资金账户权限 + * + * @param orgId + */ + public void updateApplicationAuthority(Long orgId) { + + List experimentalSystems = universitiesCollegesJurisdictionExperimentalSystemDao.getSQLManager().lambdaQuery(UniversitiesCollegesJurisdictionExperimentalSystem.class) + .andEq(UniversitiesCollegesJurisdictionExperimentalSystem::getOrgId, orgId).select(); + + StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery(); + allocationQuery.setOrgId(orgId); + List valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery); + + //获取所以的资金账号 + for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) { + int state = 1; + //获取添加院校权限,对账号进行限制 + for (UniversitiesCollegesJurisdictionExperimentalSystem item : experimentalSystems) { + + if (ObjectUtil.equals(accountAssetAllocation.getApplicationId(),item.getTypeId()) && ObjectUtil.isNotNull(item.getUseEndTime()) && DateUtil.endOfDay(item.getUseEndTime()).getTime() >= System.currentTimeMillis() && (ObjectUtil.equals(item.getUseType(), 1) || ObjectUtil.equals(item.getUseType(), 2))) { + //后期添加应用开发权限,新增的时候已经有应用添加了 + state = 2; + } else if (ObjectUtil.isEmpty(accountAssetAllocation.getApplicationId())){ + //新增学生账号,应用还没有添加,后面才添加,授权权限的时候获取应用ID设置 + ResourcesApplicationQuery resourcesApplicationQuery = new ResourcesApplicationQuery(); + if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.P2P_ACCOUNT.getText())) { + resourcesApplicationQuery.setApplicationSecondLevelRelation("P2P网络借贷公司"); + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.CROWDFUNDING_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("众筹公司"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_INVESTMENT_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易"); + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_INVESTMENT_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_INVESTMENT_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("PE/VC"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_QUANTITATIVE_TRADING_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_QUANTITATIVE_TRADING_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.BLOCKCHAIN_ASSET_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("数字资产"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.MARGIN_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("融资融券"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.INSURANCE_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("保险公司"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.SUPPLY_CHAIN_ASSET_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("供应链金融服务公司"); + + } + + if (ObjectUtil.isNotNull(resourcesApplicationQuery.getApplicationSecondLevelRelation())){ + List resourcesApplicationList = resourcesApplicationDao.getValuesByQuery(resourcesApplicationQuery); + if (CollectionUtil.isNotEmpty(resourcesApplicationList)){ + if (ObjectUtil.equals(item.getTypeId(),resourcesApplicationList.get(0).getResourcesApplicationId())){ + accountAssetAllocation.setApplicationId(item.getTypeId()); + state = 2; + } + } + } + + + } + } + accountAssetAllocation.setState(state); + + if (ObjectUtil.equals(state, 2)) { + accountAssetAllocation.setInitialCapital(Objects.equals(accountAssetAllocation.getInitialCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialCapital()); + accountAssetAllocation.setAvailableFunds(Objects.equals(accountAssetAllocation.getAvailableFunds().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getAvailableFunds()); + accountAssetAllocation.setInitialInvestmentCapital(Objects.equals(accountAssetAllocation.getInitialInvestmentCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialInvestmentCapital()); + accountAssetAllocation.setUpdateTime(new Date()); + } + if (!ObjectUtil.equals(accountAssetAllocation.getApplicationId(),-1L) && + !ObjectUtil.equals(accountAssetAllocation.getApplicationId(),-2L) && + !ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.OPTIONS_INVESTMENT_ACCOUNT.getText()) && + !ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FOREX_INVESTMENT_ACCOUNT.getText()) && + !ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.TRUST_ACCOUNT.getText())){ + studentAccountAssetAllocationDao.updateById(accountAssetAllocation); + } + } + } + + /** + * 激活该校的所有学生用户的股票/期货账户 + * + * @param orgId + */ + public void allOpenAccount(Long orgId) { + + StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery(); + allocationQuery.setOrgId(orgId); + allocationQuery.setState(1); + List valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery); + + for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) { + accountAssetAllocation.setState(2); + accountAssetAllocation.setInitialCapital(Objects.equals(accountAssetAllocation.getInitialCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialCapital()); + accountAssetAllocation.setAvailableFunds(Objects.equals(accountAssetAllocation.getAvailableFunds().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getAvailableFunds()); + accountAssetAllocation.setInitialInvestmentCapital(Objects.equals(accountAssetAllocation.getInitialInvestmentCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialInvestmentCapital()); + accountAssetAllocation.setUpdateTime(new Date()); + studentAccountAssetAllocationDao.updateById(accountAssetAllocation); + } + } + + + /** + * 转账 + * @param toAccountsApplicationId + * @param outAccountsApplicationId + * @param money + * @param studentId + * @param coreUser + * @return + */ + public JsonResult transferAccounts(Long toAccountsApplicationId, Long outAccountsApplicationId, BigDecimal money, Long studentId,CoreUser coreUser){ + + if (ObjectUtil.isEmpty(money)){ + return JsonResult.failMessage("转账金额为空"); + } + + BigDecimal transfer = money.setScale(2, RoundingMode.HALF_UP); + + //转出账户 + StudentAccountAssetAllocationQuery outAccounts = new StudentAccountAssetAllocationQuery(); + outAccounts.setState(2); + outAccounts.setApplicationId(outAccountsApplicationId); + outAccounts.setStudentId(studentId); + List outAccountsList = studentAccountAssetAllocationDao.getValuesByQuery(outAccounts); + if (CollectionUtil.isEmpty(outAccountsList)){ + return JsonResult.failMessage("转出账号未开通"); + } + StudentAccountAssetAllocation outAccountAssetAllocation = outAccountsList.get(0); + + BigDecimal availableFunds = outAccountAssetAllocation.getAvailableFunds(); + + //转入账户 + StudentAccountAssetAllocationQuery toAccounts = new StudentAccountAssetAllocationQuery(); + toAccounts.setState(2); + toAccounts.setApplicationId(toAccountsApplicationId); + toAccounts.setStudentId(studentId); + List toAccountsList = studentAccountAssetAllocationDao.getValuesByQuery(toAccounts); + + if (CollectionUtil.isEmpty(toAccountsList)){ + return JsonResult.failMessage("转入账号未开通"); + } + + StudentAccountAssetAllocation toAccountAssetAllocation = toAccountsList.get(0); + + + if (Objects.equals(availableFunds.compareTo(BigDecimal.ZERO), 0)){ + return JsonResult.failMessage("可用资金不足"); + } + + if (availableFunds.compareTo(transfer) < 0){ + return JsonResult.failMessage("超出可用资金总额"); + } + + outAccountAssetAllocation.setAvailableFunds(availableFunds.subtract(transfer)); + outAccountAssetAllocation.setInitialInvestmentCapital(outAccountAssetAllocation.getApplicationId() == -1 ? availableFunds : availableFunds.subtract(transfer)); + outAccountAssetAllocation.setTransferOutAmount(outAccountAssetAllocation.getTransferOutAmount().add(transfer)); + studentAccountAssetAllocationDao.updateById(outAccountAssetAllocation); + + + toAccountAssetAllocation.setInitialInvestmentCapital(toAccountAssetAllocation.getTransferOutAmount().add(transfer)); + toAccountAssetAllocation.setAvailableFunds(toAccountAssetAllocation.getTransferOutAmount().add(transfer)); + toAccountAssetAllocation.setTransferAmount(toAccountAssetAllocation.getTransferAmount().add(transfer)); + studentAccountAssetAllocationDao.updateById(toAccountAssetAllocation); + + StudentAccountTradingRecordSheet tradingRecordSheet = new StudentAccountTradingRecordSheet(); + tradingRecordSheet.setTransactionAmount(transfer); + tradingRecordSheet.setTransferType(toAccountAssetAllocation.getName().toString()); + tradingRecordSheet.setExitType(outAccountAssetAllocation.getName().name()); + tradingRecordSheet.setCreateTime(new Date()); + tradingRecordSheet.setStudentId(studentId); + tradingRecordSheet.setOrgId(coreUser.getOrgId()); + studentAccountTradingRecordSheetDao.insert(tradingRecordSheet); + return JsonResult.success(); + } + + + /** + * 获取转账账户 + * @param studentId + * @return + */ + public List getCapitalAccount(Long studentId){ + List select = studentAccountAssetAllocationDao.getSQLManager().lambdaQuery(StudentAccountAssetAllocation.class) + .andEq(StudentAccountAssetAllocation::getStudentId, studentId) + .andEq(StudentAccountAssetAllocation::getState, 2) + .andNotIn(StudentAccountAssetAllocation::getApplicationId, Arrays.asList(-1)) + .select(); + return select; } /** * 拷贝一些必要的信息 + * * @param loginTodo * @param param */ @@ -277,6 +607,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService * 通过token获取应用绑定的课程信息 * - * @param applicationToken 跳转时候,传递的token + * @param applicationToken 跳转时候,传递的token * @return {@link List< CourseInfo>} * @Author: lx * @Date: 2023/3/22 21:24 diff --git a/web/src/main/java/com/ibeetl/jlw/service/StudentService.java b/web/src/main/java/com/ibeetl/jlw/service/StudentService.java index 428622e6..e0414396 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/StudentService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/StudentService.java @@ -20,8 +20,7 @@ import com.ibeetl.admin.core.util.PlatformException; import com.ibeetl.admin.core.util.TimeTool; import com.ibeetl.admin.core.web.JsonResult; import com.ibeetl.admin.core.web.JsonReturnCode; -import com.ibeetl.jlw.dao.SchoolClassDao; -import com.ibeetl.jlw.dao.StudentDao; +import com.ibeetl.jlw.dao.*; import com.ibeetl.jlw.entity.*; import com.ibeetl.jlw.entity.vo.StudentLogAnalysisVO; import com.ibeetl.jlw.entity.vo.StudentLoginLogVO; @@ -112,6 +111,8 @@ public class StudentService extends CoreBaseService{ @Autowired private StudentDefenceLogInfoService studentDefenceLogInfoService; @Autowired private StudentDefenceLogNoteService studentDefenceLogNoteService; + @Autowired private StudentAccountAssetAllocationService studentAccountAssetAllocationService; + private final ExecutorService pool = Executors.newCachedThreadPool(); @Autowired @@ -476,6 +477,9 @@ public class StudentService extends CoreBaseService{ s.setUserId(createdUserId); s.setOrgId(orgId); + //新建学生用户资金总表 + studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(),orgId,createdUserId); + this.updateTemplate(s); JsonResult jsonResult = new JsonResult(); diff --git a/web/src/main/java/com/ibeetl/jlw/service/UniversitiesCollegesJurisdictionExperimentalSystemService.java b/web/src/main/java/com/ibeetl/jlw/service/UniversitiesCollegesJurisdictionExperimentalSystemService.java index 17b34558..408df3cf 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/UniversitiesCollegesJurisdictionExperimentalSystemService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/UniversitiesCollegesJurisdictionExperimentalSystemService.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; import static cn.hutool.core.date.DateTime.now; import static cn.hutool.core.util.ObjectUtil.defaultIfNull; @@ -48,6 +49,9 @@ public class UniversitiesCollegesJurisdictionExperimentalSystemService extends C @Autowired private CorePlatformService corePlatformService; + @Autowired + private StudentAccountAssetAllocationService studentAccountAssetAllocationService; + public PageQueryqueryByCondition(PageQuery query){ PageQuery ret = universitiesCollegesJurisdictionExperimentalSystemDao.queryByCondition(query); queryListAfter(ret.getList()); @@ -111,6 +115,8 @@ public class UniversitiesCollegesJurisdictionExperimentalSystemService extends C } if(universitiesCollegesJurisdictionExperimentalSystemList.size()>0){ this.insertBatch(universitiesCollegesJurisdictionExperimentalSystemList); + //应用授权后开通资金账户权限 + studentAccountAssetAllocationService.updateApplicationAuthority(uc.getOrgId()); } List urList = new ArrayList<>(); diff --git a/web/src/main/java/com/ibeetl/jlw/web/StudentAccountAssetAllocationController.java b/web/src/main/java/com/ibeetl/jlw/web/StudentAccountAssetAllocationController.java index 98dc1018..dbc01ff3 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/StudentAccountAssetAllocationController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/StudentAccountAssetAllocationController.java @@ -23,6 +23,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; +import java.math.BigDecimal; import java.util.List; import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser; @@ -48,6 +49,38 @@ public class StudentAccountAssetAllocationController{ /* 前端接口 */ + + @GetMapping(API + "/allOpenAccount.do") + @ApiOperation("激活该校的所有学生用户的股票/期货账户") + public JsonResult allOpenAccount(Long orgId,@SCoreUser CoreUser coreUser) { + if(null == coreUser){ + return JsonResult.failMessage("请登录后再操作"); + }else{ + studentAccountAssetAllocationService.allOpenAccount(orgId); + return JsonResult.success("操作成功"); + } + } + + @PostMapping(API + "/allOpenAccount.do") + @ApiOperation("转账") + public JsonResult transferAccounts(Long toAccountsApplicationId, Long outAccountsApplicationId, BigDecimal money,Long studentId, @SCoreUser CoreUser coreUser) { + if(null == coreUser){ + return JsonResult.failMessage("请登录后再操作"); + }else{ + return studentAccountAssetAllocationService.transferAccounts(toAccountsApplicationId, outAccountsApplicationId ,money , studentId,coreUser); + } + } + + @GetMapping(API + "/getCapitalAccount.do") + @ApiOperation("获取转账账户") + public JsonResult> getCapitalAccount(Long studentId, @SCoreUser CoreUser coreUser) { + if(null == coreUser){ + return JsonResult.failMessage("请登录后再操作"); + }else{ + return JsonResult.success(studentAccountAssetAllocationService.getCapitalAccount(studentId)); + } + } + @PostMapping(API + "/getPageList.do") @ApiOperation("分页列表") public JsonResult getPageList(StudentAccountAssetAllocationQuery condition,@SCoreUser CoreUser coreUser){ @@ -200,7 +233,7 @@ public class StudentAccountAssetAllocationController{ if(result.hasErrors()){ return JsonResult.failMessage(result); }else{ - + studentAccountAssetAllocationQuery.setUserId(coreUser.getId()); studentAccountAssetAllocationQuery.setOrgId(coreUser.getOrgId()); return studentAccountAssetAllocationService.add(studentAccountAssetAllocationQuery); diff --git a/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountTradingRecordSheetQuery.java b/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountTradingRecordSheetQuery.java index 70d3499e..21996db5 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountTradingRecordSheetQuery.java +++ b/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountTradingRecordSheetQuery.java @@ -7,6 +7,7 @@ import com.ibeetl.jlw.entity.StudentAccountTradingRecordSheet; import io.swagger.annotations.ApiModelProperty; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; import java.util.Date; /** @@ -18,7 +19,7 @@ public class StudentAccountTradingRecordSheetQuery extends PageParam { private Long id; @Query(name = "转入金额", display = false) @ApiModelProperty("转入金额") - private Long transactionAmount; + private BigDecimal transactionAmount; @Query(name = "转入类型", display = false) @ApiModelProperty("转入类型") private String transferType; @@ -54,10 +55,10 @@ public class StudentAccountTradingRecordSheetQuery extends PageParam { public void setId(Long id ){ this.id = id; } - public Long getTransactionAmount(){ + public BigDecimal getTransactionAmount(){ return transactionAmount; } - public void setTransactionAmount(Long transactionAmount ){ + public void setTransactionAmount(BigDecimal transactionAmount ){ this.transactionAmount = transactionAmount; } public String getTransferType(){ diff --git a/web/src/main/resources/sql/jlw/universitiesCollegesJurisdictionExperimentalSystem.md b/web/src/main/resources/sql/jlw/universitiesCollegesJurisdictionExperimentalSystem.md index 6292828b..5941a548 100644 --- a/web/src/main/resources/sql/jlw/universitiesCollegesJurisdictionExperimentalSystem.md +++ b/web/src/main/resources/sql/jlw/universitiesCollegesJurisdictionExperimentalSystem.md @@ -242,4 +242,26 @@ getAllOverdueAuthByBeforeAndAfterDays @if(!isEmpty(orgId) && orgId != 1){ and t.org_id =#orgId# @} + +getNotExpireApply +=== +* 获取不过期的应用 + +SELECT +* +FROM +`universities_colleges_jurisdiction_experimental_system` a +WHERE +1=1 +@if(!isEmpty(orgId) && orgId != 1){ +AND a.org_id = #orgId# +@} +@if(!isEmpty(typeId)){ +AND a.type_id = #typeId# +@} +@if(!isEmpty(typeIds)){ +and find_in_set(a.type_id,#typeIds#) +@} + +AND a.use_end_time >= NOW()