parent
c34518631b
commit
6ab2a32c9f
6
pom.xml
6
pom.xml
|
|
@ -20,7 +20,11 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId >pinyin4j</artifactId>
|
||||
<version >2.5.1</version >
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -88,6 +89,27 @@ public class CommonController {
|
|||
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
|
||||
*/
|
||||
@GetMapping("location/district")
|
||||
public Result createOrder(String keywords) throws JsonProcessingException {
|
||||
String districtJson = LocationUtils.district(keywords);
|
||||
public Result district(String keywords) throws JsonProcessingException {
|
||||
String districtJson = LocationUtils.district(keywords,null);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
// 将 JSON 字符串解析为 JsonNode 对象
|
||||
JsonNode jsonNode = mapper.readTree(districtJson);
|
||||
JsonNode districts = jsonNode.get("districts");
|
||||
String text = districts.toString();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import org.springframework.web.bind.annotation.RequestHeader;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* 首页其它接口
|
||||
|
|
|
|||
|
|
@ -80,31 +80,38 @@ public class UserContoller {
|
|||
@GetMapping("/shopUserInfo")
|
||||
public Result shopUserInfo(@RequestParam("userId") String userId ,@RequestHeader("openId") String openId,@RequestParam("shopId") String shopId ) throws Exception {
|
||||
TbShopUser shopUser=new TbShopUser();
|
||||
if (StringUtils.isNotBlank(shopId)) {
|
||||
if (StringUtils.isNotBlank(shopId) && !shopId.equals("null")) {
|
||||
shopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
|
||||
if (ObjectUtil.isEmpty(shopUser)) {
|
||||
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
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());
|
||||
shopUserMapper.insert(shopUser);
|
||||
shopUser = shopUserMapper.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());
|
||||
shopUserMapper.insert(shopUser);
|
||||
}else {
|
||||
shopUser.setUserId(userId);
|
||||
shopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
shopUserMapper.updateByPrimaryKey(shopUser);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
shopUser.setAmount(BigDecimal.ZERO);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public interface TbShopTableMapper {
|
|||
|
||||
String queryShopIdByTableCode(String code);
|
||||
|
||||
int upDateQrcodeNull(String code);
|
||||
int updateByPrimaryKeySelective(TbShopTable record);
|
||||
|
||||
int updateByPrimaryKey(TbShopTable record);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public interface TbShopUserMapper {
|
|||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
package com.chaozhanggui.system.cashierservice.entity.vo;
|
||||
|
||||
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;
|
||||
|
||||
|
|
@ -8,11 +13,30 @@ import java.util.List;
|
|||
* 行政区域返回vo
|
||||
*/
|
||||
@Data
|
||||
public class DistrictVo {
|
||||
private String citycode;
|
||||
public class DistrictVo{
|
||||
private Object citycode;
|
||||
private String adcode;
|
||||
private String name;
|
||||
private String center;
|
||||
private String level;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
|||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
log.info("netty连接 长连接激活");
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +114,6 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
|||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, String msg) {
|
||||
log.info("netty连接 接收到数据:{}",msg);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (StringUtils.isNotEmpty(msg)) {
|
||||
jsonObject = JSONObject.parseObject(msg);
|
||||
|
|
@ -122,7 +122,7 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
|||
}
|
||||
String type = jsonObject.getString("type");
|
||||
if(type.equals("heartbeat")){//心跳
|
||||
log.info("netty连接 接收到数据:tableId:{} meg:{}",tableId,msg);
|
||||
log.info("netty连接 接收到心跳数据:tableId:{} meg:{}",tableId,msg);
|
||||
}else {
|
||||
if (type.equals("connect")) {
|
||||
String tableId = jsonObject.getString("tableId");
|
||||
|
|
@ -139,10 +139,10 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
|||
this.shopId=shopId;
|
||||
if (webSocketMap.containsKey(key)) {
|
||||
ConcurrentHashMap<String, ChannelHandlerContext> userSocketMap = webSocketMap.get(key);
|
||||
// ChannelHandlerContext channelHandlerContext = userSocketMap.get(userId);
|
||||
// if (channelHandlerContext != null) {
|
||||
// channelHandlerContext.close();
|
||||
// }
|
||||
ChannelHandlerContext channelHandlerContext = userSocketMap.get(userId);
|
||||
if (channelHandlerContext != null) {
|
||||
channelHandlerContext.close();
|
||||
}
|
||||
userSocketMap.put(userId, ctx);
|
||||
} else {
|
||||
ConcurrentHashMap<String, ChannelHandlerContext> userSocketMap = new ConcurrentHashMap<>();
|
||||
|
|
@ -160,6 +160,7 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
|||
rabbitProducer.putCart(jsonObject.toJSONString());
|
||||
}
|
||||
else{
|
||||
log.info("netty连接 接收到接口数据:meg:{}",msg);
|
||||
jsonObject.put("tableId", this.tableId);
|
||||
jsonObject.put("shopId", this.shopId);
|
||||
if("sku".equals(type)){
|
||||
|
|
@ -222,9 +223,17 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
|||
} else if (webSocketMap.containsKey(tableId)) {
|
||||
ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(tableId);
|
||||
if(!webSockets.isEmpty()) {
|
||||
for (ChannelHandlerContext ctx : webSockets.values()) {
|
||||
sendMesToApp(message,ctx);
|
||||
for (String user : webSockets.keySet()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,16 +53,18 @@ public class CartConsumer {
|
|||
if (array.size() > 0){
|
||||
cartService.createOrder(jsonObject);
|
||||
}
|
||||
}else if(jsonObject.getString("type").equals("pendingOrder")){
|
||||
String cartDetail = redisUtil.getMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId));
|
||||
if (StringUtils.isEmpty(cartDetail)){
|
||||
throw new MsgException("购物车为空无法下单");
|
||||
}
|
||||
JSONArray array = JSON.parseArray(cartDetail);
|
||||
if (array.size() > 0){
|
||||
cartService.pendingOrder(jsonObject);
|
||||
}
|
||||
}else if(jsonObject.getString("type").equals("clearCart")){
|
||||
}
|
||||
// else if(jsonObject.getString("type").equals("pendingOrder")){
|
||||
// String cartDetail = redisUtil.getMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId));
|
||||
// if (StringUtils.isEmpty(cartDetail)){
|
||||
// throw new MsgException("购物车为空无法下单");
|
||||
// }
|
||||
// JSONArray array = JSON.parseArray(cartDetail);
|
||||
// if (array.size() > 0){
|
||||
// cartService.pendingOrder(jsonObject);
|
||||
// }
|
||||
// }
|
||||
else if(jsonObject.getString("type").equals("clearCart")){
|
||||
cartService.clearCart(jsonObject);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public class RedisCst {
|
|||
public static final String ONLINE_APP_USER = "ONLINE_APP_USER:";
|
||||
public static final String LDBL_APP_VERSION = "LDBL_APP_VERSION:";
|
||||
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 PRODUCT = "PRODUCT:";
|
||||
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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("找不到台桌");
|
||||
|
|
|
|||
|
|
@ -54,12 +54,15 @@ public class LocationUtils {
|
|||
* @param keywords
|
||||
* @return
|
||||
*/
|
||||
public static String district(String keywords) {
|
||||
public static String district(String keywords,String subdistrict) {
|
||||
Map<String, String> param = new HashMap<>();
|
||||
//超掌柜生活-用户端
|
||||
param.put("key", "7a7f2e4790ea222660a027352ee3af39");
|
||||
param.put("keywords", keywords);
|
||||
param.put("subdistrict", "1");
|
||||
if (StringUtils.isNotBlank(subdistrict)) {
|
||||
param.put("subdistrict", "2");
|
||||
}
|
||||
param.put("extensions", "base");
|
||||
String s = HttpClientUtil.doGet("https://restapi.amap.com/v3/config/district", param);
|
||||
return s;
|
||||
|
|
|
|||
|
|
@ -538,6 +538,7 @@
|
|||
from tb_order_info a
|
||||
|
||||
where user_id = #{userId}
|
||||
and order_type='miniapp'
|
||||
<if test="status != null and status != ''">
|
||||
<choose>
|
||||
<when test="status == 'unpaid'">
|
||||
|
|
|
|||
|
|
@ -170,6 +170,11 @@
|
|||
</if>
|
||||
</trim>
|
||||
</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 tb_shop_table
|
||||
<set>
|
||||
|
|
|
|||
|
|
@ -384,6 +384,10 @@
|
|||
select * from tb_shop_user where user_id=#{userId} and shop_id=#{shopId}
|
||||
</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 * from tb_shop_user where user_id=#{userId}
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue