|
@@ -281,12 +281,16 @@ class ContractRepository:
|
|
|
|
|
|
|
|
async def append_contract_url(self, templates_data, contract_item: dict):
|
|
async def append_contract_url(self, templates_data, contract_item: dict):
|
|
|
"""
|
|
"""
|
|
|
- 根据手机号,向 contract_url(JSON 列表)追加新的合同信息;
|
|
|
|
|
- 若手机号不存在,则创建新记录。
|
|
|
|
|
|
|
+ 根据 store_id,向 contract_url(JSON 列表)追加新的合同信息;
|
|
|
|
|
+ 若 store_id 不存在,则创建新记录。
|
|
|
"""
|
|
"""
|
|
|
- contact_phone = getattr(templates_data, "contact_phone", None)
|
|
|
|
|
|
|
+ store_id = getattr(templates_data, "store_id", None)
|
|
|
|
|
+ if store_id is None:
|
|
|
|
|
+ logger.error("append_contract_url missing store_id")
|
|
|
|
|
+ return False
|
|
|
|
|
+
|
|
|
result = await self._execute_with_retry(
|
|
result = await self._execute_with_retry(
|
|
|
- ContractStore.__table__.select().where(ContractStore.contact_phone == contact_phone)
|
|
|
|
|
|
|
+ ContractStore.__table__.select().where(ContractStore.store_id == store_id)
|
|
|
)
|
|
)
|
|
|
rows = result.mappings().all()
|
|
rows = result.mappings().all()
|
|
|
updated = False
|
|
updated = False
|
|
@@ -304,6 +308,9 @@ class ContractRepository:
|
|
|
update_values = {"contract_url": json.dumps(items, ensure_ascii=False)}
|
|
update_values = {"contract_url": json.dumps(items, ensure_ascii=False)}
|
|
|
if store_name:
|
|
if store_name:
|
|
|
update_values["store_name"] = store_name
|
|
update_values["store_name"] = store_name
|
|
|
|
|
+ contact_phone = getattr(templates_data, "contact_phone", None)
|
|
|
|
|
+ if contact_phone:
|
|
|
|
|
+ update_values["contact_phone"] = contact_phone
|
|
|
await self._execute_with_retry(
|
|
await self._execute_with_retry(
|
|
|
ContractStore.__table__.update()
|
|
ContractStore.__table__.update()
|
|
|
.where(ContractStore.id == row["id"])
|
|
.where(ContractStore.id == row["id"])
|
|
@@ -315,11 +322,11 @@ class ContractRepository:
|
|
|
return updated
|
|
return updated
|
|
|
# 未找到则创建新记录
|
|
# 未找到则创建新记录
|
|
|
new_record = ContractStore(
|
|
new_record = ContractStore(
|
|
|
- store_id=getattr(templates_data, "store_id", None),
|
|
|
|
|
|
|
+ store_id=store_id,
|
|
|
store_name=store_name,
|
|
store_name=store_name,
|
|
|
business_segment=getattr(templates_data, "business_segment", None),
|
|
business_segment=getattr(templates_data, "business_segment", None),
|
|
|
merchant_name=getattr(templates_data, "merchant_name", None),
|
|
merchant_name=getattr(templates_data, "merchant_name", None),
|
|
|
- contact_phone=contact_phone,
|
|
|
|
|
|
|
+ contact_phone=getattr(templates_data, "contact_phone", None),
|
|
|
contract_url=json.dumps([contract_item], ensure_ascii=False),
|
|
contract_url=json.dumps([contract_item], ensure_ascii=False),
|
|
|
seal_url='0.0',
|
|
seal_url='0.0',
|
|
|
signing_status='未签署'
|
|
signing_status='未签署'
|