Merge remote-tracking branch 'origin/master'

This commit is contained in:
Tankaikai
2025-03-17 11:02:15 +08:00
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-service/account-service/src/main/resources/rebel.xml
/cash-api/account-server/src/main/resources/rebel.xml /cash-api/account-server/src/main/resources/rebel.xml
/logs/ /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.PointsExchangeRecordService;
import com.czg.account.service.ShopUserFlowService; import com.czg.account.service.ShopUserFlowService;
import com.czg.account.service.ShopUserService; import com.czg.account.service.ShopUserService;
import com.czg.annotation.Debounce;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.utils.PageUtil; import com.czg.utils.PageUtil;
@@ -70,6 +71,7 @@ public class UShopUserController {
* @return 是否成功 * @return 是否成功
*/ */
@PostMapping @PostMapping
@Debounce("#shopUserAddDTO.phone")
public CzgResult<Boolean> join(@RequestBody @Validated ShopUserAddDTO shopUserAddDTO) { public CzgResult<Boolean> join(@RequestBody @Validated ShopUserAddDTO shopUserAddDTO) {
return CzgResult.success(shopUserService.join(StpKit.USER.getShopId(), StpKit.USER.getLoginIdAsLong(), shopUserAddDTO)); return CzgResult.success(shopUserService.join(StpKit.USER.getShopId(), StpKit.USER.getLoginIdAsLong(), shopUserAddDTO));
} }

View File

@@ -1,5 +1,6 @@
package com.czg.controller.admin; package com.czg.controller.admin;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.log.annotation.OperationLog; import com.czg.log.annotation.OperationLog;
import com.czg.order.entity.ShopOrderStatistic; import com.czg.order.entity.ShopOrderStatistic;
import com.czg.order.param.DataSummaryProductSaleParam; import com.czg.order.param.DataSummaryProductSaleParam;
@@ -38,6 +39,7 @@ public class DataSummaryController {
*/ */
@GetMapping("trade") @GetMapping("trade")
@OperationLog("营业板块-上半部分") @OperationLog("营业板块-上半部分")
@SaStaffCheckPermission("yun_xu_cha_kan_jing_ying_shu_ju")
//@SaAdminCheckPermission("dataSummary:trade") //@SaAdminCheckPermission("dataSummary:trade")
public CzgResult<ShopOrderStatistic> getTradeData(DataSummaryTradeParam param) { public CzgResult<ShopOrderStatistic> getTradeData(DataSummaryTradeParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class); ValidatorUtil.validateEntity(param, DefaultGroup.class);
@@ -52,6 +54,7 @@ public class DataSummaryController {
*/ */
@GetMapping("productSaleDate") @GetMapping("productSaleDate")
@OperationLog("商品销售-右下") @OperationLog("商品销售-右下")
@SaStaffCheckPermission("yun_xu_cha_kan_jing_ying_shu_ju")
//@SaAdminCheckPermission("dataSummary:productSaleData") //@SaAdminCheckPermission("dataSummary:productSaleData")
public CzgResult<Page<DataSummaryProductSaleRankingVo>> getProductSaleData(DataSummaryProductSaleParam param) { public CzgResult<Page<DataSummaryProductSaleRankingVo>> getProductSaleData(DataSummaryProductSaleParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class); ValidatorUtil.validateEntity(param, DefaultGroup.class);
@@ -68,6 +71,7 @@ public class DataSummaryController {
*/ */
@GetMapping("dateAmount") @GetMapping("dateAmount")
@OperationLog("销售趋势柱状图 左下") @OperationLog("销售趋势柱状图 左下")
@SaStaffCheckPermission("yun_xu_cha_kan_jing_ying_shu_ju")
//@SaAdminCheckPermission("dataSummary:dateAmount") //@SaAdminCheckPermission("dataSummary:dateAmount")
public CzgResult<DataSummaryDateAmountVo> getDateAmount(@RequestParam Integer day) { public CzgResult<DataSummaryDateAmountVo> getDateAmount(@RequestParam Integer day) {
AssertUtil.isNull(day, "天数不能为空"); AssertUtil.isNull(day, "天数不能为空");
@@ -82,6 +86,7 @@ public class DataSummaryController {
* @param day 天数 * @param day 天数
*/ */
@GetMapping("datePayType") @GetMapping("datePayType")
@SaStaffCheckPermission("yun_xu_cha_kan_jing_ying_shu_ju")
//@SaAdminCheckPermission("dataSummary:datePayType") //@SaAdminCheckPermission("dataSummary:datePayType")
public CzgResult<DataSummaryPayTypeVo> shopSummaryPayType(@RequestParam Integer day) { public CzgResult<DataSummaryPayTypeVo> shopSummaryPayType(@RequestParam Integer day) {
Long shopId = StpKit.USER.getShopId(0L); 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}) @RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE})
public void handoverPrint(String id) { 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.ShopProdStatisticService;
import com.czg.order.service.ShopTableOrderStatisticService; import com.czg.order.service.ShopTableOrderStatisticService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -11,6 +12,7 @@ import org.springframework.stereotype.Component;
* @author Administrator * @author Administrator
*/ */
@Component @Component
@Slf4j
public class StatisticTask { public class StatisticTask {
@Resource @Resource
private ShopTableOrderStatisticService shopTableOrderStatisticService; private ShopTableOrderStatisticService shopTableOrderStatisticService;
@@ -21,8 +23,11 @@ public class StatisticTask {
@Scheduled(cron = "0 0 9 * * ?") @Scheduled(cron = "0 0 9 * * ?")
public void run() { public void run() {
long start = System.currentTimeMillis();
log.info("定时任务执行,开始统计数据");
shopOrderStatisticService.statistic(); shopOrderStatisticService.statistic();
shopProdStatisticService.statistic(); shopProdStatisticService.statistic();
shopTableOrderStatisticService.statistic(); shopTableOrderStatisticService.statistic();
log.info("定时任务执行完毕,耗时:{}ms", start - System.currentTimeMillis());
} }
} }

View File

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

View File

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

View File

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

View File

@@ -18,7 +18,7 @@ public interface RedisCst {
*/ */
class classKeyExpired { class classKeyExpired {
//订单key过期 //订单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.setTimeout(1000);
adminConfig.setTokenStyle("simple-uuid"); adminConfig.setTokenStyle("simple-uuid");
adminConfig.setIsConcurrent(true); adminConfig.setIsConcurrent(true);
adminConfig.setIsShare(true); adminConfig.setIsShare(false);
MyStpLogic.ADMIN_LOGIC.setConfig(adminConfig); MyStpLogic.ADMIN_LOGIC.setConfig(adminConfig);
// 小程序配置 // 小程序配置

View File

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

View File

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

View File

@@ -33,8 +33,7 @@ public class ShopInfoAddDTO {
@NotNull(message = "状态不为空") @NotNull(message = "状态不为空")
private String detail; private String detail;
// @NotNull(message = "角色id不为空") // @NotNull(message = "角色id不为空")
// todo 默认为管理员角色,后期调整 private Long roleId;
private Long roleId = 1L;
private String phone; 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.CouponReceiveVo;
import com.czg.account.vo.UserCouponVo; import com.czg.account.vo.UserCouponVo;
import com.mybatisflex.core.BaseMapper; import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@@ -16,8 +17,9 @@ import java.util.List;
*/ */
public interface ShopActivateCouponRecordMapper extends BaseMapper<ShopActivateCouponRecord> { 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<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.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -159,7 +160,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
} }
redisService.del(RedisCst.LOGIN_CODE + loginDTO.uuid()); 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 @NotNull

View File

@@ -56,8 +56,13 @@ public class ShopSongServiceImpl extends ServiceImpl<ShopSongMapper, ShopSong> i
}else { }else {
code = RandomStringUtils.randomAlphanumeric(12); code = RandomStringUtils.randomAlphanumeric(12);
redisService.set(key, code); redisService.set(key, code);
redisService.set(key, shopId);
} }
return code; 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.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.List; 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()); JoinQueryWrapper queryWrapper = new JoinQueryWrapper().eq(ShopUser::getShopId, StpKit.USER.getShopId());
if (StrUtil.isNotBlank(key)) { if (StrUtil.isNotBlank(key)) {
queryWrapper.and(q -> { queryWrapper.and(q -> {
q.like(UserInfo::getNickName, key).or(r -> { q.like(ShopUser::getNickName, key).or(r -> {
r.like(UserInfo::getPhone, key); 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())); 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 orderInfo = new OrderInfo();
orderInfo.setUserId(userId); 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); BeanUtil.copyProperties(shopUserAddDTO, userInfo);
userInfoService.updateById(userInfo); userInfoService.updateById(userInfo);

View File

@@ -92,7 +92,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean add(RoleAddDTO roleAddDTO) { 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) { if (roleCount > 0) {
throw new ApiNotPrintException("此角色名称已存在"); throw new ApiNotPrintException("此角色名称已存在");
} }
@@ -120,7 +122,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
throw new ApiNotPrintException("角色不存在"); 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) { if (roleCount > 0) {
throw new ApiNotPrintException("此角色名称已存在"); throw new ApiNotPrintException("此角色名称已存在");
} }

View File

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

View File

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

View File

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

View File

@@ -192,6 +192,9 @@ public class PayServiceImpl implements PayService {
AssertUtil.isNull(shopUser, "会员不存在"); AssertUtil.isNull(shopUser, "会员不存在");
UserInfo userInfo = userInfoService.getById(shopUser.getUserId()); UserInfo userInfo = userInfoService.getById(shopUser.getUserId());
AssertUtil.isNull(userInfo, "用户信息不存在"); AssertUtil.isNull(userInfo, "用户信息不存在");
if (userInfo.getPayPwd() == null) {
return CzgResult.failure("未设置支付密码");
}
if (!userInfo.getPayPwd().equals(MD5Util.md5AsHex(payParam.getPwd()))) { if (!userInfo.getPayPwd().equals(MD5Util.md5AsHex(payParam.getPwd()))) {
return CzgResult.failure("支付密码错误"); return CzgResult.failure("支付密码错误");
} }
@@ -328,11 +331,17 @@ public class PayServiceImpl implements PayService {
} }
} }
if (shopUser.getIsVip().equals(0)) { if (shopUser.getIsVip().equals(0)) {
UpdateChain.of(ShopUser.class) //更新会员
.set(ShopUser::getIsVip, 1) ShopUser updateInfo = new ShopUser();
.set(ShopUser::getJoinTime, LocalDateTime.now()) updateInfo.setIsVip(1);
.eq(ShopUser::getId, payParam.getShopUserId()) updateInfo.setJoinTime(LocalDateTime.now());
.update(); 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() ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
.setId(shopUser.getId()) .setId(shopUser.getId())
@@ -544,13 +553,16 @@ public class PayServiceImpl implements PayService {
} else { } else {
orderDetail.setReturnNum(orderDetail.getReturnNum().add(refNum)); orderDetail.setReturnNum(orderDetail.getReturnNum().add(refNum));
if (orderDetail.getPackNumber().compareTo(BigDecimal.ZERO) > 0 && orderDetail.getPackNumber().compareTo(orderDetail.getNum().subtract(orderDetail.getReturnNum())) > 0) { 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.setRefundNo(refPayOrderNo);
orderDetail.setRefundRemark(orderDetail.getRefundRemark() + param.getRefundReason()); orderDetail.setRefundRemark(orderDetail.getRefundRemark() + param.getRefundReason());
if (isPay) { 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); orderDetailService.updateById(orderDetail);
if (orderDetail.getProductId() != null && orderDetail.getProductId() > 0) { if (orderDetail.getProductId() != null && orderDetail.getProductId() > 0) {
@@ -569,7 +581,7 @@ public class PayServiceImpl implements PayService {
orderInfo.setStatus(OrderStatusEnums.REFUND.getCode()); orderInfo.setStatus(OrderStatusEnums.REFUND.getCode());
// ssss // ssss
List<OrderDetail> orderDetails = orderDetailService.queryChain() 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()) .eq(OrderDetail::getOrderId, orderInfo.getId())
.list(); .list();
for (OrderDetail orderDetail : orderDetails) { 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)); Map<Long, ShopProductVo> productKv = productAllList.stream().collect(Collectors.toMap(ShopProductVo::getId, shopProductVo -> shopProductVo));
List<Long> prodGroupIdList = groupList.stream().map(ShopGroupProductVo::getId).distinct().toList(); 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()))); Map<Long, List<Long>> relationKv = relationList.stream().collect(Collectors.groupingBy(ProdGroupRelationDTO::getProdGroupId, Collectors.mapping(ProdGroupRelationDTO::getProductId, Collectors.toList())));
for (ShopGroupProductVo group : groupList) { for (ShopGroupProductVo group : groupList) {
List<Long> productIdList = relationKv.get(group.getId()); 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); return dayOfWeek.getDisplayName(TextStyle.FULL, Locale.ENGLISH);
} }
} }