shopUserService额外处理
This commit is contained in:
@@ -22,7 +22,6 @@ public interface AShopUserService {
|
|||||||
Page<ShopUser> getPushEventUser(SmsPushEventUser smsPushEventUser);
|
Page<ShopUser> getPushEventUser(SmsPushEventUser smsPushEventUser);
|
||||||
Page<ShopUser> getAcPushEventUser(SmsPushEventUser smsPushEventUser);
|
Page<ShopUser> getAcPushEventUser(SmsPushEventUser smsPushEventUser);
|
||||||
|
|
||||||
List<ShopUser> getPushEventUserList(SmsPushEventUser smsPushEventUser);
|
|
||||||
|
|
||||||
Boolean add(Long shopId, ShopUserAddDTO shopUserAddDTO);
|
Boolean add(Long shopId, ShopUserAddDTO shopUserAddDTO);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.czg.account.service;
|
package com.czg.account.service;
|
||||||
|
|
||||||
|
import com.czg.account.dto.shopuser.ShopUserAddDTO;
|
||||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||||
import com.czg.account.entity.ShopUser;
|
import com.czg.account.entity.ShopUser;
|
||||||
|
import com.czg.market.entity.SmsPushEventUser;
|
||||||
import com.czg.market.vo.InviteUserVO;
|
import com.czg.market.vo.InviteUserVO;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.mybatisflex.core.service.IService;
|
import com.mybatisflex.core.service.IService;
|
||||||
@@ -22,8 +24,16 @@ public interface ShopUserService extends IService<ShopUser> {
|
|||||||
* 返回流水Id
|
* 返回流水Id
|
||||||
*/
|
*/
|
||||||
Long updateMoney(ShopUserMoneyEditDTO shopUserEditDTO);
|
Long updateMoney(ShopUserMoneyEditDTO shopUserEditDTO);
|
||||||
|
/**
|
||||||
|
* 会自动获取到用户的主店铺id 然后获取用户信息
|
||||||
|
* 获取用户信息
|
||||||
|
*/
|
||||||
|
ShopUser getUserInfo(Long shopId, Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取店铺用户信息
|
||||||
|
* 包含会员折扣等信息
|
||||||
|
*/
|
||||||
ShopUser getShopUserInfo(Long shopId, long userId);
|
ShopUser getShopUserInfo(Long shopId, long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,15 +41,13 @@ public interface ShopUserService extends IService<ShopUser> {
|
|||||||
*/
|
*/
|
||||||
Page<InviteUserVO> getInviteUser(Long getDistributionUserId, Long shopId, Long shopUserId, Long distributionLevelId, Integer page, Integer size);
|
Page<InviteUserVO> getInviteUser(Long getDistributionUserId, Long shopId, Long shopUserId, Long distributionLevelId, Integer page, Integer size);
|
||||||
|
|
||||||
/**
|
|
||||||
* 会自动获取到用户的主店铺id 然后获取用户信息
|
|
||||||
* 获取用户信息
|
|
||||||
*/
|
|
||||||
ShopUser getUserInfo(Long shopId, Long userId);
|
|
||||||
|
|
||||||
boolean updateInfo(ShopUser shopUser);
|
boolean updateInfo(ShopUser shopUser);
|
||||||
|
|
||||||
List<ShopUser> selectBirthdayUser(LocalDate current, Long mainShopId, String userType);
|
List<ShopUser> selectBirthdayUser(LocalDate current, Long mainShopId, String userType);
|
||||||
|
|
||||||
void updateOneOrTwoAmount(Long shopUserId, Long shopId, BigDecimal bigDecimal, Integer isOne);
|
void updateOneOrTwoAmount(Long shopUserId, Long shopId, BigDecimal bigDecimal, Integer isOne);
|
||||||
|
|
||||||
|
List<ShopUser> getPushEventUserList(SmsPushEventUser smsPushEventUser);
|
||||||
|
|
||||||
|
boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import jakarta.annotation.Resource;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.apache.dubbo.config.annotation.DubboService;
|
import org.apache.dubbo.config.annotation.DubboService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -48,28 +49,28 @@ import java.util.List;
|
|||||||
* @since 2025-02-08
|
* @since 2025-02-08
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@DubboService
|
@Service
|
||||||
public class AShopUserServiceImpl implements AShopUserService {
|
public class AShopUserServiceImpl implements AShopUserService {
|
||||||
@Resource
|
@Resource
|
||||||
private ShopUserService shopUserService;
|
private ShopUserService shopUserService;
|
||||||
@Resource
|
@Resource
|
||||||
private ShopUserMapper shopUserMapper;
|
private ShopUserMapper shopUserMapper;
|
||||||
|
@Resource
|
||||||
|
private ShopInfoService shopInfoService;
|
||||||
|
@Resource
|
||||||
|
private UserInfoService userInfoService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private SysParamsService sysParamsService;
|
private SysParamsService sysParamsService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private OrderInfoService orderInfoService;
|
private OrderInfoService orderInfoService;
|
||||||
@Resource
|
|
||||||
private UserInfoService userInfoService;
|
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private MkShopCouponRecordService couponRecordService;
|
private MkShopCouponRecordService couponRecordService;
|
||||||
@Resource
|
|
||||||
private ShopInfoService shopInfoService;
|
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private MemberLevelConfigService memberLevelConfigService;
|
private MemberLevelConfigService memberLevelConfigService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private TbMemberConfigService memberConfigService;
|
private TbMemberConfigService memberConfigService;
|
||||||
@DubboReference
|
// @DubboReference
|
||||||
private MkShopConsumeDiscountRecordService consumeDiscountService;
|
// private MkShopConsumeDiscountRecordService consumeDiscountService;
|
||||||
|
|
||||||
private ShopUser getUserInfo(Long shopUserId) {
|
private ShopUser getUserInfo(Long shopUserId) {
|
||||||
ShopUser shopUser = shopUserService.queryChain().eq(ShopUser::getId, shopUserId).one();
|
ShopUser shopUser = shopUserService.queryChain().eq(ShopUser::getId, shopUserId).one();
|
||||||
@@ -136,15 +137,6 @@ public class AShopUserServiceImpl implements AShopUserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ShopUser> getPushEventUserList(SmsPushEventUser smsPushEventUser) {
|
|
||||||
Long mainShopId = shopInfoService.getMainIdByShopId(smsPushEventUser.getShopId());
|
|
||||||
smsPushEventUser.checkIsAll();
|
|
||||||
// 调用Mapper层查询
|
|
||||||
List<ShopUser> shopUsers = shopUserMapper.selectPushEventUser(mainShopId,
|
|
||||||
smsPushEventUser.getShopId(), smsPushEventUser);
|
|
||||||
return shopUsers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateInfo(Long shopId, ShopUserEditDTO shopUserEditDTO) {
|
public Boolean updateInfo(Long shopId, ShopUserEditDTO shopUserEditDTO) {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.czg.service.account.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import com.czg.account.dto.shopuser.ShopUserAddDTO;
|
||||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||||
import com.czg.account.entity.ShopUser;
|
import com.czg.account.entity.ShopUser;
|
||||||
import com.czg.account.entity.ShopUserFlow;
|
import com.czg.account.entity.ShopUserFlow;
|
||||||
@@ -13,11 +15,16 @@ import com.czg.account.service.UserInfoService;
|
|||||||
import com.czg.enums.ShopUserFlowBizEnum;
|
import com.czg.enums.ShopUserFlowBizEnum;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.entity.MemberLevelConfig;
|
import com.czg.market.entity.MemberLevelConfig;
|
||||||
|
import com.czg.market.entity.SmsPushEventUser;
|
||||||
import com.czg.market.service.MemberLevelConfigService;
|
import com.czg.market.service.MemberLevelConfigService;
|
||||||
|
import com.czg.market.service.OrderInfoService;
|
||||||
import com.czg.market.service.TbMemberConfigService;
|
import com.czg.market.service.TbMemberConfigService;
|
||||||
import com.czg.market.vo.InviteUserVO;
|
import com.czg.market.vo.InviteUserVO;
|
||||||
import com.czg.market.vo.MemberConfigVO;
|
import com.czg.market.vo.MemberConfigVO;
|
||||||
|
import com.czg.order.entity.OrderInfo;
|
||||||
import com.czg.service.account.mapper.ShopUserMapper;
|
import com.czg.service.account.mapper.ShopUserMapper;
|
||||||
|
import com.czg.system.entity.SysParams;
|
||||||
|
import com.czg.system.service.SysParamsService;
|
||||||
import com.czg.utils.PageUtil;
|
import com.czg.utils.PageUtil;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
@@ -51,9 +58,13 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||||||
@Resource
|
@Resource
|
||||||
private ShopInfoService shopInfoService;
|
private ShopInfoService shopInfoService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
|
private OrderInfoService orderInfoService;
|
||||||
|
@DubboReference
|
||||||
private MemberLevelConfigService memberLevelConfigService;
|
private MemberLevelConfigService memberLevelConfigService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private TbMemberConfigService memberConfigService;
|
private TbMemberConfigService memberConfigService;
|
||||||
|
@DubboReference
|
||||||
|
private SysParamsService sysParamsService;
|
||||||
|
|
||||||
private ShopUser getUserInfo(Long shopUserId) {
|
private ShopUser getUserInfo(Long shopUserId) {
|
||||||
ShopUser shopUser = queryChain().eq(ShopUser::getId, shopUserId).one();
|
ShopUser shopUser = queryChain().eq(ShopUser::getId, shopUserId).one();
|
||||||
@@ -181,4 +192,97 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||||||
public void updateOneOrTwoAmount(Long shopUserId, Long shopId, BigDecimal bigDecimal, Integer isOne) {
|
public void updateOneOrTwoAmount(Long shopUserId, Long shopId, BigDecimal bigDecimal, Integer isOne) {
|
||||||
mapper.updateOneOrTwoAmount(shopUserId, shopId, bigDecimal, isOne);
|
mapper.updateOneOrTwoAmount(shopUserId, shopId, bigDecimal, isOne);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ShopUser> getPushEventUserList(SmsPushEventUser smsPushEventUser) {
|
||||||
|
Long mainShopId = shopInfoService.getMainIdByShopId(smsPushEventUser.getShopId());
|
||||||
|
smsPushEventUser.checkIsAll();
|
||||||
|
// 调用Mapper层查询
|
||||||
|
List<ShopUser> shopUsers = mapper.selectPushEventUser(mainShopId,
|
||||||
|
smsPushEventUser.getShopId(), smsPushEventUser);
|
||||||
|
return shopUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO) {
|
||||||
|
Long mainId = shopInfoService.getMainIdByShopId(shopId);
|
||||||
|
// 当前用户信息
|
||||||
|
UserInfo userInfo = userInfoService.getById(userId);
|
||||||
|
ShopUser shopUser = getShopUserInfo(shopId, userId);
|
||||||
|
|
||||||
|
// 查询系统添加的会员
|
||||||
|
UserInfo oriInfo = userInfoService.getOne(new QueryWrapper().eq(UserInfo::getPhone, shopUserAddDTO.getPhone()));
|
||||||
|
if (oriInfo != null && !oriInfo.getId().equals(userId)) {
|
||||||
|
// 迁移订单
|
||||||
|
OrderInfo orderInfo = new OrderInfo();
|
||||||
|
orderInfo.setUserId(userId);
|
||||||
|
orderInfoService.update(orderInfo, new QueryWrapper().eq(OrderInfo::getUserId, oriInfo.getId()));
|
||||||
|
// 删除多余用户信息
|
||||||
|
userInfoService.removeById(oriInfo.getId());
|
||||||
|
BeanUtil.copyProperties(oriInfo, userInfo, "id", "alipayOpenId", "wechatOpenId");
|
||||||
|
|
||||||
|
ShopUser oldUserInfo = getOne(new QueryWrapper().eq(ShopUser::getMainShopId, mainId).eq(ShopUser::getUserId, oriInfo.getId()));
|
||||||
|
if (oldUserInfo != null) {
|
||||||
|
removeById(oldUserInfo.getId());
|
||||||
|
BeanUtil.copyProperties(oldUserInfo, shopUser, "id", "userId");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BeanUtil.copyProperties(shopUserAddDTO, shopUser, "accountPoints", "amount");
|
||||||
|
BeanUtil.copyProperties(shopUserAddDTO, userInfo);
|
||||||
|
userInfoService.updateById(userInfo);
|
||||||
|
if (cn.hutool.core.util.StrUtil.isBlank(shopUser.getCode())) {
|
||||||
|
shopUser.setCode(generateCode(shopId));
|
||||||
|
}
|
||||||
|
if (cn.hutool.core.util.StrUtil.isBlank(shopUser.getBirthDay())) {
|
||||||
|
shopUser.setBirthDay(null);
|
||||||
|
}
|
||||||
|
shopUser.setJoinTime(shopUser.getJoinTime() == null ? DateUtil.date().toLocalDateTime() : shopUser.getJoinTime());
|
||||||
|
|
||||||
|
|
||||||
|
return saveOrUpdate(shopUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String generateCode(long shopId) {
|
||||||
|
String code = "shop_user_code_val%d".formatted(shopId);
|
||||||
|
SysParams sysParam = sysParamsService.getOne(new QueryWrapper().eq(SysParams::getParamCode, code));
|
||||||
|
|
||||||
|
if (sysParam == null) {
|
||||||
|
SysParams sysParams = new SysParams()
|
||||||
|
.setParamValue("1")
|
||||||
|
.setParamType(1)
|
||||||
|
.setCreateTime(DateUtil.date().toLocalDateTime())
|
||||||
|
.setParamCode(code);
|
||||||
|
sysParamsService.save(sysParams);
|
||||||
|
return generateRandomCode(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
long parseLong = Long.parseLong(sysParam.getParamValue());
|
||||||
|
long l = ++parseLong;
|
||||||
|
sysParam.setParamValue(String.valueOf(l));
|
||||||
|
sysParamsService.updateById(sysParam);
|
||||||
|
|
||||||
|
return generateRandomCode(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用Hutool生成十六进制代码并随机填充字母
|
||||||
|
private String generateRandomCode(long value) {
|
||||||
|
// 生成十六进制代码,确保为10位
|
||||||
|
String hexCode = String.format("%010X", value);
|
||||||
|
|
||||||
|
// 计算需要补充的字母数量
|
||||||
|
int missingLength = 10 - hexCode.length();
|
||||||
|
StringBuilder codeBuilder = new StringBuilder(hexCode);
|
||||||
|
|
||||||
|
for (int i = 0; i < missingLength; i++) {
|
||||||
|
// 生成随机字母
|
||||||
|
char randomChar = RandomUtil.randomChar("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||||
|
codeBuilder.append(randomChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
return codeBuilder.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package com.czg.service.account.service.impl;
|
package com.czg.service.account.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.czg.account.dto.shopuser.ShopUserAddDTO;
|
import com.czg.account.dto.shopuser.ShopUserAddDTO;
|
||||||
import com.czg.account.dto.shopuser.ShopUserDetailDTO;
|
import com.czg.account.dto.shopuser.ShopUserDetailDTO;
|
||||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||||
@@ -14,14 +12,9 @@ import com.czg.config.RedisCst;
|
|||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.entity.MkShopCouponRecord;
|
import com.czg.market.entity.MkShopCouponRecord;
|
||||||
import com.czg.market.service.MkShopCouponRecordService;
|
import com.czg.market.service.MkShopCouponRecordService;
|
||||||
import com.czg.market.service.TbMemberConfigService;
|
|
||||||
import com.czg.order.entity.OrderInfo;
|
|
||||||
import com.czg.market.service.OrderInfoService;
|
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.service.RedisService;
|
import com.czg.service.RedisService;
|
||||||
import com.czg.service.account.mapper.ShopConfigMapper;
|
import com.czg.service.account.mapper.ShopConfigMapper;
|
||||||
import com.czg.system.entity.SysParams;
|
|
||||||
import com.czg.system.service.SysParamsService;
|
|
||||||
import com.czg.utils.AssertUtil;
|
import com.czg.utils.AssertUtil;
|
||||||
import com.czg.utils.JoinQueryWrapper;
|
import com.czg.utils.JoinQueryWrapper;
|
||||||
import com.czg.utils.PageUtil;
|
import com.czg.utils.PageUtil;
|
||||||
@@ -29,8 +22,7 @@ import com.mybatisflex.core.paginate.Page;
|
|||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.apache.dubbo.config.annotation.DubboService;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -41,20 +33,14 @@ import java.util.List;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
* @since 2025-02-08
|
* @since 2025-02-08
|
||||||
*/
|
*/
|
||||||
@DubboService
|
@Service
|
||||||
public class UShopUserServiceImpl implements UShopUserService {
|
public class UShopUserServiceImpl implements UShopUserService {
|
||||||
@Resource
|
@Resource
|
||||||
private ShopUserService shopUserService;
|
private ShopUserService shopUserService;
|
||||||
@DubboReference
|
|
||||||
private SysParamsService sysParamsService;
|
|
||||||
@DubboReference
|
|
||||||
private OrderInfoService orderInfoService;
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserInfoService userInfoService;
|
private UserInfoService userInfoService;
|
||||||
@Resource
|
@Resource
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
@DubboReference
|
|
||||||
private MkShopCouponRecordService couponRecordService;
|
|
||||||
@Resource
|
@Resource
|
||||||
private ShopInfoService shopInfoService;
|
private ShopInfoService shopInfoService;
|
||||||
@Resource
|
@Resource
|
||||||
@@ -64,7 +50,7 @@ public class UShopUserServiceImpl implements UShopUserService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ShopConfigMapper shopConfigMapper;
|
private ShopConfigMapper shopConfigMapper;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private TbMemberConfigService memberConfigService;
|
private MkShopCouponRecordService couponRecordService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ShopUser getShopUserInfo(Long shopId, long userId) {
|
public ShopUser getShopUserInfo(Long shopId, long userId) {
|
||||||
@@ -89,6 +75,11 @@ public class UShopUserServiceImpl implements UShopUserService {
|
|||||||
return CzgResult.success(dynamicCode);
|
return CzgResult.success(dynamicCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO) {
|
||||||
|
return shopUserService.join(shopId, userId, shopUserAddDTO);
|
||||||
|
}
|
||||||
|
|
||||||
public String generatePaymentCode(String shopId, String platformNumber) {
|
public String generatePaymentCode(String shopId, String platformNumber) {
|
||||||
// 获取当前毫秒时间戳的后四位
|
// 获取当前毫秒时间戳的后四位
|
||||||
String date = String.format("%04d", System.currentTimeMillis() % 10000);
|
String date = String.format("%04d", System.currentTimeMillis() % 10000);
|
||||||
@@ -104,88 +95,6 @@ public class UShopUserServiceImpl implements UShopUserService {
|
|||||||
return date + platformNumber + shopIdLastTwoDigits + randomPart;
|
return date + platformNumber + shopIdLastTwoDigits + randomPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String generateCode(long shopId) {
|
|
||||||
String code = "shop_user_code_val%d".formatted(shopId);
|
|
||||||
SysParams sysParam = sysParamsService.getOne(new QueryWrapper().eq(SysParams::getParamCode, code));
|
|
||||||
|
|
||||||
if (sysParam == null) {
|
|
||||||
SysParams sysParams = new SysParams()
|
|
||||||
.setParamValue("1")
|
|
||||||
.setParamType(1)
|
|
||||||
.setCreateTime(DateUtil.date().toLocalDateTime())
|
|
||||||
.setParamCode(code);
|
|
||||||
sysParamsService.save(sysParams);
|
|
||||||
return generateRandomCode(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
long parseLong = Long.parseLong(sysParam.getParamValue());
|
|
||||||
long l = ++parseLong;
|
|
||||||
sysParam.setParamValue(String.valueOf(l));
|
|
||||||
sysParamsService.updateById(sysParam);
|
|
||||||
|
|
||||||
return generateRandomCode(l);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 使用Hutool生成十六进制代码并随机填充字母
|
|
||||||
private String generateRandomCode(long value) {
|
|
||||||
// 生成十六进制代码,确保为10位
|
|
||||||
String hexCode = String.format("%010X", value);
|
|
||||||
|
|
||||||
// 计算需要补充的字母数量
|
|
||||||
int missingLength = 10 - hexCode.length();
|
|
||||||
StringBuilder codeBuilder = new StringBuilder(hexCode);
|
|
||||||
|
|
||||||
for (int i = 0; i < missingLength; i++) {
|
|
||||||
// 生成随机字母
|
|
||||||
char randomChar = RandomUtil.randomChar("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
|
||||||
codeBuilder.append(randomChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
return codeBuilder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO) {
|
|
||||||
Long mainId = shopInfoService.getMainIdByShopId(shopId);
|
|
||||||
// 当前用户信息
|
|
||||||
UserInfo userInfo = userInfoService.getById(userId);
|
|
||||||
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId);
|
|
||||||
|
|
||||||
// 查询系统添加的会员
|
|
||||||
UserInfo oriInfo = userInfoService.getOne(new QueryWrapper().eq(UserInfo::getPhone, shopUserAddDTO.getPhone()));
|
|
||||||
if (oriInfo != null && !oriInfo.getId().equals(userId)) {
|
|
||||||
// 迁移订单
|
|
||||||
OrderInfo orderInfo = new OrderInfo();
|
|
||||||
orderInfo.setUserId(userId);
|
|
||||||
orderInfoService.update(orderInfo, new QueryWrapper().eq(OrderInfo::getUserId, oriInfo.getId()));
|
|
||||||
// 删除多余用户信息
|
|
||||||
userInfoService.removeById(oriInfo.getId());
|
|
||||||
BeanUtil.copyProperties(oriInfo, userInfo, "id", "alipayOpenId", "wechatOpenId");
|
|
||||||
|
|
||||||
ShopUser oldUserInfo = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, mainId).eq(ShopUser::getUserId, oriInfo.getId()));
|
|
||||||
if (oldUserInfo != null) {
|
|
||||||
shopUserService.removeById(oldUserInfo.getId());
|
|
||||||
BeanUtil.copyProperties(oldUserInfo, shopUser, "id", "userId");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BeanUtil.copyProperties(shopUserAddDTO, shopUser, "accountPoints", "amount");
|
|
||||||
BeanUtil.copyProperties(shopUserAddDTO, userInfo);
|
|
||||||
userInfoService.updateById(userInfo);
|
|
||||||
if (StrUtil.isBlank(shopUser.getCode())) {
|
|
||||||
shopUser.setCode(generateCode(shopId));
|
|
||||||
}
|
|
||||||
if (StrUtil.isBlank(shopUser.getBirthDay())) {
|
|
||||||
shopUser.setBirthDay(null);
|
|
||||||
}
|
|
||||||
shopUser.setJoinTime(shopUser.getJoinTime() == null ? DateUtil.date().toLocalDateTime() : shopUser.getJoinTime());
|
|
||||||
|
|
||||||
|
|
||||||
return shopUserService.saveOrUpdate(shopUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ShopUserDetailDTO getInfo(Long shopId, long userId) {
|
public ShopUserDetailDTO getInfo(Long shopId, long userId) {
|
||||||
Long mainId = shopInfoService.getMainIdByShopId(shopId);
|
Long mainId = shopInfoService.getMainIdByShopId(shopId);
|
||||||
|
|||||||
@@ -6,21 +6,23 @@ import cn.hutool.core.util.IdUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.account.dto.shopuser.ShopUserAddDTO;
|
import com.czg.account.dto.shopuser.ShopUserAddDTO;
|
||||||
|
import com.czg.account.entity.ShopInfo;
|
||||||
import com.czg.account.entity.ShopUser;
|
import com.czg.account.entity.ShopUser;
|
||||||
|
import com.czg.account.entity.UserInfo;
|
||||||
import com.czg.account.entity.table.ShopUserTableDef;
|
import com.czg.account.entity.table.ShopUserTableDef;
|
||||||
import com.czg.account.entity.table.UserInfoTableDef;
|
import com.czg.account.entity.table.UserInfoTableDef;
|
||||||
import com.czg.account.service.*;
|
import com.czg.account.service.ShopInfoService;
|
||||||
|
import com.czg.account.service.ShopUserService;
|
||||||
|
import com.czg.account.service.UserInfoService;
|
||||||
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.dto.MemberConfigDTO;
|
import com.czg.market.dto.MemberConfigDTO;
|
||||||
import com.czg.account.entity.ShopInfo;
|
import com.czg.market.dto.MemberOrderDTO;
|
||||||
import com.czg.account.entity.UserInfo;
|
import com.czg.market.entity.MemberOrder;
|
||||||
import com.czg.market.entity.table.MemberOrderTableDef;
|
import com.czg.market.entity.table.MemberOrderTableDef;
|
||||||
import com.czg.market.service.OrderInfoService;
|
import com.czg.market.service.MemberOrderService;
|
||||||
import com.czg.market.service.TbMemberConfigService;
|
import com.czg.market.service.TbMemberConfigService;
|
||||||
import com.czg.market.vo.MemberConfigVO;
|
import com.czg.market.vo.MemberConfigVO;
|
||||||
import com.czg.exception.CzgException;
|
|
||||||
import com.czg.market.dto.MemberOrderDTO;
|
|
||||||
import com.czg.market.vo.MmberOrderVO;
|
import com.czg.market.vo.MmberOrderVO;
|
||||||
import com.czg.order.service.OrderPaymentService;
|
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
import com.czg.service.market.enums.OrderStatusEnums;
|
import com.czg.service.market.enums.OrderStatusEnums;
|
||||||
import com.czg.service.market.mapper.MemberOrderMapper;
|
import com.czg.service.market.mapper.MemberOrderMapper;
|
||||||
@@ -28,9 +30,6 @@ import com.czg.utils.AssertUtil;
|
|||||||
import com.czg.utils.PageUtil;
|
import com.czg.utils.PageUtil;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import com.czg.market.entity.MemberOrder;
|
|
||||||
import com.czg.market.service.MemberOrderService;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.apache.dubbo.config.annotation.DubboService;
|
import org.apache.dubbo.config.annotation.DubboService;
|
||||||
|
|
||||||
@@ -51,15 +50,9 @@ public class MemberOrderServiceImpl extends ServiceImpl<MemberOrderMapper, Membe
|
|||||||
@DubboReference
|
@DubboReference
|
||||||
private UserInfoService userInfoService;
|
private UserInfoService userInfoService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private UShopUserService uShopUserService;
|
|
||||||
@DubboReference
|
|
||||||
private ShopUserService shopUserService;
|
private ShopUserService shopUserService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private TbMemberConfigService memberConfigService;
|
private TbMemberConfigService memberConfigService;
|
||||||
@Resource
|
|
||||||
private OrderInfoService orderInfoService;
|
|
||||||
@DubboReference
|
|
||||||
private OrderPaymentService paymentService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> pageInfo(String startTime, String endTime, String key) {
|
public Map<String, Object> pageInfo(String startTime, String endTime, String key) {
|
||||||
@@ -128,7 +121,7 @@ public class MemberOrderServiceImpl extends ServiceImpl<MemberOrderMapper, Membe
|
|||||||
userInfo.setBirthDay(orderDTO.getBirthDay());
|
userInfo.setBirthDay(orderDTO.getBirthDay());
|
||||||
}
|
}
|
||||||
|
|
||||||
uShopUserService.join(orderDTO.getShopId(), orderDTO.getUserId(), new ShopUserAddDTO()
|
shopUserService.join(orderDTO.getShopId(), orderDTO.getUserId(), new ShopUserAddDTO()
|
||||||
.setPhone(userInfo.getPhone())
|
.setPhone(userInfo.getPhone())
|
||||||
.setSex(userInfo.getSex())
|
.setSex(userInfo.getSex())
|
||||||
.setHeadImg(userInfo.getHeadImg())
|
.setHeadImg(userInfo.getHeadImg())
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.czg.account.dto.QueryReceiveDto;
|
|||||||
import com.czg.account.entity.ShopInfo;
|
import com.czg.account.entity.ShopInfo;
|
||||||
import com.czg.account.entity.ShopUser;
|
import com.czg.account.entity.ShopUser;
|
||||||
import com.czg.account.entity.UserInfo;
|
import com.czg.account.entity.UserInfo;
|
||||||
import com.czg.account.service.AShopUserService;
|
|
||||||
import com.czg.account.service.ShopInfoService;
|
import com.czg.account.service.ShopInfoService;
|
||||||
import com.czg.account.service.ShopUserService;
|
import com.czg.account.service.ShopUserService;
|
||||||
import com.czg.account.service.UserInfoService;
|
import com.czg.account.service.UserInfoService;
|
||||||
@@ -63,8 +62,6 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
|||||||
private ShopInfoService shopInfoService;
|
private ShopInfoService shopInfoService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private ShopUserService shopUserService;
|
private ShopUserService shopUserService;
|
||||||
@DubboReference
|
|
||||||
private AShopUserService aShopUserService;
|
|
||||||
@Resource
|
@Resource
|
||||||
private ShopCouponMapper couponService;
|
private ShopCouponMapper couponService;
|
||||||
|
|
||||||
@@ -248,7 +245,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
|||||||
smsPushEventUser.setShopId(param.getShopId());
|
smsPushEventUser.setShopId(param.getShopId());
|
||||||
smsPushEventUser.setIsAll(1);
|
smsPushEventUser.setIsAll(1);
|
||||||
}
|
}
|
||||||
userList = aShopUserService.getPushEventUserList(smsPushEventUser);
|
userList = shopUserService.getPushEventUserList(smsPushEventUser);
|
||||||
// 2. 将JSON字符串解析为JSONArray
|
// 2. 将JSON字符串解析为JSONArray
|
||||||
JSONArray couponArray = JSON.parseArray(param.getCoupon());
|
JSONArray couponArray = JSON.parseArray(param.getCoupon());
|
||||||
|
|
||||||
@@ -284,7 +281,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
|||||||
smsPushEventUser.setShopId(param.getShopId());
|
smsPushEventUser.setShopId(param.getShopId());
|
||||||
smsPushEventUser.setIsAll(1);
|
smsPushEventUser.setIsAll(1);
|
||||||
}
|
}
|
||||||
userList = aShopUserService.getPushEventUserList(smsPushEventUser);
|
userList = shopUserService.getPushEventUserList(smsPushEventUser);
|
||||||
// 2. 将JSON字符串解析为JSONArray
|
// 2. 将JSON字符串解析为JSONArray
|
||||||
JSONArray couponArray = JSON.parseArray(param.getCoupon());
|
JSONArray couponArray = JSON.parseArray(param.getCoupon());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user