diff --git a/Atol_sell.bat b/Atol_sell.bat new file mode 100644 index 0000000..20d466c --- /dev/null +++ b/Atol_sell.bat @@ -0,0 +1,2 @@ +CD %CD% +py -3.9 payment_start.py \ No newline at end of file diff --git a/__pycache__/main.cpython-39.pyc b/__pycache__/main.cpython-39.pyc new file mode 100644 index 0000000..50c0bd5 Binary files /dev/null and b/__pycache__/main.cpython-39.pyc differ diff --git a/auth/__pycache__/auth.cpython-39.pyc b/auth/__pycache__/auth.cpython-39.pyc new file mode 100644 index 0000000..5807477 Binary files /dev/null and b/auth/__pycache__/auth.cpython-39.pyc differ diff --git a/auth/__pycache__/hashing.cpython-39.pyc b/auth/__pycache__/hashing.cpython-39.pyc new file mode 100644 index 0000000..befb391 Binary files /dev/null and b/auth/__pycache__/hashing.cpython-39.pyc differ diff --git a/auth/__pycache__/oauth2.cpython-39.pyc b/auth/__pycache__/oauth2.cpython-39.pyc new file mode 100644 index 0000000..a3a89a5 Binary files /dev/null and b/auth/__pycache__/oauth2.cpython-39.pyc differ diff --git a/auth/__pycache__/token.cpython-39.pyc b/auth/__pycache__/token.cpython-39.pyc new file mode 100644 index 0000000..22d9990 Binary files /dev/null and b/auth/__pycache__/token.cpython-39.pyc differ diff --git a/auth/login/__pycache__/__init__.cpython-39.pyc b/auth/login/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..d571812 Binary files /dev/null and b/auth/login/__pycache__/__init__.cpython-39.pyc differ diff --git a/auth/login/models/__pycache__/__init__.cpython-39.pyc b/auth/login/models/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..860a82b Binary files /dev/null and b/auth/login/models/__pycache__/__init__.cpython-39.pyc differ diff --git a/auth/login/models/__pycache__/login.cpython-39.pyc b/auth/login/models/__pycache__/login.cpython-39.pyc new file mode 100644 index 0000000..4663d63 Binary files /dev/null and b/auth/login/models/__pycache__/login.cpython-39.pyc differ diff --git a/auth/login/repository/__pycache__/__init__.cpython-39.pyc b/auth/login/repository/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..9967b1a Binary files /dev/null and b/auth/login/repository/__pycache__/__init__.cpython-39.pyc differ diff --git a/auth/login/repository/__pycache__/login.cpython-39.pyc b/auth/login/repository/__pycache__/login.cpython-39.pyc new file mode 100644 index 0000000..effdfe7 Binary files /dev/null and b/auth/login/repository/__pycache__/login.cpython-39.pyc differ diff --git a/auth/login/schemas/__pycache__/__init__.cpython-39.pyc b/auth/login/schemas/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..a2c7643 Binary files /dev/null and b/auth/login/schemas/__pycache__/__init__.cpython-39.pyc differ diff --git a/auth/login/schemas/__pycache__/login.cpython-39.pyc b/auth/login/schemas/__pycache__/login.cpython-39.pyc new file mode 100644 index 0000000..b839e4e Binary files /dev/null and b/auth/login/schemas/__pycache__/login.cpython-39.pyc differ diff --git a/auth/routers/__pycache__/__init__.cpython-39.pyc b/auth/routers/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..02168b2 Binary files /dev/null and b/auth/routers/__pycache__/__init__.cpython-39.pyc differ diff --git a/auth/routers/__pycache__/authentication.cpython-39.pyc b/auth/routers/__pycache__/authentication.cpython-39.pyc new file mode 100644 index 0000000..a227f72 Binary files /dev/null and b/auth/routers/__pycache__/authentication.cpython-39.pyc differ diff --git a/auth/routers/__pycache__/login.cpython-39.pyc b/auth/routers/__pycache__/login.cpython-39.pyc new file mode 100644 index 0000000..1443941 Binary files /dev/null and b/auth/routers/__pycache__/login.cpython-39.pyc differ diff --git a/auth/routers/__pycache__/roles.cpython-39.pyc b/auth/routers/__pycache__/roles.cpython-39.pyc new file mode 100644 index 0000000..7893e87 Binary files /dev/null and b/auth/routers/__pycache__/roles.cpython-39.pyc differ diff --git a/check_start.py b/check_start.py new file mode 100644 index 0000000..2e91025 --- /dev/null +++ b/check_start.py @@ -0,0 +1,3 @@ +import kassa.new + +kassa.new.run_get_check() \ No newline at end of file diff --git a/databases/__pycache__/__init__.cpython-39.pyc b/databases/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..316973a Binary files /dev/null and b/databases/__pycache__/__init__.cpython-39.pyc differ diff --git a/databases/mssql/__pycache__/__init__.cpython-39.pyc b/databases/mssql/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..8aa62d1 Binary files /dev/null and b/databases/mssql/__pycache__/__init__.cpython-39.pyc differ diff --git a/databases/mssql/__pycache__/general.cpython-39.pyc b/databases/mssql/__pycache__/general.cpython-39.pyc new file mode 100644 index 0000000..aeb4059 Binary files /dev/null and b/databases/mssql/__pycache__/general.cpython-39.pyc differ diff --git a/databases/pgsql/__pycache__/__init__.cpython-39.pyc b/databases/pgsql/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..63030c2 Binary files /dev/null and b/databases/pgsql/__pycache__/__init__.cpython-39.pyc differ diff --git a/databases/pgsql/__pycache__/database.cpython-39.pyc b/databases/pgsql/__pycache__/database.cpython-39.pyc new file mode 100644 index 0000000..2623a27 Binary files /dev/null and b/databases/pgsql/__pycache__/database.cpython-39.pyc differ diff --git a/kassa/__pycache__/atol.cpython-39.pyc b/kassa/__pycache__/atol.cpython-39.pyc new file mode 100644 index 0000000..2004e67 Binary files /dev/null and b/kassa/__pycache__/atol.cpython-39.pyc differ diff --git a/kassa/__pycache__/databases.cpython-39.pyc b/kassa/__pycache__/databases.cpython-39.pyc new file mode 100644 index 0000000..f88a6fd Binary files /dev/null and b/kassa/__pycache__/databases.cpython-39.pyc differ diff --git a/kassa/__pycache__/kassa.cpython-39.pyc b/kassa/__pycache__/kassa.cpython-39.pyc new file mode 100644 index 0000000..b298ff4 Binary files /dev/null and b/kassa/__pycache__/kassa.cpython-39.pyc differ diff --git a/kassa/__pycache__/models.cpython-39.pyc b/kassa/__pycache__/models.cpython-39.pyc new file mode 100644 index 0000000..737f7e1 Binary files /dev/null and b/kassa/__pycache__/models.cpython-39.pyc differ diff --git a/kassa/__pycache__/new.cpython-39.pyc b/kassa/__pycache__/new.cpython-39.pyc new file mode 100644 index 0000000..14e0183 Binary files /dev/null and b/kassa/__pycache__/new.cpython-39.pyc differ diff --git a/kassa/__pycache__/schemas.cpython-39.pyc b/kassa/__pycache__/schemas.cpython-39.pyc new file mode 100644 index 0000000..52ea14c Binary files /dev/null and b/kassa/__pycache__/schemas.cpython-39.pyc differ diff --git a/kassa/atol.py b/kassa/atol.py index e063f7f..89e7aa2 100644 --- a/kassa/atol.py +++ b/kassa/atol.py @@ -39,9 +39,7 @@ class Atol: def set_sell(self, reciept, is_refund): func = '/sell' if is_refund == 0 else '/sell_refund' - print(reciept) s = self.get_request('post', self.group_id+func, reciept) - print(s) return s def get_reciepts(self, uuid): diff --git a/kassa/cruds/__pycache__/doc.cpython-39.pyc b/kassa/cruds/__pycache__/doc.cpython-39.pyc new file mode 100644 index 0000000..ff8edb3 Binary files /dev/null and b/kassa/cruds/__pycache__/doc.cpython-39.pyc differ diff --git a/kassa/cruds/doc.py b/kassa/cruds/doc.py index c6bded9..d476441 100644 --- a/kassa/cruds/doc.py +++ b/kassa/cruds/doc.py @@ -1,3 +1,4 @@ +from ast import Dict from sqlalchemy.orm import Session import kassa.schemas as schemas import kassa.models as models @@ -25,6 +26,7 @@ def create_doc(db: Session, doc: schemas.Doc, external_id: str = None): def create_error(db: Session, error: schemas.Error, external_id: str = None): err = error + err['external_id'] = external_id err_query = db.query(models.Error).filter( models.Error.external_id == external_id) @@ -32,7 +34,7 @@ def create_error(db: Session, error: schemas.Error, external_id: str = None): err_query.update(values=err) else: - err_query = models.Error(**err, synchronize_session=False) + err_query = models.Error(**err) db.add(err_query) db.commit() @@ -43,7 +45,7 @@ def create_payload(db: Session, payload: schemas.Payload, external_id: str = Non payload_query = db.query(models.Payload).filter( models.Payload.external_id == external_id) if payload_query.first(): - payload_query.update(pay, synchronize_session=False) + payload_query.update(pay) else: pay['external_id'] = external_id diff --git a/kassa/models.py b/kassa/models.py index b061212..1155e69 100644 --- a/kassa/models.py +++ b/kassa/models.py @@ -46,7 +46,7 @@ class Doc(Base): class Atol(Base): __tablename__ = 'atol_receipts' - uuid = Column('uuid', String(length=128), primary_key=True) + uuid = Column('uuid', String(length=128), primary_key=True, nullable= True) timestamp = Column('timestamp', String(length=128)) external_id = Column('external_id', String(length=128)) status = Column('status', String(length=128)) diff --git a/kassa/new.py b/kassa/new.py index f29ffeb..4b9066f 100644 --- a/kassa/new.py +++ b/kassa/new.py @@ -1,4 +1,6 @@ +from ast import While from lib2to3.pgen2 import token +from re import A from time import sleep from typing import Dict, List, Tuple from sqlalchemy.ext.declarative import declarative_base @@ -10,6 +12,7 @@ from sqlalchemy.sql.sqltypes import DateTime from sqlalchemy import desc, cast, case, func import kassa.schemas as schemas import kassa.models as models +from kassa.cruds import doc from kassa.databases import SessionLocal from kassa.atol import Atol import datetime @@ -258,10 +261,11 @@ def get_sell(data: query): def get_client(phone: str): - return { - 'phone': phone - } - + if phone: + return { + 'phone': phone + } + return { 'email': 'test@test.ru'} def get_vat(vat: str): return {'type': vat} @@ -291,16 +295,38 @@ def clear_dict(d): return r def add_doc(sell: schemas.Sell, is_refund, token): - atol_model = Atol(token) session = SessionLocal() a = atol_model.set_sell(clear_dict(sell.dict()), is_refund) - check = models.Atol(schemas.AtolSell(**a)) - check.external_id = sell.external_id + ext_id = sell.external_id + err = a.pop('error', None) + if err: + print(err) + return doc.create_error(session, error = schemas.Error(**err), external_id = ext_id ) + + a["external_id"]= sell.external_id + check = models.Atol(**a) session.add(check) session.commit() + return a +def get_check(db: Session, uuid: str, external_id: str, token: str): + atol_model = Atol(token) + a = atol_model.get_reciepts(uuid) + err = a.pop('error', None) + if err: + print(err) + return doc.create_error(db, error = schemas.Error(**err), external_id = external_id ) + doc.create_doc(db, a, external_id) + return a + + +def get_atol_wo_doc(db: Session): + return db.query(models.Atol.uuid, models.Atol.external_id).\ + where(models.Atol.external_id.notin_(models.Doc.external_id)).\ + all() + def get_main_payment(): server = 'Sanctuary' user = 'sa' @@ -334,5 +360,20 @@ def main(): if payment == False: break sleep(1) - add_doc(sell=payment, is_refund=is_refund, token = token) - break + doc = add_doc(sell=payment, is_refund=is_refund, token = token) + print(doc) + +def run_get_check(): + session = SessionLocal() + atols = get_atol_wo_doc(session) + while len(atols)>0: + server = 'Sanctuary' + user = 'sa' + password = '159357' + db_dicts_name = 'fz54' + db = Session(autocommit=False, autoflush=False, bind=db.engine) + db_dicts = DBEngine(server, db_dicts_name, user, password) + token = get_token(db, db_dicts) + uuid, ext_id = atols.pop() + check = get_check(session, uuid, ext_id, token) + print(check) \ No newline at end of file diff --git a/kassa/schemas.py b/kassa/schemas.py index 916a556..13181c8 100644 --- a/kassa/schemas.py +++ b/kassa/schemas.py @@ -212,6 +212,7 @@ class AtolSell(BaseModel): timestamp: str status: Optional[str] = None error: Error = None + external_id: Optional[str] = None class Config: orm_mode = True diff --git a/kv/__pycache__/__init__.cpython-39.pyc b/kv/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..2fd298b Binary files /dev/null and b/kv/__pycache__/__init__.cpython-39.pyc differ diff --git a/kv/__pycache__/kv.cpython-39.pyc b/kv/__pycache__/kv.cpython-39.pyc new file mode 100644 index 0000000..21a6afb Binary files /dev/null and b/kv/__pycache__/kv.cpython-39.pyc differ diff --git a/kv/routers/__pycache__/__init__.cpython-39.pyc b/kv/routers/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..64fe67b Binary files /dev/null and b/kv/routers/__pycache__/__init__.cpython-39.pyc differ diff --git a/kv/routers/__pycache__/general.cpython-39.pyc b/kv/routers/__pycache__/general.cpython-39.pyc new file mode 100644 index 0000000..abab309 Binary files /dev/null and b/kv/routers/__pycache__/general.cpython-39.pyc differ diff --git a/payment_start.py b/payment_start.py new file mode 100644 index 0000000..bc8a4f4 --- /dev/null +++ b/payment_start.py @@ -0,0 +1,3 @@ +import kassa.new + +kassa.new.main() \ No newline at end of file diff --git a/start.bat b/start.bat new file mode 100644 index 0000000..1a80b67 --- /dev/null +++ b/start.bat @@ -0,0 +1,2 @@ +CD %CD% +py -3.9 main.py \ No newline at end of file diff --git a/Новый текстовый документ.txt b/Новый текстовый документ.txt new file mode 100644 index 0000000..1a80b67 --- /dev/null +++ b/Новый текстовый документ.txt @@ -0,0 +1,2 @@ +CD %CD% +py -3.9 main.py \ No newline at end of file