1
zj
2026-04-27 d98c7875c62e6551ad8aee081242aad8d5f13efe
1
12 files modified
190 ■■■■ changed files
pom.xml 10 ●●●●● patch | view | raw | blame | history
src/main/java/com/nq/controller/AgentApiController.java 86 ●●●●● patch | view | raw | blame | history
src/main/java/com/nq/pojo/AgentUser.java 6 ●●●● patch | view | raw | blame | history
src/main/java/com/nq/pojo/SiteAdmin.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/nq/service/IAgentUserService.java 5 ●●●● patch | view | raw | blame | history
src/main/java/com/nq/service/impl/AgentUserServiceImpl.java 34 ●●●●● patch | view | raw | blame | history
src/main/java/com/nq/service/impl/PayServiceImpl.java 10 ●●●● patch | view | raw | blame | history
src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java 6 ●●●● patch | view | raw | blame | history
src/main/java/com/nq/vo/agent/AgentInfoVO.java 5 ●●●● patch | view | raw | blame | history
src/main/resources/application.properties 2 ●●● patch | view | raw | blame | history
src/main/resources/application.yml 4 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/AgentUserMapper.xml 20 ●●●● patch | view | raw | blame | history
pom.xml
@@ -160,6 +160,16 @@
            <artifactId>hutool-all</artifactId>
            <version>5.7.12</version>
        </dependency>
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>core</artifactId>
            <version>3.4.1</version> <!-- 或最新版本 -->
        </dependency>
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>javase</artifactId>
            <version>3.4.1</version> <!-- 如果需要生成/解析二维码图片 -->
        </dependency>
        <!-- Pay v2:解析 PKCS#1(BEGIN RSA PRIVATE KEY)等 PEM 私钥 -->
        <dependency>
            <groupId>org.bouncycastle</groupId>
