From 8aa5c669bc1b46be539f56a4b2ec35d977422e59 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期三, 10 七月 2024 21:15:45 +0800 Subject: [PATCH] 分表 --- ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java | 75 +++++++++++++++++++++++++++++++++---- 1 files changed, 66 insertions(+), 9 deletions(-) diff --git a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java index 796b60c..a86bcaa 100644 --- a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java +++ b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java @@ -1,4 +1,5 @@ package com.ruoyi.goods.controller; +import java.util.Date; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -17,6 +18,7 @@ import com.ruoyi.goods.vo.TOrderVO; import com.ruoyi.study.api.domain.TUser; import com.ruoyi.study.api.feignClient.StudyClient; +import com.ruoyi.study.api.vo.UserPersonalCenterVO; import com.ruoyi.system.api.model.LoginUserParent; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -58,7 +60,38 @@ private IRegionService regionService; @Resource private TokenService tokenService; - + @PostMapping("/testAddData") + @ApiOperation(value = "测试分片", tags = {"测试分片"}) + public R<Object> testAddData() { + TOrder tOrder = new TOrder(); + tOrder.setOrderNumber(""); + tOrder.setUserId(63); + tOrder.setInsertTime(new Date()); + tOrder.setGoodsId(0); + tOrder.setCount(0); + tOrder.setState(0); + tOrder.setExpress(""); + tOrder.setExpressNumber(""); + tOrder.setExpressTime(new Date()); + tOrder.setIntegral(0); + tOrder.setCompleteTime(new Date()); + tOrder.setConsigneeName(""); + tOrder.setImg(""); + tOrder.setName(""); + tOrder.setType(""); + tOrder.setConsigneePhone(""); + tOrder.setConsigneeAddress(""); + tOrder.setProvince(""); + tOrder.setCity(""); + tOrder.setRemark(""); + tOrder.setDisabled(false); + tOrder.setCreateBy(""); + tOrder.setCreateTime(new Date()); + tOrder.setUpdateBy(""); + tOrder.setUpdateTime(new Date()); + orderService.save(tOrder); + return R.ok(); + } @PostMapping("/listType") @ApiOperation(value = "列表查询", tags = {"后台-商品类型管理"}) public R<PageInfo<TGoodsType>> listType(@RequestBody GoodsTypeQuery query) { @@ -323,11 +356,12 @@ @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "id", dataType = "String", required = true) }) - public R<Boolean> confirm(@RequestParam Integer id) { + public R<Boolean> confirm(@RequestParam String id) { if (tokenService.getLoginUser1() == null) { return R.tokenError("登录失效"); } TOrder byId = orderService.getById(id); + byId.setUserId(null); byId.setState(3); byId.setCompleteTime(new Date()); return R.ok(orderService.updateById(byId)); @@ -342,11 +376,12 @@ @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "id", dataType = "String", required = true) }) - public R<Boolean> confirmStudy(@RequestParam Integer id) { + public R<Boolean> confirmStudy(@RequestParam String id) { if (tokenService.getLoginUserStudy() == null) { return R.tokenError("登录失效"); } TOrder byId = orderService.getById(id); + byId.setUserId(null); byId.setState(3); byId.setCompleteTime(new Date()); return R.ok(orderService.updateById(byId)); @@ -595,7 +630,7 @@ @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "String", required = true), @ApiImplicitParam(value = "地址信息id", name = "recipientId", dataType = "String", required = true) }) - public R updateOrderAddressParent(@RequestParam Integer orderId, @RequestParam Integer recipientId) { + public R updateOrderAddressParent(@RequestParam String orderId, @RequestParam Integer recipientId) { if (tokenService.getLoginUser1() == null) { return R.tokenError("登录失效"); } @@ -607,6 +642,7 @@ if (!Constants.ONE.equals(order.getState())) { throw new GlobalException("订单已发货,无法修改收货地址!"); } + order.setUserId(null); order.setConsigneeName(recipient.getRecipient()); order.setConsigneePhone(recipient.getRecipientPhone()); order.setConsigneeAddress(recipient.getProvince()+recipient.getCity()+recipient.getAddress()); @@ -621,7 +657,7 @@ @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "String", required = true), @ApiImplicitParam(value = "地址信息id", name = "recipientId", dataType = "String", required = true) }) - public R updateOrderAddress(@RequestParam Integer orderId, @RequestParam Integer recipientId) { + public R updateOrderAddress(@RequestParam String orderId, @RequestParam Integer recipientId) { if (tokenService.getLoginUserStudy() == null) { return R.tokenError("登录失效"); } @@ -633,6 +669,7 @@ if (!Constants.ONE.equals(order.getState())) { throw new GlobalException("订单已发货,无法修改收货地址!"); } + order.setUserId(null); order.setConsigneeName(recipient.getRecipient()); order.setConsigneePhone(recipient.getRecipientPhone()); order.setConsigneeAddress(recipient.getProvince()+recipient.getCity()+recipient.getAddress()); @@ -662,7 +699,20 @@ if (null == loginUserStudy) { return R.tokenError("登录失效!"); } - return R.ok(goodsService.goodRecommend(loginUserStudy.getUserid())); + UserPersonalCenterVO data = studyClient.userInfo().getData(); + List<TGoodsVO> tGoodsVOS = goodsService.goodRecommend(loginUserStudy.getUserid()); + List<TGoodsVO> res = new ArrayList<>(); + int temp = 0; + for (TGoodsVO re : tGoodsVOS) { + if (temp>=3){ + break; + } + if (data.getUser().getIntegral()>=re.getIntegral()){ + res.add(re); + temp++; + } + } + return R.ok(res); } /** @@ -702,7 +752,10 @@ if (null != goods.getBasicCount()) { number += goods.getBasicCount(); } - number += orderService.getGoodBuyNumber(goods.getId()); + List<TOrder> list = orderService.list(new QueryWrapper<TOrder>().eq("goodsId", goods.getId())); + for (TOrder tOrder : list) { + number+=tOrder.getCount(); + } // 剩余兑换数量 Integer residueNumber = null; if (null != goods.getTotal()) { @@ -744,7 +797,10 @@ if (null != goods.getBasicCount()) { number += goods.getBasicCount(); } - number += orderService.getGoodBuyNumber(goods.getId()); + List<TOrder> list = orderService.list(new QueryWrapper<TOrder>().eq("goodsId", goods.getId())); + for (TOrder tOrder : list) { + number+=tOrder.getCount(); + } // 剩余兑换数量 Integer residueNumber = null; if (null != goods.getTotal()) { @@ -874,7 +930,7 @@ @PostMapping("/getOrderInfo/{id}") @ApiOperation(value = "查看详情", tags = {"后台-订单管理"}) @ApiOperationSupport(order = 11) - public R<TOrderVO> getOrderInfo(@PathVariable("id") Integer id) { + public R<TOrderVO> getOrderInfo(@PathVariable("id") String id) { TOrder byId = orderService.getById(id); TGoods byId2 = goodsService.getById(byId.getGoodsId()); TOrderVO tGoodsVO = new TOrderVO(); @@ -894,6 +950,7 @@ @ApiOperationSupport(order = 12) public R getGoodsInfo1(@RequestBody OrderDTO dto) { TOrder byId = orderService.getById(dto.getId()); + byId.setUserId(null); byId.setState(2); byId.setExpress(dto.getExpress()); byId.setExpressNumber(dto.getExpressNumber()); -- Gitblit v1.7.1