Administrator
2025-05-09 320e9165ac6cc6d90978fbef3074a8ed9add1790
src/main/java/com/taoke/autopay/service/impl/WxUserServiceImpl.java
@@ -1,5 +1,6 @@
package com.taoke.autopay.service.impl;
import com.google.gson.Gson;
import com.taoke.autopay.dao.WxUserInfoMapper;
import com.taoke.autopay.entity.SystemConfigKeyEnum;
import com.taoke.autopay.entity.WxUserInfo;
@@ -7,6 +8,8 @@
import com.taoke.autopay.service.SystemConfigService;
import com.taoke.autopay.service.WxUserService;
import com.taoke.autopay.service.WxUserSettingService;
import com.taoke.autopay.service.credit.UserCreditBalanceService;
import com.taoke.autopay.utils.IPUtil;
import com.taoke.autopay.utils.StringUtil;
import com.taoke.autopay.utils.WxApiUtil;
import org.springframework.stereotype.Service;
@@ -34,6 +37,9 @@
    @Resource
    private SystemConfigService systemConfigService;
    @Resource
    private UserCreditBalanceService userCreditBalanceService;
    @Transactional(rollbackFor = Exception.class)
    @Override
@@ -53,6 +59,7 @@
            user.setLoginTime(new Date());
            user.setCreateTime(new Date());
            wxUserInfoMapper.insertSelective(user);
            userCreditBalanceService.initializeCreditBalance(user.getId());
            return user;
        } else {
            WxUserInfo update = new WxUserInfo();
@@ -62,6 +69,7 @@
            update.setLoginTime(new Date());
            update.setUpdateTime(new Date());
            wxUserInfoMapper.updateByPrimaryKeySelective(update);
            userCreditBalanceService.initializeCreditBalance(update.getId());
            return list.get(0);
        }
    }
@@ -82,4 +90,19 @@
    public long count(WxUserInfoMapper.DaoQuery query) {
        return wxUserInfoMapper.count(query);
    }
    @Override
    public void setLatestInfoInfo(Long uid, String ip, IPUtil.IPInfo ipInfo) {
        WxUserInfo wxUserInfo=new WxUserInfo();
        wxUserInfo.setId(uid);
        wxUserInfo.setLatestIP(ip);
        wxUserInfo.setLatestIPInfo(ipInfo!=null?new Gson().toJson(ipInfo):null);
        wxUserInfo.setUpdateTime(new Date());
        wxUserInfoMapper.updateByPrimaryKeySelective(wxUserInfo);
    }
    @Override
    public void update(WxUserInfo wxUserInfo) {
        wxUserInfoMapper.updateByPrimaryKeySelective(wxUserInfo);
    }
}