Merge remote-tracking branch 'origin/master'

This commit is contained in:
Tankaikai 2025-03-17 11:02:15 +08:00
commit 066f70a3dd
24 changed files with 115 additions and 34 deletions

4
.gitignore vendored
View File

@ -56,3 +56,7 @@ build/
/cash-service/account-service/src/main/resources/rebel.xml
/cash-api/account-server/src/main/resources/rebel.xml
/logs/
/cash-api/account-server/src/main/resources/application-zs.yml
/cash-api/order-server/src/main/resources/application-zs.yml
/cash-api/product-server/src/main/resources/application-zs.yml
/cash-api/system-server/src/main/resources/application-zs.yml

View File

@ -9,6 +9,7 @@ import com.czg.account.entity.ShopUserFlow;
import com.czg.account.service.PointsExchangeRecordService;
import com.czg.account.service.ShopUserFlowService;
import com.czg.account.service.ShopUserService;
import com.czg.annotation.Debounce;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.utils.PageUtil;
@ -70,6 +71,7 @@ public class UShopUserController {
* @return 是否成功
*/
@PostMapping
@Debounce("#shopUserAddDTO.phone")
public CzgResult<Boolean> join(@RequestBody @Validated ShopUserAddDTO shopUserAddDTO) {
return CzgResult.success(shopUserService.join(StpKit.USER.getShopId(), StpKit.USER.getLoginIdAsLong(), shopUserAddDTO));
}

View File

@ -1,5 +1,6 @@
package com.czg.controller.admin;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.log.annotation.OperationLog;
import com.czg.order.entity.ShopOrderStatistic;
import com.czg.order.param.DataSummaryProductSaleParam;
@ -38,6 +39,7 @@ public class DataSummaryController {
*/
@GetMapping("trade")
@OperationLog("营业板块-上半部分")
@SaStaffCheckPermission("yun_xu_cha_kan_jing_ying_shu_ju")
//@SaAdminCheckPermission("dataSummary:trade")
public CzgResult<ShopOrderStatistic> getTradeData(DataSummaryTradeParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class);
@ -52,6 +54,7 @@ public class DataSummaryController {
*/
@GetMapping("productSaleDate")
@OperationLog("商品销售-右下")
@SaStaffCheckPermission("yun_xu_cha_kan_jing_ying_shu_ju")
//@SaAdminCheckPermission("dataSummary:productSaleData")
public CzgResult<Page<DataSummaryProductSaleRankingVo>> getProductSaleData(DataSummaryProductSaleParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class);
@ -68,6 +71,7 @@ public class DataSummaryController {
*/
@GetMapping("dateAmount")
@OperationLog("销售趋势柱状图 左下")
@SaStaffCheckPermission("yun_xu_cha_kan_jing_ying_shu_ju")
//@SaAdminCheckPermission("dataSummary:dateAmount")
public CzgResult<DataSummaryDateAmountVo> getDateAmount(@RequestParam Integer day) {
AssertUtil.isNull(day, "天数不能为空");
@ -82,6 +86,7 @@ public class DataSummaryController {
* @param day 天数
*/
@GetMapping("datePayType")
@SaStaffCheckPermission("yun_xu_cha_kan_jing_ying_shu_ju")
//@SaAdminCheckPermission("dataSummary:datePayType")
public CzgResult<DataSummaryPayTypeVo> shopSummaryPayType(@RequestParam Integer day) {
Long shopId = StpKit.USER.getShopId(0L);

View File

@ -63,6 +63,6 @@ public class PrintMqListener {
*/
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE})
public void handoverPrint(String id) {
invokeFun("handoverPrint", "java.order", id, (data) -> printerHandler.handler(data, PrinterHandler.PrintTypeEnum.ONE_AND_ORDER));
invokeFun("handoverPrint", "java.order", id, (data) -> printerHandler.handler(data, PrinterHandler.PrintTypeEnum.HANDOVER));
}
}

View File

@ -4,6 +4,7 @@ import com.czg.order.service.ShopOrderStatisticService;
import com.czg.order.service.ShopProdStatisticService;
import com.czg.order.service.ShopTableOrderStatisticService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -11,6 +12,7 @@ import org.springframework.stereotype.Component;
* @author Administrator
*/
@Component
@Slf4j
public class StatisticTask {
@Resource
private ShopTableOrderStatisticService shopTableOrderStatisticService;
@ -21,8 +23,11 @@ public class StatisticTask {
@Scheduled(cron = "0 0 9 * * ?")
public void run() {
long start = System.currentTimeMillis();
log.info("定时任务执行,开始统计数据");
shopOrderStatisticService.statistic();
shopProdStatisticService.statistic();
shopTableOrderStatisticService.statistic();
log.info("定时任务执行完毕,耗时:{}ms", start - System.currentTimeMillis());
}
}

View File

@ -1,5 +1,6 @@
package com.czg.controller.admin;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.log.annotation.OperationLog;
import com.czg.product.dto.ConsStockFlowDTO;
import com.czg.product.param.ConsCheckStockParam;
@ -34,6 +35,7 @@ public class ConsStockFlowController {
*/
@PostMapping("in")
@OperationLog("耗材入库")
@SaStaffCheckPermission("yun_xu_hao_cai_ru_ku")
//@SaAdminCheckPermission("consStockFlow:in")
public CzgResult<Void> inStock(@RequestBody ConsInOutStockHeadParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class);
@ -47,6 +49,7 @@ public class ConsStockFlowController {
*/
@PostMapping("out")
@OperationLog("耗材出库")
@SaStaffCheckPermission("yun_xu_hao_cai_chu_ku")
//@SaAdminCheckPermission("consStockFlow:out")
public CzgResult<Void> outStock(@RequestBody ConsInOutStockHeadParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class);
@ -73,6 +76,7 @@ public class ConsStockFlowController {
*/
@PostMapping("check")
@OperationLog("库存盘点")
@SaStaffCheckPermission("yun_xu_hao_cai_pan_dian")
//@SaAdminCheckPermission("consStockFlow:check")
public CzgResult<Void> checkStock(@RequestBody ConsCheckStockParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class);
@ -102,4 +106,4 @@ public class ConsStockFlowController {
Page<ConsStockFlowDTO> data = consStockFlowService.findConsStockFlowPage(param);
return CzgResult.success(data);
}
}
}

View File

@ -220,6 +220,7 @@ public class ProductController {
*/
@PostMapping("reportDamage")
@OperationLog("商品-报损")
@SaStaffCheckPermission("yun_xu_ti_jiao_bao_sun")
//@SaAdminCheckPermission("product:reportDamage")
public CzgResult<Void> reportDamage(@RequestBody ProductReportDamageParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class);

View File

@ -111,6 +111,14 @@ public class CzgControllerAdvice {
return CzgResult.success();
}
/**
* 订单超时 取消
*/
@ExceptionHandler(OrderCancelException.class)
public CzgResult<Object> handleOrderCancelException() {
return CzgResult.failure(701,"订单已过期,请重新下单");
}
/**
* 处理Hutool的断言抛出异常
*/

View File

@ -18,7 +18,7 @@ public interface RedisCst {
*/
class classKeyExpired {
//订单key过期
public static final String EXPIRED_ORDER = "expired.order:";
public static final String EXPIRED_ORDER = "expired:order:";
}

View File

@ -29,7 +29,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
// adminConfig.setTimeout(1000);
adminConfig.setTokenStyle("simple-uuid");
adminConfig.setIsConcurrent(true);
adminConfig.setIsShare(true);
adminConfig.setIsShare(false);
MyStpLogic.ADMIN_LOGIC.setConfig(adminConfig);
// 小程序配置

View File

@ -65,10 +65,13 @@ public class MyStpLogic {
throw new ApiNotPrintException("管理端登录必须传递店铺id");
}
SaSession session = logic.getSession().set("userId", id).set("isAdmin", isAdmin).set("isManager", loginType.equals(LoginType.MANAGER))
.set("loginType", loginType).set("account", account).set("shopName", shopName);
.set("loginType", loginType).set("account", account);
if (shopId != null) {
session.set("shopId", shopId);
}
if (shopName != null) {
session.set("shopName", shopName);
}
}
public void reLogin(long id) {

View File

@ -1,7 +1,10 @@
package com.czg.account.dto;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@ -10,6 +13,8 @@ import java.time.LocalDateTime;
* @author ww
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class QueryReceiveDto {
@NotNull(message = "优惠券id 不可为空")
private Long couponId;

View File

@ -33,8 +33,7 @@ public class ShopInfoAddDTO {
@NotNull(message = "状态不为空")
private String detail;
// @NotNull(message = "角色id不为空")
// todo 默认为管理员角色后期调整
private Long roleId = 1L;
private Long roleId;
private String phone;
/**
* 店铺注册类型

View File

@ -0,0 +1,16 @@
package com.czg.exception;
import java.io.Serial;
/**
* @author ww
* @description
*/
public class OrderCancelException extends RuntimeException{
@Serial
private static final long serialVersionUID = 1L;
public OrderCancelException(String message) {
super(message);
}
}

View File

@ -5,6 +5,7 @@ import com.czg.account.entity.ShopActivateCouponRecord;
import com.czg.account.vo.CouponReceiveVo;
import com.czg.account.vo.UserCouponVo;
import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -16,8 +17,9 @@ import java.util.List;
*/
public interface ShopActivateCouponRecordMapper extends BaseMapper<ShopActivateCouponRecord> {
List<CouponReceiveVo> queryReceive(QueryReceiveDto param);
List<CouponReceiveVo> queryReceive(@Param("param") QueryReceiveDto param);
List<ShopActivateCouponRecord> findByUser(List<Long> shopUserIds, Integer status);
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId,Integer type);
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type);
}

View File

@ -23,6 +23,7 @@ import jakarta.annotation.Resource;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -159,7 +160,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
}
redisService.del(RedisCst.LOGIN_CODE + loginDTO.uuid());
return new LoginVO(StpKit.USER.getTokenInfo(), promissionList, loginDTO.loginType(), shopInfo);
return new LoginVO(StpKit.USER.getTokenInfo(), new ArrayList<>(), loginDTO.loginType(), shopInfo);
}
@NotNull

View File

@ -56,8 +56,13 @@ public class ShopSongServiceImpl extends ServiceImpl<ShopSongMapper, ShopSong> i
}else {
code = RandomStringUtils.randomAlphanumeric(12);
redisService.set(key, code);
redisService.set(key, shopId);
}
return code;
}
public static void main(String[] args) {
String string = RandomStringUtils.randomAlphanumeric(12);
System.out.println(string);
}
}

View File

@ -35,6 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.Objects;
/**
@ -81,8 +82,8 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
JoinQueryWrapper queryWrapper = new JoinQueryWrapper().eq(ShopUser::getShopId, StpKit.USER.getShopId());
if (StrUtil.isNotBlank(key)) {
queryWrapper.and(q -> {
q.like(UserInfo::getNickName, key).or(r -> {
r.like(UserInfo::getPhone, key);
q.like(ShopUser::getNickName, key).or(r -> {
r.like(ShopUser::getPhone, key);
});
});
@ -272,7 +273,7 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
// 查询系统添加的会员
UserInfo oriInfo = userInfoService.getOne(new QueryWrapper().eq(UserInfo::getPhone, shopUserAddDTO.getPhone()));
if (oriInfo != null) {
if (oriInfo != null && !oriInfo.getId().equals(userId)) {
// 迁移订单
OrderInfo orderInfo = new OrderInfo();
orderInfo.setUserId(userId);
@ -288,7 +289,7 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
}
}
BeanUtil.copyProperties(shopUserAddDTO, shopUser);
BeanUtil.copyProperties(shopUserAddDTO, shopUser, "accountPoints", "amount");
BeanUtil.copyProperties(shopUserAddDTO, userInfo);
userInfoService.updateById(userInfo);

View File

@ -92,7 +92,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean add(RoleAddDTO roleAddDTO) {
long roleCount = queryChain().eq(SysRole::getName, roleAddDTO.name()).count();
long roleCount = queryChain().eq(SysRole::getName, roleAddDTO.name())
.eq(SysRole::getShopId, StpKit.USER.getShopId())
.count();
if (roleCount > 0) {
throw new ApiNotPrintException("此角色名称已存在");
}
@ -120,7 +122,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
throw new ApiNotPrintException("角色不存在");
}
long roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).ne(SysRole::getId, roleEditDTO.getId()).count();
long roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).ne(SysRole::getId, roleEditDTO.getId())
.eq(SysRole::getShopId, StpKit.USER.getShopId()).count();
if (roleCount > 0) {
throw new ApiNotPrintException("此角色名称已存在");
}

View File

@ -50,14 +50,14 @@
</select>
<select id="selectPageByKeyAndIsVip" resultType="com.czg.account.entity.ShopUser">
select tb_shop_user.*
from tb_user_info
left join tb_shop_user on tb_user_info.id = tb_shop_user.user_id ${qwSql}
from tb_shop_user
left join tb_user_info on tb_user_info.id = tb_shop_user.user_id ${qwSql}
limit ${pageOffset}, ${pageSize}
</select>
<select id="selectPageByKeyAndIsVip_COUNT" resultType="java.lang.Long">
select count(1)
from tb_user_info
left join tb_shop_user on tb_user_info.id = tb_shop_user.user_id ${qwSql}
from tb_shop_user
left join tb_user_info on tb_user_info.id = tb_shop_user.user_id ${qwSql}
</select>
<select id="selectVipCard_COUNT" resultType="java.lang.Long">
select count(1)

View File

@ -418,7 +418,7 @@ public interface PrinterImpl {
JSONObject jsonObject = (JSONObject) subItem;
jsonObject.getJSONArray("goods").forEach(item -> {
String proName = ((JSONObject) item).getString("proName");
String qty = ((JSONObject) item).getString("number -> 1");
String qty = ((JSONObject) item).getString("number");
builder.append(StrUtil.format("({}) x {}", proName, qty))
.append(signLabelInfo.br);
});

View File

@ -18,6 +18,7 @@ import com.czg.entity.notify.CzgPayNotifyDTO;
import com.czg.entity.notify.CzgRefundNotifyDTO;
import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.OrderCancelException;
import com.czg.order.dto.*;
import com.czg.order.entity.CashierCart;
import com.czg.order.entity.OrderDetail;
@ -257,7 +258,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
rabbitPublisher.sendOrderCancelMsg(orderInfo.getId().toString());
});
}
throw new ValidateException("订单已过期,请重新下单");
throw new OrderCancelException("订单已过期,请重新下单");
}
}
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
@ -265,6 +266,9 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
if (param.isVipPrice() && !shopInfo.getIsMemberPrice().equals(1)) {
throw new ValidateException("生成订单失败,该店铺不支持使用会员价");
}
if (param.getOrderAmount().compareTo(BigDecimal.ZERO) < 0) {
throw new ValidateException("生成订单失败订单金额不能小于0");
}
log.info("订单信息:{},优惠信息:{}", JSONObject.toJSONString(orderInfo), JSONObject.toJSONString(param));
Long shopId = orderInfo.getShopId();
AssertUtil.isNull(shopId, "生成支付订单失败,订单信息异常");
@ -699,6 +703,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
updateChain.set(OrderInfo::getPayType, payType.getValue());
}
updateChain.update();
orderDetailService.updateChain().set(OrderDetail::getStatus, OrderStatusEnums.DONE.getCode()).eq(OrderDetail::getOrderId, orderInfo.getId()).update();
// if (!"after-pay".equals(orderInfo.getPayMode())) {
//发送打票信息
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId().toString());
@ -786,8 +791,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
// 餐位费
if (shopInfo.getIsTableFee().equals(0)) {
orderInfo.setSeatAmount(shopInfo.getTableFee().multiply(new BigDecimal(param.getSeatNum())));
orderInfo.setSeatNum(param.getSeatNum());
}
orderInfo.setSeatNum(param.getSeatNum());
orderInfo.setUserId(param.getUserId());
orderInfo.setTableCode(param.getTableCode());
orderInfo.setPlaceNum(param.getPlaceNum());

View File

@ -192,6 +192,9 @@ public class PayServiceImpl implements PayService {
AssertUtil.isNull(shopUser, "会员不存在");
UserInfo userInfo = userInfoService.getById(shopUser.getUserId());
AssertUtil.isNull(userInfo, "用户信息不存在");
if (userInfo.getPayPwd() == null) {
return CzgResult.failure("未设置支付密码");
}
if (!userInfo.getPayPwd().equals(MD5Util.md5AsHex(payParam.getPwd()))) {
return CzgResult.failure("支付密码错误");
}
@ -328,11 +331,17 @@ public class PayServiceImpl implements PayService {
}
}
if (shopUser.getIsVip().equals(0)) {
UpdateChain.of(ShopUser.class)
.set(ShopUser::getIsVip, 1)
.set(ShopUser::getJoinTime, LocalDateTime.now())
.eq(ShopUser::getId, payParam.getShopUserId())
.update();
//更新会员
ShopUser updateInfo = new ShopUser();
updateInfo.setIsVip(1);
updateInfo.setJoinTime(LocalDateTime.now());
updateInfo.setId(payParam.getShopUserId());
shopUserService.updateById(updateInfo);
// UpdateChain.of(ShopUser.class)
// .set(ShopUser::getIsVip, 1)
// .set(ShopUser::getJoinTime, LocalDateTime.now())
// .eq(ShopUser::getId, payParam.getShopUserId())
// .update();
}
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
.setId(shopUser.getId())
@ -544,13 +553,16 @@ public class PayServiceImpl implements PayService {
} else {
orderDetail.setReturnNum(orderDetail.getReturnNum().add(refNum));
if (orderDetail.getPackNumber().compareTo(BigDecimal.ZERO) > 0 && orderDetail.getPackNumber().compareTo(orderDetail.getNum().subtract(orderDetail.getReturnNum())) > 0) {
orderDetail.setPackNumber(orderDetail.getPackNumber().subtract(orderDetail.getReturnNum()));
orderDetail.setPackNumber(orderDetail.getNum().subtract(orderDetail.getReturnNum()));
}
}
orderDetail.setRefundNo(refPayOrderNo);
orderDetail.setRefundRemark(orderDetail.getRefundRemark() + param.getRefundReason());
if (isPay) {
orderDetail.setReturnAmount(refundDetail.getReturnAmount());
orderDetail.setReturnAmount(refundDetail.getReturnAmount().add(refundDetail.getReturnAmount()));
if (orderDetail.getReturnAmount().compareTo(orderDetail.getPayAmount()) > 0) {
orderDetail.setReturnAmount(orderDetail.getPayAmount());
}
}
orderDetailService.updateById(orderDetail);
if (orderDetail.getProductId() != null && orderDetail.getProductId() > 0) {
@ -569,7 +581,7 @@ public class PayServiceImpl implements PayService {
orderInfo.setStatus(OrderStatusEnums.REFUND.getCode());
// ssss
List<OrderDetail> orderDetails = orderDetailService.queryChain()
.select(OrderDetail::getId, OrderDetail::getProductId, OrderDetail::getNum, OrderDetail::getReturnNum, OrderDetail::getReturnNum)
.select(OrderDetail::getId, OrderDetail::getProductId, OrderDetail::getNum, OrderDetail::getReturnNum, OrderDetail::getPackAmount, OrderDetail::getReturnNum)
.eq(OrderDetail::getOrderId, orderInfo.getId())
.list();
for (OrderDetail orderDetail : orderDetails) {

View File

@ -81,7 +81,7 @@ public class UProductServiceImpl extends ServiceImpl<ProductMapper, Product> imp
});
Map<Long, ShopProductVo> productKv = productAllList.stream().collect(Collectors.toMap(ShopProductVo::getId, shopProductVo -> shopProductVo));
List<Long> prodGroupIdList = groupList.stream().map(ShopGroupProductVo::getId).distinct().toList();
List<ProdGroupRelationDTO> relationList = prodGroupRelationMapper.selectListByQueryAs(query().select(ProdGroupRelation::getProdGroupId, ProdGroupRelation::getProductId).in(ProdGroupRelation::getProdGroupId, prodGroupIdList), ProdGroupRelationDTO.class);
List<ProdGroupRelationDTO> relationList = prodGroupIdList.isEmpty() ? new ArrayList<>() : prodGroupRelationMapper.selectListByQueryAs(query().select(ProdGroupRelation::getProdGroupId, ProdGroupRelation::getProductId).in(ProdGroupRelation::getProdGroupId, prodGroupIdList), ProdGroupRelationDTO.class);
Map<Long, List<Long>> relationKv = relationList.stream().collect(Collectors.groupingBy(ProdGroupRelationDTO::getProdGroupId, Collectors.mapping(ProdGroupRelationDTO::getProductId, Collectors.toList())));
for (ShopGroupProductVo group : groupList) {
List<Long> productIdList = relationKv.get(group.getId());
@ -167,4 +167,4 @@ public class UProductServiceImpl extends ServiceImpl<ProductMapper, Product> imp
return dayOfWeek.getDisplayName(TextStyle.FULL, Locale.ENGLISH);
}
}
}