From 320e9165ac6cc6d90978fbef3074a8ed9add1790 Mon Sep 17 00:00:00 2001
From: Administrator <1101184511@qq.com>
Date: 星期五, 09 五月 2025 01:21:32 +0800
Subject: [PATCH] 后台管理页面完成

---
 src/main/java/com/taoke/autopay/service/impl/WxUserServiceImpl.java |   50 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/src/main/java/com/taoke/autopay/service/impl/WxUserServiceImpl.java b/src/main/java/com/taoke/autopay/service/impl/WxUserServiceImpl.java
index 1f63c53..bcdd8f3 100644
--- a/src/main/java/com/taoke/autopay/service/impl/WxUserServiceImpl.java
+++ b/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,7 +8,10 @@
 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;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -33,46 +37,39 @@
     @Resource
     private SystemConfigService systemConfigService;
 
+    @Resource
+    private UserCreditBalanceService userCreditBalanceService;
+
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public WxUserInfo login(String openid) {
+    public WxUserInfo login(WxApiUtil.WXUserInfo wxUserInfo) {
         // 鏌ヨ鐢ㄦ埛鏄惁瀛樺湪
         WxUserInfoMapper.DaoQuery query = new WxUserInfoMapper.DaoQuery();
-        query.openId = openid;
+        query.openId = wxUserInfo.getOpenid();
         query.count = 1;
         query.start = 0;
         List<WxUserInfo> list = wxUserInfoMapper.list(query);
         if (list.size() == 0) {
             // 娌℃湁鏁版嵁锛岄渶瑕佹敞鍐�
             WxUserInfo user = new WxUserInfo();
-            user.setOpenId(openid);
+            user.setOpenId(wxUserInfo.getOpenid());
+            user.setNickName(wxUserInfo.getNickname());
+            user.setPortrait(wxUserInfo.getHeadimgurl());
             user.setLoginTime(new Date());
             user.setCreateTime(new Date());
             wxUserInfoMapper.insertSelective(user);
-
-            WxUserSettings settings = new WxUserSettings();
-            settings.setId(user.getId());
-            String value = systemConfigService.getValueCache(SystemConfigKeyEnum.DY_ORDER_MAX_PAY_COUNT_DEFAULT);
-            if (!StringUtil.isNullOrEmpty(value)) {
-                settings.setDyOrderCountPerDay(Integer.parseInt(value));
-            }
-            value = systemConfigService.getValueCache(SystemConfigKeyEnum.KS_ORDER_MAX_PAY_COUNT_DEFAULT);
-            if (!StringUtil.isNullOrEmpty(value)) {
-                settings.setKsOrderCountPerDay(Integer.parseInt(value));
-            }
-            value = systemConfigService.getValueCache(SystemConfigKeyEnum.ORDER_MAX_SUBMIT_COUNT_DEFAULT);
-            if (!StringUtil.isNullOrEmpty(value)) {
-                settings.setTotalOrderCountPerDay(Integer.parseInt(value));
-            }
-            wxUserSettingService.add(settings);
+            userCreditBalanceService.initializeCreditBalance(user.getId());
             return user;
         } else {
             WxUserInfo update = new WxUserInfo();
             update.setId(list.get(0).getId());
+            update.setNickName(wxUserInfo.getNickname());
+            update.setPortrait(wxUserInfo.getHeadimgurl());
             update.setLoginTime(new Date());
             update.setUpdateTime(new Date());
             wxUserInfoMapper.updateByPrimaryKeySelective(update);
+            userCreditBalanceService.initializeCreditBalance(update.getId());
             return list.get(0);
         }
     }
@@ -93,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);
+    }
 }

--
Gitblit v1.8.0