diff --git a/backend/shop/__pycache__/views.cpython-312.pyc b/backend/shop/__pycache__/views.cpython-312.pyc index 8c2c7bf..494b96e 100644 Binary files a/backend/shop/__pycache__/views.cpython-312.pyc and b/backend/shop/__pycache__/views.cpython-312.pyc differ diff --git a/backend/shop/views.py b/backend/shop/views.py index 4f28df1..42f76d1 100644 --- a/backend/shop/views.py +++ b/backend/shop/views.py @@ -709,9 +709,17 @@ class OrderViewSet(viewsets.ModelViewSet): order.save() try: + # 动态生成描述 + if order.config: + description = f"购买 {order.config.name} x {order.quantity}" + elif order.course: + description = f"报名 {order.course.title}" + else: + description = f"支付订单 {order.id}" + # 统一下单 (JSAPI) code, message = wxpay.pay( - description=f"购买 {order.config.name} x {order.quantity}", + description=description, out_trade_no=out_trade_no, amount={'total': amount_in_cents, 'currency': 'CNY'}, payer={'openid': user.openid}, # 小程序支付必须传 openid