Просмотр исходного кода

Merge remote-tracking branch 'origin/main' into main

# Conflicts:
#	fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendCurrencyController.java
pengzhenggao 1 неделя назад
Родитель
Сommit
18a3438ade

+ 1 - 1
fuintBackend/fuint-application/src/main/java/com/fuint/common/dto/VersionDto.java

@@ -44,7 +44,7 @@ public class VersionDto extends Page implements Serializable {
     private Date effectiveDate;
 
     @ApiModelProperty("版本id")
-    @TableId(value = "ID", type = IdType.AUTO)
+    @TableId(value = "id", type = IdType.ID_WORKER)
     private Long id;
 
     @ApiModelProperty("是否强制更新 0否 1是")

+ 5 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/TableInfoService.java

@@ -70,4 +70,9 @@ public interface TableInfoService extends IService<MtTableInfo> {
     List<MtTableInfo> queryTableInfoListByParams(Map<String, Object> params) throws BusinessCheckException;
 
 	List<MtTableInfo> selectTableListByStoreId(Long storeId, Long categoryId);
+
+    /**
+     * 校验分类是否存在
+     */
+    boolean existCategory(Long categoryId);
 }

+ 9 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/AccountServiceImpl.java

@@ -363,6 +363,10 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
         String password = loginRequest.getPassword();
         String captchaCode = loginRequest.getCaptchaCode();
         String uuid = loginRequest.getUuid();
+        String loginFrom = loginRequest.getLoginFrom();
+
+
+
 
         Boolean captchaVerify = captchaService.checkCodeByUuid(captchaCode, uuid);
         if (!captchaVerify) {
@@ -378,6 +382,11 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
             }
 
             TAccount tAccount = getAccountInfoById(accountInfo.getId());
+
+            if (StringUtils.equals("cashier", loginFrom) && ( tAccount.getStoreId() == null || tAccount.getStoreId() == 0L) ){
+                throw new BusinessCheckException("平台账号暂无权限登录");
+            }
+
             String myPassword = tAccount.getPassword();
             String inputPassword = getEntryptPassword(password, tAccount.getSalt());
             if (!myPassword.equals(inputPassword) || !tAccount.getAccountStatus().toString().equals("1")) {

+ 25 - 1
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/CartServiceImpl.java

@@ -9,9 +9,11 @@ import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.repository.mapper.MtCartMapper;
 import com.fuint.repository.mapper.MtGoodsMapper;
 import com.fuint.repository.mapper.MtGoodsSkuMapper;
+import com.fuint.repository.mapper.MtTableInfoMapper;
 import com.fuint.repository.model.MtCart;
 import com.fuint.repository.model.MtGoods;
 import com.fuint.repository.model.MtGoodsSku;
+import com.fuint.repository.model.MtTableInfo;
 import com.fuint.utils.StringUtil;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
@@ -38,6 +40,8 @@ public class CartServiceImpl extends ServiceImpl<MtCartMapper, MtCart> implement
 
     private MtGoodsSkuMapper mtGoodsSkuMapper;
 
+    private MtTableInfoMapper mtTableInfoMapper;
+
     /**
      * 切换购物车给会员
      *
@@ -310,7 +314,7 @@ public class CartServiceImpl extends ServiceImpl<MtCartMapper, MtCart> implement
     @OperationServiceLog(description = "执行挂单")
     @Transactional(rollbackFor = Exception.class)
     public MtCart setHangNo(Long cartId, String hangNo, String isVisitor) throws BusinessCheckException {
-        MtCart mtCart = mtCartMapper.selectById(cartId);
+       /* MtCart mtCart = mtCartMapper.selectById(cartId);
         if (mtCart != null) {
             mtCart.setHangNo(hangNo);
             mtCart.setUpdateTime(new Date());
@@ -318,7 +322,27 @@ public class CartServiceImpl extends ServiceImpl<MtCartMapper, MtCart> implement
             this.updateById(mtCart);
         } else {
             throw new BusinessCheckException("执行挂单失败");
+        }*/
+        // -------------------- 参数校验 --------------------
+        // 校验桌号有效性
+        LambdaQueryWrapper<MtTableInfo> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(MtTableInfo::getTableNumber, hangNo);
+        Integer tableCount = mtTableInfoMapper.selectCount(queryWrapper);
+        if (tableCount == null || tableCount == 0) {
+            throw new BusinessCheckException("执行挂单失败,桌号不存在,请确认后重试");
         }
+
+        // -------------------- 业务处理 --------------------
+        MtCart mtCart = mtCartMapper.selectById(cartId);
+        if (mtCart == null) {
+            throw new BusinessCheckException("执行挂单失败,购物车记录不存在");
+        }
+
+        // -------------------- 更新数据 --------------------
+        mtCart.setHangNo(hangNo);
+        mtCart.setUpdateTime(new Date());
+        mtCart.setIsVisitor(isVisitor);
+        this.updateById(mtCart);
         return mtCart;
     }
 }

