zoukankan      html  css  js  c++  java
  • 微信扫码支付6-更新课程销量

    一、修改课程销量

    1、service层

    接口:service_edu中CourseService

    void updateBuyCountById(String id);
    

    实现:CourseServiceImpl

    @Override
    public void updateBuyCountById(String id) {
        Course course = baseMapper.selectById(id);
        course.setBuyCount(course.getBuyCount() + 1);
        this.updateById(course);
    }
    

    2、controller层

    ApiCourseController

    @ApiOperation("根据课程id更改销售量")
    @GetMapping("inner/update-buy-count/{id}")
    public R updateBuyCountById(
        @ApiParam(value = "课程id", required = true)
        @PathVariable String id){
        courseService.updateBuyCountById(id);
        return R.ok();
    }
    

    二、远程调用接口

    1、Feign接口

    接口:service_trade 中 EduCourseService

    @GetMapping("/api/edu/course/inner/update-buy-count/{id}")
    R updateBuyCountById(@PathVariable("id") String id);
    

    2、熔断器

    EduCourseServiceFallBack

    @Override
    public R updateBuyCountById(String id) {
        log.error("熔断器被执行");
        return R.error();
    }
    

    3、RPC调用

    OrderServiceImpl

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void updateOrderStatus(Map<String, String> map) {
    
        //更新订单状态
        ......
        
        //记录支付日志
        ......
        
        //更新课程销量:有问题直接熔断
        eduCourseService.updateBuyCountById(order.getCourseId());
    }
    
  • 相关阅读:
    ACM2023
    Archlinux系统运维
    Apache2配置腾讯云SSL证书
    奇异值分解SVD
    剑指offer-不用加减乘除做加法
    负载均衡与缓存
    leetcode简单题6
    python 函数
    Mac-常用命令与快捷键
    GOM通区插件-支持GOM绝对路径-读取配置项-分割字符等功能。不定期更新
  • 原文地址:https://www.cnblogs.com/smalldong/p/13909765.html
Copyright © 2011-2022 走看看