From f1de38c5359e7c124ea26d7f9bf9078764835169 Mon Sep 17 00:00:00 2001 From: pilot <657434@03b.ru> Date: Sun, 31 May 2026 09:44:41 +0800 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BD=D0=B5=D0=B4=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- restoran_max_bot/content_bot/views.py | 16 +++++---- .../restoran_max_bot/bot_message.py | 3 +- .../restoran_max_bot/rkiper_api.py | 33 ++++++++++--------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/restoran_max_bot/content_bot/views.py b/restoran_max_bot/content_bot/views.py index 4f7cf0c..26c7545 100644 --- a/restoran_max_bot/content_bot/views.py +++ b/restoran_max_bot/content_bot/views.py @@ -2,7 +2,7 @@ from django.http import JsonResponse from django.core.handlers.wsgi import WSGIRequest from django.views.decorators.csrf import csrf_exempt -from max_bot.models import Client, ProductCategory +from max_bot.models import Client, ProductCategory, Product # Create your views here. @@ -18,14 +18,18 @@ def api_default_load(request: WSGIRequest, token): categorys = ProductCategory.objects.filter(client=50, src=1, status=1) for category in categorys: if not ProductCategory.objects.filter(client=client, src=1, status=1, title=category.title): - print(category.title) - new_category = ProductCategory.objects.create() + pk = category.pk + new_category = category new_category.pk = None new_category.client = client new_category.save() - - - + products = Product.objects.filter(client=50, status=1, up=pk) + for product in products: + new_product = product + new_product.pk = None + new_product.client = client + new_product.up = new_category.pk + new_product.save() rt = {'success': False, 'data': ''} return JsonResponse(rt, status=200) diff --git a/restoran_max_bot/restoran_max_bot/bot_message.py b/restoran_max_bot/restoran_max_bot/bot_message.py index 7690393..1df8440 100644 --- a/restoran_max_bot/restoran_max_bot/bot_message.py +++ b/restoran_max_bot/restoran_max_bot/bot_message.py @@ -54,7 +54,8 @@ def get_bonus(client: Client, phone: str, default_bonus: float, contact: Contact else: birthday = f"1990-{month}-{date}" rs = rkiper_customer_create(rkiper_server=config['url'], rkiper_token=config['token'], phone=phone, - name=contact.name, birthday=birthday, card_type=config['card_type']) + name=contact.name, birthday=birthday, bonus=config['bonus'], + discount=config['discount']) bonus = 0 return bonus diff --git a/restoran_max_bot/restoran_max_bot/rkiper_api.py b/restoran_max_bot/restoran_max_bot/rkiper_api.py index 779c197..cc9d5e4 100644 --- a/restoran_max_bot/restoran_max_bot/rkiper_api.py +++ b/restoran_max_bot/restoran_max_bot/rkiper_api.py @@ -3,30 +3,31 @@ import json from restoran_max_bot.utils import normalize_mobile_phone +# http://192.168.9.186:8890/docs def rkiper_customer_info(rkiper_server, rkiper_token, phone): url = f"http://{rkiper_server}/accounts/searchv2" phone = normalize_mobile_phone(phone) phone = '*' + phone[1:] payload = json.dumps({ - "case_sensitive": False, - "fields": [ - "email", - "tel1" - ], - "limit": 100, - "mask": f"{phone}", - "match_all": False + "case_sensitive": False, + "fields": [ + "email", + "tel1" + ], + "limit": 10, + "mask": f"{phone}", + "match_all": False }) headers = { - 'Content-Type': 'application/json', - 'X-API-Key': rkiper_token + 'Content-Type': 'application/json', + 'X-API-Key': rkiper_token } response = requests.request("POST", url, headers=headers, data=payload).json() return response -def rkiper_customer_create(rkiper_server, rkiper_token, phone, name, birthday, card_type="16"): +def rkiper_customer_create(rkiper_server, rkiper_token, phone, name, birthday, discount, bonus): url = f"http://{rkiper_server}/cardimp" phone = normalize_mobile_phone(phone) payload = json.dumps([{ @@ -36,14 +37,14 @@ def rkiper_customer_create(rkiper_server, rkiper_token, phone, name, birthday, c "phone1": f"{phone}", "phone2": f"{phone}", "email": f"{phone}", - "card_type": card_type, + "discount": f"{discount}", + "bonus": f"{bonus}", "birthday": f"{birthday}", - "department": "max bot", + "dop_info": "max bot", }]) headers = { - 'Content-Type': 'application/json', - 'X-API-Key': rkiper_token + 'Content-Type': 'application/json', + 'X-API-Key': rkiper_token } response = requests.request("POST", url, headers=headers, data=payload) - return response.json()