From aed4e4c7d76de4d0fbfe8c0b26fcdeecbd5c5b24 Mon Sep 17 00:00:00 2001 From: jiangqs <jiangqs> Date: 星期五, 26 五月 2023 18:04:47 +0800 Subject: [PATCH] 管理台用户管理 --- ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java | 145 ++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 116 insertions(+), 29 deletions(-) diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java index f78db0a..4b092e9 100644 --- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java +++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java @@ -1,9 +1,12 @@ package com.ruoyi.member.service.impl.member; +import java.util.Date; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -14,10 +17,13 @@ import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.member.domain.dto.*; import com.ruoyi.member.domain.pojo.member.MemberNurse; +import com.ruoyi.member.domain.pojo.member.MemberTotal; import com.ruoyi.member.domain.vo.*; import com.ruoyi.member.mapper.member.MemberMapper; import com.ruoyi.member.service.member.MemberNurseService; import com.ruoyi.member.service.member.MemberService; +import com.ruoyi.member.service.member.MemberTotalService; +import com.ruoyi.member.util.CodeFactoryUtil; import com.ruoyi.member.util.HttpUtils; import com.ruoyi.system.api.domain.dto.AppMiniRegisterDto; import com.ruoyi.system.api.domain.vo.AppMiniRegisterVo; @@ -46,6 +52,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -79,9 +86,6 @@ private MemberMapper memberMapper; @Resource - private StringRedisTemplate stringRedisTemplate; - - @Resource private RemoteShopService shopService; @Resource @@ -95,6 +99,9 @@ @Resource private RedisService redisService; + + @Resource + private MemberTotalService memberTotalService; /** * @description: TODO @@ -149,7 +156,7 @@ } /** - * 获取授权信息 + * 小程序注册 * @param appUserRegisterDto * @return */ @@ -183,7 +190,7 @@ JSONObject jsonUserPhoneNumber = JSONObject.parseObject(responseUserPhoneNumber); String errcode = jsonUserPhoneNumber.getString("errcode"); String errmsg = jsonUserPhoneNumber.getString("errmsg"); - if (!errcode.equals("0")) { + if (!"0".equals(errcode)) { throw new ServiceException(errmsg); } String phoneInfo = jsonUserPhoneNumber.getString("phone_info"); @@ -205,8 +212,9 @@ //获取用户为空则新建 if(member == null){ //创建新用户 + String memberId = IdUtils.simpleUUID(); sysUser = new SysUser(); - sysUser.setUserName(mobile+"-3"); + sysUser.setUserName(memberId); sysUser.setUserType("03"); sysUser.setNickName("鸿瑞堂用户"); sysUser.setAvatar("https://hongruitang.oss-cn-beijing.aliyuncs.com/default.png"); @@ -214,15 +222,19 @@ sysUser.setPassword(SecurityUtils.encryptPassword(password)); sysUser = sysUserService.registerUser(sysUser).getData(); member = new Member(); - String memberId = IdUtils.simpleUUID(); + String memberNo = createMemberNo(); + member.setMemberNo(memberNo); member.setUserId(sysUser.getUserId()); member.setDelFlag(0); member.setNickName("鸿瑞堂用户"); + member.setRealName("鸿瑞堂用户"); + member.setCustomerSource("小程序"); member.setAvatar("https://hongruitang.oss-cn-beijing.aliyuncs.com/default.png"); member.setMemberId(memberId); - member.setRelationShopId(1L); member.setBindingFlag(0); member.setCreateTime(new Date()); + member.setMobile(mobile); + initMemberTotal(memberId); }else{ sysUser = sysUserService.getSysUser(member.getUserId()).getData(); } @@ -381,6 +393,7 @@ Member member = this.getByUserId(appMemberBindingDto.getUserId()); member.setBindingFlag(appMemberBindingDto.getBindingFlag()); member.setRelationShopId(appMemberBindingDto.getShopId()); + member.setRelationShopName(appMemberBindingDto.getShopName()); this.saveOrUpdate(member); } @@ -468,8 +481,9 @@ } SysUser sysUser = sysUserService.getSysUserByMobile(phonenumber).getData(); if(sysUser==null){ + String memberId = IdUtils.simpleUUID(); sysUser = new SysUser(); - sysUser.setUserName(phonenumber); + sysUser.setUserName(memberId); sysUser.setUserType("03"); sysUser.setNickName(merMemberAddDto.getNickName()); sysUser.setAvatar("https://hongruitang.oss-cn-beijing.aliyuncs.com/default.png"); @@ -477,27 +491,32 @@ sysUser.setPassword(SecurityUtils.encryptPassword(password)); log.debug("sysUser"+sysUser.toString()); sysUser = sysUserService.registerUser(sysUser).getData(); + Member member = new Member(); + String memberNo = createMemberNo(); + member.setMemberNo(memberNo); + member.setMemberId(memberId); + member.setUserId(sysUser.getUserId()); + member.setDelFlag(0); + member.setNickName(merMemberAddDto.getNickName()); + member.setRealName(merMemberAddDto.getNickName()); + member.setGender(merMemberAddDto.getGender()); + member.setMobile(phonenumber); + member.setReferrer(merMemberAddDto.getReferrer()); + member.setBirthday(merMemberAddDto.getBirthday()); + member.setAvatar("https://hongruitang.oss-cn-beijing.aliyuncs.com/default.png"); + member.setRelationShopId(merMemberAddDto.getShopId()); + member.setWxUnionid(null); + member.setMiniOpenid(null); + member.setBindingFlag(1); + member.setRelationShopId(merMemberAddDto.getShopId()); + member.setCustomerSource("商户添加"); + member.setCreateTime(new Date()); + log.info("member-----------------"+member.toString()); + this.saveOrUpdate(member); + initMemberTotal(memberId); } - log.info("sysUser1-----------------"+sysUser.toString()); - String memberId = IdUtils.simpleUUID(); - Member member = new Member(); - member.setUserId(sysUser.getUserId()); - member.setDelFlag(0); - member.setNickName(merMemberAddDto.getNickName()); - member.setGender(merMemberAddDto.getGender()); - member.setMobile(phonenumber); - member.setReferrer(merMemberAddDto.getReferrer()); - member.setBirthday(merMemberAddDto.getBirthday()); - member.setAvatar("https://hongruitang.oss-cn-beijing.aliyuncs.com/default.png"); - member.setMemberId(memberId); - member.setRelationShopId(1L); - member.setWxUnionid(null); - member.setMiniOpenid(null); - member.setBindingFlag(1); - member.setRelationShopId(merMemberAddDto.getShopId()); - member.setCreateTime(new Date()); - log.info("member-----------------"+member.toString()); - this.saveOrUpdate(member); + + } /** @@ -572,4 +591,72 @@ } } } + + + /** + * 订单创建新用户 + * @param member + */ + @Override + public void createNewMember(Member member){ + String memberNo = createMemberNo(); + member.setMemberNo(memberNo); + member.setDelFlag(0); + member.setAvatar("https://hongruitang.oss-cn-beijing.aliyuncs.com/default.png"); + member.setBindingFlag(0); + member.setCreateTime(new Date()); + member.setCustomerSource("商户订单添加"); + this.saveOrUpdate(member); + initMemberTotal(member.getMemberId()); + } + + /** + * 生成会员统计 + * @param memberId + * @return + */ + private void initMemberTotal(String memberId){ + MemberTotal memberTotal = new MemberTotal(); + memberTotal.setMemberId(memberId); + memberTotal.setDelFlag(0); + memberTotal.setTotalIntegral(0); + memberTotal.setUsedIntegral(0); + memberTotal.setUseableIntegral(0); + memberTotal.setTotalPayMoney(new BigDecimal("0.00")); + memberTotal.setTotalPayCount(0); + memberTotal.setLastPayMoney(new BigDecimal("0.00")); + memberTotal.setTotalServiceCount(0); + memberTotal.setUsedServiceCount(0); + memberTotal.setUseableServiceCount(0); + memberTotal.setTotalActivityCount(0); + memberTotal.setTotalCycleOrder(0); + memberTotal.setToltaExperienceOrder(0); + memberTotal.setTotalServiceOrder(0); + memberTotal.setTotalGoodsOrder(0); + memberTotalService.saveOrUpdate(memberTotal); + } + + /** + * 生成会员编号 + * @return + */ + private String createMemberNo(){ + int memberTotal = memberMapper.selectCount(new LambdaQueryWrapper<Member>().eq(Member::getDelFlag, 0)); + String memberNo = CodeFactoryUtil.getMemberNo(Long.valueOf(memberTotal+1)); + return memberNo; + } + + + /** + * 平台分页获取会员列表 + * @param page + * @param merMemberPageDto + * @return + */ + @Override + public List<MgtMemberPageVo> pageMgtMember(Page page,MgtMemberPageDto merMemberPageDto){ + List<MgtMemberPageVo> memberPageVoList = memberMapper.pageMgtMember(page, merMemberPageDto); + + return memberPageVoList; + } } -- Gitblit v1.7.1