报错修改

This commit is contained in:
wangw 2025-09-24 11:05:51 +08:00
parent 307ebac8fa
commit a31bdc2396
19 changed files with 103 additions and 273 deletions

View File

@ -30,14 +30,11 @@ import java.util.List;
@RestController
@RequestMapping("/admin/shopInfo")
public class ShopInfoController {
private final ShopInfoService shopInfoService;
@Resource
private ShopInfoService shopInfoService;
@Resource
private AuthorizationService authorizationService;
public ShopInfoController(ShopInfoService shopInfoService) {
this.shopInfoService = shopInfoService;
}
/**
* 店铺列表, 只允许管理员调用
* 权限标识: shopInfo:list
@ -99,19 +96,7 @@ public class ShopInfoController {
*/
@GetMapping("branchList")
public CzgResult<List<ShopBranchSelectDTO>> findShopBranch() {
Long shopId = StpKit.USER.getShopId(0L);
String tokenValue = StpKit.USER.getTokenInfo().getTokenValue();
Long headId = StpKit.USER.getHeadId();
List<TokenSign> tokenSignList = StpKit.USER.getSession().getTokenSignList();
if (headId != null && CollUtil.isEmpty(tokenSignList)) {
shopId = StpKit.USER.getHeadShopId();
} else {
long count = tokenSignList.stream().filter(obj -> tokenValue.equals(obj.getValue())).count();
if (headId != null && count == 0) {
shopId = StpKit.USER.getHeadShopId();
}
}
List<ShopBranchSelectDTO> data = shopInfoService.findShopBranch(shopId);
List<ShopBranchSelectDTO> data = shopInfoService.findShopBranch(StpKit.USER.getShopId());
return CzgResult.success(data);
}

View File

@ -149,7 +149,7 @@ public class ShopUserController {
@PutMapping("/money")
public CzgResult<Boolean> editMoney(@RequestBody @Validated ShopUserMoneyEditDTO shopUserMoneyEditDTO) {
shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.ADMIN_IN);
return CzgResult.success(shopUserService.updateMoney(StpKit.USER.getHeadShopIdBySession(), shopUserMoneyEditDTO) > 0L);
return CzgResult.success(shopUserService.updateMoney(shopUserMoneyEditDTO) > 0L);
}
}

View File

