11 files modified
2 files added
| | |
| | | // 交易订单处理 |
| | | public static final String ROUTINGKEY_HANDLE_TRADE = "ROUTINGKEY_HANDLE_TRADE"; |
| | | |
| | | public static final String EXCHANGE_ROC = "roc-transfer"; |
| | | |
| | | public static final String QUEUE_ROC= "roc-queue"; |
| | | |
| | | public static final String ROUTING_KEY_ROC = "roc-transfer-routingKey"; |
| | | |
| | | |
| | | @Resource |
| | | private ConnectionFactory connectionFactory; |
| | | |
| | |
| | | return BindingBuilder.bind(queueHandleTrade()).to(matchTradeExchange()).with(RabbitMqConfig.ROUTINGKEY_HANDLE_TRADE); |
| | | } |
| | | |
| | | @Bean |
| | | public DirectExchange rocExchange() { |
| | | return new DirectExchange(EXCHANGE_ROC); |
| | | } |
| | | |
| | | |
| | | @Bean |
| | | public Queue rocQueue() { |
| | | return new Queue(QUEUE_ROC, true); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding bindingRoc() { |
| | | return BindingBuilder.bind(rocQueue()).to(rocExchange()).with(ROUTING_KEY_ROC); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.xcong.excoin.modules.blackchain.model; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @description 钱包表 |
| | | * @author admin |
| | | * @date 2020-09-17 14:31 |
| | | */ |
| | | |
| | | @Data |
| | | public class RocTransferDetail { |
| | | |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | |
| | | |
| | | /** |
| | | * 主地址 |
| | | */ |
| | | private String address; |
| | | |
| | | |
| | | /** |
| | | * 币种 |
| | | */ |
| | | private String symbol; |
| | | |
| | | |
| | | /** |
| | | * 余额 |
| | | */ |
| | | private BigDecimal balance; |
| | | |
| | | |
| | | } |
| | |
| | | package com.xcong.excoin.modules.coin.service; |
| | | |
| | | import com.xcong.excoin.modules.blackchain.model.RocTransferDetail; |
| | | |
| | | public interface BlockCoinService { |
| | | |
| | | public void updateEthUsdt(); |
| | |
| | | |
| | | public void updateTrc20(); |
| | | |
| | | public void updateRoc(); |
| | | public void updateRoc(RocTransferDetail transferDetail); |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void updateRoc() { |
| | | public void updateRoc(RocTransferDetail transferDetail) { |
| | | // 更新ROC |
| | | // 增加用户余额 |
| | | String address = transferDetail.getAddress(); |
| | | BigDecimal balance = transferDetail.getBalance(); |
| | | String symbol = transferDetail.getSymbol(); |
| | | if(org.apache.commons.lang.StringUtils.isBlank(address) || org.apache.commons.lang.StringUtils.isBlank(symbol) || balance ==null ){ |
| | | return; |
| | | } |
| | | |
| | | if(balance.compareTo(new BigDecimal("0.0001"))<=0){ |
| | | return; |
| | | } |
| | | |
| | | MemberCoinAddressEntity memberCoinAddress = memberCoinAddressDao.selectCoinAddressByAddressAndSymbol(address, symbol); |
| | | if(memberCoinAddress==null){ |
| | | return; |
| | | } |
| | | Long memberId = memberCoinAddress.getMemberId(); |
| | | // 查询钱包 并更新 |
| | | MemberWalletCoinEntity walletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.ROC.name()); |
| | | if (walletCoinEntity == null) { |
| | | // 创建一个钱包 |
| | | // 创建这个钱包 |
| | | walletCoinEntity = new MemberWalletCoinEntity(); |
| | | walletCoinEntity.setAvailableBalance(BigDecimal.ZERO); |
| | | walletCoinEntity.setFrozenBalance(BigDecimal.ZERO); |
| | | walletCoinEntity.setTotalBalance(BigDecimal.ZERO); |
| | | walletCoinEntity.setBorrowedFund(BigDecimal.ZERO); |
| | | walletCoinEntity.setMemberId(memberId); |
| | | walletCoinEntity.setWalletCode(symbol); |
| | | memberWalletCoinDao.insert(walletCoinEntity); |
| | | } |
| | | |
| | | memberWalletCoinDao.updateBlockBalance(walletCoinEntity.getId(), balance, BigDecimal.ZERO, 0); |
| | | |
| | | String orderNo = insertCoinCharge(address, memberId, balance, CoinTypeEnum.ROC.name(), "", BigDecimal.ZERO,null); |
| | | // 插入财务记录 |
| | | LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", balance, CoinTypeEnum.ROC.name(), 1, 1); |
| | | |
| | | try{ |
| | | ThreadPoolUtils.sendDingTalk(5); |
| | | MemberEntity member = memberDao.selectById(memberId); |
| | | if (StrUtil.isNotBlank(member.getPhone())) { |
| | | String amount = balance.toPlainString() + "ROC"; |
| | | Sms106Send.sendRechargeMsg(member.getPhone(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), orderNo); |
| | | } else { |
| | | SubMailSend.sendRechargeMail(member.getEmail(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), orderNo); |
| | | } |
| | | }catch (Exception e){ |
| | | //e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | |
|
| | | MemberCoinAddressEntity selectBlockAddress(@Param("memberId") Long memberId, @Param("symbol") String symbol);
|
| | |
|
| | | MemberCoinAddressEntity selectCoinAddressByAddressAndSymbol(@Param("address") String address, @Param("symbol") String symbol);
|
| | |
|
| | | List<MemberCoinAddressEntity> selectCoinAddressListByMap(@Param("symbol") String symbol, @Param("memberId") Long memberId);
|
| | |
|
| | | List<MemberCoinAddressEntity> selectAllBlockAddressBySymbolAndTag(@Param("symbol") String symbol, @Param("tag") String tag);
|
| | |
| | | import com.xcong.excoin.utils.ThreadPoolUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | // } |
| | | if (!AppContants.SYSTEM_REFERER.equals(registerDto.getRefererId())) { |
| | | MemberEntity isExist = memberDao.selectMemberInfoByInviteId(registerDto.getRefererId()); |
| | | if (isExist == null) { |
| | | return Result.fail("推荐人不存在"); |
| | | } |
| | | } |
| | | |
| | | if (isExist != null) { |
| | | member.setRefererId(registerDto.getRefererId()); |
| | | } |
| | | } |
| | | member.setAccountStatus(MemberEntity.ACCOUNT_STATUS_ENABLE); |
| | | member.setAccountType(MemberEntity.ACCOUNT_TYPE_NORMAL); |
| | | member.setAgentLevel(MemberEntity.ACCOUNT_AGENT_LEVEL); |
| | |
| | | boolean flag = false; |
| | | String parentId = member.getRefererId(); |
| | | String ids = ""; |
| | | while (!flag) { |
| | | while (!flag && StringUtils.isNotBlank(parentId)) { |
| | | ids += ("," + parentId); |
| | | MemberEntity parentMember = memberDao.selectMemberInfoByInviteId(parentId); |
| | | if (parentMember == null) { |
New file |
| | |
| | | package com.xcong.excoin.rabbit.consumer; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.xcong.excoin.configurations.RabbitMqConfig; |
| | | import com.xcong.excoin.modules.blackchain.model.RocTransferDetail; |
| | | import com.xcong.excoin.modules.coin.service.BlockCoinService; |
| | | import com.xcong.excoin.modules.member.dao.MemberCoinAddressDao; |
| | | import com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity; |
| | | import com.xcong.excoin.rabbit.pricequeue.OrderModel; |
| | | import com.xcong.excoin.rabbit.pricequeue.OrderOperatePriceService; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * 用户修改止损止盈价格、提价限价委托、下单爆仓价等消息 |
| | | * 后台打包开启 APP 不开启 |
| | | * @author helius |
| | | */ |
| | | @Component |
| | | //@ConditionalOnProperty(prefix = "app", name = "newest-price-update-job-contract", havingValue = "true") |
| | | public class RocBlockUpdateConsumer { |
| | | |
| | | @Resource |
| | | private BlockCoinService blockCoinService; |
| | | /** |
| | | * ROC币种同步 |
| | | * |
| | | * @param message 消息体 |
| | | * @param channel 信道 |
| | | * @date 2019年4月19日 |
| | | */ |
| | | @RabbitListener(queues = RabbitMqConfig.QUEUE_ROC) |
| | | public void onMessageMorePro(Message message, Channel channel) { |
| | | String content = new String(message.getBody()); |
| | | // 操作前的map |
| | | // 转为model |
| | | RocTransferDetail transferDetail = JSONObject.parseObject(content, RocTransferDetail.class); |
| | | blockCoinService.updateRoc(transferDetail); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | while (iterator.hasNext()) { |
| | | OrderCoinsEntity matchOrder = iterator.next(); |
| | | ExchangeTrade trade = processMatch(focusedOrder, matchOrder); |
| | | logger.info(">>>>>" + trade); |
| | | if (trade != null) { |
| | | exchangeTrades.add(trade); |
| | | } |
| | |
| | | availAmount = calculateTradedAmount(matchOrder, dealPrice); |
| | | //计算成交量 取少的 |
| | | BigDecimal tradedAmount = (availAmount.compareTo(needAmount) >= 0 ? needAmount : availAmount); |
| | | System.out.println("成交量:"+tradedAmount); |
| | | //logger.info("dealPrice={},amount={}", dealPrice, tradedAmount); |
| | | //如果成交额为0说明剩余额度无法成交,退出 |
| | | if (tradedAmount.compareTo(BigDecimal.ZERO) == 0) { |
| | |
| | | |
| | | request.setActionCard(actionCard); |
| | | OapiRobotSendResponse response = client.execute(request); |
| | | log.info(JSONObject.toJSONString(response)); |
| | | //log.info(JSONObject.toJSONString(response)); |
| | | } catch (Exception e) { |
| | | log.error("#dingtalk send error#", e); |
| | | } finally { |
| | |
| | | |
| | | private static final String URL = "http://www.qf106.com/sms.aspx"; |
| | | private static final String ID = "16606"; |
| | | private static final String ACCOUNT = "Biue"; |
| | | private static final String ACCOUNT = "golden"; |
| | | private static final String PASSWORD = "123456"; |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | public static boolean sendRechargeMsg(String phone, String time, String orderNo) { |
| | | String msg = "尊敬的用户,您的帐号于{}有一笔成功充值订单,如有疑问请联系客服,订单编号为{}"; |
| | | String msg = "尊敬的用户,您的帐号于{}有一笔成功充值订单,订单编号{}"; |
| | | String content = StrUtil.format(msg, time, orderNo); |
| | | return request(phone, content, "充值"); |
| | | } |
| | | |
| | | public static boolean sendWithdrawalMsg(String phone, String time, String orderNo) { |
| | | String msg = "尊敬的用户,您的帐号于{}有一笔成功提现订单,如有疑问请联系客服,订单编号为{}"; |
| | | String msg = "尊敬的用户,您的帐号于{}有一笔成功提现订单,订单编号为{}"; |
| | | String content = StrUtil.format(msg, time, orderNo); |
| | | return request(phone, content, "提现"); |
| | | } |
| | |
| | | param.put("telephonenumber", 0); |
| | | |
| | | String response = HttpUtil.post(URL, param); |
| | | log.info("短信发送:{}, {}", tagName, response); |
| | | //log.info("短信发送:{}, {}", tagName, response); |
| | | if ("Success".equals(XmlUtil.xmlToMap(response).get("returnstatus"))) { |
| | | return true; |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(sendVerifyCode("15773002834", "123456", 2)); |
| | | } |
| | | } |
| | |
| | | |
| | | private static final String APP_ID = "16082"; |
| | | private static final String APP_KEY = "f34c792a1112c16c190ed7190d386c4f"; |
| | | private static final String FROM = "biue@submail.biue.me"; |
| | | private static final String FROM = "goldenFlame@submail.goldflame.cc"; |
| | | private static final String SIGN_TYPE = ""; |
| | | |
| | | /** |
| | |
| | | JSONObject vars = new JSONObject(); |
| | | vars.put("code", code); |
| | | |
| | | String project = "zoKVB"; |
| | | String project = "qNv3f4"; |
| | | return request(vars, project, to); |
| | | } |
| | | |
| | |
| | | JSONObject vars = new JSONObject(); |
| | | vars.put("time", time); |
| | | vars.put("orderNo", orderNo); |
| | | String project = "x820C2"; |
| | | String project = "6dH3j"; |
| | | return request(vars, project, to); |
| | | } |
| | | |
| | | public static boolean sendWithdrawalMail(String to, String time) { |
| | | JSONObject vars = new JSONObject(); |
| | | vars.put("time", time); |
| | | String project = "e3BO91"; |
| | | String project = "Vyk0y2"; |
| | | return request(vars, project, to); |
| | | } |
| | | |
| | |
| | | public static void main(String[] args) { |
| | | // System.out.println(sendMail("546766039@qq.com", "123456")); |
| | | |
| | | System.out.println(sendRechargeMail("546766039@qq.com", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN), "123456")); |
| | | System.out.println(sendRechargeMail("512061637@qq.com", "wewewewe","123456")); |
| | | } |
| | | } |
| | |
| | | day-line: false |
| | | other-job: true |
| | | loop-job: true |
| | | rabbit-consumer: true |
| | | rabbit-consumer: false |
| | | block-job: true |
| | | |
| | | aliyun: |
| | |
| | | </if>
|
| | | </where>
|
| | | </select>
|
| | |
|
| | | <select id="selectCoinAddressByAddressAndSymbol" resultType="com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity">
|
| | | select *
|
| | | from member_coin_address
|
| | | <where>
|
| | | is_biyict = 1
|
| | | <if test="symbol != null and symbol != ''">
|
| | | and symbol = #{symbol}
|
| | | </if>
|
| | | <if test="address != null and address != ''">
|
| | | and address = #{address}
|
| | | </if>
|
| | | </where>
|
| | | </select>
|
| | |
|
| | | <select id="selectCoinAddressListByMap" resultType="com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity">
|
| | | select * from member_coin_address
|