| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.xcong.excoin.common.contants.AppContants; |
| | | import com.xcong.excoin.common.enumerates.CoinTypeEnum; |
| | | import com.xcong.excoin.modules.contract.dao.ContractEntrustOrderDao; |
| | | import com.xcong.excoin.modules.contract.dao.ContractHoldOrderDao; |
| | | import com.xcong.excoin.modules.contract.dao.ContractOrderDao; |
| | | 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.mapper.ContractHoldOrderEntityMapper; |
| | |
| | | import com.xcong.excoin.rabbit.pricequeue.whole.WholePriceDataModel; |
| | | import com.xcong.excoin.rabbit.producer.OrderProducer; |
| | | import com.xcong.excoin.utils.dingtalk.DingTalkUtils; |
| | | import lombok.SneakyThrows; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | |
| | | */ |
| | | public static void sendWholePrice(@NotNull Long memberId) { |
| | | EXECUTOR.execute(new Runnable() { |
| | | @SneakyThrows |
| | | @Override |
| | | public void run() { |
| | | Thread.sleep(500); |
| | | log.info("全仓操作价格"); |
| | | ContractHoldOrderDao contractHoldOrderDao = SpringContextHolder.getBean(ContractHoldOrderDao.class); |
| | | MemberWalletContractDao memberWalletContractDao = SpringContextHolder.getBean(MemberWalletContractDao.class); |
| | | |
| | | List<ContractHoldOrderEntity> holdOrders = contractHoldOrderDao.selectHoldOrderListByMemberId(memberId); |
| | | if (CollUtil.isEmpty(holdOrders)) { |
| | | return; |
| | | } |
| | | MemberWalletContractEntity wallet = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, CoinTypeEnum.USDT.name()); |
| | | |
| | | WholePriceDataModel wholePriceData = new WholePriceDataModel(); |
| | | List<HoldOrderDataModel> holdOrderDataModels = ContractHoldOrderEntityMapper.INSTANCE.entitiesToDataModels(holdOrders); |
| | | wholePriceData.setList(holdOrderDataModels); |
| | | |
| | | BigDecimal totalHoldBond = BigDecimal.ZERO; |
| | | for (ContractHoldOrderEntity holdOrder : holdOrders) { |
| | | totalHoldBond = totalHoldBond.add(holdOrder.getHoldBond() == null ? BigDecimal.ZERO : holdOrder.getHoldBond()); |
| | | } |
| | | |
| | | wholePriceData.setHoldBond(totalHoldBond); |
| | | wholePriceData.setBalance(wallet.getTotalBalance()); |
| | | wholePriceData.setMemberId(memberId); |
| | | |
| | | OrderProducer orderProducer = SpringContextHolder.getBean(OrderProducer.class); |
| | | |
| | | orderProducer.sendWholePrice(JSONObject.toJSONString(wholePriceData)); |
| | | orderProducer.sendWholePrice(memberId.toString()); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | } |