check and start payment added
This commit is contained in:
2
Atol_sell.bat
Normal file
2
Atol_sell.bat
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
CD %CD%
|
||||||
|
py -3.9 payment_start.py
|
BIN
__pycache__/main.cpython-39.pyc
Normal file
BIN
__pycache__/main.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/__pycache__/auth.cpython-39.pyc
Normal file
BIN
auth/__pycache__/auth.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/__pycache__/hashing.cpython-39.pyc
Normal file
BIN
auth/__pycache__/hashing.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/__pycache__/oauth2.cpython-39.pyc
Normal file
BIN
auth/__pycache__/oauth2.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/__pycache__/token.cpython-39.pyc
Normal file
BIN
auth/__pycache__/token.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/login/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
auth/login/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/login/models/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
auth/login/models/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/login/models/__pycache__/login.cpython-39.pyc
Normal file
BIN
auth/login/models/__pycache__/login.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/login/repository/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
auth/login/repository/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/login/repository/__pycache__/login.cpython-39.pyc
Normal file
BIN
auth/login/repository/__pycache__/login.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/login/schemas/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
auth/login/schemas/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/login/schemas/__pycache__/login.cpython-39.pyc
Normal file
BIN
auth/login/schemas/__pycache__/login.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/routers/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
auth/routers/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/routers/__pycache__/authentication.cpython-39.pyc
Normal file
BIN
auth/routers/__pycache__/authentication.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/routers/__pycache__/login.cpython-39.pyc
Normal file
BIN
auth/routers/__pycache__/login.cpython-39.pyc
Normal file
Binary file not shown.
BIN
auth/routers/__pycache__/roles.cpython-39.pyc
Normal file
BIN
auth/routers/__pycache__/roles.cpython-39.pyc
Normal file
Binary file not shown.
3
check_start.py
Normal file
3
check_start.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import kassa.new
|
||||||
|
|
||||||
|
kassa.new.run_get_check()
|
BIN
databases/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
databases/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
databases/mssql/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
databases/mssql/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
databases/mssql/__pycache__/general.cpython-39.pyc
Normal file
BIN
databases/mssql/__pycache__/general.cpython-39.pyc
Normal file
Binary file not shown.
BIN
databases/pgsql/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
databases/pgsql/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
databases/pgsql/__pycache__/database.cpython-39.pyc
Normal file
BIN
databases/pgsql/__pycache__/database.cpython-39.pyc
Normal file
Binary file not shown.
BIN
kassa/__pycache__/atol.cpython-39.pyc
Normal file
BIN
kassa/__pycache__/atol.cpython-39.pyc
Normal file
Binary file not shown.
BIN
kassa/__pycache__/databases.cpython-39.pyc
Normal file
BIN
kassa/__pycache__/databases.cpython-39.pyc
Normal file
Binary file not shown.
BIN
kassa/__pycache__/kassa.cpython-39.pyc
Normal file
BIN
kassa/__pycache__/kassa.cpython-39.pyc
Normal file
Binary file not shown.
BIN
kassa/__pycache__/models.cpython-39.pyc
Normal file
BIN
kassa/__pycache__/models.cpython-39.pyc
Normal file
Binary file not shown.
BIN
kassa/__pycache__/new.cpython-39.pyc
Normal file
BIN
kassa/__pycache__/new.cpython-39.pyc
Normal file
Binary file not shown.
BIN
kassa/__pycache__/schemas.cpython-39.pyc
Normal file
BIN
kassa/__pycache__/schemas.cpython-39.pyc
Normal file
Binary file not shown.
@ -39,9 +39,7 @@ class Atol:
|
|||||||
|
|
||||||
def set_sell(self, reciept, is_refund):
|
def set_sell(self, reciept, is_refund):
|
||||||
func = '/sell' if is_refund == 0 else '/sell_refund'
|
func = '/sell' if is_refund == 0 else '/sell_refund'
|
||||||
print(reciept)
|
|
||||||
s = self.get_request('post', self.group_id+func, reciept)
|
s = self.get_request('post', self.group_id+func, reciept)
|
||||||
print(s)
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def get_reciepts(self, uuid):
|
def get_reciepts(self, uuid):
|
||||||
|
BIN
kassa/cruds/__pycache__/doc.cpython-39.pyc
Normal file
BIN
kassa/cruds/__pycache__/doc.cpython-39.pyc
Normal file
Binary file not shown.
@ -1,3 +1,4 @@
|
|||||||
|
from ast import Dict
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
import kassa.schemas as schemas
|
import kassa.schemas as schemas
|
||||||
import kassa.models as models
|
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):
|
def create_error(db: Session, error: schemas.Error, external_id: str = None):
|
||||||
err = error
|
err = error
|
||||||
|
|
||||||
err['external_id'] = external_id
|
err['external_id'] = external_id
|
||||||
err_query = db.query(models.Error).filter(
|
err_query = db.query(models.Error).filter(
|
||||||
models.Error.external_id == external_id)
|
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)
|
err_query.update(values=err)
|
||||||
else:
|
else:
|
||||||
err_query = models.Error(**err, synchronize_session=False)
|
err_query = models.Error(**err)
|
||||||
db.add(err_query)
|
db.add(err_query)
|
||||||
db.commit()
|
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(
|
payload_query = db.query(models.Payload).filter(
|
||||||
models.Payload.external_id == external_id)
|
models.Payload.external_id == external_id)
|
||||||
if payload_query.first():
|
if payload_query.first():
|
||||||
payload_query.update(pay, synchronize_session=False)
|
payload_query.update(pay)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
pay['external_id'] = external_id
|
pay['external_id'] = external_id
|
||||||
|
@ -46,7 +46,7 @@ class Doc(Base):
|
|||||||
|
|
||||||
class Atol(Base):
|
class Atol(Base):
|
||||||
__tablename__ = 'atol_receipts'
|
__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))
|
timestamp = Column('timestamp', String(length=128))
|
||||||
external_id = Column('external_id', String(length=128))
|
external_id = Column('external_id', String(length=128))
|
||||||
status = Column('status', String(length=128))
|
status = Column('status', String(length=128))
|
||||||
|
59
kassa/new.py
59
kassa/new.py
@ -1,4 +1,6 @@
|
|||||||
|
from ast import While
|
||||||
from lib2to3.pgen2 import token
|
from lib2to3.pgen2 import token
|
||||||
|
from re import A
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from typing import Dict, List, Tuple
|
from typing import Dict, List, Tuple
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
@ -10,6 +12,7 @@ from sqlalchemy.sql.sqltypes import DateTime
|
|||||||
from sqlalchemy import desc, cast, case, func
|
from sqlalchemy import desc, cast, case, func
|
||||||
import kassa.schemas as schemas
|
import kassa.schemas as schemas
|
||||||
import kassa.models as models
|
import kassa.models as models
|
||||||
|
from kassa.cruds import doc
|
||||||
from kassa.databases import SessionLocal
|
from kassa.databases import SessionLocal
|
||||||
from kassa.atol import Atol
|
from kassa.atol import Atol
|
||||||
import datetime
|
import datetime
|
||||||
@ -258,10 +261,11 @@ def get_sell(data: query):
|
|||||||
|
|
||||||
|
|
||||||
def get_client(phone: str):
|
def get_client(phone: str):
|
||||||
return {
|
if phone:
|
||||||
'phone': phone
|
return {
|
||||||
}
|
'phone': phone
|
||||||
|
}
|
||||||
|
return { 'email': 'test@test.ru'}
|
||||||
|
|
||||||
def get_vat(vat: str):
|
def get_vat(vat: str):
|
||||||
return {'type': vat}
|
return {'type': vat}
|
||||||
@ -291,16 +295,38 @@ def clear_dict(d):
|
|||||||
return r
|
return r
|
||||||
|
|
||||||
def add_doc(sell: schemas.Sell, is_refund, token):
|
def add_doc(sell: schemas.Sell, is_refund, token):
|
||||||
|
|
||||||
atol_model = Atol(token)
|
atol_model = Atol(token)
|
||||||
session = SessionLocal()
|
session = SessionLocal()
|
||||||
a = atol_model.set_sell(clear_dict(sell.dict()), is_refund)
|
a = atol_model.set_sell(clear_dict(sell.dict()), is_refund)
|
||||||
check = models.Atol(schemas.AtolSell(**a))
|
ext_id = sell.external_id
|
||||||
check.external_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.add(check)
|
||||||
session.commit()
|
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():
|
def get_main_payment():
|
||||||
server = 'Sanctuary'
|
server = 'Sanctuary'
|
||||||
user = 'sa'
|
user = 'sa'
|
||||||
@ -334,5 +360,20 @@ def main():
|
|||||||
if payment == False:
|
if payment == False:
|
||||||
break
|
break
|
||||||
sleep(1)
|
sleep(1)
|
||||||
add_doc(sell=payment, is_refund=is_refund, token = token)
|
doc = add_doc(sell=payment, is_refund=is_refund, token = token)
|
||||||
break
|
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)
|
@ -212,6 +212,7 @@ class AtolSell(BaseModel):
|
|||||||
timestamp: str
|
timestamp: str
|
||||||
status: Optional[str] = None
|
status: Optional[str] = None
|
||||||
error: Error = None
|
error: Error = None
|
||||||
|
external_id: Optional[str] = None
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
|
|
||||||
|
BIN
kv/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
kv/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
kv/__pycache__/kv.cpython-39.pyc
Normal file
BIN
kv/__pycache__/kv.cpython-39.pyc
Normal file
Binary file not shown.
BIN
kv/routers/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
kv/routers/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
kv/routers/__pycache__/general.cpython-39.pyc
Normal file
BIN
kv/routers/__pycache__/general.cpython-39.pyc
Normal file
Binary file not shown.
3
payment_start.py
Normal file
3
payment_start.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import kassa.new
|
||||||
|
|
||||||
|
kassa.new.main()
|
2
Новый текстовый документ.txt
Normal file
2
Новый текстовый документ.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
CD %CD%
|
||||||
|
py -3.9 main.py
|
Reference in New Issue
Block a user