| | |
| | | @Autowired |
| | | IPayChnnelServices iPayChnnelServices; |
| | | |
| | | @Autowired |
| | | IUserService iUserService; |
| | | |
| | | @Autowired |
| | | IUserAssetsServices iUserAssetsServices; |
| | | |
| | | //分页查询管理设置 所有管理列表数据及模糊查询 |
| | | @RequestMapping({"list.do"}) |
| | | @ResponseBody |
| | |
| | | } |
| | | |
| | | |
| | | @RequestMapping("getMoney.do") |
| | | @ResponseBody |
| | | public ServerResponse updateayChnnel( |
| | | @RequestParam("userId") Integer id){ |
| | | |
| | | return iUserService.getMoney(id); |
| | | } |
| | | |
| | | |
| | | @RequestMapping("updateMoney.do") |
| | | @ResponseBody |
| | | public ServerResponse updateayChnnel( |
| | | @RequestParam("id") Integer id, @RequestParam("amt") String amt){ |
| | | return iUserAssetsServices.updateUserAssets(id,amt); |
| | | } |
| | | |
| | | } |
| | |
| | | public interface SitePayMapper extends BaseMapper<SitePay> { |
| | | int deleteByPrimaryKey(Integer paramInteger); |
| | | |
| | | int insert(SitePay paramSitePay); |
| | | // int insert(SitePay paramSitePay); |
| | | |
| | | int insertSelective(SitePay paramSitePay); |
| | | |
| | |
| | | package com.nq.service; |
| | | |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.enums.EUserAssets; |
| | | import com.nq.pojo.Bank; |
| | | import com.nq.pojo.UserAssets; |
| | |
| | | |
| | | |
| | | |
| | | ServerResponse updateUserAssets(Integer id, String amt); |
| | | |
| | | |
| | | List<UserAssets> assetsByUserId(Integer userId); |
| | |
| | | ServerResponse getMoney(HttpServletRequest request); |
| | | |
| | | |
| | | ServerResponse getMoney(Integer userId); |
| | | |
| | | ServerResponse transfer(String fromType,String toType,String amt,HttpServletRequest paramHttpServletRequest); |
| | | |
| | | void ForceSellTask(); |
| | |
| | | if (sitePay.getId() == null) { |
| | | return ServerResponse.createByErrorMsg("修改id不能为空"); |
| | | } |
| | | |
| | | int updateCount = this.sitePayMapper.updateByPrimaryKeySelective(sitePay); |
| | | int updateCount = this.sitePayMapper.updateById(sitePay); |
| | | if (updateCount > 0) { |
| | | return ServerResponse.createBySuccessMsg("修改成功"); |
| | | } |
| | |
| | | package com.nq.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.UserAssetsMapper; |
| | | import com.nq.enums.EUserAssets; |
| | | import com.nq.pojo.UserAssets; |
| | |
| | | |
| | | @Override |
| | | public UserAssets assetsByTypeAndUserId(String accetType, Integer userId) { |
| | | if(accetType.equals("SZHB")){ |
| | | accetType = "US"; |
| | | } |
| | | QueryWrapper<UserAssets> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("accect_type",accetType); |
| | | queryWrapper.eq("user_id",userId); |
| | |
| | | return userAssets; |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse updateUserAssets(Integer id, String amt) { |
| | | UserAssets userAssets = userAssetsMapper.selectById(id); |
| | | |
| | | BigDecimal bigAmt = new BigDecimal(amt); |
| | | if(amt.contains("-")){ |
| | | if(userAssets.getAvailableBalance().compareTo(bigAmt.negate())<0){ |
| | | return ServerResponse.createByErrorMsg("账户余额不足"); |
| | | } |
| | | } |
| | | userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(bigAmt)); |
| | | if( userAssetsMapper.updateById(userAssets)>0){ |
| | | return ServerResponse.createBySuccess(); |
| | | }else{ |
| | | return ServerResponse.createByErrorMsg("修改金额失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public BigDecimal getAvailableBalance(String accetType, Integer userId) { |
| | | if(accetType.equals("SZHB")){ |
| | | accetType = "US"; |
| | | } |
| | | return assetsByTypeAndUserId(accetType,userId).getAvailableBalance(); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public Boolean availablebalanceChange(String accetType, Integer userId, EUserAssets eUserAssets, BigDecimal amount, String desc, String descType) { |
| | | |
| | | |
| | | if(accetType.equals("SZHB")){ |
| | | accetType = "US"; |
| | | } |
| | | UserAssets userAssets = assetsByTypeAndUserId(accetType,userId); |
| | | if(Objects.equals(eUserAssets.getCode(), EUserAssets.BUY.getCode())){ |
| | | userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(amount)); |
| | |
| | | |
| | | @Override |
| | | public ServerResponse getMoney(HttpServletRequest request) { |
| | | |
| | | BigDecimal exchangeRate = iSiteSettingService.getSiteSetting().getExchangeRate(); |
| | | List<UserAssets> userAssetsList = userAssetsServices.assetsByUserId(getCurrentUser(request).getId()); |
| | | List<RUserAssets> rUserAssetsList = new ArrayList<>(); |
| | | |
| | | /** |
| | | * 浮动盈亏 |
| | | * */ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse getMoney(Integer userId) { |
| | | BigDecimal exchangeRate = iSiteSettingService.getSiteSetting().getExchangeRate(); |
| | | List<UserAssets> userAssetsList = userAssetsServices.assetsByUserId(userId); |
| | | List<RUserAssets> rUserAssetsList = new ArrayList<>(); |
| | | /** |
| | | * 浮动盈亏 |
| | | * */ |
| | | BigDecimal AllProfitAndLose = BigDecimal.ZERO; |
| | | /** |
| | | * 总资产 |
| | | * */ |
| | | BigDecimal allTotalAssets = BigDecimal.ZERO; |
| | | /** |
| | | * 总可用余额 |
| | | * */ |
| | | BigDecimal allAmt = BigDecimal.ZERO; |
| | | /** |
| | | * 累计盈亏 |
| | | * */ |
| | | BigDecimal AllHProfitAndLose = BigDecimal.ZERO; |
| | | /** |
| | | * 总冻结资产 |
| | | * */ |
| | | BigDecimal allFreeMoney = BigDecimal.ZERO; |
| | | /** |
| | | * 总手续费 |
| | | * */ |
| | | BigDecimal allHMoney = BigDecimal.ZERO; |
| | | for (int i = 0; i <userAssetsList.size() ; i++) { |
| | | RUserAssets rUserAssets = new RUserAssets(); |
| | | UserAssets userAssets = userAssetsList.get(i); |
| | | // 浮动盈亏 |
| | | BigDecimal profitAndLose = userAssets.getProfitAndLoss(); |
| | | BigDecimal amt = userAssets.getAvailableBalance(); |
| | | BigDecimal totalAssets = userAssets.getAvailableBalance().add(userAssets.getFreezeMoney()); |
| | | BigDecimal freeMoney = userAssets.getFreezeMoney(); |
| | | BigDecimal hMoney = userAssets.getHandlingCharge(); |
| | | BigDecimal hProfitAndLose = userAssets.getCumulativeProfitAndLoss(); |
| | | rUserAssets.setId(userAssets.getId()); |
| | | rUserAssets.setTotalMoney((totalAssets.setScale(2).toString())); |
| | | rUserAssets.setAccectType(userAssets.getAccectType()); |
| | | rUserAssets.setAvailableBalance(amt.setScale(2).toString()); |
| | | rUserAssets.setFreezeMoney(freeMoney.setScale(2).toString()); |
| | | rUserAssets.setCumulativeProfitAndLoss(hProfitAndLose.setScale(2).toString()); |
| | | rUserAssets.setHandlingCharge(hMoney.setScale(2).toString()); |
| | | rUserAssets.setProfitAndLoss(profitAndLose.setScale(2).toString()); |
| | | if(userAssets.getAccectType().equals("US")){ |
| | | rUserAssets.setSymbol("$"); |
| | | rUserAssets.setSymbolCode("USD"); |
| | | AllProfitAndLose = AllProfitAndLose.add(profitAndLose); |
| | | allTotalAssets = allTotalAssets.add(totalAssets); |
| | | allAmt = allAmt.add(amt); |
| | | AllHProfitAndLose = AllHProfitAndLose.add(hProfitAndLose); |
| | | allFreeMoney = allFreeMoney.add(freeMoney); |
| | | allHMoney = allHMoney.add(hMoney); |
| | | rUserAssets.setAvailableBalanceUSD(rUserAssets.getAvailableBalance()); |
| | | rUserAssets.setFreezeMoneyUSD(rUserAssets.getFreezeMoney()); |
| | | rUserAssets.setTotalMoneyUSD(rUserAssets.getTotalMoney()); |
| | | rUserAssets.setCumulativeProfitAndLossUSD(hProfitAndLose.setScale(2).toString()); |
| | | rUserAssets.setHandlingChargeUSD(hMoney.setScale(2).toString()); |
| | | rUserAssets.setProfitAndLossUSD(hProfitAndLose.setScale(2).toString()); |
| | | |
| | | }else{ |
| | | rUserAssets.setAvailableBalanceUSD(userAssets.getAvailableBalance().divide(exchangeRate,BigDecimal.ROUND_CEILING).toString()); |
| | | rUserAssets.setFreezeMoneyUSD(userAssets.getFreezeMoney().divide(exchangeRate,BigDecimal.ROUND_CEILING).toString()); |
| | | rUserAssets.setTotalMoneyUSD(userAssets.getTotleAssets().divide(exchangeRate,BigDecimal.ROUND_CEILING).toString()); |
| | | rUserAssets.setSymbol("RM"); |
| | | rUserAssets.setSymbolCode("MYR"); |
| | | rUserAssets.setCumulativeProfitAndLossUSD(hProfitAndLose.divide(exchangeRate,BigDecimal.ROUND_CEILING).toString()); |
| | | rUserAssets.setHandlingChargeUSD(hMoney.divide(exchangeRate,BigDecimal.ROUND_CEILING).toString()); |
| | | rUserAssets.setProfitAndLossUSD(hProfitAndLose.divide(exchangeRate,BigDecimal.ROUND_CEILING).toString()); |
| | | |
| | | AllProfitAndLose = AllProfitAndLose.add(profitAndLose.divide(exchangeRate,BigDecimal.ROUND_CEILING)); |
| | | allTotalAssets = allTotalAssets.add(totalAssets.divide(exchangeRate,BigDecimal.ROUND_CEILING)); |
| | | allAmt = allAmt.add(amt.divide(exchangeRate,BigDecimal.ROUND_CEILING)); |
| | | AllHProfitAndLose = AllHProfitAndLose.add(hProfitAndLose.divide(exchangeRate,BigDecimal.ROUND_CEILING)); |
| | | allFreeMoney = allFreeMoney.add(freeMoney.divide(exchangeRate,BigDecimal.ROUND_CEILING)); |
| | | allHMoney = allHMoney.add(hMoney.divide(exchangeRate,BigDecimal.ROUND_CEILING)); |
| | | } |
| | | rUserAssetsList.add(rUserAssets); |
| | | } |
| | | |
| | | |
| | | |
| | | RUserAssets rUserAssets = new RUserAssets(); |
| | | rUserAssets.setAccectType("ALL"); |
| | | rUserAssets.setProfitAndLoss(AllProfitAndLose.setScale(2).toString()); |
| | | rUserAssets.setProfitAndLossUSD(AllProfitAndLose.setScale(2).toString()); |
| | | rUserAssets.setHandlingCharge(allHMoney.setScale(2).toString()); |
| | | rUserAssets.setHandlingChargeUSD(allHMoney.setScale(2).toString()); |
| | | rUserAssets.setCumulativeProfitAndLoss(AllHProfitAndLose.setScale(2).toString()); |
| | | rUserAssets.setCumulativeProfitAndLossUSD(AllHProfitAndLose.setScale(2).toString()); |
| | | rUserAssets.setTotalMoney(allTotalAssets.setScale(2).toString()); |
| | | rUserAssets.setTotalMoneyUSD(allTotalAssets.setScale(2).toString()); |
| | | rUserAssets.setAvailableBalance(allAmt.setScale(2).toString()); |
| | | rUserAssets.setAvailableBalanceUSD(allAmt.setScale(2).toString()); |
| | | rUserAssets.setFreezeMoney(allFreeMoney.setScale(2).toString()); |
| | | rUserAssets.setFreezeMoneyUSD(allFreeMoney.setScale(2).toString()); |
| | | rUserAssets.setSymbol("$"); |
| | | rUserAssets.setSymbolCode("USD"); |
| | | rUserAssetsList.add(rUserAssets); |
| | | |
| | | return ServerResponse.createBySuccess(rUserAssetsList); |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse transfer(String fromType, String toType, String amt,HttpServletRequest paramHttpServletRequest) { |
| | | |
| | | User user = userService.getCurrentUser(paramHttpServletRequest); |
| | |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://45.204.85.67111:6306/stock?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | url: jdbc:mysql://45.204.85.67:7306/stock?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | name: root |
| | | password: f6fac591b6fcd9d6 |
| | | password: Tji7mxYsCxsxCLsG |
| | | druid: |
| | | # 初始连接数 |
| | | initialSize: 5 |
| | |
| | | delete from site_pay |
| | | where id = #{id,jdbcType=INTEGER} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.nq.pojo.SitePay" > |
| | | insert into site_pay (id, c_type,form_url,form_code,channel_type, channel_name, |
| | | channel_desc, channel_account, channel_img, |
| | | channel_min_limit, channel_max_limit, is_show, |
| | | is_lock, totalPrice) |
| | | values (#{id,jdbcType=INTEGER}, #{cType,jdbcType=INTEGER},#{formUrl,jdbcType=VARCHAR},#{formCode,jdbcType=VARCHAR}, |
| | | #{channelType,jdbcType=VARCHAR}, #{channelName,jdbcType=VARCHAR}, |
| | | #{channelDesc,jdbcType=VARCHAR}, #{channelAccount,jdbcType=VARCHAR}, #{channelImg,jdbcType=VARCHAR}, |
| | | #{channelMinLimit,jdbcType=INTEGER}, #{channelMaxLimit,jdbcType=INTEGER}, #{isShow,jdbcType=INTEGER}, |
| | | #{isLock,jdbcType=INTEGER},#{totalPrice,jdbcType=DECIMAL}) |
| | | </insert> |
| | | <!-- <insert id="insert" parameterType="com.nq.pojo.SitePay" >--> |
| | | <!-- insert into site_pay (id, c_type,form_url,form_code,channel_type, channel_name,--> |
| | | <!-- channel_desc, channel_account, channel_img,--> |
| | | <!-- channel_min_limit, channel_max_limit, is_show,--> |
| | | <!-- is_lock, total_price)--> |
| | | <!-- values (#{id,jdbcType=INTEGER}, #{cType,jdbcType=INTEGER},#{formUrl,jdbcType=VARCHAR},#{formCode,jdbcType=VARCHAR},--> |
| | | <!-- #{channelType,jdbcType=VARCHAR}, #{channelName,jdbcType=VARCHAR},--> |
| | | <!-- #{channelDesc,jdbcType=VARCHAR}, #{channelAccount,jdbcType=VARCHAR}, #{channelImg,jdbcType=VARCHAR},--> |
| | | <!-- #{channelMinLimit,jdbcType=INTEGER}, #{channelMaxLimit,jdbcType=INTEGER}, #{isShow,jdbcType=INTEGER},--> |
| | | <!-- #{isLock,jdbcType=INTEGER},#{totalPrice,jdbcType=DECIMAL})--> |
| | | <!-- </insert>--> |
| | | <insert id="insertSelective" parameterType="com.nq.pojo.SitePay" > |
| | | insert into site_pay |
| | | <trim prefix="(" suffix=")" suffixOverrides="," > |
| | |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://14.128.50.174:6306/stock?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | url: jdbc:mysql://45.204.85.67:7306/stock?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | name: root |
| | | password: f6fac591b6fcd9d6 |
| | | password: Tji7mxYsCxsxCLsG |
| | | druid: |
| | | # 初始连接数 |
| | | initialSize: 5 |
| | |
| | | delete from site_pay |
| | | where id = #{id,jdbcType=INTEGER} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.nq.pojo.SitePay" > |
| | | insert into site_pay (id, c_type,form_url,form_code,channel_type, channel_name, |
| | | channel_desc, channel_account, channel_img, |
| | | channel_min_limit, channel_max_limit, is_show, |
| | | is_lock, totalPrice) |
| | | values (#{id,jdbcType=INTEGER}, #{cType,jdbcType=INTEGER},#{formUrl,jdbcType=VARCHAR},#{formCode,jdbcType=VARCHAR}, |
| | | #{channelType,jdbcType=VARCHAR}, #{channelName,jdbcType=VARCHAR}, |
| | | #{channelDesc,jdbcType=VARCHAR}, #{channelAccount,jdbcType=VARCHAR}, #{channelImg,jdbcType=VARCHAR}, |
| | | #{channelMinLimit,jdbcType=INTEGER}, #{channelMaxLimit,jdbcType=INTEGER}, #{isShow,jdbcType=INTEGER}, |
| | | #{isLock,jdbcType=INTEGER},#{totalPrice,jdbcType=DECIMAL}) |
| | | </insert> |
| | | <!-- <insert id="insert" parameterType="com.nq.pojo.SitePay" >--> |
| | | <!-- insert into site_pay (id, c_type,form_url,form_code,channel_type, channel_name,--> |
| | | <!-- channel_desc, channel_account, channel_img,--> |
| | | <!-- channel_min_limit, channel_max_limit, is_show,--> |
| | | <!-- is_lock, total_price)--> |
| | | <!-- values (#{id,jdbcType=INTEGER}, #{cType,jdbcType=INTEGER},#{formUrl,jdbcType=VARCHAR},#{formCode,jdbcType=VARCHAR},--> |
| | | <!-- #{channelType,jdbcType=VARCHAR}, #{channelName,jdbcType=VARCHAR},--> |
| | | <!-- #{channelDesc,jdbcType=VARCHAR}, #{channelAccount,jdbcType=VARCHAR}, #{channelImg,jdbcType=VARCHAR},--> |
| | | <!-- #{channelMinLimit,jdbcType=INTEGER}, #{channelMaxLimit,jdbcType=INTEGER}, #{isShow,jdbcType=INTEGER},--> |
| | | <!-- #{isLock,jdbcType=INTEGER},#{totalPrice,jdbcType=DECIMAL})--> |
| | | <!-- </insert>--> |
| | | <insert id="insertSelective" parameterType="com.nq.pojo.SitePay" > |
| | | insert into site_pay |
| | | <trim prefix="(" suffix=")" suffixOverrides="," > |