Commit 5688b2ff by yanglei

卡片(充值成功+查询充值记录)

parent 6a3a759e
...@@ -326,3 +326,40 @@ def run_nfc_card_pay_refund(): ...@@ -326,3 +326,40 @@ def run_nfc_card_pay_refund():
db.session.commit() db.session.commit()
return BaseResponse() return BaseResponse()
#查询充值记录
@nfc_card_route.route('/user_pay_record', methods=['POST'])
def run_nfc_card_user_pay_record():
json_data = request.get_json()
card_no = json_data["card_no"]
card_result = NfcCard.query.filter_by(card_no=card_no, status=1).first()
if not card_result:
return jsonify(NFC_CARD_NOT_EXIST)
card_result = NfcCardPayRecord.query.filter_by(card_no=card_no).all()
result_data=[]
for card in card_result:
record={
"card_no":card.card_no,
"user_id":card.user_id,
"pay_money":card.pay_money,
"created_at":card. created_at
}
result_data.append(record)
return BaseResponse(data=result_data)
#充值成功后改变数据库
@nfc_card_route.route('/user_pay_succeed', methods=['POST'])
def run_nfc_card_pay_succeed():
json_data=request.get_json()
card_no = json_data["card_no"]
money = json_data["money"]
card_result = NfcCard.query.filter_by(card_no=card_no,status=1).first()
if not card_result:
return jsonify(NFC_CARD_NOT_EXIST)
card_result.money += int(money)
db.session.add(card_result)
db.session.commit()
return BaseResponse()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment