查询省市

会员关联
桌码绑定新的 旧的清除
This commit is contained in:
2024-06-13 09:35:21 +08:00
parent c34518631b
commit 6ab2a32c9f
18 changed files with 189 additions and 90 deletions

View File

@@ -93,6 +93,7 @@ public class CartService1 {
try {
String tableId = jsonObject.getString("tableId");
String shopId = jsonObject.getString("shopId");
String productId = jsonObject.getString("productId");
String key = tableId + "-" + shopId;
JSONArray jsonArray = new JSONArray();
BigDecimal amount = BigDecimal.ZERO;
@@ -103,14 +104,17 @@ public class CartService1 {
redisUtil.saveMessage(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), Math.round(stock) + "");
}
String skuNum = redisUtil.getMessage(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"));
if (Integer.valueOf(skuNum) < 1) {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "该商品库存已售罄");
jsonObject1.put("data", new ArrayList<>());
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
log.error("该商品库存已售罄 skuId:{}", jsonObject.getString("skuId"));
throw new MsgException("该商品库存已售罄");
TbProduct tbProduct = productMapper.selectById(Integer.valueOf(productId));
if (tbProduct.getIsStock() == 1) {
if (Integer.valueOf(skuNum) < 1) {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "该商品库存已售罄");
jsonObject1.put("data", new ArrayList<>());
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
log.error("该商品库存已售罄 skuId:{}", jsonObject.getString("skuId"));
throw new MsgException("该商品库存已售罄");
}
}
if (jsonObject.getInteger("num") > 0) {
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "1");
@@ -163,7 +167,6 @@ public class CartService1 {
}
}
productSkuMapper.updateStockById(jsonObject.getString("skuId"), jsonObject.getInteger("num"));
// AppWebSocketServer.getRecordMap().put(jsonObject.getString("tableId"), returnList);
redisUtil.saveMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId), jsonArray.toJSONString());
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "success");
@@ -244,7 +247,6 @@ public class CartService1 {
BigDecimal saleAmount = BigDecimal.ZERO;
String couponId = "";
BigDecimal couponAmount = BigDecimal.ZERO;
Map<Integer, TbProductSku> skuMap = new HashMap<>();
List<TbOrderDetail> orderDetails = new ArrayList<>();
Integer orderId = 0;
TbMerchantAccount tbMerchantAccount = merchantAccountMapper.selectByShopId(jsonObject.getString("shopId"));
@@ -267,7 +269,6 @@ public class CartService1 {
if (Objects.nonNull(tbProduct)) {
saleAmount = saleAmount.add(tbProduct.getSalePrice());
}
skuMap.put(tbProduct.getId(), tbProduct);
TbOrderDetail orderDetail = new TbOrderDetail();
orderDetail.setCreateTime(new Date());
orderDetail.setNum(cashierCart.getNumber());
@@ -445,6 +446,7 @@ public class CartService1 {
jsonObject12.put("data", new JSONArray());
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
redisUtil.saveMessage(RedisCst.ORDER_EXPIRED.concat(orderId.toString()), orderId.toString(), 60 * 16L);
} catch (Exception e) {
log.info("长链接错误 addCart{}", e.getMessage());
e.printStackTrace();
@@ -497,7 +499,7 @@ public class CartService1 {
if (Objects.isNull(array) || array.isEmpty() || array.size() < 1) {
for (int i = 0; i < array.size(); i++) {
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(array.get(i).toString(), TbCashierCart.class);
// String result = redisUtil.secAdd(RedisCst.PRODUCT+shopId+":"+jsonObject.getString("skuId"),cashierCart.getNumber().toString());
redisUtil.secAdd(RedisCst.PRODUCT+shopId+":"+jsonObject.getString("skuId"),cashierCart.getNumber().toString());
productSkuMapper.updateAddStockById(jsonObject.getString("skuId"), cashierCart.getNumber());
}

View File

@@ -92,6 +92,7 @@ public class LoginService {
if(!CollectionUtils.isEmpty(tbShopUsers)){
for (TbShopUser tbShopUser : tbShopUsers) {
tbShopUser.setUserId(userInfo.getId() + "");
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
}
}
@@ -111,10 +112,12 @@ public class LoginService {
if(StringUtils.isNotBlank(telephone)){
if (StringUtils.isBlank(phone) || !phone.equals(telephone)) {
userInfo.setTelephone(telephone);
userInfo.setUpdatedAt(System.currentTimeMillis());
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectAllByUserId(userInfo.getId().toString());
for (TbShopUser tbShopUser : tbShopUsers) {
tbShopUser.setTelephone(phone);
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
}
}

View File

@@ -71,33 +71,41 @@ public class ProductService {
return Result.fail("台桌信息不存在");
}
TbShopUser tbShopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId);
TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId);
try{
if (ObjectUtil.isEmpty(tbShopUser)) {
if (ObjectUtil.isEmpty(shopUser)) {
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
tbShopUser = new TbShopUser();
tbShopUser.setName(tbUserInfo.getNickName());
tbShopUser.setSex(tbUserInfo.getSex());
tbShopUser.setBirthDay(tbUserInfo.getBirthDay());
tbShopUser.setLevel(Byte.parseByte("1"));
tbShopUser.setCode(RandomUtil.randomNumbers(8));
tbShopUser.setTelephone(tbUserInfo.getTelephone());
tbShopUser.setAmount(BigDecimal.ZERO);
tbShopUser.setIsVip(Byte.parseByte("0"));
tbShopUser.setCreditAmount(BigDecimal.ZERO);
tbShopUser.setConsumeAmount(BigDecimal.ZERO);
tbShopUser.setConsumeNumber(0);
tbShopUser.setLevelConsume(BigDecimal.ZERO);
tbShopUser.setStatus(Byte.parseByte("1"));
tbShopUser.setShopId(shopId);
tbShopUser.setUserId(userId);
tbShopUser.setMiniOpenId(openId);
tbShopUser.setCreatedAt(System.currentTimeMillis());
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.insert(tbShopUser);
} else {
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
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(shopId);
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 {
shopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(shopUser);
}
}catch (Exception e){
log.info("通过桌码获取shopId 进行用户绑定错误:{}",e.getMessage());
@@ -184,10 +192,10 @@ public class ProductService {
//经纬度(附近一km)
Map<String, double[]> topAndBottomMap = LocationUtils.returnLLSquarePoint(
Double.parseDouble(homeDto.getLng()), Double.parseDouble(homeDto.getLat()), homeDto.getDistanceInKm());
Long stTime = null;
Long enTime = null;
List<ShopGroupInfoVo> shopGroupInfoVos = new ArrayList<>();
if (homeDto.getOrderBy() == 4) {
Long stTime = null;
Long enTime = null;
if (homeDto.getDateType() == 0) {
stTime = DateUtils.getDayStartLong();
enTime = DateUtils.getDayEndLong();
@@ -197,7 +205,8 @@ public class ProductService {
}
shopGroupInfoVos = tbProductMapper.selHotGroups(
homeDto.getProName(),homeDto.getType(),
DateUtils.getStrTime(new Date(stTime)), DateUtils.getStrTime(new Date(enTime)),
// 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(

View File

@@ -1,12 +1,11 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.annotation.ResultCode;
import com.chaozhanggui.system.cashierservice.dao.TbShopAreaMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopTableMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopArea;
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -25,6 +24,10 @@ public class ShopTableService {
private TbShopAreaMapper shopAreaMapper;
public Result bindingQrcode(TbShopTable shopTable){
if(StringUtils.isBlank(shopTable.getQrcode())){
return Result.fail("绑定桌码不可为空");
}
shopTableMapper.upDateQrcodeNull(shopTable.getQrcode());
TbShopTable shopTableId = shopTableMapper.selectByPrimaryKey(shopTable.getId());
if (shopTableId == null){
return Result.fail("找不到台桌");