From a6adc81366d372c10bea78024a09e408a2ad31d6 Mon Sep 17 00:00:00 2001 From: GYJ <1157756119@qq.com> Date: Wed, 19 Jun 2024 17:36:45 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=AC=BE=E5=9B=9E=E6=BB=9A=E5=BA=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../cashierservice/service/PayService.java | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index 7096985..105a094 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -21,6 +21,7 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; @@ -84,6 +85,13 @@ public class PayService { TbShopInfoMapper tbShopInfoMapper; @Autowired TbQuickPayMapper tbQuickPayMapper; + + @Autowired + private TbProductSkuMapper productSkuMapper; + + @Autowired + private RedisUtils redisUtil; + @Value("${gateway.url}") private String gateWayUrl; @Value("${client.backUrl}") @@ -905,9 +913,19 @@ public class PayService { // jsonObject.put("data",new ReturnWTZInfo(orderId+"",newOrderInfo.getPayAmount(),details)); producer.putOrderCollect(jsonObject.toJSONString()); - producer.printMechine(String.valueOf(newOrderInfo.getId())); + // 更新商品库存 + for (TbOrderDetail detail : returnDetail) { + detail = tbOrderDetailMapper.selectByPrimaryKey(detail.getId()); + + TbProductSku productSku = productSkuMapper.selectByPrimaryKey(detail.getProductSkuId()); + if (ObjectUtil.isNotEmpty(productSku)) { + redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":" + productSku.getId().toString(), String.valueOf(detail.getReturnNum() + productSku.getStockNumber().intValue())); + productSkuMapper.updateByskuIdSub(productSku.getId(), detail.getReturnNum() * -1); + } + } + return Result.success(CodeEnum.SUCCESS); }