From 07de03ccae02d00be243911a003115fe9b24f863 Mon Sep 17 00:00:00 2001 From: huliguo <2023611923@qq.com> Date: 星期二, 08 四月 2025 16:07:07 +0800 Subject: [PATCH] 订单部分+个人中心部分 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java | 85 +++++++++++++++++++++++++++++++++++------- 1 files changed, 71 insertions(+), 14 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java index 02e4ffc..6529950 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java @@ -17,13 +17,11 @@ import com.ruoyi.order.vo.VerifiableShopVo; import com.ruoyi.other.api.domain.*; import com.ruoyi.other.mapper.ShopMapper; +import com.ruoyi.other.mapper.ShopScoreMapper; import com.ruoyi.other.service.*; import com.ruoyi.other.util.GeodesyUtil; import com.ruoyi.other.util.tencentMap.TencentMapUtil; -import com.ruoyi.other.vo.NearbyShopVO; -import com.ruoyi.other.vo.SaveWithdrawalAccount; -import com.ruoyi.other.vo.ShopDetailVO; -import com.ruoyi.other.vo.ShopStatistics; +import com.ruoyi.other.vo.*; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.feignClient.SysUserClient; import com.ruoyi.system.api.feignClient.UserShopClient; @@ -70,6 +68,8 @@ @Resource private ShopMapper shopMapper; @Resource + private ShopScoreMapper shopScoreMapper; + @Resource private UserShopClient userShopClient; @Resource private GoodsService goodsService; @@ -79,9 +79,61 @@ private OrderClient orderClient; @Resource private ReceiverBankChannelService receiverBankChannelService; + @Resource + private ShopScoreService shopScoreService; + /** + * 门店打分 + * @return + */ + @PostMapping("/shopScore") + @ApiOperation(value = "门店打分", tags = {"小程序-个人中心"}) + public R<Void> shopScore(@RequestBody ShopScore shopScore) { + if (null==shopScore.getShopId()){ + return R.fail("门店不能为空"); + } + if (null==shopScore.getScore()){ + return R.fail("评分不能为空"); + } + //验证门店是否存在 + Shop one = shopService.getOne(new LambdaQueryWrapper<Shop>().eq(Shop::getId, shopScore.getShopId()).eq(Shop::getStatus, 1).eq(Shop::getDelFlag, 0)); + if (null == one){ + return R.fail("门店不存在"); + } + LoginUser loginUserApplet = tokenService.getLoginUserApplet(); + shopScore.setAppUserId(loginUserApplet.getUserid()); + shopScore.setCreateTime(LocalDateTime.now()); + shopScoreService.save(shopScore); + //计算,更新到门店中 + //总评分 + List<BigDecimal> scores = shopScoreMapper.selectList(new LambdaQueryWrapper<ShopScore>().eq(ShopScore::getShopId, shopScore.getShopId())).stream().map(ShopScore::getScore).collect(Collectors.toList()); + BigDecimal score = getScore(scores); + one.setId(shopScore.getShopId().intValue()); + one.setScore(score.doubleValue()); + shopMapper.updateById(one); + return R.ok(); + } + /** + * 计算评分 + */ + private BigDecimal getScore(List<BigDecimal> scores) { + if (scores == null || scores.isEmpty()) { + return BigDecimal.ZERO.setScale(1, RoundingMode.HALF_UP); // 默认返回 0.0 + } + + // 计算总分 + BigDecimal totalScore = scores.stream().reduce(BigDecimal.ZERO, BigDecimal::add); + + // 计算平均值,并保留 1 位小数(四舍五入) + BigDecimal averageScore = totalScore.divide( + new BigDecimal(scores.size()), + 1, // 保留 1 位小数 + RoundingMode.HALF_UP // 四舍五入 + ); + return averageScore; + } @PostMapping @ApiOperation(value = "新增门店", tags = {"管理后台-门店管理"}) @@ -201,7 +253,7 @@ @DeleteMapping("/deleteShop") @ApiOperation(value = "删除门店", tags = {"管理后台-门店管理"}) public R<Void> deleteShop(@ApiParam("门店id") @RequestParam("id") Integer id){ - List<Goods> list1 = goodsService.list(new LambdaQueryWrapper<Goods>().eq(Goods::getDelFlag, 0).eq(Goods::getAppointStore, 1).eq(Goods::getStatus, 2)); + /*List<Goods> list1 = goodsService.list(new LambdaQueryWrapper<Goods>().eq(Goods::getDelFlag, 0).eq(Goods::getAppointStore, 1).eq(Goods::getStatus, 2)); if(list1.size() > 0){ Set<Integer> collect1 = list1.stream().map(Goods::getId).collect(Collectors.toSet()); long count = goodsShopService.count(new LambdaQueryWrapper<GoodsShop>().eq(GoodsShop::getShopId, id).in(GoodsShop::getGoodsId, collect1)); @@ -228,7 +280,7 @@ if(data.size() > 0){ //删除门店后台账号和关系数据 sysUserClient.delShopUser(shop.getId(), 2); - } + }*/ return R.ok(); } @@ -404,7 +456,7 @@ @GetMapping("/list") @ApiOperation(value = "门店列表", tags = {"管理后台-门店管理"}) - public R<IPage<Shop>> list(@ApiParam("页码") @RequestParam Integer pageNum,@ApiParam("每一页数据大小") Integer pageSize,Shop shop){ + public R<IPage<Shop>> list(@ApiParam("页码") @RequestParam("pageNum") Integer pageNum,@ApiParam("每一页数据大小") @RequestParam("pageSize") Integer pageSize,Shop shop){ IPage<Shop> shopIPage = shopService.getShopList(pageNum, pageSize, shop); for (Shop record : shopIPage.getRecords()) { record.setLaveUsePoint(record.getLavePoint()); @@ -459,16 +511,19 @@ /** - * 附近门店列表 + * 附近门店列表/更多门店 */ @GetMapping("/nearbyShopList") - @ApiOperation(value = "附近门店列表", tags = {"小程序-首页"}) + @ApiOperation(value = "附近门店列表/更多门店", tags = {"小程序-首页"}) public R<List<NearbyShopVO>> nearbyShopList(@ApiParam("经度") @RequestParam BigDecimal longitude, - @ApiParam("纬度") @RequestParam BigDecimal latitude) { - return R.ok(shopService.nearbyShopList(longitude, latitude)); + @ApiParam("纬度") @RequestParam BigDecimal latitude, + Shop shop) { + return R.ok(shopService.nearbyShopList(longitude, latitude,shop)); } - + /** + * 门店详情 + */ @GetMapping("/shopDetail") @ApiOperation(value = "门店详情", tags = {"小程序-首页"}) public R<ShopDetailVO> shopDetail(@ApiParam("门店id") @RequestParam Integer shopId, @@ -476,6 +531,7 @@ @ApiParam("纬度") @RequestParam BigDecimal latitude) { return R.ok(shopService.getShopDetail(shopId, longitude, latitude)); } + /** @@ -599,7 +655,7 @@ @GetMapping("/getVerifiableShop") @ApiOperation(value = "获取可核销门店列表", tags = {"购物车-小程序"}) public R<List<VerifiableShopVo>> getVerifiableShop(String longitude, String latitude, Integer goodsId){ - String city = TencentMapUtil.inverseGeographicalAnalysis(longitude, latitude, false); + /* String city = TencentMapUtil.inverseGeographicalAnalysis(longitude, latitude, false); if(null == city){ city = "510100"; } @@ -633,7 +689,8 @@ return o1.getDistance().compareTo(o2.getDistance()); } }); - return R.ok(verifiableShopVoList); + return R.ok(verifiableShopVoList);*/ + return null; } -- Gitblit v1.7.1