| | |
| | | |
| | | |
| | | public static <T> ServerResponse<T> createBySuccessMsg(String msg,HttpServletRequest request) { |
| | | return new ServerResponse(ResponseCode.SUCCESS.getCode(), new GoogleTranslateUtil().translate(msg,request.getHeader(LANG))); |
| | | return new ServerResponse(ResponseCode.SUCCESS.getCode(), msg); |
| | | } |
| | | |
| | | public static <T> ServerResponse<T> createBySuccess(T data) { |
| | |
| | | |
| | | |
| | | public static <T> ServerResponse<T> createBySuccess(String data,HttpServletRequest request) { |
| | | return new ServerResponse(ResponseCode.SUCCESS.getCode(), new GoogleTranslateUtil().translate(data,request.getHeader(LANG))); |
| | | return new ServerResponse(ResponseCode.SUCCESS.getCode(), data); |
| | | } |
| | | |
| | | public static <T> ServerResponse<T> createBySuccess(String msg, T data) { |
| | |
| | | return new ServerResponse(ResponseCode.ERROR.getCode(), errormsg); |
| | | } |
| | | public static <T> ServerResponse<T> createByErrorMsg(String errormsg, HttpServletRequest request) { |
| | | return new ServerResponse(ResponseCode.ERROR.getCode(), new GoogleTranslateUtil().translate(errormsg,request.getHeader(LANG))); |
| | | return new ServerResponse(ResponseCode.ERROR.getCode(), errormsg); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | |
| | | @Controller |
| | |
| | | //注册用户 短信发送 |
| | | @RequestMapping({"sendRegSms.do"}) |
| | | @ResponseBody |
| | | public ServerResponse sendRegSms(String phoneNum) { |
| | | public ServerResponse sendRegSms(@RequestParam("phoneNum") String phoneNum, |
| | | HttpServletRequest request) { |
| | | if (StringUtils.isBlank(phoneNum)) { |
| | | return ServerResponse.createByErrorMsg("发送失败,手机号不能为空"); |
| | | return ServerResponse.createByErrorMsg("发送失败,手机号不能为空",request); |
| | | } |
| | | |
| | | smsUtil smsUtil = new smsUtil(); |
| | | log.info("smsphone"+phoneNum); |
| | | log.info("短信发送验证码手机号:"+phoneNum); |
| | | String code = smsUtil.sendSMS(phoneNum); |
| | | if (!StringUtils.isEmpty(code)) { |
| | | SiteSmsLog siteSmsLog = new SiteSmsLog(); |
| | |
| | | siteSmsLog.setSmsTemplate("字段无用"); |
| | | siteSmsLog.setAddTime(DateTimeUtil.getCurrentDate()); |
| | | iSiteSmsLogService.addData(siteSmsLog); |
| | | return ServerResponse.createBySuccessMsg("发送成功"); |
| | | return ServerResponse.createBySuccessMsg("发送成功",request); |
| | | } else { |
| | | return ServerResponse.createByErrorMsg("短信发送失败,请重试"); |
| | | return ServerResponse.createByErrorMsg("短信发送失败,请重试",request); |
| | | } |
| | | } |
| | | |
| | |
| | | //注册 |
| | | @RequestMapping(value = {"reg.do"}, method = {RequestMethod.POST}) |
| | | @ResponseBody |
| | | public ServerResponse reg(@RequestParam("agentCode") String agentCode, @RequestParam("phone") String phone, @RequestParam(value = "yzmCode", defaultValue = "") String yzmCode, @RequestParam("userPwd") String userPwd, HttpServletRequest httpServletRequest) { |
| | | public ServerResponse reg(@RequestParam("agentCode") String agentCode, |
| | | @RequestParam("phone") String phone, |
| | | @RequestParam(value = "yzmCode", defaultValue = "") String yzmCode, |
| | | @RequestParam("userPwd") String userPwd, |
| | | HttpServletRequest httpServletRequest) { |
| | | return this.iUserService.reg(yzmCode, agentCode, phone, userPwd, httpServletRequest); |
| | | } |
| | | |
| | |
| | | |
| | | StockDz stockDz = this.stockDzMapper.selectOne(new QueryWrapper<StockDz>().eq("id", userPositionCheckDz.getDzId())); |
| | | |
| | | UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId("IN", user.getId()); |
| | | UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId(EStockType.ST.getCode(), user.getId()); |
| | | if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){ |
| | | return ServerResponse.createByErrorMsg("用户账户有待补资金未补齐,审核失败"); |
| | | } |
| | |
| | | userPosition.setId(null); |
| | | userPosition.setDzId(stockDz.getId()); |
| | | userPositionMapper.insert(userPosition); |
| | | userAssetsServices.availablebalanceChange(EStockType.IN.getCode(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"",""); |
| | | userAssetsServices.availablebalanceChange(EStockType.ST.getCode(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"",""); |
| | | return ServerResponse.createBySuccessMsg("审核成功,订单已转客户持仓"); |
| | | } |
| | | } |
| | |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.EChoMapper; |
| | | import com.nq.dao.UserAssetsMapper; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.pojo.EChoBean; |
| | | import com.nq.pojo.User; |
| | | import com.nq.pojo.UserAssets; |
| | |
| | | } |
| | | } |
| | | User user = this.iUserService.getCurrentRefreshUser(request); |
| | | UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId("IN", user.getId()); |
| | | UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId(EStockType.ST.getCode(), user.getId()); |
| | | if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){ |
| | | return ServerResponse.createByErrorMsg("请先缴清待补资金", request); |
| | | } |
| | |
| | | @RequestParam("payAmt") String payAmt, |
| | | @RequestParam("img") String currency, |
| | | HttpServletRequest request) { |
| | | log.info("发起 fly 线上支付 payType = {} payAmt = {} currency = {}", new Object[]{payType, payAmt, currency}); |
| | | return this.iPayService.flyPay(payType, payAmt, currency, request); |
| | | } |
| | | |
| | |
| | | package com.nq.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.nq.pojo.AgentUser; |
| | | import com.nq.pojo.SiteNews; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | |
| | | */ |
| | | @Mapper |
| | | @Repository |
| | | public interface SiteNewsMapper { |
| | | public interface SiteNewsMapper extends BaseMapper<SiteNews> { |
| | | |
| | | /** |
| | | * [新增] |
| | | * @author lr |
| | | * @date 2020/08/05 |
| | | **/ |
| | | int insert(SiteNews siteNews); |
| | | |
| | | /** |
| | | * [刪除] |
| | | * @author lr |
| | | * @date 2020/08/05 |
| | | **/ |
| | | int delete(int id); |
| | | |
| | | /** |
| | | * [更新] |
| | | * @author lr |
| | | * @date 2020/08/05 |
| | | **/ |
| | | int update(SiteNews siteNews); |
| | | |
| | | /** |
| | | * [查询] 根据主键 id 查询 |
| | |
| | | public static EStockType getEStockTypeByCode(String code){ |
| | | if(EStockType.US.getCode().equals(code)){ |
| | | return US; |
| | | |
| | | }else if(EStockType.HK.getCode().equals(code)){ |
| | | return HK; |
| | | }else if(EStockType.MAS.getCode().equals(code)){ |
| | | return MAS; |
| | | }else if(EStockType.IN.getCode().equals(code)){ |
| | | return IN; |
| | | }else if(EStockType.ST.getCode().equals(code)){ |
| | | return ST; |
| | | }else{ |
| | | return MAS; |
| | | } |
| | |
| | | package com.nq.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | |
| | | import java.util.Date; |
| | | |
| | | |
| | | public class SiteLoginLog { |
| | | @TableId(type = IdType.AUTO,value = "id") |
| | | private Integer id; |
| | | private Integer userId; |
| | | private String userName; |
| | |
| | | package com.nq.pojo; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | |
| | | import javax.xml.soap.Text; |
| | |
| | | /** |
| | | * 新闻主键id |
| | | */ |
| | | @TableId(type = IdType.AUTO,value = "id") |
| | | private Integer id; |
| | | |
| | | /** |
| | |
| | | * 新闻内容 |
| | | */ |
| | | private String content; |
| | | |
| | | public SiteNews() { |
| | | } |
| | | |
| | | } |
| | |
| | | ServerResponse deleteWithdraw(Integer withdrawId); |
| | | |
| | | List<UserWithdraw> exportByAdmin( Integer agentId, Integer userId, String realName, Integer state, String beginTime, String endTime, HttpServletRequest request); |
| | | |
| | | } |
| | |
| | | |
| | | UserAssets userAssets = userAssetsMapper.selectOne(new LambdaQueryWrapper<UserAssets>() |
| | | .eq(UserAssets::getUserId, orderEchoBean.getUserId()) |
| | | .eq(UserAssets::getAccectType, "IN") |
| | | .eq(UserAssets::getAccectType, EStockType.ST.getCode()) |
| | | ); |
| | | userAssets.setAvailableBalance(userAssets.getAvailableBalance().subtract(money)); |
| | | userAssets.setFreezeMoney(userAssets.getFreezeMoney().add(money)); |
| | |
| | | BigDecimal aml = incomeAmount.add(money); |
| | | UserAssets userAssets = userAssetsMapper.selectOne(new LambdaQueryWrapper<UserAssets>() |
| | | .eq(UserAssets::getUserId, orderEchoBean.getUserId()) |
| | | .eq(UserAssets::getAccectType, "IN") |
| | | .eq(UserAssets::getAccectType, EStockType.ST.getCode()) |
| | | ); |
| | | if (userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0) { |
| | | continue; |
| | |
| | | userRecharge.setAgentId(user.getAgentId()); |
| | | String ordersn = KeyUtils.getRechargeOrderSn(); |
| | | userRecharge.setOrderSn(ordersn); |
| | | userRecharge.setPayChannel("1"); |
| | | userRecharge.setPayChannel(sitePay.getChannelName()); |
| | | userRecharge.setPayAmt(new BigDecimal(payAmt)); |
| | | userRecharge.setOrderStatus(Integer.valueOf(0)); |
| | |
| | | |
| | | @Override |
| | | public int update(SiteNews model) { |
| | | int ret = siteNewsMapper.update(model); |
| | | int ret = siteNewsMapper.updateById(model); |
| | | return ret>0 ? ret: 0; |
| | | } |
| | | |
| | |
| | | public ServerResponse save(SiteNews model) { |
| | | int ret = 0; |
| | | if(model!=null && model.getId()>0){ |
| | | ret = siteNewsMapper.update(model); |
| | | ret = siteNewsMapper.updateById(model); |
| | | } else{ |
| | | ret = siteNewsMapper.insert(model); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void grabNews() { |
| | | addNews(1, PropertiesUtil.getProperty("JS_IN_HTTP_URL") + "stock-markets?key=" + PropertiesUtil.getProperty("JS_IN_KEY") + "&type=6"); |
| | | String apiUrl = PropertiesUtil.getProperty("ST_HTTP_API"); |
| | | String apiKey = PropertiesUtil.getProperty("ST_KEY"); |
| | | |
| | | // 定义需要抓取的类型 |
| | | int[] types = {1, 2, 3}; |
| | | |
| | | // 批量抓取新闻 |
| | | for (int type : types) { |
| | | String url = apiUrl + "stock-markets?key=" + apiKey + "&type=" + type; |
| | | addNews(type, url); |
| | | } |
| | | } |
| | | |
| | | private void addNews(Integer type, String url) { |
| | | try { |
| | | String newlist = HttpRequest.doGrabGet(url); |
| | | |
| | | JSONArray jsonArray = JSONArray.fromObject(newlist); |
| | | |
| | | if (jsonArray.size() > 0) { |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | String newsId = jsonObject.getString("id"); |
| | | |
| | | // 检查是否已经存在新闻 |
| | | if (siteNewsMapper.getNewsBySourceIdCount(newsId) == 0) { |
| | | SiteNews siteNews = new SiteNews(); |
| | | siteNews.setSourceId(newsId); |
| | | siteNews.setSourceName(""); |
| | | siteNews.setTitle(jsonObject.getString("title")); |
| | | |
| | | Long showTime = jsonObject.getLong("time"); |
| | | siteNews.setShowTime(new Date(showTime * 1000)); |
| | | if(jsonObject.has("img")){ |
| | | convertBase64ToImage(jsonObject.getString("img"),PropertiesUtil.getProperty("ftp.address")+newsId+".jpg"); |
| | | siteNews.setImgurl(PropertiesUtil.getProperty("ftp.server.http.prefix")+newsId+".jpg"); |
| | | |
| | | if (jsonObject.has("img")) { |
| | | String imageUrl = jsonObject.getString("img"); |
| | | String imagePath = PropertiesUtil.getProperty("ftp.address") + newsId + ".jpg"; |
| | | convertBase64ToImage(imageUrl, imagePath); |
| | | siteNews.setImgurl(PropertiesUtil.getProperty("ftp.server.http.prefix") + newsId + ".jpg"); |
| | | } |
| | | |
| | | siteNews.setDescription(jsonObject.getString("content")); |
| | | siteNews.setContent(jsonObject.getString("content")); |
| | | siteNews.setStatus(1); |
| | | siteNews.setType(type); |
| | | siteNews.setType(type == 3 ? 4 : type); // type == 3 时设为 4 |
| | | |
| | | siteNewsMapper.insert(siteNews); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("添加新闻出现异常: " + e.getMessage()); |
| | | log.error("添加新闻时出错,URL: {}, 类型: {}, 错误信息: {}", url, type, e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | |
| | | List<Stock> stockList = new ArrayList<>(); |
| | | if (stockType.equals("99")) { |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | stockList.addAll(stockMapper.findZtStockListByKeyWords(keyWords, stockPlate, "IN", Integer.valueOf(0))); |
| | | stockList.addAll(stockMapper.findZtStockListByKeyWords(keyWords, stockPlate, EStockType.ST.getCode(), Integer.valueOf(0))); |
| | | } else if (stockType.equals("100")) { |
| | | User user = iUserService.getCurrentRefreshUser(request); |
| | | if (user == null) { |
| | |
| | | Gson gson = new Gson(); |
| | | List<kData> dataList = gson.fromJson(object.toString(), new TypeToken<List<kData>>(){}.getType()); |
| | | |
| | | Stock stock = stockMapper.selectOne(new LambdaQueryWrapper<Stock>().eq(Stock::getStockCode, pid).eq(Stock::getStockType, "IN")); |
| | | Stock stock = stockMapper.selectOne(new LambdaQueryWrapper<Stock>().eq(Stock::getStockCode, pid).eq(Stock::getStockType, EStockType.ST.getCode())); |
| | | BigDecimal nowPrice = iPriceServices.getNowPrice(stock.getStockCode()); |
| | | Map singleStock = getSingleStock(stock.getStockCode()); |
| | | StockVO stockVO = (StockVO)singleStock.get("stock"); |
| | |
| | | import com.nq.dao.StockSettingMapper; |
| | | import com.nq.dao.StockTimeSettingMapper; |
| | | import com.nq.dao.TradingHourMapper; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.pojo.Stock; |
| | | import com.nq.pojo.StockSetting; |
| | | import com.nq.pojo.StockTimeSetting; |
| | |
| | | @Override |
| | | public Boolean timeCheck(String stockCode) { |
| | | StockSetting stockSetting = stockSettingMapper.selectOne(new QueryWrapper<StockSetting>().eq("stock_code",stockCode)); |
| | | StockTimeSetting stockTimeSetting = stockTimeSettingMapper.selectOne(new QueryWrapper<StockTimeSetting>().eq("accets_type","IN")); |
| | | StockTimeSetting stockTimeSetting = stockTimeSettingMapper.selectOne(new QueryWrapper<StockTimeSetting>().eq("accets_type", EStockType.ST.getCode())); |
| | | if(stockSetting!= null){ |
| | | // 说明进入盘前交易或者盘后交易时间 |
| | | Date newDate = new Date(); |
| | |
| | | userRecharge.setPayAmt(new BigDecimal(amt.intValue())); |
| | | userRecharge.setAddTime(new Date()); |
| | | userRecharge.setPayTime(new Date()); |
| | | userRecharge.setOrderStatus(Integer.valueOf(1)); |
| | | userRecharge.setOrderStatus(Integer.valueOf(0)); |
| | | userRecharge.setPayId(1); |
| | | userRechargeMapper.insert(userRecharge); |
| | | } |
| | |
| | | userAssets.setAmountToBeCovered(BigDecimal.ZERO); |
| | | userAssets.setHandlingChargeWritten(BigDecimal.ZERO); |
| | | }else{ |
| | | BigDecimal amountToBeCovered = userAssets.getAmountToBeCovered().subtract(amount); |
| | | userAssets.setFreezeMoney(userAssets.getFreezeMoney().add(amount)); |
| | | userAssets.setAmountToBeCovered(amountToBeCovered); |
| | | userAssets.setHandlingChargeWritten(BigDecimal.ZERO); |
| | | userAssets.setAmountToBeCovered(availableBalance.negate()); |
| | | } |
| | | }else{ |
| | | userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(amount)); |
| | |
| | | |
| | | UserAssets userAssets = userAssetsMapper.selectOne(new LambdaQueryWrapper<UserAssets>() |
| | | .eq(UserAssets::getUserId, userPosition.getUserId()) |
| | | .eq(UserAssets::getAccectType, "IN") |
| | | .eq(UserAssets::getAccectType, EStockType.ST.getCode()) |
| | | ); |
| | | if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){ |
| | | return ServerResponse.createByErrorMsg("请先缴清待补资金", request); |
| | |
| | | // StringBuffer gid = new StringBuffer(); |
| | | // gid.append(stockSubscribe.getStockType()!=null?stockSubscribe.getStockType():""); |
| | | // gid.append(userStockSubscribe.getNewCode()!=null?userStockSubscribe.getNewCode():"stock code invaild"); |
| | | userPosition.setStockGid("IN"); |
| | | userPosition.setStockGid(EStockType.ST.getCode()); |
| | | userPosition.setBuyOrderId(GeneratePosition.getPositionId()); |
| | | userPosition.setBuyOrderTime(new Date()); |
| | | userPosition.setBuyOrderPrice(userStockSubscribe.getBuyPrice()); |
| | |
| | | userPosition.setNewId(stockSubscribe.getNewlistId()); |
| | | int ret = 0; |
| | | ret = this.userPositionMapper.insert(userPosition); |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId("IN", userPosition.getUserId()); |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId(EStockType.ST.getCode(), userPosition.getUserId()); |
| | | if(null == userAssets){ |
| | | return ServerResponse.createByErrorMsg("新股转持仓失败"); |
| | | } |
| | | userAssetsMapper.updateById(userAssets); |
| | | iUserAssetsServices.availablebalanceChange("IN", userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", ""); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.ST.getCode(), userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", ""); |
| | | if (ret > 0) { |
| | | userStockSubscribe.setStatus(5); |
| | | userStockSubscribeMapper.update1(userStockSubscribe); |
| | |
| | | if (siteProduct.getRealNameDisplay() && user.getIsLock().intValue() == 1) { |
| | | return ServerResponse.createByErrorMsg("Order failed, account has been locked"); |
| | | } |
| | | UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId("IN", user.getId()); |
| | | UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId(EStockType.ST.getCode(), user.getId()); |
| | | if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){ |
| | | return ServerResponse.createByErrorMsg("请先缴清待补资金", request); |
| | | } |
| | |
| | | UserPosition userPosition = getUserPosition(dzId,num, user, stockDz, nowPrice, stock, buyAmt); |
| | | userPositionMapper.insert(userPosition); |
| | | BigDecimal buy_fee_amt = siteSettingBuyFee.multiply(buyAmt); |
| | | userAssetsServices.availablebalanceChange(EStockType.IN.getCode(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"",""); |
| | | iUserAssetsServices.availablebalanceChange("IN", userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", ""); |
| | | userAssetsServices.availablebalanceChange(EStockType.ST.getCode(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"",""); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.ST.getCode(), userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", ""); |
| | | return ServerResponse.createBySuccess("购买成功", request); |
| | | } |
| | | |
| | |
| | | for (UserPosition position : list) { |
| | | UserAssets userAssets = userAssetsMapper.selectOne(new LambdaQueryWrapper<UserAssets>() |
| | | .eq(UserAssets::getUserId, position.getUserId()) |
| | | .eq(UserAssets::getAccectType, "IN") |
| | | .eq(UserAssets::getAccectType, EStockType.ST.getCode()) |
| | | ); |
| | | if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){ |
| | | continue; |
| | |
| | | |
| | | for (int i = 0; i <userRecharges.size() ; i++) { |
| | | SitePay s = sitePayMapper.selectById(userRecharges.get(i).getPayId()); |
| | | userRecharges.get(i).setAssetsType(EStockType.IN.getSymbol1()); |
| | | userRecharges.get(i).setChannelName(EStockType.IN.getSymbol()); |
| | | userRecharges.get(i).setAssetsType(EStockType.ST.getSymbol1()); |
| | | userRecharges.get(i).setChannelName(EStockType.ST.getSymbol()); |
| | | } |
| | | |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | |
| | | userRecharge.setPayTime(new Date()); |
| | | userRecharge.setOrderStatus(Integer.valueOf(1)); |
| | | userRecharge.setPayId(1); |
| | | userAssetsServices.availablebalanceChange(EStockType.IN.getCode(), |
| | | userAssetsServices.availablebalanceChange(EStockType.ST.getCode(), |
| | | userId,EUserAssets.TOP_UP,new BigDecimal(amt),"",""); |
| | | int insertCount = this.userRechargeMapper.insert(userRecharge); |
| | | if (insertCount > 0) { |
| | |
| | | IUserService iUserService; |
| | | |
| | | |
| | | public ServerResponse reg(String yzmCode, String agentCode, String phone, String userPwd, HttpServletRequest request) { |
| | | public ServerResponse reg(String yzmCode, String agentCode, String phone, String userPwd,HttpServletRequest request) { |
| | | if (StringUtils.isBlank(agentCode) || StringUtils.isBlank(phone) || |
| | | StringUtils.isBlank(userPwd) || StringUtils.isBlank(yzmCode)) { |
| | | return ServerResponse.createByErrorMsg("注册失败。该参数不能为空",request); |
| | | } |
| | | |
| | | |
| | | String keys = "AliyunSmsCode:" + phone; |
| | | String redis_yzm = RedisShardedPoolUtils.get(keys); |
| | | String redis_yzm = RedisShardedPoolUtils.get(phone); |
| | | |
| | | log.info("redis_yzm = {},yzmCode = {}", redis_yzm, yzmCode); |
| | | if (!yzmCode.equals(redis_yzm) && !"6666".equals(yzmCode)) { |
| | | return ServerResponse.createByErrorMsg("由于验证码不正确,注册失败。过程",request); |
| | | if (!yzmCode.equals(redis_yzm)) { |
| | | return ServerResponse.createByErrorMsg("由于验证码不正确,注册失败。", request); |
| | | } |
| | | |
| | | |
| | | AgentUser agentUser = this.iAgentUserService.findByCode(agentCode); |
| | | if (agentUser == null) { |
| | |
| | | if (user.getIsLogin().intValue() == 1) { |
| | | return ServerResponse.createByErrorMsg("登录失败。账户锁定",request); |
| | | } |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.IN.getCode(),user.getId()); |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.ST.getCode(),user.getId()); |
| | | this.iSiteLoginLogService.saveLog(user, request); |
| | | return ServerResponse.createBySuccess(user); |
| | | } |
| | |
| | | userPositions = userPositionMapper. |
| | | findMyPositionByCodeAndSpell(userId, |
| | | "","", |
| | | 0, "IN"); |
| | | 0, EStockType.ST.getCode()); |
| | | |
| | | |
| | | List<UserPositionVO> userPositionVOS = Lists.newArrayList(); |
| | |
| | | ServerResponse money = iUserService.getMoney(user.getId()); |
| | | List<RUserAssets> rUserAssetsList = (List<RUserAssets>) money.getData(); |
| | | RUserAssets rUserAssets = rUserAssetsList.stream() |
| | | .filter(stock -> "IN".equals(stock.getAccectType())) |
| | | .filter(stock -> EStockType.ST.getCode().equals(stock.getAccectType())) |
| | | .findFirst() |
| | | .orElse(null); |
| | | |
| | |
| | | |
| | | int insertCount = this.userMapper.insert(user); |
| | | dbUser = userMapper.selectOne(queryWrapper); |
| | | userAssetsServices.getAvailableBalance(EStockType.IN.getCode(),dbUser.getId() ); |
| | | userAssetsServices.availablebalanceChange(EStockType.IN.getCode(),dbUser.getId(),EUserAssets.TOP_UP,new BigDecimal(amt),"",""); |
| | | userAssetsServices.getAvailableBalance(EStockType.ST.getCode(),dbUser.getId() ); |
| | | userAssetsServices.availablebalanceChange(EStockType.ST.getCode(),dbUser.getId(),EUserAssets.TOP_UP,new BigDecimal(amt),"",""); |
| | | if (insertCount > 0) { |
| | | return ServerResponse.createBySuccessMsg("Success"); |
| | | } |
| | |
| | | ServerResponse money = iUserService.getMoney(user.getId()); |
| | | List<RUserAssets> rUserAssetsList = (List<RUserAssets>) money.getData(); |
| | | RUserAssets rUserAssets = rUserAssetsList.stream() |
| | | .filter(stock -> "IN".equals(stock.getAccectType())) |
| | | .filter(stock -> EStockType.ST.getCode().equals(stock.getAccectType())) |
| | | .findFirst() |
| | | .orElse(null); |
| | | |
| | |
| | | return ServerResponse.createByErrorMsg("参数错误",request); |
| | | } |
| | | User user = iUserService.getCurrentRefreshUser(request); |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId("IN",user.getId()); |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId(EStockType.ST.getCode(),user.getId()); |
| | | if (model.getNewCode() != null) { |
| | | StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new QueryWrapper<StockSubscribe>() |
| | | .eq("newlist_id", model.getNewlistId())); |
| | |
| | | // bound = new BigDecimal(model.getApplyNums()).multiply(stockSubscribe.getPrice()); |
| | | // } |
| | | // |
| | | BigDecimal useEnaAmount = iUserAssetsServices.getAvailableBalance(EStockType.IN.getCode(), user.getId()); |
| | | BigDecimal useEnaAmount = iUserAssetsServices.getAvailableBalance(EStockType.ST.getCode(), user.getId()); |
| | | if(useEnaAmount.compareTo(bound)<0){ |
| | | return ServerResponse.createByErrorMsg("余额不足,配售失败",request); |
| | | } |
| | |
| | | UserStockSubscribe userStockSubscribe = Convert.convert(UserStockSubscribe.class, model); |
| | | userStockSubscribe.setNewStockId(stockSubscribe.getNewlistId()); |
| | | ret = userStockSubscribeMapper.insert(userStockSubscribe); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.IN.getCode(), user.getId(),EUserAssets.BUY,bound.negate(),"",""); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.ST.getCode(), user.getId(),EUserAssets.BUY,bound.negate(),"",""); |
| | | if (ret > 0) { |
| | | return ServerResponse.createBySuccessMsg("配售成功",request); |
| | | } else { |
| | |
| | | } |
| | | |
| | | //客户中签直接扣除客户账户可用资金 |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId("IN", userStockSubscribe.getUserId()); |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId(EStockType.ST.getCode(), userStockSubscribe.getUserId()); |
| | | if (model.getStatus() == 3 && model.getApplyNumber() != null){ |
| | | if(stockSubscribe.getType() == 1){ |
| | | model.setBond((stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice()).multiply(BigDecimal.valueOf(model.getApplyNumber()))); |
| | |
| | | } |
| | | BigDecimal cCount = new BigDecimal(model.getApplyNums()-model.getApplyNumber()); |
| | | BigDecimal tMoney = ((stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice())).multiply(cCount); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.IN.getCode(),userStockSubscribe.getUserId(), |
| | | iUserAssetsServices.availablebalanceChange(EStockType.ST.getCode(),userStockSubscribe.getUserId(), |
| | | EUserAssets.TOP_UP,tMoney,"",""); |
| | | model.setBond((stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice()).multiply(BigDecimal.valueOf(model.getApplyNumber()))); |
| | | model.setDbMoney(BigDecimal.ZERO); |
| | |
| | | userStockSubscribe.setSubmitTime(DateTimeUtil.getCurrentDate()); |
| | | userStockSubscribe.setStatus(4); |
| | | BigDecimal bigDecimal = iUserAssetsServices. |
| | | getAvailableBalance(EStockType.IN.getCode(), |
| | | getAvailableBalance(EStockType.ST.getCode(), |
| | | userStockSubscribe.getUserId()); |
| | | |
| | | BigDecimal multiply = userStockSubscribe.getBuyPrice().multiply(new BigDecimal(userStockSubscribe.getApplyNumber())); |
| | | if(bigDecimal.compareTo(multiply) <= 0){ |
| | | return ServerResponse.createByErrorMsg("余额不足",request); |
| | | } |
| | | iUserAssetsServices.availablebalanceChange(EStockType.IN.getCode(),userStockSubscribe.getUserId(), |
| | | iUserAssetsServices.availablebalanceChange(EStockType.ST.getCode(),userStockSubscribe.getUserId(), |
| | | EUserAssets.BUY,multiply.negate(),"",""); |
| | | userStockSubscribe.setDbMoney(BigDecimal.ZERO); |
| | | userStockSubscribeMapper.update1(userStockSubscribe); |
| | |
| | | import com.google.gson.Gson; |
| | | import com.nq.dao.*; |
| | | import com.nq.enums.EConfigKey; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.enums.EUserAssets; |
| | | import com.nq.pay.PayUtil; |
| | | import com.nq.pojo.*; |
| | |
| | | @Autowired |
| | | UserAssetsMapper userAssetsMapper; |
| | | |
| | | @Autowired |
| | | UserAssetsServices userAssetsServices; |
| | | |
| | | @Resource |
| | | StockTimeSettingMapper stockTimeSettingMapper; |
| | | |
| | |
| | | } |
| | | |
| | | private boolean getServerResponse() { |
| | | StockTimeSetting stockTimeSetting = stockTimeSettingMapper.selectOne(new QueryWrapper<StockTimeSetting>().eq("accets_type","IN")); |
| | | StockTimeSetting stockTimeSetting = stockTimeSettingMapper.selectOne(new QueryWrapper<StockTimeSetting>().eq("accets_type", EStockType.ST.getCode())); |
| | | if(stockTimeSetting == null){ |
| | | return false; |
| | | } |
| | |
| | | User user = this.userMapper.selectById(userWithdraw.getUserId()); |
| | | |
| | | |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId("IN", user.getId()); |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId(EStockType.ST.getCode(), user.getId()); |
| | | if (userAssets == null) { |
| | | return ServerResponse.createByErrorMsg("用户资金账户不存在"); |
| | | } |
| | |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("用户不存在"); |
| | | } |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId("IN", user.getId()); |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId(EStockType.ST.getCode(), user.getId()); |
| | | if (userAssets == null) { |
| | | return ServerResponse.createByErrorMsg("用户资金账户不存在"); |
| | | } |
| | |
| | | public static final String RK_COMPANY_INFO = "rk_company_info"; |
| | | |
| | | |
| | | /** |
| | | * 短信code |
| | | */ |
| | | public static final String verification_code= "verification_code"; |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | package com.nq.utils.smsUtil; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.nq.controller.SmsApiController; |
| | | import com.nq.utils.PropertiesUtil; |
| | | import com.nq.utils.pay.CmcPayOuterRequestUtil; |
| | | import com.nq.utils.redis.RedisKeyConstant; |
| | | import com.nq.utils.redis.RedisShardedPoolUtils; |
| | | import org.apache.commons.lang3.RandomStringUtils; |
| | | import org.slf4j.Logger; |
| | |
| | | private static final Logger log = LoggerFactory.getLogger(SmsApiController.class); |
| | | |
| | | public String sendSMS(String telephone) { |
| | | String code = RandomStringUtils.randomNumeric(4); |
| | | CmcPayOuterRequestUtil requestUtil = new CmcPayOuterRequestUtil(); |
| | | |
| | | String sign = "【短信签名】"; |
| | | String uid = PropertiesUtil.getProperty("dxb.sms.USERNAME"); |
| | | String key = PropertiesUtil.getProperty("dxb.sms.PASSWORD"); |
| | | // String coding = PropertiesUtil.getProperty("wj.sms.coding"); |
| | | String smscontent = sign+"您正在申请手机注册,验证码为:" + code + ",5分钟内有效!"; |
| | | //设置签名 |
| | | |
| | | // 生成6位数字验证码 |
| | | String verificationCode = RandomStringUtils.randomNumeric(6); |
| | | |
| | | try { |
| | | uid = URLEncoder.encode(uid,"UTF-8"); |
| | | smscontent = URLEncoder.encode(smscontent,"UTF-8"); |
| | | } catch (UnsupportedEncodingException e){ |
| | | e.printStackTrace(); |
| | | // 将验证码存入 Redis,设置 30 秒过期时间 |
| | | String redisKey = RedisKeyConstant.verification_code + ":" + telephone; // 使用电话号码作为唯一标识符 |
| | | RedisShardedPoolUtils.setEx(redisKey, verificationCode, 30); |
| | | } catch (Exception e) { |
| | | // 捕获异常并记录日志,避免程序崩溃 |
| | | System.err.println("Error storing verification code in Redis: " + e.getMessage()); |
| | | // 你可以根据需要做进一步的异常处理,比如重新抛出异常 |
| | | } |
| | | // String url = "http://"+ cod+ing +".api.smschinese.cn/?Uid="+ uid +"&Key="+ key +"&smsMob=" + telephone + "&smsText="+sign+smscontent; |
| | | String url ="https://api.smsbao.com/sms?u="+uid+"&p="+key+"&m="+telephone+"&c="+smscontent; |
| | | log.info("smsurl"+url); |
| | | String result = requestUtil.sendGet(url); |
| | | log.info("smsresult="+result+"==code="+code); |
| | | if (Integer.valueOf(result) < 0) { |
| | | return ""; |
| | | } else { |
| | | String keys = "AliyunSmsCode:" + telephone; |
| | | RedisShardedPoolUtils.setEx(keys, code, 5400); |
| | | return code; |
| | | } |
| | | |
| | | // 返回验证码 |
| | | return verificationCode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 找回密码 |
| | | */ |
| | |
| | | stockListVO.setColor(0); |
| | | }else{ |
| | | stockListVO.setColor(1); |
| | | stockListVO.setHcrateP("+"+realTimeStock.getPcp()+"%"); |
| | | stockListVO.setHcrateP(realTimeStock.getPcp()+"%"); |
| | | } |
| | | stockListVO.setNowPrice(realTimeStock.getLast()); |
| | | stockListVO.setToday_max(realTimeStock.getHigh()); |
| | |
| | | /* |
| | | * 新聞資訊抓取 |
| | | * */ |
| | | @Scheduled(cron = "0 0/5 * * * ?") |
| | | @Scheduled(cron = "0/10 * * * * ?") |
| | | public void NewsInfoTask() { |
| | | if (NewsInfoTask.get()) { // 判断任务是否在处理中 |
| | | return; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /* |
| | | * 新聞公告抓取 |
| | | * */ |
| | | // @Scheduled(cron = "0 0/30 9-20 * * ?") |
| | | // public void ArtInfoTask() { |
| | | // this.iSiteArticleService.grabArticle(); |
| | | // } |
| | | } |
| | |
| | | import com.nq.dao.UserAssetsMapper; |
| | | import com.nq.dao.UserMapper; |
| | | import com.nq.dao.UserStockSubscribeMapper; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.pojo.StockSubscribe; |
| | | import com.nq.pojo.User; |
| | | import com.nq.pojo.UserAssets; |
| | |
| | | List<UserStockSubscribe> userStockSubscribes = userStockSubscribeMapper.selectList(new LambdaQueryWrapper<UserStockSubscribe>() |
| | | .eq(UserStockSubscribe::getStatus, 3)); |
| | | userStockSubscribes.forEach(f->{ |
| | | UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId("IN",f.getUserId()); |
| | | UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId(EStockType.ST.getCode(),f.getUserId()); |
| | | if(null != userAssets && userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) == 0){ |
| | | f.setStatus(4); |
| | | userStockSubscribeMapper.updateById(f); |
| | |
| | | if (syncINStockDataLock.tryLock()) { |
| | | try { |
| | | syncINStockData.set(true); // 设置处理中标识为true |
| | | loadAllStock(EStockType.IN); |
| | | loadAllStock(EStockType.ST); |
| | | } finally { |
| | | syncINStockDataLock.unlock(); |
| | | syncINStockData.set(false); // 设置处理中标识为false |
| | |
| | | * 同步美国股票 |
| | | */ |
| | | // @Scheduled(cron = "0 0/30 * * * ?") |
| | | public void loadStockCompanies() { |
| | | loadAllCompanies(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 加载公司信息 |
| | | */ |
| | | public void loadAllCompanies() { |
| | | List<Stock> list = stockMapper.findStockList(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | Stock stock = list.get(i); |
| | | EStockType eStockType = EStockType.getEStockTypeByCode(stock.getStockType()); |
| | | String result = HttpClientRequest.doGet(eStockType.stockUrl + "companies?pid=+" + stock.getStockCode() + "+country_id=" + eStockType.getContryId() + "&size=1&page=1&key=" + eStockType.stockKey); |
| | | try { |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | JSONObject companiesInfo = jsonObject.getJSONArray("data").getJSONObject(0); |
| | | RedisKeyUtil.setCacheCompanies(stock, new Gson().toJson(companiesInfo)); |
| | | } catch (Exception e) { |
| | | log.info(""); |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | // public void loadStockCompanies() { |
| | | // loadAllCompanies(); |
| | | // } |
| | | // |
| | | // |
| | | // /** |
| | | // * 加载公司信息 |
| | | // */ |
| | | // public void loadAllCompanies() { |
| | | // List<Stock> list = stockMapper.findStockList(); |
| | | // for (int i = 0; i < list.size(); i++) { |
| | | // Stock stock = list.get(i); |
| | | // EStockType eStockType = EStockType.getEStockTypeByCode(stock.getStockType()); |
| | | // String result = HttpClientRequest.doGet(eStockType.stockUrl + "companies?pid=+" + stock.getStockCode() + "+country_id=" + eStockType.getContryId() + "&size=1&page=1&key=" + eStockType.stockKey); |
| | | // try { |
| | | // JSONObject jsonObject = JSONObject.parseObject(result); |
| | | // JSONObject companiesInfo = jsonObject.getJSONArray("data").getJSONObject(0); |
| | | // RedisKeyUtil.setCacheCompanies(stock, new Gson().toJson(companiesInfo)); |
| | | // } catch (Exception e) { |
| | | // log.info(""); |
| | | // |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | /** |
| | | * 加载所有股票数据 |
| | |
| | | * 强制平仓 |
| | | */ |
| | | // @Scheduled(cron = "0/1 * * * * ?") |
| | | public void stockConstraint() { |
| | | if (stockConstraint.get()) { // 判断任务是否在处理中 |
| | | return; |
| | | } |
| | | if (stockConstraintLock.tryLock()) { |
| | | try { |
| | | stockConstraint.set(true); // 设置处理中标识为true |
| | | List<UserPosition> userPositions = userPositionMapper.selectList(new LambdaQueryWrapper<UserPosition>().isNull(UserPosition::getSellOrderId)); |
| | | if (CollectionUtils.isNotEmpty(userPositions)) { |
| | | userPositionService.stockConstraint(userPositions); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("强制平仓任务错误:" + e.getMessage()); |
| | | } finally { |
| | | stockConstraintLock.unlock(); |
| | | stockConstraint.set(false); // 设置处理中标识为false |
| | | } |
| | | } else { |
| | | log.info("强制平仓任务--------->上次任务还未执行完成,本次任务忽略"); |
| | | } |
| | | } |
| | | // public void stockConstraint() { |
| | | // if (stockConstraint.get()) { // 判断任务是否在处理中 |
| | | // return; |
| | | // } |
| | | // if (stockConstraintLock.tryLock()) { |
| | | // try { |
| | | // stockConstraint.set(true); // 设置处理中标识为true |
| | | // List<UserPosition> userPositions = userPositionMapper.selectList(new LambdaQueryWrapper<UserPosition>().isNull(UserPosition::getSellOrderId)); |
| | | // if (CollectionUtils.isNotEmpty(userPositions)) { |
| | | // userPositionService.stockConstraint(userPositions); |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // log.error("强制平仓任务错误:" + e.getMessage()); |
| | | // } finally { |
| | | // stockConstraintLock.unlock(); |
| | | // stockConstraint.set(false); // 设置处理中标识为false |
| | | // } |
| | | // } else { |
| | | // log.info("强制平仓任务--------->上次任务还未执行完成,本次任务忽略"); |
| | | // } |
| | | // } |
| | | } |
| | |
| | | |
| | | Map<String, WebSocketClient> retMap = new HashMap<>(2); |
| | | try { |
| | | WebsocketRunClient websocketRunClient = new WebsocketRunClient(new URI(PropertiesUtil.getProperty("ST_HTTP_API")),EStockType.IN); |
| | | WebsocketRunClient websocketRunClient = new WebsocketRunClient(new URI(PropertiesUtil.getProperty("ST_WS_URL")),EStockType.ST); |
| | | websocketRunClient.connect(); |
| | | websocketRunClient.setConnectionLostTimeout(0); |
| | | new Thread(() -> { |
| | |
| | | static { |
| | | httpPost = new HttpPost("http://127.0.0.1:8001/api/sendNotification"); // 初始化 HttpPost |
| | | } |
| | | |
| | | private Timer heartbeatTimer; |
| | | @Override |
| | | public void onOpen(ServerHandshake serverHandshake) { |
| | | send(("key:"+ eStockType.getStockKey()+":"+eStockType.getContryId()).getBytes()); |
| | | // Timer heartbeatTimer; |
| | | // // 启动心跳定时器 |
| | | // heartbeatTimer = new Timer(); |
| | | // heartbeatTimer.schedule(new TimerTask() { |
| | | // @Override |
| | | // public void run() { |
| | | // send(("key:"+ eStockType.getStockKey()+":"+eStockType.getContryId()).getBytes()); |
| | | // } |
| | | // }, 0, 3000); // 每3秒发送一次心跳消息 |
| | | // 启动心跳定时器 |
| | | heartbeatTimer = new Timer(); |
| | | heartbeatTimer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | send("heartbeat"); |
| | | } |
| | | }, 0, 3000); // 每3秒发送一次心跳消息 |
| | | } |
| | | |
| | | @Override |
| | | public void onMessage(String s) { |
| | | if(!s.equals("pong") && !s.equals("身份验证成功")){ |
| | | if(!s.equals("pong") && !s.equals("身份验证成功") && !s.equals("请先身份校验")){ |
| | | Map<String, String> stringObjectMap = jsonToMap(s); |
| | | StockRealTimeBean stockRealTimeBean = new StockRealTimeBean(); |
| | | stockRealTimeBean.setPid(stringObjectMap.get("Id").toString()); |
| | |
| | | stockRealTimeBean.setPc(stringObjectMap.get("Chg").toString()); |
| | | stockRealTimeBean.setPcp(stringObjectMap.get("ChgPct").toString()+"%"); |
| | | stockRealTimeBean.setTime(stringObjectMap.get("Time").toString()); |
| | | RedisKeyUtil.setCacheRealTimeStock(EStockType.IN,stockRealTimeBean); |
| | | RedisKeyUtil.setCacheRealTimeStock(EStockType.ST,stockRealTimeBean); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | try { |
| | | if(!stockRealTimeBean.getPcp().contains("-")){ |
| | | stockRealTimeBean.setPcp("+"+stringObjectMap.get("ChgPct").toString()+"%"); |
| | | } |
| | | String json = objectMapper.writeValueAsString(stockRealTimeBean); |
| | | sendLoca(json); |
| | | // sendLoca(json); |
| | | StockRealTimeBean stockDetailBean = new Gson().fromJson(s, StockRealTimeBean.class); |
| | | RedisKeyUtil.setCacheRealTimeStock(EStockType.ST,stockDetailBean); |
| | | } catch (JsonProcessingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void onClose(int i, String s, boolean b) { |
| | | log.info("websocket 印度股票 关闭"+1); |
| | | public void onClose(int code, String reason, boolean remote) { |
| | | System.out.println("连接关闭: " + reason); |
| | | if (heartbeatTimer != null) { |
| | | heartbeatTimer.cancel(); // 取消心跳定时器 |
| | | } |
| | | // 尝试重新连接 |
| | | try { |
| | | System.out.println("尝试重新连接..."); |
| | | Thread.sleep(10000); // 10秒后尝试重新连接 |
| | | connect(); // 重新连接 |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onError(Exception e) { |
| | | log.info("websocket 错误"); |
| | | log.info("websocket 错误"+e.getMessage()); |
| | | } |
| | | |
| | | public void sendLoca(String message) { |
| | |
| | | //@Configuration |
| | | //public class WsClientConfig { |
| | | // |
| | | // private static final String SERVER_URL = PropertiesUtil.getProperty("JS_IN_HTTP_API"); |
| | | // private static final String AUTH_KEY = PropertiesUtil.getProperty("JS_IN_KEY"); |
| | | // private static final String ROOM_ID = "14"; |
| | | // private static final String SERVER_URL = PropertiesUtil.getProperty("ST_HTTP_API"); |
| | | // private static final String AUTH_KEY = PropertiesUtil.getProperty("ST_KEY"); |
| | | // private static final String ROOM_ID = "52"; |
| | | // private static Socket socket; |
| | | // |
| | | // private static HttpClient httpClient = HttpClients.createDefault(); // 单例化 HttpClient |
| | |
| | | HK_WS_URL = ws://test-ws.js-stock.top |
| | | HK_KEY = mG8QQDdjGuLjLnrryd0B |
| | | |
| | | ST_HTTP_API = http://api-sa.js-stock.top |
| | | ST_HTTP_API = http://api-sa.js-stock.top/ |
| | | ST_WS_URL = ws://api-sa-ws.js-stock.top |
| | | ST_KEY = eiFMWvMcKgVlCYKD7S4y |
| | | |
| | |
| | | content |
| | | </sql> |
| | | |
| | | <insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.nq.pojo.SiteNews"> |
| | | INSERT INTO site_news |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test ='null != type'> |
| | | type, |
| | | </if> |
| | | <if test ='null != title'> |
| | | title, |
| | | </if> |
| | | <if test ='null != sourceId'> |
| | | source_id, |
| | | </if> |
| | | <if test ='null != sourceName'> |
| | | source_name, |
| | | </if> |
| | | <if test ='null != views'> |
| | | views, |
| | | </if> |
| | | <if test ='null != status'> |
| | | status, |
| | | </if> |
| | | <if test ='null != showTime'> |
| | | show_time, |
| | | </if> |
| | | <if test ='null != addTime'> |
| | | add_time, |
| | | </if> |
| | | <if test ='null != updateTime'> |
| | | update_time, |
| | | </if> |
| | | <if test ='null != imgurl'> |
| | | imgurl, |
| | | </if> |
| | | <if test ='null != description'> |
| | | description, |
| | | </if> |
| | | <if test ='null != content'> |
| | | content |
| | | </if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test ='null != type'> |
| | | #{type}, |
| | | </if> |
| | | <if test ='null != title'> |
| | | #{title}, |
| | | </if> |
| | | <if test ='null != sourceId'> |
| | | #{sourceId}, |
| | | </if> |
| | | <if test ='null != sourceName'> |
| | | #{sourceName}, |
| | | </if> |
| | | <if test ='null != views'> |
| | | #{views}, |
| | | </if> |
| | | <if test ='null != status'> |
| | | #{status}, |
| | | </if> |
| | | <if test ='null != showTime'> |
| | | #{showTime}, |
| | | </if> |
| | | <if test ='null != addTime'> |
| | | #{addTime}, |
| | | </if> |
| | | <if test ='null != updateTime'> |
| | | #{updateTime}, |
| | | </if> |
| | | <if test ='null != imgurl'> |
| | | #{imgurl}, |
| | | </if> |
| | | <if test ='null != description'> |
| | | #{description}, |
| | | </if> |
| | | <if test ='null != content'> |
| | | #{content} |
| | | </if> |
| | | </trim> |
| | | </insert> |
| | | |
| | | <delete id="delete" > |
| | | DELETE FROM site_news |
| | | WHERE id = #{id} |
| | | </delete> |
| | | |
| | | <update id="update" parameterType="com.nq.pojo.SiteNews"> |
| | | UPDATE site_news |
| | | <set> |
| | | <if test ='null != type'>type = #{type},</if> |
| | | <if test ='null != title'>title = #{title},</if> |
| | | <if test ='null != sourceId'>source_id = #{sourceId},</if> |
| | | <if test ='null != sourceName'>source_name = #{sourceName},</if> |
| | | <if test ='null != views'>views = #{views},</if> |
| | | <if test ='null != status'>status = #{status},</if> |
| | | <if test ='null != showTime'>show_time = #{showTime},</if> |
| | | <if test ='null != addTime'>add_time = #{addTime},</if> |
| | | <if test ='null != updateTime'>update_time = #{updateTime},</if> |
| | | <if test ='null != imgurl'>imgurl = #{imgurl},</if> |
| | | <if test ='null != description'>description = #{description},</if> |
| | | <if test ='null != content'>content = #{content}</if> |
| | | </set> |
| | | WHERE id = #{id} |
| | | </update> |
| | | |
| | | |
| | | <select id="load" resultMap="BaseResultMap"> |
| | | SELECT <include refid="Base_Column_List" /> |
| | | FROM site_news |