Commit 4c467601 by 岳巧源

add sql

parent bab0f438
Showing with 36 additions and 10 deletions
......@@ -6,6 +6,19 @@ import requests
url = "/sync/Address/updateAddress" # 线上地址需要更改
def get_user_detail_address_by_code(province: int, city: int, district: int, detail_address: str) -> str:
db = mysql.connector.connect(
host="232.db.liexindev.me",
user="liexin",
password="liexin#zsyM",
database="liexin"
)
sql = "select region_name from lie_region where region_id in (" + str(province) + "," + str(city) + "," + str(district) + ") " + "order by field (" + "region_id" + "," + str(province) + "," + str(city) + "," + str(district) + ") "
user_detail_address = ""
def pur():
db = mysql.connector.connect(
host="master.db2.liexindev.me",
......@@ -44,15 +57,28 @@ def liexin():
consignee_district = row[7]
consignee_address = row[8]
uc_id = row[9]
detail_address = ""
# 获取收票地址
tax_detail_address = ""
sql = "select region_name from lie_region where region_id in " + "(" + str(consignee_province) + "," + str(consignee_city) + "," + str(consignee_district) + ") " + "order by field (" + "region_id" + "," + str(consignee_province) + "," + str(consignee_city) + "," + str(consignee_district) + ")"
cursor.execute(sql)
address_result = cursor.fetchall()
for i in range(len(address_result)):
if len(address_result[i]) == 0:
tax_address_result = cursor.fetchall()
for i in range(len(tax_address_result)):
if len(tax_address_result[i]) == 0:
continue
detail_address += address_result[i][0]
detail_address += consignee_address
tax_detail_address += tax_address_result[i][0]
tax_detail_address += consignee_address
# 获取客户地址
user_detail_address = []
sql_user_address = "select province, city, district, detail_address from lie_user_address where uc_id = " + str(uc_id)
cursor.execute(sql_user_address)
user_address_result = cursor.fetchall()
for i in range(len(user_address_result)):
pass
json_map = {
"company_name_cn": tax_title, # tax_title
......@@ -71,7 +97,7 @@ def liexin():
"source_id": "consignee_address_" + str(tax_id),
"source_code": user_sn,
"address_type": "收票地址",
"address": detail_address
"address": tax_detail_address
},
{
"source_id": "user_address_" + str(tax_id),
......@@ -110,7 +136,7 @@ def crm():
json_map = {
"company_name_cn": com_name, # com_name
"business_license": business_license_src, # business_license_src
"source_system_id": "3",
"source_system_id": "3", # 1供应商 2供应链 3crm 4一体化 5采购系统 6-订单系统
"create_uid": str(creator_id), # creator_id
"create_name": creator_name, # creator_name
"address_data": [
......@@ -122,7 +148,7 @@ def crm():
}
]
}
if com_addr == "":
if len(com_addr):
json_map["address_data"] = []
post_data_to_update_address(json_map)
print("-------------------------crm已更新!--------------------------------")
......@@ -136,4 +162,4 @@ def post_data_to_update_address(data: dict):
if __name__ == '__main__':
liexin()
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 sign in to comment