Commit d2108791 by baiquan

init

parent 21a0795d
import execjs
from loguru import logger from loguru import logger
from celery.result import AsyncResult from celery.result import AsyncResult
from fastapi import FastAPI, APIRouter from fastapi import FastAPI, APIRouter
from fastapi import status from fastapi import status
from pydantic import BaseModel from pydantic import BaseModel
from celery_app import celery_app from celery_app import celery_app
from errors import * from errors import *
import os
# 创建 logs 目录(如果不存在)
os.makedirs("logs", exist_ok=True)
# 添加日志文件输出,按7天滚动
logger.add("logs/api.log", rotation="7 day", level="INFO", encoding="utf-8", backtrace=True, diagnose=True)
app = FastAPI(title="doudian数据同步平台") app = FastAPI(title="doudian数据同步平台")
sync_router = APIRouter(prefix="/sync", tags=["同步接口"]) sync_router = APIRouter(prefix="/sync", tags=["同步接口"])
...@@ -19,7 +22,8 @@ class SyncShopRequest(BaseModel): ...@@ -19,7 +22,8 @@ class SyncShopRequest(BaseModel):
class SyncShopInfoRequest(BaseModel): class SyncShopInfoRequest(BaseModel):
browser_id: str browser_id: str
listen_data: dict listen_url: str
open_url: str
class CreateTemplateRequest(BaseModel): class CreateTemplateRequest(BaseModel):
cookies: dict cookies: dict
......
...@@ -83,13 +83,15 @@ def search_category(cookies, key): ...@@ -83,13 +83,15 @@ def search_category(cookies, key):
print(response.text) print(response.text)
return response.json()['data'] return response.json()['data']
def get_a_bogus(a_bogus_js_path, params,data, userAgent):
def get_a_bogus(a_bogus_js_path, params, data, userAgent):
with open(a_bogus_js_path, 'r', encoding='gbk') as f: with open(a_bogus_js_path, 'r', encoding='gbk') as f:
a_bogus_js = f.read() a_bogus_js = f.read()
a_bogus = execjs.compile(a_bogus_js).call('get_ab', params,data, userAgent) a_bogus = execjs.compile(a_bogus_js).call('get_ab', params, data, userAgent)
# print(f'a_bogus: {a_bogus}') # print(f'a_bogus: {a_bogus}')
return a_bogus return a_bogus
def get_schema(cookies, category_id): def get_schema(cookies, category_id):
params = { params = {
'appid': '1', 'appid': '1',
...@@ -107,9 +109,9 @@ def get_schema(cookies, category_id): ...@@ -107,9 +109,9 @@ def get_schema(cookies, category_id):
'_bid': 'ffa_goods', '_bid': 'ffa_goods',
} }
url = 'https://fxg.jinritemai.com/product/tproduct/getSchema' url = 'https://fxg.jinritemai.com/product/tproduct/getSchema'
a_bogus = get_a_bogus('./js/a_bogus.js', urlencode(params), json_data, headers['User-Agent']) a_bogus = get_a_bogus('a_bogus.js', urlencode(params), json_data, headers['User-Agent'])
params['a_bogus'] = a_bogus params['a_bogus'] = a_bogus
response = requests.post(url,params=params,cookies=cookies,headers=headers,json=json_data,impersonate="chrome131") response = requests.post(url, params=params, cookies=cookies, headers=headers, json=json_data, impersonate="chrome131")
print(response.text) print(response.text)
return response.json()['data'] return response.json()['data']
...@@ -128,8 +130,8 @@ def upload_image_by_bytes(cookies, image_bytes): ...@@ -128,8 +130,8 @@ def upload_image_by_bytes(cookies, image_bytes):
url = 'https://fxg.jinritemai.com/product/img/batchupload?_bid=ffa_goods' url = 'https://fxg.jinritemai.com/product/img/batchupload?_bid=ffa_goods'
mp = CurlMime() mp = CurlMime()
for i, byte_data in enumerate(image_bytes): for i, byte_data in enumerate(image_bytes):
mp.addpart(name=f"image[{i}]", content_type="image/jpeg",filename=f"image_{i}.jpg", data=byte_data) mp.addpart(name=f"image[{i}]", content_type="image/jpeg", filename=f"image_{i}.jpg", data=byte_data)
response = requests.post(url,cookies=cookies,headers=headers,data={"foo":"bar"},multipart=mp,impersonate="chrome131") response = requests.post(url, cookies=cookies, headers=headers, data={"foo": "bar"}, multipart=mp, impersonate="chrome131")
print(response.text) print(response.text)
mp.close() mp.close()
return response.json()['data'] return response.json()['data']
...@@ -156,6 +158,7 @@ def get_prettify_info(cookies, category_id, url_list): ...@@ -156,6 +158,7 @@ def get_prettify_info(cookies, category_id, url_list):
print(response.text) print(response.text)
return response.json()['data'] return response.json()['data']
def generate_id(length=18): def generate_id(length=18):
"""生成18位随机数字ID""" """生成18位随机数字ID"""
return str(random.randint(10 ** (length - 1), 10 ** length - 1)) return str(random.randint(10 ** (length - 1), 10 ** length - 1))
...@@ -199,7 +202,7 @@ def build_spec_structure(spec_params): ...@@ -199,7 +202,7 @@ def build_spec_structure(spec_params):
{'id': value_id, 'name': value, {'id': value_id, 'name': value,
'image_url': spec_params.get('specs_images')['specs_images_values'][value]}) 'image_url': spec_params.get('specs_images')['specs_images_values'][value]})
else: else:
spec_values.append({'id': value_id, 'name': value }) spec_values.append({'id': value_id, 'name': value})
value_mapping[value] = value_id value_mapping[value] = value_id
spec_mapping[spec_name] = value_mapping spec_mapping[spec_name] = value_mapping
result['spec_detail']['value'].append({ result['spec_detail']['value'].append({
...@@ -228,20 +231,22 @@ def build_spec_structure(spec_params): ...@@ -228,20 +231,22 @@ def build_spec_structure(spec_params):
return result return result
def search_brand_prefix(cookies, category_id, brand_name): def search_brand_prefix(cookies, category_id, brand_name):
params = { params = {
'cid': str(category_id), 'cid': str(category_id),
'query': brand_name, 'query': brand_name,
'appid': '1', 'appid': '1',
} }
url = 'https://fxg.jinritemai.com/product/tproduct/brandPrefix' url = 'https://fxg.jinritemai.com/product/tproduct/brandPrefix'
response = requests.get(url,params=params,cookies=cookies,headers=headers) response = requests.get(url, params=params, cookies=cookies, headers=headers)
search_result = response.json()['data'] search_result = response.json()['data']
print(search_result) print(search_result)
if not search_result: if not search_result:
return None return None
return search_result[0] return search_result[0]
def add_with_schema(cookies, schema, goods_params): def add_with_schema(cookies, schema, goods_params):
if goods_params.get('detail_prettify_image', None): if goods_params.get('detail_prettify_image', None):
prettify_info = get_prettify_info(cookies, schema['context']['category_id'], goods_params['detail_prettify_image']) prettify_info = get_prettify_info(cookies, schema['context']['category_id'], goods_params['detail_prettify_image'])
...@@ -274,7 +279,7 @@ def add_with_schema(cookies, schema, goods_params): ...@@ -274,7 +279,7 @@ def add_with_schema(cookies, schema, goods_params):
'title': { # 商品标题 'title': { # 商品标题
'value': goods_params['title'], 'value': goods_params['title'],
}, },
'after_sale': { # 售后政策 'after_sale': { # 售后政策
'value': { 'value': {
'quality_problem_return': { 'quality_problem_return': {
'option_id': None, 'option_id': None,
...@@ -284,8 +289,8 @@ def add_with_schema(cookies, schema, goods_params): ...@@ -284,8 +289,8 @@ def add_with_schema(cookies, schema, goods_params):
'option_id': goods_params.get('supply_day_return_selector', '7-1'), # 7-1 7天无理由 7-3 7天无理由退货(安装后不支持) 7-5 7天无理由退货(使用后不支持) 7-6 7天无理由退货(定制类不支持) 'option_id': goods_params.get('supply_day_return_selector', '7-1'), # 7-1 7天无理由 7-3 7天无理由退货(安装后不支持) 7-5 7天无理由退货(使用后不支持) 7-6 7天无理由退货(定制类不支持)
'selected': True, 'selected': True,
}, },
'three_guarantees': { # 售后服务承诺 'three_guarantees': { # 售后服务承诺
'option_id': goods_params.get('three_guarantees', '-1'), # -1 不包含 2 延长售后服务有效期 'option_id': goods_params.get('three_guarantees', '-1'), # -1 不包含 2 延长售后服务有效期
'selected': True, 'selected': True,
}, },
...@@ -381,8 +386,8 @@ def add_with_schema(cookies, schema, goods_params): ...@@ -381,8 +386,8 @@ def add_with_schema(cookies, schema, goods_params):
}, },
'main_pic_video': { # 主图视频 'main_pic_video': { # 主图视频
'value': [{ 'value': [{
"resource_id": "v0decag10000d08sj0fog65tje0hvkf0", # video_id "resource_id": "v0decag10000d08sj0fog65tje0hvkf0", # video_id
"video_choice": 1 "video_choice": 1
}], }],
}, },
'pickup_method': { 'pickup_method': {
...@@ -394,25 +399,25 @@ def add_with_schema(cookies, schema, goods_params): ...@@ -394,25 +399,25 @@ def add_with_schema(cookies, schema, goods_params):
'product_type': { 'product_type': {
'value': '0', 'value': '0',
}, },
'qualification': { # 商品购买要求 'qualification': { # 商品购买要求
'value': {}, 'value': {},
}, },
'reduce_type': { # 订单库存计数 'reduce_type': { # 订单库存计数
'value': goods_params.get('reduce_type', '1'), # 1 下单减库存 2 付款减库存 'value': goods_params.get('reduce_type', '1'), # 1 下单减库存 2 付款减库存
}, },
'short_product_name': { 'short_product_name': {
'value': goods_params.get('short_product_name', ''), # 导购短标题 'value': goods_params.get('short_product_name', ''), # 导购短标题
}, },
'start_sale_type': { # 商品状态 0 上架 1 下架 'start_sale_type': { # 商品状态 0 上架 1 下架
'value': goods_params.get('start_sale_type', '0'), 'value': goods_params.get('start_sale_type', '0'),
}, },
'title_prefix': { 'title_prefix': {
'value': '', 'value': '',
}, },
'title_suffix': { # 标题后缀 'title_suffix': { # 标题后缀
'value': '', 'value': '',
}, },
'title_use_brand_name': { # 标题是否使用品牌名 'title_use_brand_name': { # 标题是否使用品牌名
'value': goods_params.get('title_use_brand_name', False), 'value': goods_params.get('title_use_brand_name', False),
}, },
'detail_prettify_uri': { 'detail_prettify_uri': {
...@@ -796,7 +801,6 @@ def add_with_schema(cookies, schema, goods_params): ...@@ -796,7 +801,6 @@ def add_with_schema(cookies, schema, goods_params):
print(response.text) print(response.text)
if __name__ == '__main__': if __name__ == '__main__':
account = 'dybaihuo58@163.com' account = 'dybaihuo58@163.com'
password = 'Cc123123' password = 'Cc123123'
...@@ -806,7 +810,6 @@ if __name__ == '__main__': ...@@ -806,7 +810,6 @@ if __name__ == '__main__':
'PHPSESSID_SS': '232b5651dcd01b596b830d540362643d', 'PHPSESSID_SS': '232b5651dcd01b596b830d540362643d',
} }
pic_image_path_list = ['image1.jpg', 'image2.jpg', 'image3.jpg', 'image4.jpg', 'image5.jpg'] pic_image_path_list = ['image1.jpg', 'image2.jpg', 'image3.jpg', 'image4.jpg', 'image5.jpg']
image_bytes = [] image_bytes = []
for image_path in pic_image_path_list: for image_path in pic_image_path_list:
...@@ -823,13 +826,13 @@ if __name__ == '__main__': ...@@ -823,13 +826,13 @@ if __name__ == '__main__':
'main_image_three_to_four': [], 'main_image_three_to_four': [],
'white_background_pic': [], 'white_background_pic': [],
'detail_prettify_image': [], 'detail_prettify_image': [],
'delivery_delay_day': '2', # 现货发货时间 1 次日发 2 48小时 3 当日发 4 大于48小时发货 'delivery_delay_day': '2', # 现货发货时间 1 次日发 2 48小时 3 当日发 4 大于48小时发货
'reduce_type': '1', # 1 下单减库存 2 付款减库存 'reduce_type': '1', # 1 下单减库存 2 付款减库存
'freight_id': '640336706', 'freight_id': '640336706',
'supply_day_return_selector': '7-1', # 7-1 7天无理由 7-3 7天无理由退货(安装后不支持) 7-5 7天无理由退货(使用后不支持) 7-6 7天无理由退货(定制类不支持) 'supply_day_return_selector': '7-1', # 7-1 7天无理由 7-3 7天无理由退货(安装后不支持) 7-5 7天无理由退货(使用后不支持) 7-6 7天无理由退货(定制类不支持)
'three_guarantees': '-1', # -1 不包含 2 延长售后服务有效期 'three_guarantees': '-1', # -1 不包含 2 延长售后服务有效期
# 'extended_duration': '30', # 延长售后服务有效期 30 30天 60 60天 90 90天 120 120天 180 180天 365 1年 # 'extended_duration': '30', # 延长售后服务有效期 30 30天 60 60天 90 90天 120 120天 180 180天 365 1年
'start_sale_type': '0', # 商品状态 0 上架 1 下架 'start_sale_type': '0', # 商品状态 0 上架 1 下架
'spec_params': { 'spec_params': {
# 'specs_name': [], # 'specs_name': [],
'specs_name': ['颜色', 'size'], 'specs_name': ['颜色', 'size'],
......
...@@ -31,6 +31,8 @@ async def sendRequest(method: HttpMethod, url: str, json_data: dict = None, **kw ...@@ -31,6 +31,8 @@ async def sendRequest(method: HttpMethod, url: str, json_data: dict = None, **kw
# 判断是否有code字段 # 判断是否有code字段
if 'code' in response: if 'code' in response:
if response['code'] != 0: if response['code'] != 0:
logger.error(f'hub接口异常返回值:{response}')
logger.error(json_data)
raise HubAPIError(msg=response['msg']) raise HubAPIError(msg=response['msg'])
if response['code'] != 0: if response['code'] != 0:
...@@ -102,8 +104,11 @@ async def closeBrowser(browser_id: str = ""): ...@@ -102,8 +104,11 @@ async def closeBrowser(browser_id: str = ""):
if browser_status_data: if browser_status_data:
containers = browser_status_data.get('containers', {}) containers = browser_status_data.get('containers', {})
if containers: if containers:
if (containers[0]['status'] == 1 or containers[0]['status'] == 0) and containers[0]['containerCode'] == browser_id: try:
return await sendRequest("POST", url=url, json_data=data) if (containers[0]['status'] == 1 or containers[0]['status'] == 0) and containers[0]['containerCode'] == browser_id:
return await sendRequest("POST", url=url, json_data=data)
except Exception as e:
logger.error(f"关闭浏览器异常-->{e}")
async def checkBrowserStatus(browser_id: str = ""): async def checkBrowserStatus(browser_id: str = ""):
""" """
......
...@@ -11193,8 +11193,6 @@ window.bdms || function () { ...@@ -11193,8 +11193,6 @@ window.bdms || function () {
function get_ab(params,data,ua) { function get_ab(params,data,ua) {
if (typeof data == "object")
data = JSON.stringify(data)
return window.bdms.init._v[2].p[48].apply(null, [0, 1, 14, params, data, ua]) return window.bdms.init._v[2].p[48].apply(null, [0, 1, 14, params, data, ua])
} }
......
...@@ -3,8 +3,8 @@ from asyncio.log import logger ...@@ -3,8 +3,8 @@ from asyncio.log import logger
from DrissionPage import Chromium from DrissionPage import Chromium
from DrissionPage.common import Settings from DrissionPage.common import Settings
from common import setup_proxy from common import setup_proxy
from config import settings
from errors import * from errors import *
from hub_ import * from hub_ import *
...@@ -30,6 +30,7 @@ HEADERS = { ...@@ -30,6 +30,7 @@ HEADERS = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0',
} }
async def syncShop(container_name: str): async def syncShop(container_name: str):
""" """
同步店铺 同步店铺
...@@ -134,6 +135,7 @@ async def syncShopInfo(parameter: dict = None): ...@@ -134,6 +135,7 @@ async def syncShopInfo(parameter: dict = None):
except: except:
raise NotFoundError('获取数据失败') raise NotFoundError('获取数据失败')
def getRegionNodeList(): def getRegionNodeList():
params = { params = {
'level': '4', 'level': '4',
...@@ -142,8 +144,10 @@ def getRegionNodeList(): ...@@ -142,8 +144,10 @@ def getRegionNodeList():
response = requests.get('https://ecomuser.snssdk.com/area/getdivision', params=params, headers=HEADERS) response = requests.get('https://ecomuser.snssdk.com/area/getdivision', params=params, headers=HEADERS)
return response.json()['data']['region_node_list'] return response.json()['data']['region_node_list']
REGION_NODE_LIST = getRegionNodeList() REGION_NODE_LIST = getRegionNodeList()
def getProductName(product_type, product_name): def getProductName(product_type, product_name):
if product_type == 'province': if product_type == 'province':
for region_node in REGION_NODE_LIST: for region_node in REGION_NODE_LIST:
...@@ -159,6 +163,7 @@ def getProductName(product_type, product_name): ...@@ -159,6 +163,7 @@ def getProductName(product_type, product_name):
else: else:
raise NotFoundError("未找到城市") raise NotFoundError("未找到城市")
async def createTemplate(cookies, template_params, proxies): async def createTemplate(cookies, template_params, proxies):
addr = proxies['addr'] addr = proxies['addr']
port = proxies['port'] port = proxies['port']
...@@ -170,10 +175,10 @@ async def createTemplate(cookies, template_params, proxies): ...@@ -170,10 +175,10 @@ async def createTemplate(cookies, template_params, proxies):
'aid': '4272', 'aid': '4272',
} }
template = { template = {
'name': template_params['template_name'], # 模板名称 'name': template_params['template_name'], # 模板名称
'mode': int(template_params['mode']), # 运费类型 # 0 阶梯计费 1 固定计费 2 商家包邮 'mode': int(template_params['mode']), # 运费类型 # 0 阶梯计费 1 固定计费 2 商家包邮
'product_province': getProductName('province', template_params['product_province']), # 发货省份id 'product_province': getProductName('province', template_params['product_province']), # 发货省份id
'product_city': getProductName('city', template_params['product_city']), # 发货市id 'product_city': getProductName('city', template_params['product_city']), # 发货市id
} }
rule_list = [] rule_list = []
try: try:
...@@ -210,22 +215,22 @@ async def createTemplate(cookies, template_params, proxies): ...@@ -210,22 +215,22 @@ async def createTemplate(cookies, template_params, proxies):
'id': getProductName('province', area_name) 'id': getProductName('province', area_name)
}) })
if region_tree_list: if region_tree_list:
rule_list.append({ # 指定地区直邮运费规则 rule_list.append({ # 指定地区直邮运费规则
'rule_type': 22, 'rule_type': 22,
'column_type': 1, 'column_type': 1,
'condition_list': [ 'condition_list': [
{ {
'address_condition': { # 指定地区直邮运费规则 'address_condition': { # 指定地区直邮运费规则
'region_tree_list': region_tree_list, 'region_tree_list': region_tree_list,
}, },
}, },
], ],
'formula': { 'formula': {
formula: { formula: {
start: int(designated_area['billing_rules']['start']) if pricing_method == '0' else str(designated_area['billing_rules']['start']), # 起始件数 start: int(designated_area['billing_rules']['start']) if pricing_method == '0' else str(designated_area['billing_rules']['start']), # 起始件数
'start_amount_yuan': designated_area['billing_rules']['start_amount_yuan'], # 起始运费 'start_amount_yuan': designated_area['billing_rules']['start_amount_yuan'], # 起始运费
step: int(designated_area['billing_rules']['step']) if pricing_method == '0' else str(designated_area['billing_rules']['step']), # 每次递增件数 step: int(designated_area['billing_rules']['step']) if pricing_method == '0' else str(designated_area['billing_rules']['step']), # 每次递增件数
'step_amount_yuan': designated_area['billing_rules']['step_amount_yuan'], # 每次递增运费 'step_amount_yuan': designated_area['billing_rules']['step_amount_yuan'], # 每次递增运费
}, },
}, },
}) })
...@@ -247,8 +252,8 @@ async def createTemplate(cookies, template_params, proxies): ...@@ -247,8 +252,8 @@ async def createTemplate(cookies, template_params, proxies):
'id': getProductName('province', area_name) 'id': getProductName('province', area_name)
}) })
if region_tree_list: if region_tree_list:
rule_list.append({ # 包邮运费规则 rule_list.append({ # 包邮运费规则
'rule_type': 1, # 包邮运费规则 'rule_type': 1, # 包邮运费规则
'column_type': 1, 'column_type': 1,
'condition_list': [ 'condition_list': [
{ {
...@@ -264,16 +269,16 @@ async def createTemplate(cookies, template_params, proxies): ...@@ -264,16 +269,16 @@ async def createTemplate(cookies, template_params, proxies):
], ],
}) })
transfer_freight = template_params['transfer_freight'] transfer_freight = template_params['transfer_freight']
rule_list.append({ # 中转运费默认规则 rule_list.append({ # 中转运费默认规则
'column_type': 2, # 中转运费规则 'column_type': 2, # 中转运费规则
'is_default': True, 'is_default': True,
'rule_type': 22, 'rule_type': 22,
'formula': { 'formula': {
formula: { formula: {
start: int(transfer_freight['default_billing_rules']['start']) if pricing_method == '0' else str(transfer_freight['default_billing_rules']['start']), # 起始件数 start: int(transfer_freight['default_billing_rules']['start']) if pricing_method == '0' else str(transfer_freight['default_billing_rules']['start']), # 起始件数
'start_amount_yuan': transfer_freight['default_billing_rules']['start_amount_yuan'], # 起始运费 'start_amount_yuan': transfer_freight['default_billing_rules']['start_amount_yuan'], # 起始运费
step: int(transfer_freight['default_billing_rules']['step']) if pricing_method == '0' else str(transfer_freight['default_billing_rules']['step']), # 每次递增件数 step: int(transfer_freight['default_billing_rules']['step']) if pricing_method == '0' else str(transfer_freight['default_billing_rules']['step']), # 每次递增件数
'step_amount_yuan': transfer_freight['default_billing_rules']['step_amount_yuan'], # 每次递增运费 'step_amount_yuan': transfer_freight['default_billing_rules']['step_amount_yuan'], # 每次递增运费
}, },
}, },
}) })
...@@ -346,8 +351,8 @@ async def createTemplate(cookies, template_params, proxies): ...@@ -346,8 +351,8 @@ async def createTemplate(cookies, template_params, proxies):
'id': getProductName('province', area_name) 'id': getProductName('province', area_name)
}) })
if region_tree_list: if region_tree_list:
rule = { # 限售规则 rule = { # 限售规则
'rule_type': 30, # 限售规则 'rule_type': 30, # 限售规则
'column_type': 3, 'column_type': 3,
'condition_list': [ 'condition_list': [
{ {
...@@ -356,7 +361,7 @@ async def createTemplate(cookies, template_params, proxies): ...@@ -356,7 +361,7 @@ async def createTemplate(cookies, template_params, proxies):
}, },
}, },
], ],
'reason': restriction['reason'], # 限售原因 'reason': restriction['reason'], # 限售原因
} }
if restriction.get('end_time'): if restriction.get('end_time'):
rule['end_time'] = int(restriction['end_time']) rule['end_time'] = int(restriction['end_time'])
...@@ -370,8 +375,8 @@ async def createTemplate(cookies, template_params, proxies): ...@@ -370,8 +375,8 @@ async def createTemplate(cookies, template_params, proxies):
'rule_type': 21, 'rule_type': 21,
'formula': { 'formula': {
'fixed_formula': { 'fixed_formula': {
'fixed_amount_yuan': default_billing_rules['fixed_amount_yuan'], # 固定运费 'fixed_amount_yuan': default_billing_rules['fixed_amount_yuan'], # 固定运费
}, },
}, },
}) })
if direct_mail.get('designated_area'): if direct_mail.get('designated_area'):
...@@ -439,8 +444,8 @@ async def createTemplate(cookies, template_params, proxies): ...@@ -439,8 +444,8 @@ async def createTemplate(cookies, template_params, proxies):
'rule_type': 21, 'rule_type': 21,
'formula': { 'formula': {
'fixed_formula': { 'fixed_formula': {
'fixed_amount_yuan': transfer_freight['default_billing_rules']['fixed_amount_yuan'], # 固定运费 'fixed_amount_yuan': transfer_freight['default_billing_rules']['fixed_amount_yuan'], # 固定运费
}, },
}, },
}) })
if transfer_freight.get('designated_area'): if transfer_freight.get('designated_area'):
...@@ -463,7 +468,7 @@ async def createTemplate(cookies, template_params, proxies): ...@@ -463,7 +468,7 @@ async def createTemplate(cookies, template_params, proxies):
], ],
'formula': { 'formula': {
'fixed_formula': { 'fixed_formula': {
'fixed_amount_yuan': designated_area['billing_rules']['fixed_amount_yuan'], # 固定运费 'fixed_amount_yuan': designated_area['billing_rules']['fixed_amount_yuan'], # 固定运费
}, },
}, },
}) })
...@@ -564,7 +569,7 @@ async def createTemplate(cookies, template_params, proxies): ...@@ -564,7 +569,7 @@ async def createTemplate(cookies, template_params, proxies):
} }
logger.info(rule_list) logger.info(rule_list)
url = 'https://fxg.jinritemai.com/freight/template/createTemplate' url = 'https://fxg.jinritemai.com/freight/template/createTemplate'
response = session.post(url,params=params,cookies=cookies,headers=HEADERS,json=json_data).json() response = session.post(url, params=params, cookies=cookies, headers=HEADERS, json=json_data).json()
logger.info(response) logger.info(response)
if response['code'] != 0: if response['code'] != 0:
msg = response.get('msg', '') msg = response.get('msg', '')
......
...@@ -40,12 +40,13 @@ def execute_sync_shop(container_name: str): ...@@ -40,12 +40,13 @@ def execute_sync_shop(container_name: str):
} }
@shared_task(name='sync_shop_info') @shared_task(name='sync_shop_info')
def execute_sync_shop_info(browser_id: str, listen_data: list): def execute_sync_shop_info(browser_id: str, listen_url: str, open_url: str):
"""执行店铺信息同步任务""" """执行店铺信息同步任务"""
try: try:
parameter = { parameter = {
'browser_id': browser_id, 'browser_id': browser_id,
'listen_data': listen_data 'listen_url': listen_url,
'open_url': open_url,
} }
result = asyncio.run(syncShopInfo(parameter)) result = asyncio.run(syncShopInfo(parameter))
return { return {
...@@ -168,6 +169,7 @@ def execute_generate_a_bogus(params:str | dict,data: dict,ua: str): ...@@ -168,6 +169,7 @@ def execute_generate_a_bogus(params:str | dict,data: dict,ua: str):
ctx = execjs.compile(js_code) ctx = execjs.compile(js_code)
if type(params) == dict: if type(params) == dict:
params = urlencode(params) params = urlencode(params)
data = json.dumps(data)
result = ctx.call('get_ab', params, data, ua) result = ctx.call('get_ab', params, data, ua)
return { return {
'code': 200, 'code': 200,
......
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