huangxiao пре 1 недеља
родитељ
комит
b3c94b88c2

+ 34 - 0
src/main/java/net/mingsoft/tf/biz/IGuestBiz.java

@@ -0,0 +1,34 @@
+package net.mingsoft.tf.biz;
+
+import net.mingsoft.base.biz.IBaseBiz;
+import net.mingsoft.tf.entity.GuestEntity;
+
+/**
+ * 游客业务
+ *
+ * @author 阿白
+ * 创建日期:2025年10月23日 下午6:41:34<br/>
+ * 历史修订:<br/>
+ */
+public interface IGuestBiz extends IBaseBiz<GuestEntity> {
+    /**
+     * 保存游客
+     * <p>
+     * 如果已经存在,就查询
+     */
+    GuestEntity saveGuest(String openid);
+
+    /**
+     * 删除游客
+     * <p>
+     * 会修改邀请关联
+     */
+    void deleteGuest(String openid, String userId);
+
+    /**
+     * 修改游客
+     * <p>
+     * 可关联邀请
+     */
+    void updateGuest(String openid, String icon, String nickName, String code);
+}

+ 0 - 15
src/main/java/net/mingsoft/tf/biz/IPeopleExhibitorBiz.java

@@ -22,20 +22,5 @@ public interface IPeopleExhibitorBiz extends IBaseBiz<PeopleExhibitorEntity> {
 
     IPeopleExhibitorDao getDao();
 
-    /**
-     * 保存游客
-     * <p>
-     * 如果已经存在,就查询
-     */
-    PeopleExhibitorEntity saveGuest(String openid);
 
-    /**
-     * 删除游客
-     */
-    void deleteGuest(String openid);
-
-    /**
-     * 修改游客
-     */
-    void updateGuest(String openid, String icon, String nickName);
 }

+ 61 - 0
src/main/java/net/mingsoft/tf/biz/impl/GuestBizImpl.java

@@ -0,0 +1,61 @@
+package net.mingsoft.tf.biz.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import net.mingsoft.base.biz.impl.BaseBizImpl;
+import net.mingsoft.base.dao.IBaseDao;
+import net.mingsoft.tf.biz.IGuestBiz;
+import net.mingsoft.tf.biz.IPeopleExhibitorBiz;
+import net.mingsoft.tf.dao.IGuestDao;
+import net.mingsoft.tf.entity.GuestEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 游客业务持久化层
+ *
+ * @author 阿白
+ * 创建日期:2025年10月23日 下午6:41:34<br/>
+ * 历史修订:<br/>
+ */
+@Service
+public class GuestBizImpl extends BaseBizImpl<IGuestDao, GuestEntity> implements IGuestBiz {
+    @Autowired
+    private IGuestDao guestDao;
+    @Autowired
+    private IPeopleExhibitorBiz peopleExhibitorBiz;
+
+    @Override
+    protected IBaseDao<GuestEntity> getDao() {
+        return guestDao;
+    }
+
+    @Override
+    public GuestEntity saveGuest(String openid) {
+        GuestEntity entity = guestDao.selectOne(new LambdaQueryWrapper<>(GuestEntity.class)
+                .eq(GuestEntity::getOpenId, openid));
+        if (entity != null) {
+            return entity;
+        }
+        GuestEntity newEntity = new GuestEntity();
+        newEntity.setOpenId(openid);
+        save(newEntity);
+        return newEntity;
+    }
+
+    @Override
+    public void deleteGuest(String openid, String userId) {
+        guestDao.delete(new LambdaQueryWrapper<>(GuestEntity.class)
+                .eq(GuestEntity::getOpenId, openid));
+        peopleExhibitorBiz.update("update people_exhibitor set people=? where people=?", openid, userId);
+    }
+
+    @Override
+    public void updateGuest(String openid, String icon, String nickName, String code) {
+        GuestEntity newEntity = new GuestEntity();
+        newEntity.setIcon(icon);
+        newEntity.setNickName(nickName);
+        getDao().update(newEntity, new LambdaQueryWrapper<>(GuestEntity.class)
+                .eq(GuestEntity::getOpenId, openid));
+        peopleExhibitorBiz.join(openid, code);
+    }
+}

+ 3 - 29
src/main/java/net/mingsoft/tf/biz/impl/PeopleExhibitorBizImpl.java