+ 7 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/TableInfoServiceImpl.java

@@ -173,4 +173,11 @@ public class TableInfoServiceImpl extends ServiceImpl<MtTableInfoMapper, MtTable
                 .eq(MtTableInfo::getCategoryId, categoryId)
                 .eq(MtTableInfo::getDeleteFlag, 0));
     }
+    @Override
+    public boolean existCategory(Long categoryId) {
+        return mtTableInfoMapper.selectCount(
+                new LambdaQueryWrapper<MtTableInfo>()
+                        .eq(MtTableInfo::getId, categoryId)
+        ) > 0;
+    }
 }

+ 3 - 5
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendAccountController.java

@@ -1,5 +1,6 @@
 package com.fuint.module.backendApi.controller;
 
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.fuint.common.Constants;
 import com.fuint.common.dto.AccountDto;
 import com.fuint.common.dto.AccountInfo;
@@ -28,10 +29,7 @@ import lombok.AllArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 后台管理员管理
@@ -318,7 +316,7 @@ public class BackendAccountController extends BaseController {
         }
 
         AccountInfo accountInfo = tAccountService.getAccountByName(accountName);
-        if (accountInfo != null && accountInfo.getId() != id.intValue()) {
+        if (accountInfo != null && !Objects.equals(accountInfo.getId(),id)) {
             return getFailureResult(201, "该用户名已存在");
         }
 

+ 39 - 10
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendCashierController.java

@@ -18,6 +18,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.beans.BeanUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.lang.reflect.InvocationTargetException;
@@ -373,7 +374,6 @@ public class BackendCashierController extends BaseController {
         if (StringUtil.isEmpty(userId)) {
             isVisitor = YesOrNoEnum.YES.getKey();
         }
-
         if (StringUtil.isNotEmpty(cartIds)) {
             String[] ids = cartIds.split(",");
             if (ids.length > 0) {
@@ -400,34 +400,63 @@ public class BackendCashierController extends BaseController {
         if (accountInfo == null) {
             return getFailureResult(1001, I18nUtil.getMessage("notAuthenticated"));
         }
+        // 获取当前店铺ID(从登录账户信息中)
         Long storeId = accountInfo.getStoreId();
-        //获取餐桌列表
-        List<MtTableInfo> tableInfoList = tableInfoService.selectTableListByStoreId(storeId,categoryId);
+        // -------------------- 新增校验:分类存在性检查 --------------------
+        if (!tableInfoService.existCategory(categoryId)) {
+//            log.warn("请求非法分类 | storeId={} categoryId={}", storeId, categoryId);
+            return getFailureResult(2001, "该餐桌分类不存在");
+        }
 
+        //获取指定分类的餐桌列表
+        //调用tableInfoService查询当前店铺下的餐桌
+        List<MtTableInfo> tableInfoList = tableInfoService.selectTableListByStoreId(storeId,categoryId);
+        // 构建返回数据列表
         List<HangUpDto> dataList = new ArrayList<>();
 
+        // 遍历每个餐桌,检查是否有挂单
 	    for (MtTableInfo mtTableInfo : tableInfoList) {
+            // 从餐桌信息中获取桌号作为挂单号
 		    String hangNo = mtTableInfo.getTableNumber();
+            //构造查询参数
 		    Map<String, Object> param = new HashMap<>();
-		    param.put("hangNo", hangNo);
-		    param.put("merchantId", accountInfo.getMerchantId());
-		    param.put("storeId", storeId);
+		    param.put("hangNo", hangNo);// 当前桌号
+		    param.put("merchantId", accountInfo.getMerchantId());// 商户ID
+		    param.put("storeId", storeId);  // 店铺ID
+            //查询关联的购物车列表(挂单记录)
 		    List<MtCart> cartList = cartService.queryCartListByParams(param);
+            //构建返回DTO对象
 		    HangUpDto dto = new HangUpDto();
+            // 设置默认值
 		    dto.setIsEmpty(true);
 		    if (!cartList.isEmpty()) {
+                // 存在挂单时的处理逻辑
+
+                //获取用户信息
                 Long userId = cartList.get(0).getUserId();
 			    String isVisitor = cartList.get(0).getIsVisitor();
-			    Map<String, Object> cartInfo = orderService.calculateCartGoods(accountInfo.getMerchantId(), userId, cartList, 0L, false, PlatformTypeEnum.PC.getCode(), OrderModeEnum.ONESELF.getKey());
-			    dto.setNum(Integer.parseInt(cartInfo.get("totalNum").toString()));
-			    dto.setAmount(new BigDecimal(cartInfo.get("totalPrice").toString()));
+                // 计算购物车商品总价和数量 调用订单服务进行计算
+			    Map<String, Object> cartInfo = orderService.calculateCartGoods(
+                        accountInfo.getMerchantId(),
+                        userId,
+                        cartList,
+                        0L,  // 使用的卡券ID 未使用优惠券
+                        false,  // isUsePoint 不使用积分
+                        PlatformTypeEnum.PC.getCode(),  // 平台类型:PC端
+                        OrderModeEnum.ONESELF.getKey()// 订单模式:自取
+                );
+                //填充数据
+			    dto.setNum(Integer.parseInt(cartInfo.get("totalNum").toString()));//数量
+			    dto.setAmount(new BigDecimal(cartInfo.get("totalPrice").toString()));//商品总价
+                // 非访客订单时获取会员信息
 			    if (isVisitor.equals(YesOrNoEnum.NO.getKey())) {
 				    MtUser userInfo = memberService.queryMemberById(userId);
 				    dto.setMemberInfo(userInfo);
 			    }
+                //设置更新时间(取第一个购物车记录的更新时间)
 			    String dateTime = DateUtil.formatDate(cartList.get(0).getUpdateTime(), "yyyy-MM-dd HH:mm:ss");
 			    dto.setDateTime(dateTime);
-			    dto.setIsEmpty(false);
+			    dto.setIsEmpty(false);// 标记为有挂单
 		    }
 		    dto.setHangNo(hangNo);
 		    dataList.add(dto);

+ 1 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendCurrencyController.java

@@ -4,6 +4,7 @@ import com.fuint.common.dto.ext.CurrencyDto;
 import com.fuint.common.param.PageParam;
 import com.fuint.common.service.CurrencyService;
 import com.fuint.common.util.I18nUtil;
+import com.fuint.common.util.TokenUtil;
 import com.fuint.common.vo.CurrencyVo;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.web.BaseController;

+ 1 - 1
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendStoreController.java

@@ -212,7 +212,7 @@ public class BackendStoreController extends BaseController {
 		String contact = CommonUtil.replaceXSS(params.get("contact").toString());
 		String phone = CommonUtil.replaceXSS(params.get("phone").toString());
 		String countryId = params.get("countryId") == null ? "" : CommonUtil.replaceXSS(params.get("countryId").toString());
-		String currencyId = params.get("currencyId") == null ? YesOrNoEnum.NO.getKey() : CommonUtil.replaceXSS(params.get("currencyId").toString());
+		String currencyId = params.get("currencyId") == null ? null : CommonUtil.replaceXSS(params.get("currencyId").toString());
 		String serviceFeeRate = params.get("serviceFeeRate") == null ? "" : CommonUtil.replaceXSS(params.get("serviceFeeRate").toString());
 		String description = params.get("description") == null ? "" : CommonUtil.replaceXSS(params.get("description").toString());
 		String isDefault = params.get("isDefault") == null ? YesOrNoEnum.NO.getKey() : CommonUtil.replaceXSS(params.get("isDefault").toString());

+ 3 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/request/LoginRequest.java

@@ -24,4 +24,7 @@ public class LoginRequest implements Serializable {
 
     @ApiModelProperty(value="图形验证码uuid", name="uuid")
     private String uuid;
+
+    @ApiModelProperty(value="登录入口", name="loginFrom")
+    private String loginFrom;
 }

+ 9 - 7
fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtVersion.java

@@ -33,6 +33,14 @@ public class MtVersion implements Serializable {
     @TableField(value = "create_user_id",fill = FieldFill.INSERT)
     private String createUserId;
 
+    @ApiModelProperty("更新时间")
+    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
+    private Date updateTime;
+
+    @ApiModelProperty("修改用户id")
+    @TableField(value = "update_user_id",fill = FieldFill.INSERT_UPDATE)
+    private String updateUserId;
+
     @ApiModelProperty("是否删除 0否 1是")
     private Integer deleteFlag;
 
@@ -46,7 +54,7 @@ public class MtVersion implements Serializable {
     private Date effectiveDate;
 
     @ApiModelProperty("版本id")
-    @TableId(value = "ID", type = IdType.AUTO)
+    @TableId(value = "id", type = IdType.ID_WORKER)
     private Long id;
 
     @ApiModelProperty("是否强制更新 0否 1是")
@@ -70,12 +78,6 @@ public class MtVersion implements Serializable {
     @ApiModelProperty("版本类型")
     private String type;
 
-    @ApiModelProperty("更新时间")
-//    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
-    private Date updateTime;
 
-    @ApiModelProperty("修改用户id")
-//    @TableField(value = "update_user_id",fill = FieldFill.INSERT_UPDATE)
-    private String updateUserId;
 
 }