扫码点餐部分
This commit is contained in:
@@ -69,8 +69,8 @@ public class ProductService {
|
||||
@Autowired
|
||||
private TbUserInfoMapper tbUserInfoMapper;
|
||||
|
||||
public Result queryShopIdByTableCode(String userId,String openId,String code,String lat,String lng) {
|
||||
if(StringUtils.isBlank(code)) return Result.fail("桌码信息为空");
|
||||
public Result queryShopIdByTableCode(String userId, String openId, String code, String lat, String lng) {
|
||||
if (StringUtils.isBlank(code)) return Result.fail("桌码信息为空");
|
||||
if (StringUtils.isBlank(lat) || lat.equals("undefined")) {
|
||||
lat = "34.343207";
|
||||
lng = "108.939645";
|
||||
@@ -88,43 +88,43 @@ public class ProductService {
|
||||
concurrentMap.put("storeInfo", shopInfo);
|
||||
concurrentMap.put("distance", distance);
|
||||
TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, tbShopTable.getShopId().toString());
|
||||
try{
|
||||
try {
|
||||
if (ObjectUtil.isEmpty(shopUser)) {
|
||||
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
// shopUser = tbShopUserMapper.selectByPhoneAndShopId(tbUserInfo.getTelephone(), shopId);
|
||||
// if(ObjectUtil.isEmpty(shopUser)){
|
||||
shopUser=new TbShopUser();
|
||||
shopUser.setName(tbUserInfo.getNickName());
|
||||
shopUser.setSex(tbUserInfo.getSex());
|
||||
shopUser.setBirthDay(tbUserInfo.getBirthDay());
|
||||
shopUser.setLevel(Byte.parseByte("1"));
|
||||
String dynamicCode = RandomUtil.randomNumbers(8);
|
||||
shopUser.setCode(dynamicCode);
|
||||
shopUser.setTelephone(tbUserInfo.getTelephone());
|
||||
shopUser.setAmount(BigDecimal.ZERO);
|
||||
shopUser.setIsVip(Byte.parseByte("0"));
|
||||
shopUser.setCreditAmount(BigDecimal.ZERO);
|
||||
shopUser.setConsumeAmount(BigDecimal.ZERO);
|
||||
shopUser.setConsumeNumber(0);
|
||||
shopUser.setLevelConsume(BigDecimal.ZERO);
|
||||
shopUser.setStatus(Byte.parseByte("1"));
|
||||
shopUser.setShopId(tbShopTable.getShopId().toString());
|
||||
shopUser.setUserId(userId);
|
||||
shopUser.setMiniOpenId(openId);
|
||||
shopUser.setCreatedAt(System.currentTimeMillis());
|
||||
shopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.insert(shopUser);
|
||||
shopUser = new TbShopUser();
|
||||
shopUser.setName(tbUserInfo.getNickName());
|
||||
shopUser.setSex(tbUserInfo.getSex());
|
||||
shopUser.setBirthDay(tbUserInfo.getBirthDay());
|
||||
shopUser.setLevel(Byte.parseByte("1"));
|
||||
String dynamicCode = RandomUtil.randomNumbers(8);
|
||||
shopUser.setCode(dynamicCode);
|
||||
shopUser.setTelephone(tbUserInfo.getTelephone());
|
||||
shopUser.setAmount(BigDecimal.ZERO);
|
||||
shopUser.setIsVip(Byte.parseByte("0"));
|
||||
shopUser.setCreditAmount(BigDecimal.ZERO);
|
||||
shopUser.setConsumeAmount(BigDecimal.ZERO);
|
||||
shopUser.setConsumeNumber(0);
|
||||
shopUser.setLevelConsume(BigDecimal.ZERO);
|
||||
shopUser.setStatus(Byte.parseByte("1"));
|
||||
shopUser.setShopId(tbShopTable.getShopId().toString());
|
||||
shopUser.setUserId(userId);
|
||||
shopUser.setMiniOpenId(openId);
|
||||
shopUser.setCreatedAt(System.currentTimeMillis());
|
||||
shopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.insert(shopUser);
|
||||
// }else {
|
||||
// shopUser.setUserId(userId);
|
||||
// shopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
// tbShopUserMapper.updateByPrimaryKey(shopUser);
|
||||
// }
|
||||
}else {
|
||||
} else {
|
||||
shopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.updateByPrimaryKey(shopUser);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.info("通过桌码获取shopId 进行用户绑定错误:{}",e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.info("通过桌码获取shopId 进行用户绑定错误:{}", e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS, concurrentMap);
|
||||
@@ -138,7 +138,7 @@ public class ProductService {
|
||||
if (ObjectUtil.isNotEmpty(tbProducts) && tbProducts.size() > 0) {
|
||||
tbProducts.parallelStream().forEach(it -> {
|
||||
TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId()));
|
||||
it.setUnitSnap(tbShopUnit!=null?tbShopUnit.getName():"");
|
||||
it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : "");
|
||||
it.setCartNumber("0");
|
||||
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
|
||||
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
|
||||
@@ -148,7 +148,9 @@ public class ProductService {
|
||||
AtomicDouble sum = new AtomicDouble(0.0);
|
||||
BigDecimal lowerPrice = null;
|
||||
for (TbProductSku item : tbProductSkus) {
|
||||
sum.addAndGet(item.getStockNumber());
|
||||
if (item.getRealSalesNumber() != null) {
|
||||
sum.addAndGet(item.getRealSalesNumber());
|
||||
}
|
||||
if (lowerPrice == null || lowerPrice.compareTo(item.getSalePrice()) > 0) {
|
||||
lowerPrice = item.getSalePrice();
|
||||
}
|
||||
@@ -195,12 +197,12 @@ public class ProductService {
|
||||
List<TbProductGroup> groupList = tbProductGroupMapper.selectByShopId(shopId, id);
|
||||
if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) {
|
||||
//热销
|
||||
TbProductGroup hot =new TbProductGroup();
|
||||
TbProductGroup hot = new TbProductGroup();
|
||||
hot.setName("热销");
|
||||
List<TbProduct> hots = tbProductMapper.selectHot(shopId);
|
||||
hots.parallelStream().forEach(it -> {
|
||||
TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId()));
|
||||
it.setUnitSnap(tbShopUnit!=null?tbShopUnit.getName():"");
|
||||
it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : "");
|
||||
it.setCartNumber("0");
|
||||
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
|
||||
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
|
||||
@@ -210,7 +212,9 @@ public class ProductService {
|
||||
AtomicDouble sum = new AtomicDouble(0.0);
|
||||
BigDecimal lowerPrice = null;
|
||||
for (TbProductSku item : tbProductSkus) {
|
||||
sum.addAndGet(item.getStockNumber());
|
||||
if (item.getRealSalesNumber() != null) {
|
||||
sum.addAndGet(item.getRealSalesNumber());
|
||||
}
|
||||
if (lowerPrice == null || lowerPrice.compareTo(item.getSalePrice()) > 0) {
|
||||
lowerPrice = item.getSalePrice();
|
||||
}
|
||||
@@ -260,7 +264,6 @@ public class ProductService {
|
||||
it.setProductSkuResult(skuResult);
|
||||
});
|
||||
hot.setProducts(hots);
|
||||
|
||||
//商品
|
||||
groupList.parallelStream().forEach(g -> {
|
||||
String in = g.getProductIds().substring(1, g.getProductIds().length() - 1);
|
||||
@@ -272,7 +275,7 @@ public class ProductService {
|
||||
if (ObjectUtil.isNotEmpty(products) && products.size() > 0) {
|
||||
products.parallelStream().forEach(it -> {
|
||||
TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId()));
|
||||
it.setUnitSnap(tbShopUnit!=null?tbShopUnit.getName():"");
|
||||
it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : "");
|
||||
it.setCartNumber("0");
|
||||
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
|
||||
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
|
||||
@@ -282,7 +285,9 @@ public class ProductService {
|
||||
AtomicDouble sum = new AtomicDouble(0.0);
|
||||
BigDecimal lowerPrice = null;
|
||||
for (TbProductSku item : tbProductSkus) {
|
||||
sum.addAndGet(item.getStockNumber());
|
||||
if (item.getRealSalesNumber() != null) {
|
||||
sum.addAndGet(item.getRealSalesNumber());
|
||||
}
|
||||
if (lowerPrice == null || lowerPrice.compareTo(item.getSalePrice()) > 0) {
|
||||
lowerPrice = item.getSalePrice();
|
||||
}
|
||||
@@ -340,7 +345,7 @@ public class ProductService {
|
||||
g.setProducts(new ArrayList<>());
|
||||
}
|
||||
});
|
||||
|
||||
groupList.add(0, hot);
|
||||
concurrentMap.put("productInfo", groupList);
|
||||
}
|
||||
|
||||
@@ -348,13 +353,13 @@ public class ProductService {
|
||||
}
|
||||
|
||||
|
||||
public Result queryProductSku(String code,String shopId, String productId, String spec_tag) {
|
||||
public Result queryProductSku(String code, String shopId, String productId, String spec_tag) {
|
||||
if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(productId)) {
|
||||
return Result.fail("参数错误");
|
||||
}
|
||||
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByShopIdAndProductIdAndSpec(shopId, productId, spec_tag);
|
||||
if(StringUtils.isNotBlank(code)) {
|
||||
if (StringUtils.isNotBlank(code)) {
|
||||
Integer sum = tbProductMapper.selectByCodeAndSkuId(code, tbProductSkuWithBLOBs.getId(), shopId);
|
||||
tbProductSkuWithBLOBs.setNumber(sum);
|
||||
}
|
||||
@@ -394,13 +399,13 @@ public class ProductService {
|
||||
stTime = enTime - 3600000L * 2;
|
||||
}
|
||||
shopGroupInfoVos = tbProductMapper.selHotGroups(
|
||||
homeDto.getProName(),homeDto.getType(),
|
||||
homeDto.getProName(), homeDto.getType(),
|
||||
// DateUtils.getStrTime(new Date(stTime)), DateUtils.getStrTime(new Date(enTime)),
|
||||
null, null,
|
||||
homeDto.getAddress(), homeDto.getOrderBy().toString(), homeDto.getLng(), homeDto.getLat());
|
||||
} else {
|
||||
shopGroupInfoVos = tbProductMapper.selGroups(
|
||||
homeDto.getProName(),homeDto.getType(),
|
||||
homeDto.getProName(), homeDto.getType(),
|
||||
topAndBottomMap.get("rightTopPoint")[1], topAndBottomMap.get("rightTopPoint")[0],
|
||||
topAndBottomMap.get("leftBottomPoint")[1], topAndBottomMap.get("leftBottomPoint")[0],
|
||||
homeDto.getAddress(), homeDto.getOrderBy().toString(), homeDto.getLng(), homeDto.getLat());
|
||||
@@ -546,7 +551,7 @@ public class ProductService {
|
||||
productInfo.setPhone(tbShopInfo.getPhone());
|
||||
productInfo.setLat(tbShopInfo.getLat());
|
||||
productInfo.setLng(tbShopInfo.getLng());
|
||||
if(StringUtils.isNotBlank(tbShopInfo.getBusinessStartDay())){
|
||||
if (StringUtils.isNotBlank(tbShopInfo.getBusinessStartDay())) {
|
||||
productInfo.setBusinessTime(tbShopInfo.getBusinessStartDay() + "至" + tbShopInfo.getBusinessEndDay() + " " + tbShopInfo.getBusinessTime());
|
||||
}
|
||||
String distance = LocationUtils.getDistanceString(
|
||||
@@ -627,16 +632,16 @@ public class ProductService {
|
||||
/**
|
||||
* 库存修改
|
||||
*
|
||||
* @param tbProduct 商品
|
||||
* @param tbProduct 商品
|
||||
* @param tbProductSkuWithBLOBs sku
|
||||
* @param buyNum 购买数量
|
||||
* @param buyNum 购买数量
|
||||
*/
|
||||
public void updateStock(TbProduct tbProduct, TbProductSkuWithBLOBs tbProductSkuWithBLOBs, Integer buyNum) {
|
||||
if (tbProduct.getIsDistribute() == 1) {
|
||||
if (tbProductMapper.decrStock(String.valueOf(tbProduct.getId()), buyNum) < 1) {
|
||||
throw new MsgException("库存修改失败,请稍后再试");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
if (tbProductSkuMapper.decrStock(String.valueOf(tbProductSkuWithBLOBs.getId()), buyNum) < 1) {
|
||||
throw new MsgException("库存修改失败,请稍后再试");
|
||||
}
|
||||
@@ -648,7 +653,7 @@ public class ProductService {
|
||||
if (tbProductMapper.decrStock(String.valueOf(id), buyNum) < 1) {
|
||||
throw new MsgException("库存不足,下单失败");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
if (tbProductSkuMapper.decrStock(String.valueOf(skuId), buyNum) < 1) {
|
||||
throw new MsgException("库存不足,下单失败");
|
||||
}
|
||||
@@ -660,7 +665,7 @@ public class ProductService {
|
||||
if (tbProductMapper.decrStockUnCheck(String.valueOf(id), buyNum) < 1) {
|
||||
throw new MsgException("库存不足,下单失败");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
if (tbProductSkuMapper.decrStockUnCheck(String.valueOf(skuId), buyNum) < 1) {
|
||||
throw new MsgException("库存不足,下单失败");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user