Commit 73ca437f by Aeolus

update

parent 86145334
...@@ -19,7 +19,8 @@ from models.base_model import db ...@@ -19,7 +19,8 @@ from models.base_model import db
from models.models import NfcCard, NfcCardPayRecord, NfcCardPayRefund from models.models import NfcCard, NfcCardPayRecord, NfcCardPayRefund
from service.rent_service import RentService from service.rent_service import RentService
from service.wechat_service import WeChatPayService from service.wechat_service import WeChatPayService
from utils.error_code import NFC_CARD_NOT_EXIST, NFC_CARD_ACTIVATED_ERROR, WE_MINIAPP_PAY_FAIL, NO_RENT_RECORD from utils.error_code import NFC_CARD_NOT_EXIST, NFC_CARD_ACTIVATED_ERROR, WE_MINIAPP_PAY_FAIL, NO_RENT_RECORD, \
NO_NFC_CARD_ERROR
from utils.my_redis_cache import redis_client from utils.my_redis_cache import redis_client
from utils.my_response import BaseResponse from utils.my_response import BaseResponse
...@@ -53,6 +54,37 @@ def run_nfc_card_activate(): ...@@ -53,6 +54,37 @@ def run_nfc_card_activate():
return BaseResponse() return BaseResponse()
@nfc_card_route.route("my_cards", methods=["POST"])
def get_my_cards():
json_data = request.get_json()
page = json_data["page"]
page_size = json_data["pageSize"]
filter_list = [
NfcCard.user_id == g.user.id,
NfcCard.status.in_([1, -1])
]
total_count = NfcCard.query.filter(*filter_list).count()
if not total_count:
return BaseResponse(data=[], total=total_count, page=page, pageSize=page_size)
cards = NfcCard.query.filter(*filter_list).offset((page - 1) * page_size).limit(page_size).all()
if not cards:
return jsonify(NO_NFC_CARD_ERROR)
return_data = []
for card in cards:
tmp_data = {
"card_no": card.card_no,
"nick_name": card.nick_name,
"phone": card.phone,
"money": card.money,
"status": card.status,
}
return_data.append(tmp_data)
return BaseResponse(data=return_data, total=total_count, page=page, pageSize=page_size)
@nfc_card_route.route("pay", methods=["POST"]) @nfc_card_route.route("pay", methods=["POST"])
def run_nfc_card_pay(): def run_nfc_card_pay():
json_data = request.get_json() json_data = request.get_json()
......
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