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