查询省市

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

@@ -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();

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.RestController;
import javax.annotation.Resource;
import java.util.concurrent.ExecutionException;
/**
* 首页其它接口

View File

@@ -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);