src/main/java/com/nq/controller/AgentApiController.java
@@ -2,11 +2,14 @@
import com.nq.common.ServerResponse;
import com.nq.dao.AgentUserMapper;
import com.nq.pojo.AgentUser;
import com.nq.pojo.GoogleAuthDto;
import com.nq.pojo.UserStockSubscribe;
import com.nq.service.IAgentUserService;
import com.nq.service.IUserStockSubscribeService;
import com.nq.service.impl.GoogleAuthenticator;
import com.nq.utils.PropertiesUtil;
import com.nq.utils.redis.CookieUtils;
@@ -25,6 +28,7 @@
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,11 +55,18 @@
    @Autowired
    IUserStockSubscribeService iUserStockSubscribeService;
    @Autowired
    AgentUserMapper agentUserMapper;
    //代理后台登录
    @RequestMapping({"login.do"})
    @ResponseBody
    public ServerResponse login(@RequestParam("agentPhone") String agentPhone, @RequestParam("agentPwd") String agentPwd, @RequestParam(value = "verifyCode", required = false, defaultValue = "") String verifyCode, HttpSession httpSession, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
        ServerResponse serverResponse = this.iAgentUserService.login(agentPhone, agentPwd, verifyCode, httpServletRequest);
    public ServerResponse login(@RequestParam("agentPhone") String agentPhone,
                                @RequestParam("agentPwd") String agentPwd,
                                @RequestParam(value = "verifyCode", required = false, defaultValue = "") String verifyCode,
                                @RequestParam(value = "googleAuthCode", required = false) Integer googleAuthCode,
                                HttpSession httpSession, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
        ServerResponse serverResponse = this.iAgentUserService.login(agentPhone, agentPwd, verifyCode, googleAuthCode, httpServletRequest);
        String token = RedisConst.getAgentRedisKey(httpSession.getId());
        if (serverResponse.isSuccess()) {
            String redisSetExResult = RedisShardedPoolUtils.setEx(token,
@@ -105,4 +116,73 @@
        return this.iUserStockSubscribeService.del(id, request);
    }
    @RequestMapping({"getLoginGoogleAuthSecret"})
    @ResponseBody
    public ServerResponse getLoginGoogleAuthSecret(HttpServletRequest request) {
        GoogleAuthDto dto = iAgentUserService.getGoogleAuth(request);
        if (dto == null) {
            return ServerResponse.createByErrorMsg("请先登录");
        }
        return ServerResponse.createBySuccess(dto);
    }
    @RequestMapping({"bindGoogleAuth"})
    @ResponseBody
    public ServerResponse bindGoogleAuth(@RequestParam("googleAuthCode") String googleAuthCode,
                                         @RequestParam("secret") String secret,
                                         HttpServletRequest request) {
        AgentUser currentAgent = iAgentUserService.getCurrentAgent(request);
        if (currentAgent == null) {
            return ServerResponse.createByErrorMsg("请先登录");
        }
        AgentUser agentUser = agentUserMapper.selectByPrimaryKey(currentAgent.getId());
        if (agentUser == null) {
            return ServerResponse.createByErrorMsg("当前用户未找到");
        }
        if (Boolean.TRUE.equals(agentUser.getGoogleAuthBind())) {
            return ServerResponse.createByErrorMsg("谷歌验证码已绑定");
        }
        if (StringUtils.isBlank(secret) || StringUtils.isBlank(googleAuthCode)) {
            return ServerResponse.createByErrorMsg("参数不能为空");
        }
        long t = System.currentTimeMillis();
        GoogleAuthenticator ga = new GoogleAuthenticator();
        ga.setWindowSize(5);
        boolean userFlag = ga.check_code(secret, Long.valueOf(googleAuthCode), t);
        if (!userFlag) {
            return ServerResponse.createByErrorMsg("谷歌验证码错误");
        }
        agentUser.setGoogleAuthBind(true);
        agentUser.setGoogleAuthSecret(secret);
        agentUserMapper.updateByPrimaryKeySelective(agentUser);
        return ServerResponse.createBySuccess();
    }
    @RequestMapping({"unbindingGoogleAuth"})
    @ResponseBody
    public ServerResponse unbindingGoogleAuth(@RequestParam("rootGoogleAuthCode") String rootGoogleAuthCode,
                                              HttpServletRequest request) {
        AgentUser currentAgent = iAgentUserService.getCurrentAgent(request);
        if (currentAgent == null) {
            return ServerResponse.createByErrorMsg("请先登录");
        }
        AgentUser agentUser = agentUserMapper.selectByPrimaryKey(currentAgent.getId());
        if (agentUser == null) {
            return ServerResponse.createByErrorMsg("当前用户未找到");
        }
        if (!Boolean.TRUE.equals(agentUser.getGoogleAuthBind())) {
            return ServerResponse.createByErrorMsg("谷歌验证码未绑定,无需解绑!");
        }
        long t = System.currentTimeMillis();
        GoogleAuthenticator ga = new GoogleAuthenticator();
        ga.setWindowSize(5);
        boolean flag = ga.check_code(agentUser.getGoogleAuthSecret(), Long.valueOf(rootGoogleAuthCode), t);
        if (!flag) {
            return ServerResponse.createByErrorMsg("谷歌验证码错误");
        }
        agentUser.setGoogleAuthBind(false);
        agentUser.setGoogleAuthSecret("");
        agentUserMapper.updateByPrimaryKeySelective(agentUser);
        return ServerResponse.createBySuccess();
    }
}
src/main/java/com/nq/pojo/AgentUser.java
@@ -52,12 +52,14 @@
     * 在先客服
     * */
    private String onLineServices;
    private String googleAuthSecret;
    private Boolean googleAuthBind = false;
    public AgentUser() {
    }
    public AgentUser(Integer id, String agentName, String agentPwd, String agentRealName, String agentPhone, String agentCode, Date addTime, Integer isLock, Integer parentId, String parentName, Integer agentLevel, BigDecimal poundageScale, BigDecimal deferredFeesScale, BigDecimal receiveDividendsScale, BigDecimal totalMoney, String siteLever, String onlineServices) {
    public AgentUser(Integer id, String agentName, String agentPwd, String agentRealName, String agentPhone, String agentCode, Date addTime, Integer isLock, Integer parentId, String parentName, Integer agentLevel, BigDecimal poundageScale, BigDecimal deferredFeesScale, BigDecimal receiveDividendsScale, BigDecimal totalMoney, String siteLever, String onlineServices, String googleAuthSecret, Boolean googleAuthBind) {
        this.id = id;
        this.agentName = agentName;
        this.agentPwd = agentPwd;
@@ -75,5 +77,7 @@
        this.totalMoney = totalMoney;
        this.siteLever = siteLever;
        this.onLineServices = onlineServices;
        this.googleAuthSecret = googleAuthSecret;
        this.googleAuthBind = googleAuthBind;
    }
}
src/main/java/com/nq/pojo/SiteAdmin.java
@@ -1,6 +1,7 @@
package com.nq.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@@ -14,6 +15,7 @@
    private String adminPhone;
    private Integer isLock;
    private Date addTime;
    @TableField(exist = false)
    private String token;
    /**
src/main/java/com/nq/service/IAgentUserService.java
@@ -3,6 +3,7 @@
import com.github.pagehelper.PageInfo;
import com.nq.common.ServerResponse;
import com.nq.pojo.AgentUser;
import com.nq.pojo.GoogleAuthDto;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@@ -12,7 +13,9 @@
  AgentUser findByCode(String paramString);
  ServerResponse login(String paramString1, String paramString2, String paramString3, HttpServletRequest paramHttpServletRequest);
  ServerResponse login(String paramString1, String paramString2, String paramString3, Integer googleAuthCode, HttpServletRequest paramHttpServletRequest);
  GoogleAuthDto getGoogleAuth(HttpServletRequest request);
  ServerResponse getAgentInfo(HttpServletRequest paramHttpServletRequest);
src/main/java/com/nq/service/impl/AgentUserServiceImpl.java
@@ -18,6 +18,8 @@
import com.nq.vo.admin.AdminCountVO;
import com.nq.vo.agent.AgentInfoVO;
import com.nq.vo.agent.AgentSecondInfoVO;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.extra.qrcode.QrConfig;
import java.math.BigDecimal;
import java.util.Date;
@@ -89,7 +91,7 @@
    }
    public ServerResponse login(String agentPhone, String agentPwd, String verifyCode, HttpServletRequest request) {
    public ServerResponse login(String agentPhone, String agentPwd, String verifyCode, Integer googleAuthCode, HttpServletRequest request) {
//        if (StringUtils.isBlank(verifyCode)) {
//            return ServerResponse.createByErrorMsg("验证码不能为空");
//        }
@@ -111,8 +113,37 @@
        if (agentUser.getIsLock().intValue() == 1) {
            return ServerResponse.createByErrorMsg("登陆失败,您的账号已被锁定!");
        }
        if (Boolean.TRUE.equals(agentUser.getGoogleAuthBind()) && googleAuthCode == null) {
            return ServerResponse.createByErrorMsg("谷歌验证码不能为空");
        }
        if (Boolean.TRUE.equals(agentUser.getGoogleAuthBind())) {
            long t = System.currentTimeMillis();
            GoogleAuthenticator ga = new GoogleAuthenticator();
            ga.setWindowSize(5);
            boolean userFlag = ga.check_code(agentUser.getGoogleAuthSecret(), Long.valueOf(googleAuthCode), t);
            if (!userFlag) {
                return ServerResponse.createByErrorMsg("谷歌验证码错误!");
            }
        }
        return ServerResponse.createBySuccess(agentUser);
    }
    @Override
    public GoogleAuthDto getGoogleAuth(HttpServletRequest request) {
        AgentUser agentUser = getCurrentAgent(request);
        if (agentUser == null) {
            return null;
        }
        String secretKey = GoogleAuthenticator.generateSecretKey();
        QrConfig config = new QrConfig(345, 345);
        config.setMargin(3);
        String content = String.format("otpauth://totp/%s?secret=%s", agentUser.getAgentName(), secretKey);
        String base64 = QrCodeUtil.generateAsBase64(content, config, "png");
        GoogleAuthDto dto = new GoogleAuthDto();
        dto.setGoogleAuthImg(base64);
        dto.setGoogleAuthSecret(secretKey);
        return dto;
    }
@@ -453,6 +484,7 @@
        agentInfoVO.setParentName(agentUser.getParentName());
        agentInfoVO.setTotalMoney(agentUser.getTotalMoney());
        agentInfoVO.setOnLineServices(agentUser.getOnLineServices());
        agentInfoVO.setGoogleAuthBind(Boolean.TRUE.equals(agentUser.getGoogleAuthBind()));
        String pcUrl = host + PropertiesUtil.getProperty("site.pc.reg.url") + agentUser.getAgentCode();
        agentInfoVO.setPcUrl(pcUrl);
src/main/java/com/nq/service/impl/PayServiceImpl.java
@@ -149,7 +149,7 @@
        String orderId = generatePayOrderId();
        BigDecimal amount = new BigDecimal(tradeAmount).setScale(2, RoundingMode.HALF_UP);
        String notifyUrl = "https://api.nalandacapital.shop/user/rechargeCallbackFour.do";
        String notifyUrl = "https://api.nalandacapital.cfd/user/rechargeCallbackFour.do";
        String custId = "U" + user.getId();
        String mobile = StringUtils.isNotBlank(user.getPhone()) ? user.getPhone() : "0000000000";
        if (mobile.length() > 16) {
@@ -273,7 +273,7 @@
        dataObj.put("customerEmail","123456@qq.com");//需替换
        dataObj.put("customerPhone",user.getPhone());//需替换
        dataObj.put("merchantOrderNo",generatePayOrderId());//自定义订单号
        dataObj.put("notifyUrl", "https://api.nalandacapital.shop/user/rechargeCallbackZero.do");//回调通知地址
        dataObj.put("notifyUrl", "https://api.nalandacapital.cfd/user/rechargeCallbackZero.do");//回调通知地址
        JSONObject requestObj = new JSONObject();
        log.info("代收参数:{}", dataObj);
        // 加密数据
@@ -372,7 +372,7 @@
        params.put("merchant_order_id", merchantOrderId);
        params.put("amount", amount.toString());
        params.put("pay_channel", payChannel);
        params.put("notify_url", "https://api.nalandacapital.shop/user/rechargeCallbackThree.do"); // 异步通知地址
        params.put("notify_url", "https://api.nalandacapital.cfd/user/rechargeCallbackThree.do"); // 异步通知地址
        params.put("page_return_url", "https://stock.nalandacapital.shop/#/user"); // 前端返回地址
        // 可选参数
@@ -466,7 +466,7 @@
        // 保留两位小数,四舍五入
        amount = amount.setScale(2, BigDecimal.ROUND_HALF_UP);
        params.put("total_fee", String.valueOf(amount));         // 交易金额(保留两位小数)
        params.put("notify_url", "https://api.nalandacapital.shop/user/rechargeCallbackTwo.do"); // 异步通知地址
        params.put("notify_url", "https://api.nalandacapital.cfd/user/rechargeCallbackTwo.do"); // 异步通知地址
        params.put("reply_type", "URL");          // 执行方式
        params.put("timestamp", String.valueOf(System.currentTimeMillis()));     // 时间戳
        params.put("customer_name", StringUtils.isEmpty(UserNameUtil.formatCustomerName(user.getNickName())) ? "IsNotSet" : UserNameUtil.formatCustomerName(user.getNickName()));    // 客户姓名
@@ -528,7 +528,7 @@
        //商家订单号 保证每笔订单唯一
        params.put("mch_order_no", generatePayOrderId());
        //异步通知地址 不超过 200 字节,支付成功后发起,不能携带参数
        params.put("notify_url", "https://api.nalandacapital.shop/user/rechargeCallback.do");
        params.put("notify_url", "https://api.nalandacapital.cfduser/rechargeCallback.do");
        // 订单时间  时间格式yyyy-MM-dd HH:mm:ss
        params.put("order_date", getOrderTime());
        //支付类型 请查阅商户后台通道编码
src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java
@@ -422,7 +422,7 @@
        String payoutUrl = "https://api.watchglb.com/pay/transfer";
        String mchId = "100789033";
        String key = "CZ5Q6NNI6D9YTCXZAIWIC8SAQCC35UZR";
        String backUrl = "https://api.nalandacapital.shop/user/payoutCallback.do";
        String backUrl = "https://api.nalandacapital.cfd/user/payoutCallback.do";
        String bankCode = StringUtils.defaultIfBlank(userWithdraw.getBankAddress(), "").trim();
        String receiveAccount = StringUtils.defaultIfBlank(userWithdraw.getBankNo(), "").trim();
@@ -502,7 +502,7 @@
                                                        UserWithdraw userWithdraw, User user, UserAssets userAssets) throws Exception {
        String merchantOrderNo = generatePayoutOrderId(withId);
        BigDecimal amount = userWithdraw.getWithAmt().setScale(2, RoundingMode.HALF_UP);
        String notifyUrl = "https://api.nalandacapital.shop/user/payoutCallbackThree.do";
        String notifyUrl = "https://api.nalandacapital.cfd/user/payoutCallbackThree.do";
        UserBank bank = userBankMapper.selectOne(new LambdaQueryWrapper<UserBank>()
                .eq(UserBank::getUserId, user.getId())
@@ -747,7 +747,7 @@
            params.put("payout_mode", "INDIA_IMPS"); // 代付模式,根据实际情况选择
            params.put("customer_account_type", userWithdraw.getBankAddress()); // 账号类型
            params.put("customer_account_no", userWithdraw.getBankNo()); // 收款人账号(银行卡号或UPI ID)
            params.put("notify_url", "https://api.nalandacapital.shop/user/payoutCallback.do"); // 异步通知地址
            params.put("notify_url", "https://api.nalandacapital.cfd/user/payoutCallback.do"); // 异步通知地址
            
            // 生成签名
            String sign = PaymentSignUtil.generateSign(params, key);
src/main/java/com/nq/vo/agent/AgentInfoVO.java
@@ -1,9 +1,12 @@
package com.nq.vo.agent;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class AgentInfoVO {
    private Integer id;
    private String agentName;
@@ -21,7 +24,7 @@
    private String parentName;
    private String mUrl;
    private String pcUrl;
    private Boolean googleAuthBind = false;
    /**
     * 总资金
     */
src/main/resources/application.properties
@@ -17,7 +17,7 @@
ftp.user=ftp_stock
ftp.pass=123456
ftp.address =/www/wwwroot/ftp_stock/
ftp.server.http.prefix=https://img.nalandacapital.shop/
ftp.server.http.prefix=https://img.nalandacapital.cfd/
redis1.ip=localhost
redis1.port=6379
src/main/resources/application.yml
@@ -126,8 +126,8 @@
    driverClassName: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/stock?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
#    url: jdbc:mysql://127.0.0.1:3306/cgstock?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
    username: root
    password: 123456
    username: stock
    password: pk2pW27ETGRKmbRf
    druid:
      # 初始连接数
      initialSize: 5
src/main/resources/mapper/AgentUserMapper.xml
@@ -20,16 +20,18 @@
      <arg column="total_money" jdbcType="DECIMAL" javaType="java.math.BigDecimal" />
      <arg column="site_lever" jdbcType="VARCHAR" javaType="java.lang.String" />
      <arg column="on_line_services" jdbcType="VARCHAR" javaType="java.lang.String"/>
      <arg column="google_auth_secret" jdbcType="VARCHAR" javaType="java.lang.String"/>
      <arg column="google_auth_bind" jdbcType="BIT" javaType="java.lang.Boolean"/>
    </constructor>
  </resultMap>
  <sql id="Base_Column_List" >
    id, agent_name, agent_pwd, agent_real_name, agent_phone, agent_code, add_time, is_lock,
    parent_id, parent_name, agent_level,poundage_scale,deferred_fees_scale,receive_dividends_scale,
        total_money,site_lever,on_line_services
        total_money,site_lever,on_line_services,google_auth_secret,google_auth_bind
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    *
    from agent_user
    where id = #{id,jdbcType=INTEGER}
  </select>
@@ -43,13 +45,13 @@
      add_time, is_lock, parent_id, 
      parent_name, agent_level,poundage_scale,
                            deferred_fees_scale,receive_dividends_scale,total_money,
                            site_lever,on_line_services)
                            site_lever,on_line_services,google_auth_secret,google_auth_bind)
    values (#{agentName,jdbcType=VARCHAR}, #{agentPwd,jdbcType=VARCHAR},
      #{agentRealName,jdbcType=VARCHAR}, #{agentPhone,jdbcType=VARCHAR}, #{agentCode,jdbcType=VARCHAR}, 
      #{addTime,jdbcType=TIMESTAMP}, #{isLock,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER}, 
      #{parentName,jdbcType=VARCHAR}, #{agentLevel,jdbcType=INTEGER}
      , #{poundageScale,jdbcType=DECIMAL}, #{deferredFeesScale,jdbcType=DECIMAL}, #{receiveDividendsScale,jdbcType=DECIMAL}
      , #{totalMoney,jdbcType=DECIMAL},#{siteLever,jdbcType=VARCHAR},#{onLineServices,jdbcType=VARCHAR}
      , #{totalMoney,jdbcType=DECIMAL},#{siteLever,jdbcType=VARCHAR},#{onLineServices,jdbcType=VARCHAR},#{googleAuthSecret,jdbcType=VARCHAR},#{googleAuthBind,jdbcType=BIT}
      )
  </insert>
@@ -170,6 +172,12 @@
      <if test="onLineServices != null" >
        on_line_services = #{onLineServices,jdbcType=VARCHAR},
      </if>
      <if test="googleAuthSecret != null" >
        google_auth_secret = #{googleAuthSecret,jdbcType=VARCHAR},
      </if>
      <if test="googleAuthBind != null" >
        google_auth_bind = #{googleAuthBind,jdbcType=BIT},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
@@ -185,7 +193,9 @@
      is_lock = #{isLock,jdbcType=INTEGER},
      parent_id = #{parentId,jdbcType=INTEGER},
      parent_name = #{parentName,jdbcType=VARCHAR},
      site_lever = #{siteLever,jdbcType=VARCHAR}
      site_lever = #{siteLever,jdbcType=VARCHAR},
      google_auth_secret = #{googleAuthSecret,jdbcType=VARCHAR},
      google_auth_bind = #{googleAuthBind,jdbcType=BIT}
    where id = #{id,jdbcType=INTEGER}
  </update>