进店即会员 取消
长链接 异常打印
This commit is contained in:
@@ -90,7 +90,7 @@ public class UserContoller {
|
|||||||
shopUser.setCode(dynamicCode);
|
shopUser.setCode(dynamicCode);
|
||||||
shopUser.setTelephone(tbUserInfo.getTelephone());
|
shopUser.setTelephone(tbUserInfo.getTelephone());
|
||||||
shopUser.setAmount(BigDecimal.ZERO);
|
shopUser.setAmount(BigDecimal.ZERO);
|
||||||
shopUser.setIsVip(Byte.parseByte("1"));
|
shopUser.setIsVip(Byte.parseByte("0"));
|
||||||
shopUser.setCreditAmount(BigDecimal.ZERO);
|
shopUser.setCreditAmount(BigDecimal.ZERO);
|
||||||
shopUser.setConsumeAmount(BigDecimal.ZERO);
|
shopUser.setConsumeAmount(BigDecimal.ZERO);
|
||||||
shopUser.setConsumeNumber(0);
|
shopUser.setConsumeNumber(0);
|
||||||
|
|||||||
@@ -44,6 +44,13 @@ public class CartConsumer {
|
|||||||
} else if(jsonObject.getString("type").equals("createOrder")){
|
} else if(jsonObject.getString("type").equals("createOrder")){
|
||||||
String cartDetail = redisUtil.getMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId));
|
String cartDetail = redisUtil.getMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId));
|
||||||
if (StringUtils.isEmpty(cartDetail)){
|
if (StringUtils.isEmpty(cartDetail)){
|
||||||
|
log.info("createOrder购物车为空");
|
||||||
|
// JSONObject jsonObject1 = new JSONObject();
|
||||||
|
// jsonObject1.put("status", "success");
|
||||||
|
// jsonObject1.put("msg", "订单已存在");
|
||||||
|
// jsonObject1.put("type", jsonObject.getString("type"));
|
||||||
|
// jsonObject1.put("data", "{\"id\": \"-1\"}");
|
||||||
|
// AppWebSocketServer.AppSendInfo(jsonObject1,tableId+"-"+shopId, jsonObject.getString("userId"), true);
|
||||||
throw new MsgException("购物车为空无法下单");
|
throw new MsgException("购物车为空无法下单");
|
||||||
}
|
}
|
||||||
JSONArray array = JSON.parseArray(cartDetail);
|
JSONArray array = JSON.parseArray(cartDetail);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class CartService {
|
|||||||
private TbSystemCouponsMapper systemCouponsMapper;
|
private TbSystemCouponsMapper systemCouponsMapper;
|
||||||
|
|
||||||
// @Transactional(rollbackFor = Exception.class)
|
// @Transactional(rollbackFor = Exception.class)
|
||||||
public void createCart(JSONObject jsonObject) throws Exception {
|
public void createCart(JSONObject jsonObject) {
|
||||||
try {
|
try {
|
||||||
String tableId = jsonObject.getString("tableId");
|
String tableId = jsonObject.getString("tableId");
|
||||||
String shopId = jsonObject.getString("shopId");
|
String shopId = jsonObject.getString("shopId");
|
||||||
@@ -144,55 +144,60 @@ public class CartService {
|
|||||||
jsonObject1.put("amount", amount);
|
jsonObject1.put("amount", amount);
|
||||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.getMessage();
|
log.info("长链接错误 createCart{}",e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, String tableId, String shopId) throws Exception {
|
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, String tableId, String shopId) throws Exception {
|
||||||
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
|
try {
|
||||||
String key=tableId+"-"+shopId;
|
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
|
||||||
if (Objects.isNull(product)) {
|
String key=tableId+"-"+shopId;
|
||||||
JSONObject jsonObject1 = new JSONObject();
|
if (Objects.isNull(product)) {
|
||||||
jsonObject1.put("status", "fail");
|
JSONObject jsonObject1 = new JSONObject();
|
||||||
jsonObject1.put("msg", "该商品不存在");
|
jsonObject1.put("status", "fail");
|
||||||
jsonObject1.put("data", new ArrayList<>());
|
jsonObject1.put("msg", "该商品不存在");
|
||||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, userId.toString(), true);
|
jsonObject1.put("data", new ArrayList<>());
|
||||||
throw new MsgException("该商品不存在");
|
AppWebSocketServer.AppSendInfo(jsonObject1,key, userId.toString(), true);
|
||||||
|
throw new MsgException("该商品不存在");
|
||||||
|
}
|
||||||
|
TbProductSkuWithBLOBs productSku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
||||||
|
if (Objects.isNull(productSku)) {
|
||||||
|
JSONObject jsonObject1 = new JSONObject();
|
||||||
|
jsonObject1.put("status", "fail");
|
||||||
|
jsonObject1.put("msg", "该商品规格不存在");
|
||||||
|
jsonObject1.put("data", new ArrayList<>());
|
||||||
|
AppWebSocketServer.AppSendInfo(jsonObject1,key, userId.toString(), true);
|
||||||
|
throw new MsgException("该商品规格不存在");
|
||||||
|
}
|
||||||
|
TbCashierCart cashierCart = new TbCashierCart();
|
||||||
|
cashierCart.setProductId(productId);
|
||||||
|
cashierCart.setSkuId(skuId);
|
||||||
|
cashierCart.setNumber(num);
|
||||||
|
cashierCart.setCoverImg(product.getCoverImg());
|
||||||
|
cashierCart.setName(product.getName());
|
||||||
|
cashierCart.setCategoryId(product.getCategoryId());
|
||||||
|
cashierCart.setShopId(shopId);
|
||||||
|
cashierCart.setUserId(userId);
|
||||||
|
cashierCart.setTableId(tableId);
|
||||||
|
cashierCart.setSkuName(productSku.getSpecSnap());
|
||||||
|
cashierCart.setIsPack("false");
|
||||||
|
cashierCart.setIsGift("false");
|
||||||
|
cashierCart.setUserId(userId);
|
||||||
|
cashierCart.setStatus("create");
|
||||||
|
cashierCart.setType((byte) 0);
|
||||||
|
cashierCart.setSalePrice(productSku.getSalePrice());
|
||||||
|
cashierCart.setCreatedAt(Instant.now().toEpochMilli());
|
||||||
|
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
|
||||||
|
cashierCart.setTotalNumber(num);
|
||||||
|
cashierCart.setPackFee(BigDecimal.ZERO);
|
||||||
|
cashierCart.setRefundNumber(0);
|
||||||
|
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee())));
|
||||||
|
cashierCartMapper.insert(cashierCart);
|
||||||
|
return cashierCart;
|
||||||
|
}catch (Exception e){
|
||||||
|
log.info("长链接错误 addCart{}",e.getMessage());
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
TbProductSkuWithBLOBs productSku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
|
||||||
if (Objects.isNull(productSku)) {
|
|
||||||
JSONObject jsonObject1 = new JSONObject();
|
|
||||||
jsonObject1.put("status", "fail");
|
|
||||||
jsonObject1.put("msg", "该商品规格不存在");
|
|
||||||
jsonObject1.put("data", new ArrayList<>());
|
|
||||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, userId.toString(), true);
|
|
||||||
throw new MsgException("该商品规格不存在");
|
|
||||||
}
|
|
||||||
TbCashierCart cashierCart = new TbCashierCart();
|
|
||||||
cashierCart.setProductId(productId);
|
|
||||||
cashierCart.setSkuId(skuId);
|
|
||||||
cashierCart.setNumber(num);
|
|
||||||
cashierCart.setCoverImg(product.getCoverImg());
|
|
||||||
cashierCart.setName(product.getName());
|
|
||||||
cashierCart.setCategoryId(product.getCategoryId());
|
|
||||||
cashierCart.setShopId(shopId);
|
|
||||||
cashierCart.setUserId(userId);
|
|
||||||
cashierCart.setTableId(tableId);
|
|
||||||
cashierCart.setSkuName(productSku.getSpecSnap());
|
|
||||||
cashierCart.setIsPack("false");
|
|
||||||
cashierCart.setIsGift("false");
|
|
||||||
cashierCart.setUserId(userId);
|
|
||||||
cashierCart.setStatus("create");
|
|
||||||
cashierCart.setType((byte) 0);
|
|
||||||
cashierCart.setSalePrice(productSku.getSalePrice());
|
|
||||||
cashierCart.setCreatedAt(Instant.now().toEpochMilli());
|
|
||||||
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
|
|
||||||
cashierCart.setTotalNumber(num);
|
|
||||||
cashierCart.setPackFee(BigDecimal.ZERO);
|
|
||||||
cashierCart.setRefundNumber(0);
|
|
||||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee())));
|
|
||||||
cashierCartMapper.insert(cashierCart);
|
|
||||||
return cashierCart;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -411,6 +416,7 @@ public class CartService {
|
|||||||
jsonObject12.put("data", new JSONArray());
|
jsonObject12.put("data", new JSONArray());
|
||||||
AppWebSocketServer.AppSendInfo(jsonObject12, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
AppWebSocketServer.AppSendInfo(jsonObject12, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.info("长链接错误 addCart{}",e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -453,28 +459,33 @@ public class CartService {
|
|||||||
return "WX" + date + randomNum;
|
return "WX" + date + randomNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearCart(JSONObject jsonObject) throws IOException {
|
public void clearCart(JSONObject jsonObject){
|
||||||
String shopId = jsonObject.getString("shopId");
|
try{
|
||||||
if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
|
String shopId = jsonObject.getString("shopId");
|
||||||
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
|
||||||
if (Objects.isNull(array) || array.isEmpty() || array.size() < 1) {
|
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
||||||
for (int i = 0; i < array.size(); i++) {
|
if (Objects.isNull(array) || array.isEmpty() || array.size() < 1) {
|
||||||
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(array.get(i).toString(), TbCashierCart.class);
|
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());
|
// String result = redisUtil.secAdd(RedisCst.PRODUCT+shopId+":"+jsonObject.getString("skuId"),cashierCart.getNumber().toString());
|
||||||
productSkuMapper.updateAddStockById(jsonObject.getString("skuId"), cashierCart.getNumber());
|
productSkuMapper.updateAddStockById(jsonObject.getString("skuId"), cashierCart.getNumber());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cashierCartMapper.updateStatusByTableId(jsonObject.getString("tableId"), "closed");
|
||||||
|
redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)), new JSONArray().toJSONString());
|
||||||
|
JSONObject jsonObject1 = new JSONObject();
|
||||||
|
jsonObject1.put("status", "success");
|
||||||
|
jsonObject1.put("msg", "成功");
|
||||||
|
jsonObject1.put("type", "clearCart");
|
||||||
|
jsonObject1.put("amount", BigDecimal.ZERO);
|
||||||
|
jsonObject1.put("data", new ArrayList<>());
|
||||||
|
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.info("长链接错误 clearCart{}",e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
cashierCartMapper.updateStatusByTableId(jsonObject.getString("tableId"), "closed");
|
|
||||||
redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)), new JSONArray().toJSONString());
|
|
||||||
JSONObject jsonObject1 = new JSONObject();
|
|
||||||
jsonObject1.put("status", "success");
|
|
||||||
jsonObject1.put("msg", "成功");
|
|
||||||
jsonObject1.put("type", "clearCart");
|
|
||||||
jsonObject1.put("amount", BigDecimal.ZERO);
|
|
||||||
jsonObject1.put("data", new ArrayList<>());
|
|
||||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -694,25 +705,31 @@ public class CartService {
|
|||||||
jsonObject12.put("data", new JSONArray());
|
jsonObject12.put("data", new JSONArray());
|
||||||
AppWebSocketServer.AppSendInfo(jsonObject12, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
AppWebSocketServer.AppSendInfo(jsonObject12, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.getMessage();
|
log.info("长链接错误 pendingOrder{}",e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queryCart(JSONObject jsonObject) throws IOException {
|
public void queryCart(JSONObject jsonObject) {
|
||||||
String shopId = jsonObject.getString("shopId");
|
try {
|
||||||
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
String shopId = jsonObject.getString("shopId");
|
||||||
BigDecimal amount = BigDecimal.ZERO;
|
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
||||||
for (int i = 0; i < array.size(); i++) {
|
BigDecimal amount = BigDecimal.ZERO;
|
||||||
JSONObject object = array.getJSONObject(i);
|
for (int i = 0; i < array.size(); i++) {
|
||||||
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
JSONObject object = array.getJSONObject(i);
|
||||||
amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
||||||
|
amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||||
|
}
|
||||||
|
JSONObject jsonObject1 = new JSONObject();
|
||||||
|
jsonObject1.put("status", "success");
|
||||||
|
jsonObject1.put("msg", "成功");
|
||||||
|
jsonObject1.put("type", jsonObject.getString("type"));
|
||||||
|
jsonObject1.put("data", array);
|
||||||
|
jsonObject1.put("amount", amount);
|
||||||
|
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.info("长链接错误 queryCart{}",e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
JSONObject jsonObject1 = new JSONObject();
|
|
||||||
jsonObject1.put("status", "success");
|
|
||||||
jsonObject1.put("msg", "成功");
|
|
||||||
jsonObject1.put("type", jsonObject.getString("type"));
|
|
||||||
jsonObject1.put("data", array);
|
|
||||||
jsonObject1.put("amount", amount);
|
|
||||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,12 +90,6 @@ public class LoginService {
|
|||||||
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(telephone);
|
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(telephone);
|
||||||
if(CollectionUtils.isEmpty(tbShopUsers)){
|
if(CollectionUtils.isEmpty(tbShopUsers)){
|
||||||
for (TbShopUser tbShopUser : tbShopUsers) {
|
for (TbShopUser tbShopUser : tbShopUsers) {
|
||||||
userInfo.setNickName(tbShopUser.getName());
|
|
||||||
userInfo.setSex(tbShopUser.getSex());
|
|
||||||
userInfo.setBirthDay(tbShopUser.getBirthDay());
|
|
||||||
tbShopUser.setLevel(Byte.parseByte("1"));
|
|
||||||
String dynamicCode = RandomUtil.randomNumbers(8);
|
|
||||||
tbShopUser.setCode(dynamicCode);
|
|
||||||
tbShopUser.setUserId(userInfo.getId() + "");
|
tbShopUser.setUserId(userInfo.getId() + "");
|
||||||
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
|
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
|
||||||
}
|
}
|
||||||
@@ -185,12 +179,6 @@ public class LoginService {
|
|||||||
}
|
}
|
||||||
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(phone);
|
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(phone);
|
||||||
for (TbShopUser tbShopUser : tbShopUsers) {
|
for (TbShopUser tbShopUser : tbShopUsers) {
|
||||||
userInfo.setNickName(tbShopUser.getName());
|
|
||||||
userInfo.setSex(tbShopUser.getSex());
|
|
||||||
userInfo.setBirthDay(tbShopUser.getBirthDay());
|
|
||||||
tbShopUser.setLevel(Byte.parseByte("1"));
|
|
||||||
String dynamicCode = RandomUtil.randomNumbers(8);
|
|
||||||
tbShopUser.setCode(dynamicCode);
|
|
||||||
tbShopUser.setUserId(userInfo.getId() + "");
|
tbShopUser.setUserId(userInfo.getId() + "");
|
||||||
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
|
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class ProductService {
|
|||||||
tbShopUser.setCode(RandomUtil.randomNumbers(8));
|
tbShopUser.setCode(RandomUtil.randomNumbers(8));
|
||||||
tbShopUser.setTelephone(tbUserInfo.getTelephone());
|
tbShopUser.setTelephone(tbUserInfo.getTelephone());
|
||||||
tbShopUser.setAmount(BigDecimal.ZERO);
|
tbShopUser.setAmount(BigDecimal.ZERO);
|
||||||
tbShopUser.setIsVip(Byte.parseByte("1"));
|
tbShopUser.setIsVip(Byte.parseByte("0"));
|
||||||
tbShopUser.setCreditAmount(BigDecimal.ZERO);
|
tbShopUser.setCreditAmount(BigDecimal.ZERO);
|
||||||
tbShopUser.setConsumeAmount(BigDecimal.ZERO);
|
tbShopUser.setConsumeAmount(BigDecimal.ZERO);
|
||||||
tbShopUser.setConsumeNumber(0);
|
tbShopUser.setConsumeNumber(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user