@@ -34,7 +34,9 @@ public class PeopleExhibitorBizImpl extends BaseBizImpl<IPeopleExhibitorDao, Peo
 
     @Override
     public void join(String user, String code) {
-        Optional.ofNullable(exhibitorBiz.queryByInvitationCode(code))
+        Optional.ofNullable(code)
+                .filter(StrUtil::isNotBlank)
+                .map(exhibitorBiz::queryByInvitationCode)
                 .map(ExhibitorEntity::getExhibitorUser)
                 // 稳一手,自己不能邀请自己
                 .filter(exhibitorUser -> !StrUtil.equals(exhibitorUser, user))
@@ -52,32 +54,4 @@ public class PeopleExhibitorBizImpl extends BaseBizImpl<IPeopleExhibitorDao, Peo
                 })
                 .ifPresent(this::save);
     }
-
-    @Override
-    public PeopleExhibitorEntity saveGuest(String openid) {
-        PeopleExhibitorEntity entity = peopleExhibitorDao.selectOne(new LambdaQueryWrapper<>(PeopleExhibitorEntity.class)
-                .eq(PeopleExhibitorEntity::getOpenId, openid));
-        if (entity != null) {
-            return entity;
-        }
-        PeopleExhibitorEntity newEntity = new PeopleExhibitorEntity();
-        newEntity.setOpenId(openid);
-        save(newEntity);
-        return newEntity;
-    }
-
-    @Override
-    public void deleteGuest(String openid) {
-        peopleExhibitorDao.delete(new LambdaQueryWrapper<>(PeopleExhibitorEntity.class)
-                .eq(PeopleExhibitorEntity::getOpenId, openid));
-    }
-
-    @Override
-    public void updateGuest(String openid, String icon, String nickName) {
-        PeopleExhibitorEntity newEntity = new PeopleExhibitorEntity();
-        newEntity.setIcon(icon);
-        newEntity.setNickName(nickName);
-        peopleExhibitorDao.update(newEntity, new LambdaQueryWrapper<>(PeopleExhibitorEntity.class)
-                .eq(PeopleExhibitorEntity::getOpenId, openid));
-    }
 }

+ 15 - 0
src/main/java/net/mingsoft/tf/dao/IGuestDao.java

@@ -0,0 +1,15 @@
+package net.mingsoft.tf.dao;
+
+import net.mingsoft.base.dao.IBaseDao;
+import net.mingsoft.tf.entity.GuestEntity;
+
+/**
+ * 游客持久层
+ *
+ * @author 阿白
+ * 创建日期:2025年10月23日 下午6:41:34<br/>
+ * 历史修订:<br/>
+ */
+public interface IGuestDao extends IBaseDao<GuestEntity> {
+
+}

+ 4 - 3
src/main/java/net/mingsoft/tf/dao/IPeopleExhibitorDao.java

@@ -19,13 +19,14 @@ public interface IPeopleExhibitorDao extends IBaseDao<PeopleExhibitorEntity> {
      *
      * @param exhibitor 展商
      */
-    Integer summary(String exhibitor);
+    List<Map<String, Object>> summary(String exhibitor);
 
     /**
      * 明细
      *
      * @param exhibitor 展商
-     * @param lastId    最后一条的用户ID
+     * @param last      最后一条数据的时间
+     * @param size      页条数
      */
-    List<Map<String, Object>> details(String exhibitor, String lastId);
+    List<Map<String, Object>> details(String exhibitor, String last, Integer size);
 }

+ 26 - 22
src/main/java/net/mingsoft/tf/dao/IPeopleExhibitorDao.xml

@@ -2,31 +2,35 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="net.mingsoft.tf.dao.IPeopleExhibitorDao">
 	<select id="summary">
-		select count(*)
-		from (select people, exhibitor
-			  from people_exhibitor where exhibitor=#{exhibitor}
-			  union
-			  select LINK_ID, INVITATION_USER_ID
-			  from mdiy_model_people_info
-			  where INVITATION_USER_ID is not null and INVITATION_USER_ID=#{exhibitor}
-			 ) as join_data
+		select type,count(*) num
+		from (select p.PU_ICON, p.PU_NICKNAME, p.CREATE_DATE, '已注册' type
+			  from people_user p
+					   join people_exhibitor as pe on p.PEOPLE_ID = pe.people
+			  where pe.exhibitor = #{exhibitor}
+			  union all
+			  select p.icon, p.NICK_NAME, p.CREATE_DATE, '未注册' type
+			  from guest p
+					   join people_exhibitor as pe on p.open_Id = pe.people
+			  where exhibitor = #{exhibitor}
+			 ) tmp
+		group by type
 	</select>
 	<select id="details">
