| | |
| | | package com.xcong.excoin.modules.contract.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.xcong.excoin.modules.coin.dao.MemberAccountFlowEntityDao; |
| | | import com.xcong.excoin.modules.coin.entity.MemberAccountFlowEntity; |
| | | import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity; |
| | | import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity; |
| | | import com.xcong.excoin.modules.contract.entity.ContractOrderEntity; |
| | |
| | | import com.xcong.excoin.modules.contract.service.ContractEntrustOrderService; |
| | | import com.xcong.excoin.modules.contract.service.ContractHoldOrderService; |
| | | import com.xcong.excoin.modules.contract.service.ContractOrderService; |
| | | import com.xcong.excoin.modules.member.dao.AgentReturnDao; |
| | | import com.xcong.excoin.modules.member.entity.AgentReturnEntity; |
| | | import com.xcong.excoin.modules.member.entity.MemberEntity; |
| | | import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity; |
| | |
| | | import com.xcong.excoin.utils.CacheSettingUtils; |
| | | import com.xcong.excoin.utils.CalculateUtil; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | @Resource |
| | | MemberService memberService; |
| | | |
| | | @Resource |
| | | private AgentReturnDao agentReturnDao; |
| | | |
| | | @Resource |
| | | private MemberAccountFlowEntityDao memberAccountFlowEntityDao; |
| | | |
| | | |
| | | |
| | |
| | | BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount()); |
| | | memberWalletContractService.increaseWalletContractBalanceById(totalBalance,totalReturn,null,wallet.getId()); |
| | | |
| | | // 流水记录 TODO 531 |
| | | // MemberAccountFlowRecord record = new MemberAccountFlowRecord(); |
| | | // record.setCreateTime(new Date()); |
| | | // record.setDirectionSource("止盈平仓"); |
| | | // record.setRemark("止盈平仓"); |
| | | // record.setMemberBalance(wallet.getAvailableBalance()); |
| | | // record.setMemberid(order.getMemberId()); |
| | | // record.setSymbolName(order.getSymbol()); |
| | | // record.setMemberName(wallet.getMemberName()); |
| | | // record.setMemberPhone(order.getMemberPhone()); |
| | | // record.setPrice(profitLossPrice + order.getPrePrice()); |
| | | // memberService.addFlowRecord(record); |
| | | // |
| | | // //返佣 TODO 531 |
| | | // calYj(order.getMemberId(), new BigDecimal(order.getClosingPrice()), order, 2); |
| | | // 流水记录 TODO 531e |
| | | insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓"); |
| | | |
| | | //返佣 |
| | | calYj(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, 2); |
| | | } |
| | | } |
| | | } |
| | |
| | | BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount()); |
| | | memberWalletContractService.increaseWalletContractBalanceById(totalBalance,totalReturn,null,wallet.getId()); |
| | | |
| | | // // 流水记录 TODO 531 |
| | | // MemberAccountFlowRecord record = new MemberAccountFlowRecord(); |
| | | // record.setCreateTime(new Date()); |
| | | // record.setDirectionSource("止盈平仓"); |
| | | // record.setRemark("止盈平仓"); |
| | | // record.setMemberBalance(wallet.getAvailableBalance()); |
| | | // record.setMemberid(order.getMemberId()); |
| | | // record.setSymbolName(order.getSymbol()); |
| | | // record.setMemberName(wallet.getMemberName()); |
| | | // record.setMemberPhone(order.getMemberPhone()); |
| | | // record.setPrice(profitLossPrice + order.getPrePrice()); |
| | | // memberService.addFlowRecord(record); |
| | | // |
| | | // //返佣 TODO 531 |
| | | // calYj(order.getMemberId(), new BigDecimal(order.getClosingPrice()), order, 2); |
| | | |
| | | insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓"); |
| | | |
| | | //返佣 |
| | | calYj(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, 2); |
| | | } |
| | | } |
| | | } |
| | |
| | | BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount()); |
| | | memberWalletContractService.increaseWalletContractBalanceById(totalBalance,totalReturn,null,wallet.getId()); |
| | | |
| | | // 流水记录 TODO 531 |
| | | // MemberAccountFlowRecord record = new MemberAccountFlowRecord(); |
| | | // record.setCreateTime(new Date()); |
| | | // record.setDirectionSource("开多止损平仓"); |
| | | // record.setRemark("开多止损平仓"); |
| | | // record.setMemberBalance(wallet.getAvailableBalance()); |
| | | // record.setMemberid(order.getMemberId()); |
| | | // record.setSymbolName(order.getSymbol()); |
| | | // record.setMemberName(wallet.getMemberName()); |
| | | // record.setMemberPhone(order.getMemberPhone()); |
| | | // record.setPrice(profitLossPrice + order.getPrePrice()); |
| | | // memberService.addFlowRecord(record); |
| | | // |
| | | // //返佣 TODO |
| | | // calYj(order.getMemberId(), new BigDecimal(order.getClosingPrice()), order, 2); |
| | | insertAccountFlow(order, wallet, profitLossPrice, "开多止损平仓"); |
| | | |
| | | //返佣 |
| | | calYj(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, 2); |
| | | } |
| | | } |
| | | } |
| | |
| | | BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount()); |
| | | memberWalletContractService.increaseWalletContractBalanceById(totalBalance,totalReturn,null,wallet.getId()); |
| | | |
| | | // 流水记录 TODO 531 |
| | | // MemberAccountFlowRecord record = new MemberAccountFlowRecord(); |
| | | // record.setCreateTime(new Date()); |
| | | // record.setDirectionSource("开空止损平仓"); |
| | | // record.setRemark("开空止损平仓"); |
| | | // record.setMemberBalance(wallet.getAvailableBalance()); |
| | | // record.setMemberid(order.getMemberId()); |
| | | // record.setSymbolName(order.getSymbol()); |
| | | // record.setMemberName(wallet.getMemberName()); |
| | | // record.setMemberPhone(order.getMemberPhone()); |
| | | // record.setPrice(profitLossPrice + order.getPrePrice()); |
| | | // memberService.addFlowRecord(record); |
| | | // |
| | | // //返佣 TODO |
| | | // calYj(order.getMemberId(), new BigDecimal(order.getClosingPrice()), order, 2); |
| | | // |
| | | insertAccountFlow(order, wallet, profitLossPrice, "开空止损平仓"); |
| | | |
| | | //返佣 |
| | | calYj(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, 2); |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void insertAccountFlow(ContractHoldOrderEntity order, MemberWalletContractEntity wallet, BigDecimal profitLossPrice, String source) { |
| | | MemberAccountFlowEntity record = new MemberAccountFlowEntity(); |
| | | record.setCreateTime(new Date()); |
| | | record.setSource(source); |
| | | record.setRemark(source); |
| | | record.setBalance(wallet.getAvailableBalance()); |
| | | record.setMemberId(order.getMemberId()); |
| | | record.setSymbol(order.getSymbol()); |
| | | record.setPrice(profitLossPrice.add(order.getPrePaymentAmount())); |
| | | memberAccountFlowEntityDao.insert(record); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | memberWalletContractService.increaseWalletContractBalanceById(null,totalBalance,null,wallet.getId()); |
| | | // TODO 531 待写 |
| | | //calYj(memId, new BigDecimal(coinsCoinsOrder.getClosingPrice()), coinsCoinsOrder, 1); |
| | | calYj(memId, contractOrderEntity.getClosingFeeAmount(), contractOrderEntity, 1); |
| | | } |
| | | } |
| | | } |
| | |
| | | BigDecimal totalPrice = coinsOrder.getPrePaymentAmount().negate(); |
| | | //Double totalPrice = - coinsOrder.getPrePrice(); |
| | | memberWalletContractService.increaseWalletContractBalanceById(null,totalPrice,null,usdt.getId()); |
| | | |
| | | // 流水记录 TODO |
| | | // MemberAccountFlowRecord record = new MemberAccountFlowRecord(); |
| | | // record.setCreateTime(new Date()); |
| | | // record.setDirectionSource("系统自动平仓"); |
| | | // record.setRemark("系统自动平仓"); |
| | | // record.setMemberBalance(coinsOrder.getPrePrice()); |
| | | // record.setMemberid(memId); |
| | | // record.setSymbolName(null); |
| | | // record.setMemberName(null); |
| | | // record.setMemberPhone(null); |
| | | // record.setPrice(coinsOrder.getPrePrice()); |
| | | // memberService.addFlowRecord(record); |
| | | MemberAccountFlowEntity record = new MemberAccountFlowEntity(); |
| | | record.setCreateTime(new Date()); |
| | | record.setSource("系统自动平仓"); |
| | | record.setRemark("系统自动平仓"); |
| | | record.setBalance(usdt.getAvailableBalance()); |
| | | record.setMemberId(memId); |
| | | record.setSymbol(coinsOrder.getSymbol()); |
| | | record.setPrice(coinsOrder.getPrePaymentAmount()); |
| | | memberAccountFlowEntityDao.insert(record); |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | agent.setOrderId(order.getId()); |
| | | agent.setOrderNo(order.getOrderNo()); |
| | | agent.setRefererId(agentMember.getId()); |
| | | agent.setOrderType(order.getClosingType()); |
| | | agent.setOrderType(order.getOrderType()); |
| | | agent.setReturnSymbol(order.getSymbol()); |
| | | agent.setIsReturn(0); |
| | | agent.setReturnAmount(entry.getValue()); |
| | | agent.setClosingType(order.getClosingType()); |
| | | if (type == 1) {//开仓 |
| | | agent.setOpeningFeeAmount(order.getOpeningFeeAmount()); |
| | | } else if (type == 2) {//平仓 |
| | |
| | | agent.setHoldingFeeAmount(order.getHoldAmount()); |
| | | } |
| | | agent.setInviteId(entry.getKey()); |
| | | //agentReturnMapper.insert(agent); |
| | | agentReturnDao.insert(agent); |
| | | } |
| | | |
| | | |