1、资产配置

beetlsql3-dev
wgf 2 years ago
parent 59b63f133a
commit 5b3a5d563e

@ -44,4 +44,11 @@ public interface UniversitiesCollegesJurisdictionExperimentalSystemDao extends B
* @Date: 2023/3/19 23:38
*/
List<UniversitiesCollegesJurisdictionExperimentalSystem> getAllOverdueAuthByBeforeAndAfterDays(@Param("beforeDays") Long beforeDays, @Param("afterDays") Long afterDays, @Param("orgId") Long orgId);
/**
*
* @param orgId
* @return
*/
List<UniversitiesCollegesJurisdictionExperimentalSystem> getNotExpireApply( @Param("orgId") Long orgId , @Param("typeId") String typeIds);
}

@ -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;
}

@ -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("区块链资产账户"),
/**期权投资账户*/

@ -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<StudentAccountAssetAllocation>{
public class StudentAccountAssetAllocationService extends CoreBaseService<StudentAccountAssetAllocation> {
@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 PageQuery<StudentAccountAssetAllocation>queryByCondition(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<StudentAccountAssetAllocation> queryByCondition(PageQuery query) {
PageQuery ret = studentAccountAssetAllocationDao.queryByCondition(query);
queryListAfter(ret.getList());
return ret;
}
public PageQuery<StudentAccountAssetAllocation>queryByConditionQuery(PageQuery query){
PageQuery ret = studentAccountAssetAllocationDao.queryByConditionQuery(query);
public PageQuery<StudentAccountAssetAllocation> 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<list.size();i++){
ids += list.get(i).toString()+(i==list.size()-1?"":",");
for (int i = 0; null != list && i < list.size(); i++) {
ids += list.get(i).toString() + (i == list.size() - 1 ? "" : ",");
}
if(StringUtils.isNotBlank(ids)){
if (StringUtils.isNotBlank(ids)) {
studentAccountAssetAllocationDao.deleteStudentAccountAssetAllocationByIds(ids);
}
}
public void deleteStudentAccountAssetAllocation(String ids){
public void deleteStudentAccountAssetAllocation(String ids) {
try {
studentAccountAssetAllocationDao.deleteStudentAccountAssetAllocationByIds(ids);
} catch (Exception e) {
@ -83,7 +105,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
}
}
public String addAll(StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery){
public String addAll(StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery) {
String msg = "";
List<StudentAccountAssetAllocation> studentAccountAssetAllocationList = new ArrayList<>();
try {
@ -91,11 +113,12 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
} catch (Exception e) {
try {
studentAccountAssetAllocationList.add(JSONObject.parseObject(studentAccountAssetAllocationQuery.getStudentAccountAssetAllocationJsonStr(), StudentAccountAssetAllocation.class));
} catch (Exception e1) {}
} catch (Exception e1) {
}
}
ToolUtils.deleteNullList(studentAccountAssetAllocationList);
if(null != studentAccountAssetAllocationList && studentAccountAssetAllocationList.size()>0){
for(int i=0;i<studentAccountAssetAllocationList.size();i++){
if (null != studentAccountAssetAllocationList && studentAccountAssetAllocationList.size() > 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<Studen
return msg;
}
public JsonResult add(StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery){
public JsonResult add(StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery) {
String msg = "";
StudentAccountAssetAllocation studentAccountAssetAllocation = studentAccountAssetAllocationQuery.pojo();
studentAccountAssetAllocationDao.insert(studentAccountAssetAllocation);
@ -117,54 +140,54 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
return jsonResult;
}
public String edit(StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery){
public String edit(StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery) {
String msg = "";
StudentAccountAssetAllocation studentAccountAssetAllocation = studentAccountAssetAllocationQuery.pojo();
studentAccountAssetAllocationDao.updateTemplateById(studentAccountAssetAllocation);
return msg;
}
public String updateGivenByIds(StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery){
public String updateGivenByIds(StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery) {
String msg = "";
if(StringUtils.isNotBlank(studentAccountAssetAllocationQuery.get_given())){
if (StringUtils.isNotBlank(studentAccountAssetAllocationQuery.get_given())) {
boolean flag = studentAccountAssetAllocationDao.updateGivenByIds(studentAccountAssetAllocationQuery) > 0;
if(!flag){
if (!flag) {
msg = "更新指定参数失败";
}
}else{
} else {
msg = "指定参数为空";
}
return msg;
}
public List<StudentAccountAssetAllocation> getValues (Object paras){
public List<StudentAccountAssetAllocation> getValues(Object paras) {
return sqlManager.select(SqlId.of("jlw.studentAccountAssetAllocation.getStudentAccountAssetAllocationValues"), StudentAccountAssetAllocation.class, paras);
}
public List<StudentAccountAssetAllocation> getValuesByQuery (StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery){
public List<StudentAccountAssetAllocation> getValuesByQuery(StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery) {
return studentAccountAssetAllocationDao.getValuesByQuery(studentAccountAssetAllocationQuery);
}
public List<StudentAccountAssetAllocation> getValuesByQueryNotWithPermission (StudentAccountAssetAllocationQuery studentAccountAssetAllocationQuery){
public List<StudentAccountAssetAllocation> 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<StudentAccountAssetAllocation> 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<StudentAccountAssetAllocation> 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<Studen
* : <br>
* 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<Studen
/**
*
*
* @param applicationToken token
* @param applicationToken token
* @return
*/
public LoginTodo validateAndGetLoginTodo(String applicationToken) {
@ -254,12 +277,319 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
/**
*
*/
public void createFundAccountWithUserCreated() {
public void createFundAccountWithUserCreated(Long studentId, Long orgId, Long userId) {
//开设7个账户现金账户100万银行账户0元其他应用的账户开设但是未被激活没有初始资金
AccountTypeEnum[] values = AccountTypeEnum.values();
UniversitiesColleges universitiesColleges = universitiesCollegesDao.getByOrgId(orgId);
for (int i = 0; i < values.length; i++) {
StudentAccountAssetAllocation allocation = new StudentAccountAssetAllocation();
allocation.setStudentId(studentId);
//先默认不开通,条件符合就开通
allocation.setState(1);
ResourcesApplicationQuery query = new ResourcesApplicationQuery();
if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.P2P_ACCOUNT.getText())) {
query.setApplicationSecondLevelRelation("P2P网络借贷公司");
} else if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.CROWDFUNDING_ACCOUNT.getText())) {
query.setApplicationSecondLevelRelation("众筹公司");
} else if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.EQUITY_FUND_INVESTMENT_ACCOUNT.getText())) {
query.setApplicationSecondLevelRelation("证券交易");
} else if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.FUTURES_INVESTMENT_ACCOUNT.getText())) {
query.setApplicationSecondLevelRelation("证券交易");
} else if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.EQUITY_INVESTMENT_ACCOUNT.getText())) {
query.setApplicationSecondLevelRelation("PE/VC");
} else if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.EQUITY_FUND_QUANTITATIVE_TRADING_ACCOUNT.getText())) {
query.setApplicationSecondLevelRelation("智能交易");
} else if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.FUTURES_QUANTITATIVE_TRADING_ACCOUNT.getText())) {
query.setApplicationSecondLevelRelation("智能交易");
} else if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.BLOCKCHAIN_ASSET_ACCOUNT.getText())) {
query.setApplicationSecondLevelRelation("数字资产");
} else if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.MARGIN_ACCOUNT.getText())) {
query.setApplicationSecondLevelRelation("融资融券");
} else if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.INSURANCE_ACCOUNT.getText())) {
query.setApplicationSecondLevelRelation("保险公司");
} else if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.SUPPLY_CHAIN_ASSET_ACCOUNT.getText())) {
query.setApplicationSecondLevelRelation("供应链金融服务公司");
}
if (ObjectUtil.equals(values[i].getText(), AccountTypeEnum.CASH_ACCOUNT.getText()) || ObjectUtil.equals(values[i].getText(), AccountTypeEnum.BANK_ACCOUNT.getText())) {
allocation.setState(2);
allocation.setApplicationId(ObjectUtil.equals(values[i].getText(), AccountTypeEnum.CASH_ACCOUNT.getText()) ? -2L : -1L );
allocation.setInitialCapital(ObjectUtil.equals(values[i].getText(), AccountTypeEnum.CASH_ACCOUNT.getText()) ?
new BigDecimal(1000000) : BigDecimal.ZERO);
allocation.setAvailableFunds(ObjectUtil.equals(values[i].getText(), AccountTypeEnum.CASH_ACCOUNT.getText()) ?
new BigDecimal(1000000) : BigDecimal.ZERO);
allocation.setInitialInvestmentCapital(ObjectUtil.equals(values[i].getText(), AccountTypeEnum.CASH_ACCOUNT.getText()) ?
new BigDecimal(1000000) : BigDecimal.ZERO);
} else {
if (ObjectUtil.isNotNull(query.getApplicationSecondLevelRelation())) {
List<ResourcesApplication> applications = resourcesApplicationDao.getValuesByQuery(query);
if (CollectionUtil.isNotEmpty(applications)) {
allocation.setApplicationId(applications.get(0).getResourcesApplicationId());
List<UniversitiesCollegesJurisdictionExperimentalSystem> 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<UniversitiesCollegesJurisdictionExperimentalSystem> experimentalSystems = universitiesCollegesJurisdictionExperimentalSystemDao.getSQLManager().lambdaQuery(UniversitiesCollegesJurisdictionExperimentalSystem.class)
.andEq(UniversitiesCollegesJurisdictionExperimentalSystem::getOrgId, orgId).select();
StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery();
allocationQuery.setOrgId(orgId);
List<StudentAccountAssetAllocation> 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<ResourcesApplication> 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<StudentAccountAssetAllocation> 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<String> 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<StudentAccountAssetAllocation> 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<StudentAccountAssetAllocation> 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<StudentAccountAssetAllocation> getCapitalAccount(Long studentId){
List<StudentAccountAssetAllocation> 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<Studen
/**
*
* availableFunds
*
* @param applicationToken
* @param param
* @return
@ -319,7 +650,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
* : <br>
* token
*
* @param applicationToken token
* @param applicationToken token
* @return {@link List< CourseInfo>}
* @Author: lx
* @Date: 2023/3/22 21:24

@ -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<Student>{
@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<Student>{
s.setUserId(createdUserId);
s.setOrgId(orgId);
//新建学生用户资金总表
studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(),orgId,createdUserId);
this.updateTemplate(s);
JsonResult jsonResult = new JsonResult();

@ -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 PageQuery<UniversitiesCollegesJurisdictionExperimentalSystem>queryByCondition(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<UniversitiesCollegesJurisdictionCurriculumResourcesQuery> urList = new ArrayList<>();

@ -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<String> 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<String> 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<List<StudentAccountAssetAllocation>> 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<PageQuery> 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);

@ -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(){

@ -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()

Loading…
Cancel
Save