@ -34,7 +34,7 @@ public class UserController {
*/
@PutMapping
public CzgResult<Boolean> update(@RequestBody UserInfoEditDTO userInfoEditDTO) {
return CzgResult.success(userInfoService.updateInfo(StpKit.USER.getUsableShopId(), StpKit.USER.getLoginIdAsLong(), userInfoEditDTO));
return CzgResult.success(userInfoService.updateInfo(StpKit.USER.getShopId(), StpKit.USER.getLoginIdAsLong(), userInfoEditDTO));
}
/**

View File

@ -2,13 +2,13 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.1.31:3306/czg_cashier?useUnicode=true&characterEncoding=utf-8
username: root
password: Chaozg123.
url: jdbc:mysql://192.168.0.68:3306/czg_cashier?useUnicode=true&characterEncoding=utf-8
username: qijin
password: Star*0217
data:
redis:
host: 192.168.1.31
host: 192.168.0.68
port: 6379
password: Chaozg123.
timeout: 1000

View File

@ -25,4 +25,6 @@ public interface AShopUserService {
ShopUserSummaryDTO getSummary(Long shopId, Integer isVip);
ShopUser getDetail(Integer id, Integer userId);
Long updateMoney(ShopUserMoneyEditDTO shopUserEditDTO);
}

View File

@ -19,7 +19,7 @@ public interface ShopUserService extends IService<ShopUser> {
/**
* 返回流水Id
*/
Long updateMoney(Long shopId, ShopUserMoneyEditDTO shopUserEditDTO);
Long updateMoney(ShopUserMoneyEditDTO shopUserEditDTO);
ShopUser getShopUserInfo(Long shopId, long userId);

View File

@ -1,17 +0,0 @@
package com.czg.account.service;
/**
* 店铺用户同步Service
* @author tankaikai
* @since 2025-04-08 10:17
*/
public interface ShopUserSyncService {
/**
* 同步合并主分店会员信息
*
* @param headShopId 主店id
* @param branchShopId 分店id
*/
void syncMergeShopUser(Long headShopId, Long branchShopId);
}

View File

@ -29,4 +29,8 @@ public interface UShopUserService {
ShopUserDetailDTO getInfo(Long shopId, long userId);
/**
* 返回流水Id
*/
Long updateMoney(ShopUserMoneyEditDTO shopUserEditDTO);
}

View File

@ -5,43 +5,32 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.shopuser.*;
import com.czg.account.entity.*;
import com.czg.account.service.*;
import com.czg.config.RedisCst;
import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.enums.YesNoEnum;
import com.czg.account.entity.ShopUser;
import com.czg.account.entity.UserInfo;
import com.czg.account.service.AShopUserService;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserService;
import com.czg.account.service.UserInfoService;
import com.czg.exception.ApiNotPrintException;
import com.czg.market.entity.MkShopCouponRecord;
import com.czg.market.service.MkShopCouponRecordService;
import com.czg.market.service.TbMemberConfigService;
import com.czg.order.entity.OrderInfo;
import com.czg.order.service.OrderDetailService;
import com.czg.order.service.OrderInfoService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.service.RedisService;
import com.czg.service.account.mapper.ShopConfigMapper;
import com.czg.service.account.mapper.ShopUserMapper;
import com.czg.system.entity.SysParams;
import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil;
import com.czg.utils.JoinQueryWrapper;
import com.czg.utils.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
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.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
/**
@ -60,28 +49,12 @@ public class AShopUserServiceImpl implements AShopUserService {
private SysParamsService sysParamsService;
@DubboReference
private OrderInfoService orderInfoService;
@DubboReference
private OrderDetailService orderDetailService;
@Resource
private ShopUserFlowService shopUserFlowService;
@Resource
private UserInfoService userInfoService;
@Resource
private RedisService redisService;
@DubboReference
private MkShopCouponRecordService couponRecordService;
@Resource
// private ShopInfoMapper shopInfoMapper;
private ShopInfoService shopInfoService;
@Resource
private ShopExtendService shopExtendService;
@Resource
private FreeDineConfigService freeDineConfigService;
@Resource
private ShopConfigMapper shopConfigMapper;
@DubboReference
private TbMemberConfigService memberConfigService;
private ShopUser getUserInfo(Long shopUserId) {
ShopUser shopUser = shopUserService.queryChain().eq(ShopUser::getId, shopUserId).one();
@ -101,19 +74,19 @@ public class AShopUserServiceImpl implements AShopUserService {
@Override
public Boolean updateInfo(Long shopId, ShopUserEditDTO shopUserEditDTO) {
if (StrUtil.isNotBlank(shopUserEditDTO.getPhone())) {
long count = count(new QueryWrapper().eq(ShopUser::getShopId, shopId).eq(ShopUser::getPhone, shopUserEditDTO.getPhone()).ne(ShopUser::getId, shopUserEditDTO.getId()));
long count = shopUserService.count(new QueryWrapper().eq(ShopUser::getMainShopId, shopId).eq(ShopUser::getPhone, shopUserEditDTO.getPhone()).ne(ShopUser::getId, shopUserEditDTO.getId()));
if (count > 0) {
throw new ApiNotPrintException("手机号已存在");
}
}
ShopUser shopUser = getUserInfo(shopId, shopUserEditDTO.getId());
ShopUser shopUser = getUserInfo(shopUserEditDTO.getId());
BeanUtil.copyProperties(shopUserEditDTO, shopUser);
return updateById(shopUser);
return shopUserService.updateById(shopUser);
}
@Override
public ShopUserSummaryDTO getSummary(Long shopId, Integer isVip) {
return mapper.selectUserSummary(shopId, isVip);
return shopUserMapper.selectUserSummary(shopId, isVip);
}
@Override
@ -131,12 +104,13 @@ public class AShopUserServiceImpl implements AShopUserService {
shopUser.setSourceShopId(shopId);
shopUser.setUserId(userInfo.getId());
shopUser.setJoinTime(shopUser.getIsVip() != null && shopUser.getIsVip() == 1 ? DateUtil.date().toLocalDateTime() : null);
return save(shopUser);
return shopUserService.save(shopUser);
}
@Override
public ShopUser getDetail(Integer id, Integer userId) {
ShopUser shopUser = getOne(new QueryWrapper().eq(ShopUser::getShopId, StpKit.USER.getUsableShopId()).eq(ShopUser::getId, id).eq(ShopUser::getUserId, userId));
Long mainId = shopInfoService.getMainIdByShopId(StpKit.USER.getShopId());
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, mainId).eq(ShopUser::getId, id).eq(ShopUser::getUserId, userId));
long count = couponRecordService.count(new QueryWrapper()
.eq(MkShopCouponRecord::getShopUserId, shopUser.getId())
.eq(MkShopCouponRecord::getStatus, 0)
@ -147,4 +121,49 @@ public class AShopUserServiceImpl implements AShopUserService {
shopUserDTO.setOrderNumber(orderInfoService.count(new QueryWrapper().eq(OrderInfo::getUserId, userId).eq(OrderInfo::getShopId, StpKit.USER.getShopId(0L)).eq(OrderInfo::getStatus, "done")));
return shopUserDTO;
}
@Override
public Long updateMoney(ShopUserMoneyEditDTO shopUserEditDTO) {
return shopUserService.updateMoney(shopUserEditDTO);
}
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();
}
}

View File

@ -170,7 +170,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
if (takeNumberDTO.getUserId() != null) {
ShopUser shopUser = shopUserService.queryChain()
.eq(ShopUser::getStatus, 1)
.eq(ShopUser::getShopId, shopId)
.eq(ShopUser::getSourceShopId, shopId)
.eq(ShopUser::getId, takeNumberDTO.getUserId()).one();
if (shopUser == null) {
throw new ApiNotPrintException("用户不存在");

View File

@ -9,7 +9,6 @@ import com.czg.account.enums.BranchDataSyncMethodEnum;
import com.czg.account.enums.ShopTypeEnum;
import com.czg.account.param.ShopBranchParam;
import com.czg.account.service.ShopBranchService;
import com.czg.account.service.ShopUserSyncService;
import com.czg.enums.YesNoEnum;
import com.czg.exception.CzgException;
import com.czg.product.service.ShopSyncService;
@ -44,8 +43,6 @@ public class ShopBranchServiceImpl implements ShopBranchService {
private ShopInfoMapper shopInfoMapper;
@DubboReference
private ShopSyncService shopSyncService;
@Resource
private ShopUserSyncService shopUserSyncService;
@Override
@ -116,10 +113,6 @@ public class ShopBranchServiceImpl implements ShopBranchService {
shopSyncService.sync(shopId, branchShop.getId(), sysUserId);
log.info("同步结束店铺id{}分店id{} 操作人Id:{}", shopId, branchShop.getId(), sysUserId);
});
ThreadUtil.execAsync(() -> {
// 同步会员信息
shopUserSyncService.syncMergeShopUser(shopId, branchShop.getId());
});
}
@Override

View File

@ -376,7 +376,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
@Override
public List<ShopBranchSelectDTO> findShopBranch(Long shopId) {
List<ShopBranchSelectDTO> list = new ArrayList<>();
ShopInfo shopInfo = mapper.selectOneById(shopId);
ShopInfo shopInfo = getById(shopId);
ShopBranchSelectDTO head = new ShopBranchSelectDTO();
head.setShopId(shopInfo.getId());
head.setShopName(shopInfo.getShopName());
@ -385,7 +385,8 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
if (loginType.compareTo(MyStpLogic.LoginType.STAFF) == 0) {
return list;
}
List<ShopInfo> branchList = mapper.selectListByQuery(query().select(ShopInfo::getId, ShopInfo::getShopName).eq(ShopInfo::getMainId, shopId).orderBy(ShopInfo::getId, true));
Long mainIdByShopId = getMainIdByShopId(shopId);
List<ShopInfo> branchList = mapper.selectListByQuery(query().select(ShopInfo::getId, ShopInfo::getShopName).eq(ShopInfo::getMainId, mainIdByShopId).orderBy(ShopInfo::getId, true));
for (ShopInfo info : branchList) {
ShopBranchSelectDTO branch = new ShopBranchSelectDTO();
branch.setShopId(info.getId());

View File

@ -64,7 +64,7 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
@Override
@Transactional
public Long updateMoney(Long shopId, ShopUserMoneyEditDTO shopUserEditDTO) {
public Long updateMoney(ShopUserMoneyEditDTO shopUserEditDTO) {
shopUserEditDTO.setMoney(shopUserEditDTO.getMoney().setScale(2, RoundingMode.DOWN));
ShopUser userInfo = getUserInfo(shopUserEditDTO.getId());

View File

@ -1,170 +0,0 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONWriter;
import com.czg.account.entity.ShopUser;
import com.czg.account.entity.ShopUserFlow;
import com.czg.account.service.ShopUserSyncService;
import com.czg.service.account.mapper.ShopUserMapper;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 店铺用户同步Service实现类
*
* @author tankaikai
* @since 2025-04-08 10:18
*/
@Service
public class ShopUserSyncServiceImpl implements ShopUserSyncService {
@Resource
private ShopUserMapper shopUserMapper;
/**
* 同步合并主分店会员信息
*
* @param headShopId 主店id
* @param branchShopId 分店id
*/
@Override
public synchronized void syncMergeShopUser(Long headShopId, Long branchShopId) {
// 合并前置逻辑查询主店分店手机号码不为空的会员信息分店和主店手机号码进行匹配
// 合并逻辑0分店没有绑定手机号的会员把shop_id改为主店shop_id把分店会员信息jsonArray格式化存储至主店用户信息的merged_users字段中
// 合并逻辑1主店分店一致如果手机号码一致则把分店会员信息中的 积分余额消费金额消费次数合并到主店会员信息中把分店会员信息jsonArray格式化存储至主店用户信息的merged_users字段中再把分店用户信息删除
// 合并逻辑2主店有分店没有不用采取任何操作使用主店的会员信息
// 合并逻辑3主店没有分店有把shop_id改为主店shop_id把分店会员信息jsonArray格式化存储至merged_users字段中
// 合并逻辑4当用户补充了手机号码或则修改了手机号码则需要按照手机号码进行会员信息合并把逻辑123重新执行一遍
List<ShopUser> branchShopNotPhoneUserList = shopUserMapper.selectListByQuery(QueryWrapper.create().eq(ShopUser::getShopId, branchShopId)
.and(q -> {
q.isNull(ShopUser::getPhone).or(q1 -> {
q1.eq(ShopUser::getPhone, "");
});
}));
// 分店没有绑定手机号的会员
for (ShopUser shopUser : branchShopNotPhoneUserList) {
Long historyShopId = shopUser.getShopId();
Long historyUserId = shopUser.getUserId();
JSONObject branch = JSONObject.from(shopUser, JSONWriter.Feature.WriteMapNullValue);
JSONArray objects = new JSONArray();
objects.add(branch);
shopUser.setShopId(headShopId);
shopUser.setMergedUsers(objects.toJSONString(JSONWriter.Feature.WriteMapNullValue));
shopUserMapper.update(shopUser);
// 更新会员流水记录到主店
UpdateChain.of(ShopUserFlow.class)
.set(ShopUserFlow::getShopId, headShopId)
.eq(ShopUserFlow::getShopId, historyShopId)
.eq(ShopUserFlow::getUserId, historyUserId)
.update();
}
List<ShopUser> headShopUserList = shopUserMapper.selectListByQuery(QueryWrapper.create().eq(ShopUser::getShopId, headShopId).isNotNull(ShopUser::getPhone));
List<ShopUser> branchShopUserList = shopUserMapper.selectListByQuery(QueryWrapper.create().eq(ShopUser::getShopId, branchShopId).isNotNull(ShopUser::getPhone));
// 如果分店没有符合条件的会员则不进行合并
if (CollUtil.isEmpty(branchShopUserList)) {
return;
}
Map<String, ShopUser> headShopUserKv = headShopUserList.stream().collect(Collectors.toMap(ShopUser::getPhone, shopUser -> shopUser));
Map<String, ShopUser> branchShopUserKv = branchShopUserList.stream().collect(Collectors.toMap(ShopUser::getPhone, shopUser -> shopUser));
Set<String> headShopPhoneList = headShopUserList.stream().map(ShopUser::getPhone).collect(Collectors.toSet());
Set<String> branchShopPhoneList = branchShopUserList.stream().map(ShopUser::getPhone).collect(Collectors.toSet());
Set<String> phoneSet = new HashSet<>();
phoneSet.addAll(headShopPhoneList);
phoneSet.addAll(branchShopPhoneList);
// 执行合并逻辑
for (String phone : phoneSet) {
ShopUser headShopUser = headShopUserKv.get(phone);
ShopUser branchShopUser = branchShopUserKv.get(phone);
// 1.如果都有
if (ObjUtil.isNotNull(headShopUser) && ObjUtil.isNotNull(branchShopUser)) {
toMergeCase1(headShopUser, branchShopUser);
// 2.如果主店有分店没有
} else if (ObjUtil.isNotNull(headShopUser) && ObjUtil.isNull(branchShopUser)) {
toMergeCase2(headShopUser, branchShopId);
// 3.如果主店没有分店有
} else if (ObjUtil.isNull(headShopUser) && ObjUtil.isNotNull(branchShopUser)) {
toMergeCase3(headShopId, branchShopUser);
}
}
}
/**
* 合并会员信息 1.如果都有
*
* @param headShopUser 主店会员
* @param branchShopUser 分店会员
*/
public void toMergeCase1(ShopUser headShopUser, ShopUser branchShopUser) {
// 合并逻辑1主店分店一致如果手机号码一致则把分店会员信息中的 积分余额消费金额消费次数合并到主店会员信息中把分店会员信息jsonArray格式化存储至主店用户信息的merged_users字段中再把分店用户信息删除
headShopUser.setAccountPoints(NumberUtil.nullToZero(headShopUser.getAccountPoints()) + (NumberUtil.nullToZero(branchShopUser.getAccountPoints())));
headShopUser.setAmount(NumberUtil.nullToZero(headShopUser.getAmount()).add(NumberUtil.nullToZero(branchShopUser.getAmount())));
headShopUser.setConsumeCount(NumberUtil.nullToZero(headShopUser.getConsumeCount()) + (NumberUtil.nullToZero(branchShopUser.getConsumeCount())));
headShopUser.setConsumeAmount(NumberUtil.nullToZero(headShopUser.getConsumeAmount()).add(NumberUtil.nullToZero(branchShopUser.getConsumeAmount())));
headShopUser.setUpdateTime(LocalDateTime.now());
String mergedUsers = StrUtil.emptyToDefault(headShopUser.getMergedUsers(), "[]");
JSONArray objects = JSON.parseArray(mergedUsers);
objects.add(JSONObject.from(branchShopUser, JSONWriter.Feature.WriteMapNullValue));
headShopUser.setMergedUsers(JSON.toJSONString(objects, JSONWriter.Feature.WriteMapNullValue));
shopUserMapper.update(headShopUser);
// 更新会员流水记录到主店
UpdateChain.of(ShopUserFlow.class)
.set(ShopUserFlow::getShopId, headShopUser.getShopId())
.eq(ShopUserFlow::getShopId, branchShopUser.getShopId())
.eq(ShopUserFlow::getUserId, branchShopUser.getUserId())
.update();
shopUserMapper.delete(branchShopUser);
}
/**
* 合并会员信息 2.如果主店有分店没有
*
* @param headShopUser 主店会员
* @param branchShopId 分店id
*/
public void toMergeCase2(ShopUser headShopUser, Long branchShopId) {
// 合并逻辑2主店有分店没有不用采取任何操作使用主店的会员信息
}
/**
* 合并会员信息 3.如果主店没有分店有
*
* @param headShopId 主店id
* @param branchShopUser 分店会员信息
*/
public void toMergeCase3(Long headShopId, ShopUser branchShopUser) {
// 合并逻辑3主店没有分店有把shop_id改为主店shop_id把分店会员信息jsonArray格式化存储至merged_users字段中
Long historyShopId = branchShopUser.getShopId();
Long historyUserId = branchShopUser.getUserId();
JSONObject branch = JSONObject.from(branchShopUser, JSONWriter.Feature.WriteMapNullValue);
JSONArray objects = new JSONArray();
objects.add(branch);
branchShopUser.setShopId(headShopId);
branchShopUser.setMergedUsers(objects.toJSONString(JSONWriter.Feature.WriteMapNullValue));
shopUserMapper.update(branchShopUser);
// 更新会员流水记录到主店
UpdateChain.of(ShopUserFlow.class)
.set(ShopUserFlow::getShopId, headShopId)
.eq(ShopUserFlow::getShopId, historyShopId)
.eq(ShopUserFlow::getUserId, historyUserId)
.update();
}
}

View File

@ -7,9 +7,11 @@ import com.alibaba.fastjson2.JSONObject;
import com.czg.account.dto.menu.MenuAddDTO;
import com.czg.account.dto.menu.MenuEditDTO;
import com.czg.account.entity.CashMenu;
import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.SysMenu;
import com.czg.account.entity.SysUsersRoles;
import com.czg.account.service.CashMenuService;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.SysMenuService;
import com.czg.account.vo.MenuVO;
import com.czg.exception.ApiNotPrintException;
@ -17,6 +19,7 @@ import com.czg.sa.StpKit;
import com.czg.service.account.mapper.SysMenuMapper;
import com.czg.service.account.mapper.SysUsersRolesMapper;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.DbChain;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
@ -28,6 +31,7 @@ import java.util.stream.Collectors;
/**
* 系统菜单 服务层实现
*
* @author Administrator
*/
@Service
@ -39,6 +43,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
private SysUsersRolesMapper sysUsersRolesMapper;
@Resource
private CashMenuService cashMenuService;
@Resource
private ShopInfoService shopInfoService;
@Override
public List<MenuVO> getMenu() {
@ -47,7 +53,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
List<SysUsersRoles> roleList = sysUsersRolesMapper.selectListByQuery(query().select(SysUsersRoles::getRoleId).eq(SysUsersRoles::getUserId, sysUserId));
List<Long> roleIdList = roleList.stream().map(SysUsersRoles::getRoleId).toList();
Long shopId = StpKit.USER.getShopId(0L);
boolean isEnableSync = StpKit.USER.isEnableSync(shopId);
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
boolean isEnableSync = mainShopId.equals(shopId);
if (isEnableSync && roleIdList.contains(2L)) {
List<SysMenu> headShopPromissionList = sysMenuMapper.selectByRoleId(2L);
List<SysMenu> branchShopPromissionList = sysMenuMapper.selectByRoleId(3L);
@ -83,7 +90,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
return allMenus.stream()
.map(item -> BeanUtil.copyProperties(item, MenuVO.class))
.collect(Collectors.toList());
}else {
} else {
allMenus = list(new QueryWrapper().orderBy(SysMenu::getMenuSort, false));
return buildMenuTree(allMenus);
}

View File

@ -6,6 +6,7 @@ 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.ShopUserDetailDTO;
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
import com.czg.account.entity.*;
import com.czg.account.service.*;
@ -241,4 +242,9 @@ public class UShopUserServiceImpl implements UShopUserService {
shopUserDetailDTO.setPayPwd(userInfo.getPayPwd());
return shopUserDetailDTO;
}
@Override
public Long updateMoney(ShopUserMoneyEditDTO shopUserEditDTO) {
return shopUserService.updateMoney(shopUserEditDTO);
}
}

View File

@ -24,13 +24,13 @@ import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
/**
* 服务层实现
* 服务层实现
*
* @author Administrator
* @since 2025-02-11
*/
@DubboService
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService{
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {
@Resource
private ShopUserMapper shopUserMapper;
@Resource
@ -59,7 +59,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
if (save(userInfo)) {
if (shopId != -1L) {
ShopUser shopUser = BeanUtil.copyProperties(userInfo, ShopUser.class);
return shopUserMapper.updateByQuery(shopUser, new QueryWrapper().eq(ShopUser::getShopId, shopId).eq(ShopUser::getUserId, userId)) > 0;
return shopUserMapper.updateByQuery(shopUser, new QueryWrapper().eq(ShopUser::getSourceShopId, shopId).eq(ShopUser::getUserId, userId)) > 0;
}
return true;
}

View File

@ -859,7 +859,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.CASH_IN);
}
//更新会员余额 并生成流水
Long flowId = shopUserService.updateMoney(shopUser.getSourceShopId(), shopUserMoneyEditDTO);
Long flowId = shopUserService.updateMoney(shopUserMoneyEditDTO);
if (payment.getRelatedId() == null) {
return;
}

View File

@ -239,7 +239,7 @@ public class PayServiceImpl implements PayService {
.setBizEnum(ShopUserFlowBizEnum.ORDER_PAY)
.setRelationId(orderInfo.getId());
//更新会员余额 并生成流水
Long flowId = shopUserService.updateMoney(shopUser.getSourceShopId(), shopUserMoneyEditDTO);
Long flowId = shopUserService.updateMoney(shopUserMoneyEditDTO);
orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
LocalDateTime.now(), flowId, PayEnums.VIP_PAY);
return CzgResult.success();
@ -370,7 +370,7 @@ public class PayServiceImpl implements PayService {
.setRemark("现金充值")
.setBizEnum(ShopUserFlowBizEnum.CASH_IN);
//更新会员余额 并生成流水
Long flowId = shopUserService.updateMoney(shopUser.getSourceShopId(), shopUserMoneyEditDTO);
Long flowId = shopUserService.updateMoney(shopUserMoneyEditDTO);
//TODO 以前的会员活动
//shopActivateService.giveActivate(shopUser, payParam.getAmount(), payParam.getActivateId(), flowId);
return CzgResult.success();
@ -535,7 +535,7 @@ public class PayServiceImpl implements PayService {
.setRelationId(refPaymentId)
.setRechargeId(inFlow.getId());
//更新会员余额 并生成流水
shopUserService.updateMoney(shopUser.getSourceShopId(), shopUserMoneyEditDTO);
shopUserService.updateMoney(shopUserMoneyEditDTO);
userFlowService.updateRefund(inFlow.getId(), refPayParam.getRefAmount());
if (giftFlow != null && (giftFlow.getAmount().subtract(giftFlow.getRefundAmount())).compareTo(BigDecimal.ZERO) > 0) {
ShopUserMoneyEditDTO giftFlowEdit = new ShopUserMoneyEditDTO()
@ -547,7 +547,7 @@ public class PayServiceImpl implements PayService {
.setRelationId(refPaymentId)
.setRechargeId(giftFlow.getId());
//更新会员余额 并生成流水
shopUserService.updateMoney(shopUser.getSourceShopId(), giftFlowEdit);
shopUserService.updateMoney(giftFlowEdit);
userFlowService.updateRefund(giftFlow.getId(), giftFlow.getAmount());
}
//移除优惠券
@ -670,7 +670,7 @@ public class PayServiceImpl implements PayService {
.setType(1)
.setRelationId(orderInfo.getId())
.setBizEnum(ShopUserFlowBizEnum.ORDER_REFUND);
shopUserService.updateMoney(shopUser.getSourceShopId(), shopUserMoneyEditDTO);
shopUserService.updateMoney(shopUserMoneyEditDTO);
} else if (orderInfo.getPayType().equals(PayEnums.CREDIT_PAY.getValue())) {
AssertUtil.isNull(orderInfo.getCreditBuyerId(), "挂账单退款失败,未查询到挂账人");
buyerOrderService.partRefund(orderInfo.getCreditBuyerId().toString(), orderInfo.getId(), param.getRefundAmount());