|
|
|
|
@@ -2,23 +2,29 @@ package com.czg.service.account.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.CoordinateUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.crypto.SecureUtil;
|
|
|
|
|
import com.czg.account.dto.PageDTO;
|
|
|
|
|
import com.czg.account.dto.shopinfo.ShopInfoAddDTO;
|
|
|
|
|
import com.czg.account.dto.shopinfo.ShopInfoByCodeDTO;
|
|
|
|
|
import com.czg.account.dto.shopinfo.ShopInfoEditDTO;
|
|
|
|
|
import com.czg.account.entity.*;
|
|
|
|
|
import com.czg.account.service.*;
|
|
|
|
|
import com.czg.enums.StatusEnum;
|
|
|
|
|
import com.czg.exception.ApiNotPrintException;
|
|
|
|
|
import com.czg.exception.CzgException;
|
|
|
|
|
import com.czg.sa.StpKit;
|
|
|
|
|
import com.czg.service.account.mapper.ShopInfoMapper;
|
|
|
|
|
import com.czg.utils.AssertUtil;
|
|
|
|
|
import com.czg.utils.GeoUtil;
|
|
|
|
|
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.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author Administrator
|
|
|
|
|
@@ -28,11 +34,27 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
|
|
|
|
@Resource
|
|
|
|
|
private SysUserService sysUserService;
|
|
|
|
|
@Resource
|
|
|
|
|
private SysUsersRolesService sysUsersRolesService;
|
|
|
|
|
@Resource
|
|
|
|
|
private SysRoleService sysRoleService;
|
|
|
|
|
@Resource
|
|
|
|
|
private MerchantRegisterService merchantRegisterService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ShopTableService shopTableService;
|
|
|
|
|
|
|
|
|
|
private ShopInfo getShopInfo(Long shopId) {
|
|
|
|
|
ShopInfo shopInfo = getById(shopId);
|
|
|
|
|
if (shopInfo == null) {
|
|
|
|
|
throw new ApiNotPrintException("店铺不存在");
|
|
|
|
|
}
|
|
|
|
|
if ((DateUtil.date().toLocalDateTime().isAfter(shopInfo.getExpireTime())) || shopInfo.getStatus() != StatusEnum.ENABLED.value()) {
|
|
|
|
|
throw new ApiNotPrintException("店铺已过期,请联系商家");
|
|
|
|
|
}
|
|
|
|
|
if (StatusEnum.DISABLE.value() == shopInfo.getOnSale()) {
|
|
|
|
|
throw new ApiNotPrintException("店铺已停业,请联系商家");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shopInfo.setBookingSms(null);
|
|
|
|
|
shopInfo.setOperationPwd(null);
|
|
|
|
|
shopInfo.setBindAccount(null);
|
|
|
|
|
return shopInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Page<ShopInfo> get(PageDTO pageDTO, String shopName, Integer status) {
|
|
|
|
|
@@ -99,4 +121,24 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
|
|
|
|
public ShopInfo detail() {
|
|
|
|
|
return queryChain().eq(ShopInfo::getId, StpKit.USER.getLoginIdAsLong()).one();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ShopInfoByCodeDTO getByCode(String tableCode, String lat, String lng, boolean checkState) {
|
|
|
|
|
ShopTable shopTable = shopTableService.queryChain().eq(ShopTable::getTableCode, tableCode).one();
|
|
|
|
|
if (shopTable == null) {
|
|
|
|
|
throw new ApiNotPrintException("错误的台桌码");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (checkState && !shopTable.canUseByStatus()) {
|
|
|
|
|
throw new ApiNotPrintException("台桌状态不可用");
|
|
|
|
|
}
|
|
|
|
|
ShopInfo shopInfo = getShopInfo(shopTable.getShopId());
|
|
|
|
|
|
|
|
|
|
double distance = 0;
|
|
|
|
|
if (StrUtil.isAllNotBlank(lat, lng, shopInfo.getLat(), shopInfo.getLng())) {
|
|
|
|
|
// 计算距离,单位:米
|
|
|
|
|
distance = GeoUtil.getDistance(Long.parseLong(shopInfo.getLat()), Long.parseLong(shopInfo.getLng()), Long.parseLong(lat), Long.parseLong(lng));
|
|
|
|
|
}
|
|
|
|
|
return new ShopInfoByCodeDTO(distance, shopInfo, shopTable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|