Commit de9657e4 by 岳巧源

modify sql

parent 962072df
Showing with 68 additions and 21 deletions
......@@ -6,7 +6,23 @@ import requests
url = "/sync/Address/updateAddress" # 线上地址需要更改
def pur():
db = mysql.connector.connect(
host="master.db2.liexindev.me",
user="liexin_purchase",
password="liexin_purchase#zsyM",
database="liexin_purchase"
)
cursor = db.cursor()
cursor.execute("")
result = cursor.fetchall()
for row in result:
json_map = {
}
######################################################
def liexin():
db = mysql.connector.connect(
host="232.db.liexindev.me",
......@@ -15,36 +31,60 @@ def liexin():
database="liexin"
)
cursor = db.cursor()
cursor.execute("select tax_title, business_license from lie_taxinfo")
cursor.execute("select tax_title, business_license, tax_id, user_sn, company_address, consignee_province, consignee_city, consignee_district, consignee_address from lie_taxinfo")
result = cursor.fetchall()
for row in result:
tax_title = row[0]
business_license = row[1]
tax_id = row[2]
user_sn = row[3]
company_address = row[4]
consignee_province = row[5]
consignee_city = row[6]
consignee_district = row[7]
consignee_address = row[8]
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:
continue
detail_address += address_result[i][0]
detail_address += consignee_address
json_map = {
"company_name_cn": row[0], # tax_title
"business_license": row[1], # business_license
"company_name_cn": tax_title, # tax_title
"business_license": business_license, # business_license
"source_system_id": "", # ?????
"create_uid": "", # ????
"create_name": "", # ?????
"address_data": [
{
"source_id": "tax_id_" ,
"source_code": "",
"address_type": "",
"address": ""
"source_id": "tax_id_" + str(tax_id),
"source_code": user_sn,
"address_type": "", # ????? 直接写“发票地址”这几个汉字么?
"address": company_address
},
{
"source_id": "",
"source_code": "",
"address_type": "",
"address": ""
"source_id": "consignee_address_" + str(tax_id),
"source_code": user_sn,
"address_type": "", # ????? 直接写“收票地址”这几个汉字么?
"address": detail_address
},
{
"source_id": "",
"source_code": "",
"address_type": "",
"source_id": "user_address_" + str(tax_id),
"source_code": user_sn,
"address_type": "", # ????? 直接写“客户地址”这几个汉字么?
"address": ""
}
]
}
post_data_to_update_address(json_map)
print("-------------------------liexin已更新!--------------------------------")
#########################################################################
def crm():
......@@ -59,18 +99,25 @@ def crm():
"select com_name, business_license_src, creator_id, creator_name, id, com_addr from lie_company where com_category in (0, 1)")
result = cursor.fetchall()
for row in result:
com_name = row[0]
business_license_src = row[1]
creator_id = row[2]
creator_name = row[3]
id = row[4]
com_addr = row[5]
json_map = {
"company_name_cn": row[0], # com_name
"business_license": row[1], # business_license_src
"company_name_cn": com_name, # com_name
"business_license": business_license_src, # business_license_src
"source_system_id": "3",
"create_uid": str(row[2]), # creator_id
"create_name": row[3], # creator_name
"create_uid": str(creator_id), # creator_id
"create_name": creator_name, # creator_name
"address_data": [
{
"source_id": "company_" + str(row[4]), # id
"source_id": "company_" + str(id), # id
"source_code": "", # ???? 为空
"address_type": "", # 这个不确定
"address": row[5] # com_addr
"address": com_addr # com_addr
}
]
}
......@@ -86,4 +133,4 @@ def post_data_to_update_address(data: dict):
if __name__ == '__main__':
pass
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