type
status
date
slug
summary
tags
category
titleIcon
password
icon
calloutIcon
📌
记录一次简单的debug分析过程 - 天机学堂结算优惠前端不显示问题

背景概要

  • 在购物车结算服务中,用户具有优惠卷但结算不显示。
notion image
notion image
注:复盘时已经修复,使用的是没有优惠劵的用户展示结算界面

链路1-前端请求

  • 先明确计算优惠劵方案的接口路径,为/available,挂在tj-promotion服务下
notion image
  • 考察前端请求,并没有/available的请求路径
notion image
  • 一个请求tj-learning,不属于相关内容,排除
notion image
  • 一个请求order相关,属于相关内容,进一步考察相关代码
notion image

链路2-后端服务

网关部分的内容可以自行查阅,不再赘述,也可以自行断点确定是否接口真是与前端对应的
  • 定位到对应接口
notion image
  • 查看内容,发现相关优惠劵业务未实现,问题定位到prePlaceOrder接口
notion image
  • 核对gogs里master分支相关代码,无相关实现,需要自行补充
notion image
notion image

链路3-核查前端代码

  • 切换至前端源码,定位请求API回调
notion image
  • 在对应page下查找相关使用
notion image
  • 在对应返回数据中,应该有以下结构:
discounts:array
  • ids:array<number>
  • rules:array
  • discountAmount:number
notion image
  • 继续沿着orderInfo赋值变量的使用,可以看到还需要:
courses:array
  • name: string
  • coverUrl: string
  • price: number
notion image

链路4-回归计算接口

  • 现在重回优惠计算的接口,观察返回参数
notion image
  • List<CouponDiscountDTO>:array
    • ids(List<Long>):array<number>
    • rules(List):array
    • discountAmount(Integer):number
  • 出参与所需重叠,需要将计算优惠的返回参数传回前端
notion image
  • courses:array
    • name: string
    • coverUrl: string
    • price: number
  • 由于课程信息的参数没有现成的VO复用,需要自行补充
notion image

链路5-回归原接口

  • 重回原接口,在返回值参数里面补充信息
notion image
notion image
  • 补充实现计算优惠业务逻辑
notion image

问题解决

  • 重启tj-trade服务,重新切回页面,再次测试
notion image
  • 可以选择优惠劵
notion image
  • 正确获得优惠后金额
notion image

其他常见问题

Feign调用404

  • feign调用需要补上写在Controller类上的部分路径,提供完整路径调用,路径不全可能出现404错误
notion image
  • 相关日志
notion image

No format fit for date string

  • 构造LocalDateTime的时候错误地传入时间戳,
notion image
  • 切换为AOP分布式锁版本后的领劵业务没有从lua版本的优惠劵缓存写切换为一般版本的缓存写,使得时间是时间戳形式,而不是LocalDateTime
notion image
notion image

后台业务响应但前端没有展示

  • 参考以下流程,更换tj-portal
正常预期效果:
notion image
解决方案:
1.虚拟机上自带的tj-admin会出现这样的情况,可以使用API直接发放
2.对前端资料的tj-admin在npm i后重新npm run build(注意使用build,dev环境打包,prod打包js文件不全),对打包的dist文件夹重命名tj-admin上传虚拟机替换目录(/usr/local/src)下tj-admin,重新进入即可。

了解更多

 
天机学堂Day01复盘-环境搭建天机学堂Day02-Day05复盘-课表|计划|进度|问答业务
Loading...
CamelliaV
CamelliaV
Java;CV;ACGN
最新发布
单例模式的四种写法
2025-4-24
体验MCP
2025-4-24
MetingJS使用自定义音乐源-CF+Huggingface部署
2025-4-2
博客访问站点测速分析与对比
2025-3-26
前端模块化
2025-3-16
Voxel2Mesh相关论文精读与代码复现
2025-3-15
公告
计划:
  • LLM相关
  • 支付业务 & 双token无感刷新
  • (线程池计算优惠方案)天机学堂Day09-Day12复盘-优惠劵业务
  • (业务复盘,技术汇总)天机学堂完结复盘
  • hot 100
 
2024-2025CamelliaV.

CamelliaV | Java;CV;ACGN


  1. 1 给予你的爱 Xi YuaN/Digital Vengeance/唢清
  2. 2 スペルビア帝国/夜 平松建治
  3. 3 Imagination QQHHh
  4. 4 virtues QQHHh
  5. 5 Tricolor (short ver.) Digital Vengeance/44
  6. 6 港口夜 - 四周年 月代彩
  7. 7 神よ、その黄昏よ 金﨑猛
  8. 8 絆炎 (English Ver) Katherine Eames
  9. 9 ラストエンゲージ~祈りの呪文 馬場泰久
  10. 10 an evening calm fripSide
  11. 11 フレスベルグの少女~風花雪月~ Caro
  12. 12 Answer 北原春希/小木曽雪菜
  13. 13 Kiss Kiss Kiss BENI
  14. 14 远航高歌 染音若蔡/阿南
  15. 15 Sentimental Blue Trident
  16. 16 目指す先にあるもの Falcom Sound Team J.D.K.
  17. 17 Night City r e l/Artemis Delta
  18. 18 Gimme×Gimme P*Light/Giga/初音ミク/鏡音リン
  19. 19 桃幻浪漫 Airots/Active Planets & AUGUST
  20. 20 DESIRE 美郷あき
  21. 21 镜花堂(feat.芬璃尔) 幻塔手游/Rux
  22. 22 she was sitting under the osmanthus tree 梶浦由記
给予你的爱 - Xi YuaN/Digital Vengeance/唢清
00:00 / 03:59