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