查询省市

会员关联
桌码绑定新的 旧的清除
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

@@ -20,7 +20,11 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId >pinyin4j</artifactId>
<version >2.5.1</version >
</dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>

View File

@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
@@ -88,6 +89,27 @@ public class CommonController {
return Result.success(CodeEnum.SUCCESS, carouselList); return Result.success(CodeEnum.SUCCESS, carouselList);
} }
/**
* 查询省市
*/
@GetMapping("location/districtAll")
public Result districtAll() throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
if(redisUtil.exists("DISTRICTALL")){
String str=redisUtil.getMessage("DISTRICTALL");
JsonNode jsonNode = mapper.readTree(str);
return Result.success(CodeEnum.SUCCESS, jsonNode);
}else {
String districtJson = LocationUtils.district("100000","2");//中国
JsonNode jsonNode = mapper.readTree(districtJson);
JsonNode districts = jsonNode.get("districts");
List<DistrictVo> cityInfoList = mapper.readValue(districts.get(0).get("districts").toString(), mapper.getTypeFactory().constructCollectionType(List.class, DistrictVo.class));
Collections.sort(cityInfoList, (o1, o2) -> o1.getNameAsPY().compareTo(o2.getNameAsPY()));
redisUtil.saveMessage("DISTRICTALL",mapper.writeValueAsString(cityInfoList),7*24*3600L);
return Result.success(CodeEnum.SUCCESS, cityInfoList);
}
}
/** /**
* 行政区域查询 * 行政区域查询
* *
@@ -95,10 +117,9 @@ public class CommonController {
* @return * @return
*/ */
@GetMapping("location/district") @GetMapping("location/district")
public Result createOrder(String keywords) throws JsonProcessingException { public Result district(String keywords) throws JsonProcessingException {
String districtJson = LocationUtils.district(keywords); String districtJson = LocationUtils.district(keywords,null);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
// 将 JSON 字符串解析为 JsonNode 对象
JsonNode jsonNode = mapper.readTree(districtJson); JsonNode jsonNode = mapper.readTree(districtJson);
JsonNode districts = jsonNode.get("districts"); JsonNode districts = jsonNode.get("districts");
String text = districts.toString(); String text = districts.toString();

View File

@@ -10,7 +10,6 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.concurrent.ExecutionException;
/** /**
* 首页其它接口 * 首页其它接口

View File

@@ -80,31 +80,38 @@ public class UserContoller {
@GetMapping("/shopUserInfo") @GetMapping("/shopUserInfo")
public Result shopUserInfo(@RequestParam("userId") String userId ,@RequestHeader("openId") String openId,@RequestParam("shopId") String shopId ) throws Exception { public Result shopUserInfo(@RequestParam("userId") String userId ,@RequestHeader("openId") String openId,@RequestParam("shopId") String shopId ) throws Exception {
TbShopUser shopUser=new TbShopUser(); TbShopUser shopUser=new TbShopUser();
if (StringUtils.isNotBlank(shopId)) { if (StringUtils.isNotBlank(shopId) && !shopId.equals("null")) {
shopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId); shopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
if (ObjectUtil.isEmpty(shopUser)) { if (ObjectUtil.isEmpty(shopUser)) {
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId)); TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
shopUser = new TbShopUser(); shopUser = shopUserMapper.selectByPhoneAndShopId(tbUserInfo.getTelephone(), shopId);
shopUser.setName(tbUserInfo.getNickName()); if(ObjectUtil.isEmpty(shopUser)){
shopUser.setSex(tbUserInfo.getSex()); shopUser=new TbShopUser();
shopUser.setBirthDay(tbUserInfo.getBirthDay()); shopUser.setName(tbUserInfo.getNickName());
shopUser.setLevel(Byte.parseByte("1")); shopUser.setSex(tbUserInfo.getSex());
String dynamicCode = RandomUtil.randomNumbers(8); shopUser.setBirthDay(tbUserInfo.getBirthDay());
shopUser.setCode(dynamicCode); shopUser.setLevel(Byte.parseByte("1"));
shopUser.setTelephone(tbUserInfo.getTelephone()); String dynamicCode = RandomUtil.randomNumbers(8);
shopUser.setAmount(BigDecimal.ZERO); shopUser.setCode(dynamicCode);
shopUser.setIsVip(Byte.parseByte("0")); shopUser.setTelephone(tbUserInfo.getTelephone());
shopUser.setCreditAmount(BigDecimal.ZERO); shopUser.setAmount(BigDecimal.ZERO);
shopUser.setConsumeAmount(BigDecimal.ZERO); shopUser.setIsVip(Byte.parseByte("0"));
shopUser.setConsumeNumber(0); shopUser.setCreditAmount(BigDecimal.ZERO);
shopUser.setLevelConsume(BigDecimal.ZERO); shopUser.setConsumeAmount(BigDecimal.ZERO);
shopUser.setStatus(Byte.parseByte("1")); shopUser.setConsumeNumber(0);
shopUser.setShopId(shopId); shopUser.setLevelConsume(BigDecimal.ZERO);
shopUser.setUserId(userId); shopUser.setStatus(Byte.parseByte("1"));
shopUser.setMiniOpenId(openId); shopUser.setShopId(shopId);
shopUser.setCreatedAt(System.currentTimeMillis()); shopUser.setUserId(userId);
shopUser.setUpdatedAt(System.currentTimeMillis()); shopUser.setMiniOpenId(openId);
shopUserMapper.insert(shopUser); shopUser.setCreatedAt(System.currentTimeMillis());
shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.insert(shopUser);
}else {
shopUser.setUserId(userId);
shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.updateByPrimaryKey(shopUser);
}
} }
}else { }else {
shopUser.setAmount(BigDecimal.ZERO); shopUser.setAmount(BigDecimal.ZERO);

View File

@@ -24,6 +24,7 @@ public interface TbShopTableMapper {
String queryShopIdByTableCode(String code); String queryShopIdByTableCode(String code);
int upDateQrcodeNull(String code);
int updateByPrimaryKeySelective(TbShopTable record); int updateByPrimaryKeySelective(TbShopTable record);
int updateByPrimaryKey(TbShopTable record); int updateByPrimaryKey(TbShopTable record);

View File

@@ -27,6 +27,7 @@ public interface TbShopUserMapper {
TbShopUser selectByUserIdAndShopId(@Param("userId") String userId,@Param("shopId") String shopId); TbShopUser selectByUserIdAndShopId(@Param("userId") String userId,@Param("shopId") String shopId);
TbShopUser selectByPhoneAndShopId(@Param("phone") String phone,@Param("shopId") String shopId);
List<TbShopUser> selectAllByUserId(@Param("userId") String userId); List<TbShopUser> selectAllByUserId(@Param("userId") String userId);

View File

@@ -1,6 +1,11 @@
package com.chaozhanggui.system.cashierservice.entity.vo; package com.chaozhanggui.system.cashierservice.entity.vo;
import lombok.Data; import lombok.Data;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
import java.util.List; import java.util.List;
@@ -8,11 +13,30 @@ import java.util.List;
* 行政区域返回vo * 行政区域返回vo
*/ */
@Data @Data
public class DistrictVo { public class DistrictVo{
private String citycode; private Object citycode;
private String adcode; private String adcode;
private String name; private String name;
private String center; private String center;
private String level; private String level;
private List<DistrictVo> districts; private List<DistrictVo> districts;
public String getNameAsPY() {
return getPinYin(name);
}
public String getPinYin(String name){
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
// 设置声调类型为WITH_TONE_MARK
format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
// 设置拼音输出的大小写格式为小写
format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
String pinyin = "";
try {
pinyin = PinyinHelper.toHanYuPinyinString(name,format , "", false);
} catch (BadHanyuPinyinOutputFormatCombination e) {
return pinyin;
}
return pinyin;
}
} }

View File

@@ -65,6 +65,7 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
@Override @Override
public void channelActive(ChannelHandlerContext ctx) throws Exception { public void channelActive(ChannelHandlerContext ctx) throws Exception {
log.info("netty连接 长连接激活");
super.channelActive(ctx); super.channelActive(ctx);
} }
@@ -113,7 +114,6 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
@Override @Override
public void channelRead(ChannelHandlerContext ctx, String msg) { public void channelRead(ChannelHandlerContext ctx, String msg) {
log.info("netty连接 接收到数据:{}",msg);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
if (StringUtils.isNotEmpty(msg)) { if (StringUtils.isNotEmpty(msg)) {
jsonObject = JSONObject.parseObject(msg); jsonObject = JSONObject.parseObject(msg);
@@ -122,7 +122,7 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
} }
String type = jsonObject.getString("type"); String type = jsonObject.getString("type");
if(type.equals("heartbeat")){//心跳 if(type.equals("heartbeat")){//心跳
log.info("netty连接 接收到数据tableId:{} meg:{}",tableId,msg); log.info("netty连接 接收到心跳数据tableId:{} meg:{}",tableId,msg);
}else { }else {
if (type.equals("connect")) { if (type.equals("connect")) {
String tableId = jsonObject.getString("tableId"); String tableId = jsonObject.getString("tableId");
@@ -139,10 +139,10 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
this.shopId=shopId; this.shopId=shopId;
if (webSocketMap.containsKey(key)) { if (webSocketMap.containsKey(key)) {
ConcurrentHashMap<String, ChannelHandlerContext> userSocketMap = webSocketMap.get(key); ConcurrentHashMap<String, ChannelHandlerContext> userSocketMap = webSocketMap.get(key);
// ChannelHandlerContext channelHandlerContext = userSocketMap.get(userId); ChannelHandlerContext channelHandlerContext = userSocketMap.get(userId);
// if (channelHandlerContext != null) { if (channelHandlerContext != null) {
// channelHandlerContext.close(); channelHandlerContext.close();
// } }
userSocketMap.put(userId, ctx); userSocketMap.put(userId, ctx);
} else { } else {
ConcurrentHashMap<String, ChannelHandlerContext> userSocketMap = new ConcurrentHashMap<>(); ConcurrentHashMap<String, ChannelHandlerContext> userSocketMap = new ConcurrentHashMap<>();
@@ -160,6 +160,7 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
rabbitProducer.putCart(jsonObject.toJSONString()); rabbitProducer.putCart(jsonObject.toJSONString());
} }
else{ else{
log.info("netty连接 接收到接口数据meg:{}",msg);
jsonObject.put("tableId", this.tableId); jsonObject.put("tableId", this.tableId);
jsonObject.put("shopId", this.shopId); jsonObject.put("shopId", this.shopId);
if("sku".equals(type)){ if("sku".equals(type)){
@@ -222,9 +223,17 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
} else if (webSocketMap.containsKey(tableId)) { } else if (webSocketMap.containsKey(tableId)) {
ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(tableId); ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(tableId);
if(!webSockets.isEmpty()) { if(!webSockets.isEmpty()) {
for (ChannelHandlerContext ctx : webSockets.values()) { for (String user : webSockets.keySet()) {
sendMesToApp(message,ctx); ChannelHandlerContext ctx = webSockets.get(user);
if (ctx != null) {
log.info("netty连接 发送消息 桌码群发 userId:{}",user);
sendMesToApp(message,ctx);
}else {
log.info("netty连接 发送消息 桌码群发 userId:{} 失败",user);
}
} }
}else {
log.info("netty连接 发送消息 桌码群发 tableId:{} 失败",tableId);
} }
} }
} }

View File

@@ -53,16 +53,18 @@ public class CartConsumer {
if (array.size() > 0){ if (array.size() > 0){
cartService.createOrder(jsonObject); cartService.createOrder(jsonObject);
} }
}else if(jsonObject.getString("type").equals("pendingOrder")){ }
String cartDetail = redisUtil.getMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId)); // else if(jsonObject.getString("type").equals("pendingOrder")){
if (StringUtils.isEmpty(cartDetail)){ // String cartDetail = redisUtil.getMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId));
throw new MsgException("购物车为空无法下单"); // if (StringUtils.isEmpty(cartDetail)){
} // throw new MsgException("购物车为空无法下单");
JSONArray array = JSON.parseArray(cartDetail); // }
if (array.size() > 0){ // JSONArray array = JSON.parseArray(cartDetail);
cartService.pendingOrder(jsonObject); // if (array.size() > 0){
} // cartService.pendingOrder(jsonObject);
}else if(jsonObject.getString("type").equals("clearCart")){ // }
// }
else if(jsonObject.getString("type").equals("clearCart")){
cartService.clearCart(jsonObject); cartService.clearCart(jsonObject);
} }
} catch (Exception e) { } catch (Exception e) {

View File

@@ -14,6 +14,7 @@ public class RedisCst {
public static final String ONLINE_APP_USER = "ONLINE_APP_USER:"; public static final String ONLINE_APP_USER = "ONLINE_APP_USER:";
public static final String LDBL_APP_VERSION = "LDBL_APP_VERSION:"; public static final String LDBL_APP_VERSION = "LDBL_APP_VERSION:";
public static final String TABLE_CART = "TABLE:CART:"; public static final String TABLE_CART = "TABLE:CART:";
public static final String ORDER_EXPIRED = "ORDER:EXPIRED:";
public static final String TABLE_ORDER = "TABLE:ORDER:"; public static final String TABLE_ORDER = "TABLE:ORDER:";
public static final String PRODUCT = "PRODUCT:"; public static final String PRODUCT = "PRODUCT:";

View File

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

View File

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

View File

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

View File

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

View File

@@ -54,12 +54,15 @@ public class LocationUtils {
* @param keywords * @param keywords
* @return * @return
*/ */
public static String district(String keywords) { public static String district(String keywords,String subdistrict) {
Map<String, String> param = new HashMap<>(); Map<String, String> param = new HashMap<>();
//超掌柜生活-用户端 //超掌柜生活-用户端
param.put("key", "7a7f2e4790ea222660a027352ee3af39"); param.put("key", "7a7f2e4790ea222660a027352ee3af39");
param.put("keywords", keywords); param.put("keywords", keywords);
param.put("subdistrict", "1"); param.put("subdistrict", "1");
if (StringUtils.isNotBlank(subdistrict)) {
param.put("subdistrict", "2");
}
param.put("extensions", "base"); param.put("extensions", "base");
String s = HttpClientUtil.doGet("https://restapi.amap.com/v3/config/district", param); String s = HttpClientUtil.doGet("https://restapi.amap.com/v3/config/district", param);
return s; return s;

View File

@@ -538,6 +538,7 @@
from tb_order_info a from tb_order_info a
where user_id = #{userId} where user_id = #{userId}
and order_type='miniapp'
<if test="status != null and status != ''"> <if test="status != null and status != ''">
<choose> <choose>
<when test="status == 'unpaid'"> <when test="status == 'unpaid'">

View File

@@ -170,6 +170,11 @@
</if> </if>
</trim> </trim>
</insert> </insert>
<update id="upDateQrcodeNull" parameterType="java.lang.String">
update tb_shop_table
set qrcode = ''
where qrcode = #{qrcode,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopTable"> <update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopTable">
update tb_shop_table update tb_shop_table
<set> <set>

View File

@@ -384,6 +384,10 @@
select * from tb_shop_user where user_id=#{userId} and shop_id=#{shopId} select * from tb_shop_user where user_id=#{userId} and shop_id=#{shopId}
</select> </select>
<select id="selectByPhoneAndShopId" resultMap="BaseResultMap">
select * from tb_shop_user where telephone=#{phone} and shop_id=#{shopId}
</select>
<select id="selectAllByUserId" resultMap="BaseResultMap"> <select id="selectAllByUserId" resultMap="BaseResultMap">
select * from tb_shop_user where user_id=#{userId} select * from tb_shop_user where user_id=#{userId}
</select> </select>