-		select p.PEOPLE_ID,p.PU_REAL_NAME, p.PU_ICON, p.PU_NICKNAME,'type' type
-		from people_user p
-				 join (select people, exhibitor
-					   from people_exhibitor
-					   where exhibitor = #{exhibitor}
-					   union
-					   select LINK_ID, INVITATION_USER_ID
-					   from mdiy_model_people_info
-					   where INVITATION_USER_ID is not null
-						 and INVITATION_USER_ID = #{exhibitor}) as join_data
-					  on p.PEOPLE_ID = join_data.people
+		select *
+		from (select p.PU_ICON, p.PU_NICKNAME, p.CREATE_DATE, '已注册' type
+			  from people_user p
+					   join people_exhibitor as pe on p.PEOPLE_ID = pe.people
+			  where pe.exhibitor = #{exhibitor}
+			  union all
+			  select p.icon, p.NICK_NAME, p.CREATE_DATE, '未注册' type
+			  from guest p
+					   join people_exhibitor as pe on p.open_Id = pe.people
+			  where exhibitor = #{exhibitor}
+			  ) tmp
 		<where>
-		<if test="lastId != null and lastId != ''">p.PEOPLE_ID &lt; #{lastId}</if>
+			<if test="last != null and last != ''">CREATE_DATE &lt; #{last}</if>
 		</where>
-		order by p.PEOPLE_ID desc
-		limit 20
+		order by CREATE_DATE desc
+		limit #{size}
 	</select>
 </mapper>

+ 22 - 0
src/main/java/net/mingsoft/tf/entity/GuestEntity.java

@@ -0,0 +1,22 @@
+package net.mingsoft.tf.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import net.mingsoft.base.entity.BaseEntity;
+
+/**
+ * 游客实体
+ *
+ * @author 阿白
+ * 创建日期:2025年10月23日 下午6:41:34<br/>
+ * 历史修订:<br/>
+ */
+@Data
+@TableName("guest")
+@EqualsAndHashCode(callSuper = true)
+public class GuestEntity extends BaseEntity {
+    private String openId;
+    private String icon;
+    private String nickName;
+}

+ 0 - 4
src/main/java/net/mingsoft/tf/entity/PeopleExhibitorEntity.java

@@ -19,8 +19,4 @@ public class PeopleExhibitorEntity extends BaseEntity {
     private String people;
     private String exhibitor;
     private String code;
-    private String openId;
-    private String icon;
-    private String nickName;
-
 }

+ 8 - 9
src/main/java/net/mingsoft/tf/wx/ExhibitorAction.java

@@ -61,23 +61,22 @@ public class ExhibitorAction extends BaseAction {
     public ResultData invitationSummary() {
         Map<String, Object> map = new HashMap<>();
         // 总人数
-        Integer summary = peopleExhibitorBiz.getDao().summary(PeopleUtil.getPeopleBean().getPeopleId());
-        map.put("total", summary);
-        map.put("register", summary);
-        // TODO 已到场
-        map.put("arrived", null);
+        peopleExhibitorBiz.getDao().summary(PeopleUtil.getPeopleBean().getPeopleId());
+        // map.put("total", summary);
+        // map.put("register", summary);
+        // // TODO 已到场
+        // map.put("arrived", null);
         return ResultData.build().success(map);
     }
 
     @Operation(summary = "微信-邀请的用户明细")
     @Parameters({
-            @Parameter(name = "lastId", description = "当前页最后一个用户ID", required = true, in = ParameterIn.QUERY)
+            @Parameter(name = "last", description = "当前页最后一条数据的时间", required = true, in = ParameterIn.QUERY)
     })
     @GetMapping(value = "/invitation/details")
     @ResponseBody
-    public ResultData invitationDetails(String lastId) {
-        // TODO 这里的状态怎么计算?
-        return Optional.ofNullable(peopleExhibitorBiz.getDao().details(PeopleUtil.getPeopleBean().getPeopleId(), lastId))
+    public ResultData invitationDetails(String last) {
+        return Optional.ofNullable(peopleExhibitorBiz.getDao().details(PeopleUtil.getPeopleBean().getPeopleId(), last, 20))
                 .map(ResultData.build()::success)
                 .orElseGet(ResultData.build()::success);
     }

+ 25 - 7
src/main/java/net/mingsoft/tf/wx/WxPeopleAction.java

@@ -24,8 +24,10 @@ import net.mingsoft.people.action.web.PeopleAction;
 import net.mingsoft.people.biz.IPeopleBiz;
 import net.mingsoft.people.entity.PeopleEntity;
 import net.mingsoft.tf.biz.IExhibitorBiz;
+import net.mingsoft.tf.biz.IGuestBiz;
 import net.mingsoft.tf.biz.IPeopleExhibitorBiz;
-import net.mingsoft.tf.entity.PeopleExhibitorEntity;
+import net.mingsoft.tf.entity.GuestEntity;
+import net.mingsoft.tf.wx.dto.GuestRequest;
 import net.mingsoft.tf.wx.dto.WxCustomUserNamePasswordToken;
 import net.mingsoft.tf.wx.dto.WxRegisterRequest;
 import org.apache.commons.lang3.StringUtils;
@@ -62,6 +64,8 @@ public class WxPeopleAction extends BaseAction {
     private IExhibitorBiz exhibitorBiz;
     @Autowired
     private IPeopleExhibitorBiz peopleExhibitorBiz;
+    @Autowired
+    private IGuestBiz guestBiz;
     @Value("${wx.appid}")
     private String appid;
     @Value("${wx.secret}")
@@ -78,6 +82,20 @@ public class WxPeopleAction extends BaseAction {
         return null;
     }
 
+    @Operation(summary = "微信-游客,可修改信息和关联邀请")
+    @Parameters({
+            @Parameter(name = "openid", description = "openid", required = true, in = ParameterIn.QUERY),
+            @Parameter(name = "icon", description = "头像", in = ParameterIn.QUERY),
+            @Parameter(name = "nickName", description = "昵称", in = ParameterIn.QUERY),
+            @Parameter(name = "code", description = "邀请码", in = ParameterIn.QUERY)
+    })
+    @PostMapping(value = "/guest")
+    @ResponseBody
+    public ResultData guest(@RequestBody GuestRequest guest) {
+        guestBiz.updateGuest(guest.getOpenid(), guest.getIcon(), guest.getNickName(), guest.getCode());
+        return ResultData.build().success();
+    }
+
     @Operation(summary = "微信-登录")
     @Parameters({
             @Parameter(name = "code", description = "code", required = true, in = ParameterIn.QUERY)
@@ -100,12 +118,12 @@ public class WxPeopleAction extends BaseAction {
                         if (login.isSuccess()) {
                             map.putAll(login.getData(Map.class));
                             map.put("guest", false);
-                        } else {
-                            PeopleExhibitorEntity entity = peopleExhibitorBiz.saveGuest(openid);
-                            map.put("puIcon", entity.getIcon());
-                            map.put("puNickname", entity.getNickName());
-                            map.put("guest", true);
                         }
+                    } else {
+                        GuestEntity entity = guestBiz.saveGuest(openid);
+                        map.put("puIcon", entity.getIcon());
+                        map.put("puNickname", entity.getNickName());
+                        map.put("guest", true);
                     }
                     return ResultData.build().success(map);
                 })
@@ -143,9 +161,9 @@ public class WxPeopleAction extends BaseAction {
         people.setPeoplePassword(RandomUtil.randomString(8));
         ResultData register = peopleAction.register(people, request, response);
         if (register.isSuccess()) {
-            peopleExhibitorBiz.deleteGuest(people.getPeopleName());
             PeopleEntity user = this.peopleBiz.getEntityByUserName(people.getPeopleName());
             String linkId = user.getId();
+            guestBiz.deleteGuest(people.getPeopleName(), linkId);
             ModelMap modelData = new ExtendedModelMap();
             modelData.put("companyName", people.getCompanyName());
             modelData.put("position", people.getPosition());

+ 11 - 0
src/main/java/net/mingsoft/tf/wx/dto/GuestRequest.java

@@ -0,0 +1,11 @@
+package net.mingsoft.tf.wx.dto;
+
+import lombok.Data;
+
+@Data
+public class GuestRequest {
+    private String openid;
+    private String icon;
+    private String nickName;
+    private String code;
+}