ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserCoupon.java
@@ -32,6 +32,8 @@ @TableId("id") private Long id; @TableField(exist = false) private String idStr; @ApiModelProperty(value = "删除标志(0=否,1=是)") @TableField("del_flag") ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/VerifiableShopVo.java
@@ -15,4 +15,6 @@ private Integer id; @ApiModelProperty("门店名称") private String name; @ApiModelProperty("距离") private Long distance; } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Shop.java
@@ -170,5 +170,29 @@ private LocalDateTime createTime; @ApiModelProperty(value = "省") @TableField("province") private String province; @ApiModelProperty(value = "省编号") @TableField("province_code") private String provinceCode; @ApiModelProperty(value = "市") @TableField("city") private String city; @ApiModelProperty(value = "市编号") @TableField("city_code") private String cityCode; @ApiModelProperty(value = "区") @TableField("district") private String district; @ApiModelProperty(value = "区编号") @TableField("district_code") private String districtCode; } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java
@@ -586,4 +586,21 @@ } return R.ok(); } @ResponseBody @GetMapping("/switchShop") @ApiOperation(value = "切换门店", tags = {"门店后台-首页"}) public R switchShop(@PathVariable("shopId") Integer shopId){ Long userid = tokenService.getLoginUser().getUserid(); UserShop one = userShopService.getOne(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, userid).eq(UserShop::getShopId, shopId)); if(null == one){ return R.fail("切换失败"); } SysUser sysUser = userService.getById(userid); sysUser.setObjectId(shopId); userService.updateById(sysUser); return R.ok(); } } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -228,13 +228,13 @@ @Override public int insertDept(SysDept dept) { SysDept info = deptMapper.selectDeptById(dept.getParentId()); // 如果父节点不为正常状态,则不允许新增子节点 if (null != info && !UserConstants.DEPT_NORMAL.equals(info.getStatus())) { throw new ServiceException("部门停用,不允许新增"); } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); // SysDept info = deptMapper.selectDeptById(dept.getParentId()); // // 如果父节点不为正常状态,则不允许新增子节点 // if (null != info && !UserConstants.DEPT_NORMAL.equals(info.getStatus())) // { // throw new ServiceException("部门停用,不允许新增"); // } // dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); //判断店铺数据 Long userid = tokenService.getLoginUser().getUserid(); SysUser sysUser = sysUserService.getById(userid); @@ -253,14 +253,14 @@ @Override public int updateDept(SysDept dept) { SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId()); if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) { String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); String oldAncestors = oldDept.getAncestors(); dept.setAncestors(newAncestors); updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); } // SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); // SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId()); // if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) { // String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); // String oldAncestors = oldDept.getAncestors(); // dept.setAncestors(newAncestors); // updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); // } //判断店铺数据 Long userid = tokenService.getLoginUser().getUserid(); SysUser sysUser = sysUserService.getById(userid); ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java
@@ -75,6 +75,7 @@ .lt(status!=null&&status==3,UserCoupon::getEndTime, LocalDateTime.now()) .eq(UserCoupon::getAppUserId, userid).page(Page.of(pageNum-1, pageSize)); for (UserCoupon record : page.getRecords()) { record.setIdStr(record.getId().toString()); CouponInfo data = couponClient.detail(record.getCouponId()).getData(); CouponInfoVo vo = new CouponInfoVo(); BeanUtils.copyProperties(data,vo); @@ -228,6 +229,14 @@ BeanUtils.copyProperties(couponInfo, couponInfoVo); couponInfoVo.setGoodNames(goods.stream().map(Goods::getName).collect(Collectors.toList())); userCoupon.setCouponInfoVo(couponInfoVo); if (userCoupon.getUseTime()==null){ userCoupon.setStatus(1); if (userCoupon.getEndTime().isBefore(LocalDateTime.now())){ userCoupon.setStatus(3); } }else { userCoupon.setStatus(2); } return R.ok(userCoupon); } @@ -239,10 +248,10 @@ if(null == userCoupon){ return R.ok("核销码错误"); } if(userCoupon.getStatus() == 2){ if(userCoupon.getUseTime() != null){ return R.ok("优惠券已使用"); } if(userCoupon.getStatus() == 3){ if(LocalDateTime.now().isAfter(userCoupon.getEndTime())){ return R.ok("优惠券已过期"); } userCoupon.setStatus(2); ruoyi-service/ruoyi-order/pom.xml
@@ -156,6 +156,13 @@ <artifactId>sdk</artifactId> <version>1.0.11</version> </dependency> <!-- 计算两坐标间的直线距离 --> <dependency> <groupId>org.gavaghan</groupId> <artifactId>geodesy</artifactId> <version>1.1.3</version> </dependency> </dependencies> <build> ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java
@@ -113,33 +113,7 @@ } @ResponseBody @GetMapping("/getVerifiableShop") @ApiOperation(value = "获取可核销门店列表", tags = {"购物车-小程序"}) public R<List<VerifiableShopVo>> getVerifiableShop(){ LoginUser loginUser = tokenService.getLoginUserApplet(); List<ShoppingCart> shoppingCarts = shoppingCartService.list(new LambdaQueryWrapper<ShoppingCart>() .eq(ShoppingCart::getAppUserId, loginUser.getUserid())); List<Integer> goodsIds = shoppingCarts.stream().map(ShoppingCart::getGoodsId).collect(Collectors.toList()); GetGoodsShopByGoodsIds goodsShopByGoodsIds = new GetGoodsShopByGoodsIds(); goodsShopByGoodsIds.setGoodsIds(goodsIds); R<List<GoodsShop>> r = goodsShopClient.getGoodsShopByGoodsIds(goodsShopByGoodsIds); List<GoodsShop> goodsShops = r.getData(); List<VerifiableShopVo> verifiableShopVoList = new ArrayList<>(); if (CollectionUtil.isNotEmpty(goodsShops)){ for (GoodsShop goodsShop : goodsShops) { R<Shop> shopR = shopClient.getShopById(goodsShop.getShopId()); if (R.isSuccess(shopR) && null != shopR.getData()){ VerifiableShopVo verifiableShopVo = new VerifiableShopVo(); verifiableShopVo.setId(shopR.getData().getId()); verifiableShopVo.setName(shopR.getData().getName()); verifiableShopVoList.add(verifiableShopVo); } } } return R.ok(verifiableShopVoList); } @GetMapping("/getGoodsPrice") ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -335,7 +335,7 @@ @Override public R cancelOrder(Long orderId) { Order order = this.getById(orderId); if(Arrays.asList(4, 5, 6, 7, 8).contains(order.getOrderStatus())){ if(Arrays.asList(5, 6, 7).contains(order.getOrderStatus())){ return R.fail("无效的操作"); } order.setOrderStatus(5); ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/GeodesyUtil.java
File was renamed from ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/GeodesyUtil.java @@ -1,4 +1,4 @@ package com.ruoyi.other.task; package com.ruoyi.order.util; import com.ruoyi.common.core.utils.StringUtils; import org.gavaghan.geodesy.Ellipsoid; @@ -68,6 +68,6 @@ public static void main(String[] ages){ GeodesyUtil geodesyUtil = new GeodesyUtil(); geodesyUtil.getDistance("115.481028,39.989643", "114.465302,40.004717"); getDistance("115.481028,39.989643", "114.465302,40.004717"); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -11,11 +11,14 @@ import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.order.vo.VerifiableShopVo; import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.domain.ShopScore; import com.ruoyi.other.mapper.ShopMapper; import com.ruoyi.other.service.ShopScoreService; import com.ruoyi.other.service.ShopService; import com.ruoyi.other.util.GeodesyUtil; import com.ruoyi.other.util.tencentMap.TencentMapUtil; import com.ruoyi.other.vo.NearbyShopVO; import com.ruoyi.other.vo.ShopDetailVO; import com.ruoyi.other.vo.ShopStatistics; @@ -34,10 +37,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Set; import java.util.*; import java.util.stream.Collectors; /** @@ -95,6 +95,10 @@ shop.setServerOrderNumber(0); shop.setCustomOrderNumber(0); shop.setAppUserId(appUser.getId()); String city = TencentMapUtil.inverseGeographicalAnalysis(shop.getLongitude(), shop.getLatitude(), false); shop.setProvinceCode(city.substring(0, 2) + "0000"); shop.setCityCode(city.substring(0, 4) + "00"); shop.setDistrictCode(city); shopService.save(shop); AppUserShop appUserShop = new AppUserShop(); @@ -195,10 +199,13 @@ if (!shopService.cheUserByPhone(phone)) { return R.fail("该手机号未注册"); } String city = TencentMapUtil.inverseGeographicalAnalysis(shop.getLongitude(), shop.getLatitude(), false); shop.setProvinceCode(city.substring(0, 2) + "0000"); shop.setCityCode(city.substring(0, 4) + "00"); shop.setDistrictCode(city); Shop old_shop = shopService.getById(shop.getId()); shopService.updateById(shop); //修改管理员 if(!phone.equals(old_shop.getPhone())){ AppUser appUser = appUserClient.getAppUserById(old_shop.getAppUserId()); //需要先判断用户是否没有关联任何门店 List<AppUserShop> userShops = appUserShopClient.getAppUserShop(appUser.getId()).getData(); @@ -259,7 +266,6 @@ userShop.setShopId(shop.getId()); userShop.setRoleType(1); userShopClient.saveUserShop(userShop); } } return R.ok(); } @@ -448,5 +454,55 @@ public void updateShop(@RequestBody Shop shop){ shopService.updateById(shop); } @ResponseBody @GetMapping("/getVerifiableShop") @ApiOperation(value = "获取可核销门店列表", tags = {"购物车-小程序"}) public R<List<VerifiableShopVo>> getVerifiableShop(String longitude, String latitude){ String city = TencentMapUtil.inverseGeographicalAnalysis(longitude, latitude, false); city = city.substring(0, 4) + "00"; List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getCityCode, city)); List<VerifiableShopVo> verifiableShopVoList = new ArrayList<>(); for (Shop shop : list) { VerifiableShopVo vo = new VerifiableShopVo(); vo.setId(shop.getId()); vo.setName(shop.getName()); Double wgs84 = GeodesyUtil.getDistance(longitude + "," + latitude, shop.getLongitude() + "," + shop.getLatitude()).get("WGS84"); vo.setDistance(wgs84.longValue()); verifiableShopVoList.add(vo); } verifiableShopVoList.sort(new Comparator<VerifiableShopVo>() { @Override public int compare(VerifiableShopVo o1, VerifiableShopVo o2) { return o1.getDistance().compareTo(o2.getDistance()); } }); return R.ok(verifiableShopVoList); } @ResponseBody @GetMapping("/getSysUserShop") @ApiOperation(value = "获取可切换的门店列表", tags = {"门店后台-首页"}) public R<List<VerifiableShopVo>> getSysUserShop(){ Long userid = tokenService.getLoginUser().getUserid(); UserShop userShop = new UserShop(); userShop.setUserId(userid); List<UserShop> data = userShopClient.getUserShop(userShop).getData(); List<Integer> collect = data.stream().map(UserShop::getShopId).collect(Collectors.toList()); List<Shop> shops = shopService.listByIds(collect); List<VerifiableShopVo> list = new ArrayList<>(); for (Shop shop : shops) { VerifiableShopVo vo = new VerifiableShopVo(); vo.setId(shop.getId()); vo.setName(shop.getName()); list.add(vo); } return R.ok(list); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianController.java
@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; /** * <p> @@ -103,7 +104,9 @@ @ApiOperation(value = "技师列表", tags = {"技师列表-小程序"}) public R<TableDataInfo<TechnicianVO>> technicianListByShopId(@ApiParam("门店id") @RequestParam Long shopId,@ApiParam("技师姓名") String name) { startPage(); return R.ok(getDataTable(technicianService.getTechnicianListByShopId(shopId,name))); List<TechnicianVO> technicianListByShopId = technicianService.getTechnicianListByShopId(shopId, name); TableDataInfo<TechnicianVO> dataTable = getDataTable(technicianListByShopId); return R.ok(dataTable); } @GetMapping("/manage/list") ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/GeodesyUtil.javacopy from ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/GeodesyUtil.java copy to ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/GeodesyUtil.java
File was copied from ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/GeodesyUtil.java @@ -1,4 +1,4 @@ package com.ruoyi.other.task; package com.ruoyi.other.util; import com.ruoyi.common.core.utils.StringUtils; import org.gavaghan.geodesy.Ellipsoid; @@ -68,6 +68,6 @@ public static void main(String[] ages){ GeodesyUtil geodesyUtil = new GeodesyUtil(); geodesyUtil.getDistance("115.481028,39.989643", "114.465302,40.004717"); getDistance("115.481028,39.989643", "114.465302,40.004717"); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/tencentMap/TencentMapUtil.java
New file @@ -0,0 +1,40 @@ package com.ruoyi.other.util.tencentMap; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; /** * 腾讯地图 * @author zhibing.pu * @Date 2024/12/19 9:37 */ @Slf4j public class TencentMapUtil { private static String key = "NH7BZ-XNW6Z-IKUX7-TL3H2-UN6RO-KKFHQ"; /** * 根据经纬度获取行政区划代码 * @param lon 经度 * @param lat 纬度 * @param poi 是否返回周边poi * @return */ public static String inverseGeographicalAnalysis(String lon, String lat, boolean poi){ HttpRequest get = HttpUtil.createGet("https://apis.map.qq.com/ws/geocoder/v1/?location=" + lat + "," + lon + "&key=" + key + "&get_poi=" + (poi ? 1 : 0)); HttpResponse execute = get.execute(); JSONObject jsonObject = JSON.parseObject(execute.body()); Integer status = jsonObject.getInteger("status"); if(0 != status){ log.error(jsonObject.getString("message")); return null; } JSONObject result = jsonObject.getJSONObject("result"); JSONObject ad_info = result.getJSONObject("ad_info"); return ad_info.getString("adcode"); } }