Commit da4dd649 by 岳巧源

add sql

parent 4c467601
Showing with 40 additions and 19 deletions
......@@ -15,7 +15,17 @@ def get_user_detail_address_by_code(province: int, city: int, district: int, det
)
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 = ""
cursor = db.cursor()
cursor.execute(sql)
result = cursor.fetchall()
for i in range(len(result)):
if len(result[i]) == 0:
continue
user_detail_address += result[i][0]
user_detail_address += detail_address
cursor.close()
db.close()
return user_detail_address
......@@ -70,43 +80,52 @@ def liexin():
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()
user_detail_address_list = []
for i in range(len(user_address_result)):
pass
province = user_address_result[i][0]
city = user_address_result[i][1]
district = user_address_result[i][2]
detail_address = user_address_result[i][3]
user_address = get_user_detail_address_by_code(province, city, district, detail_address)
user_detail_address_list.append(user_address)
json_map = {
"company_name_cn": tax_title, # tax_title
"business_license": business_license, # business_license
"source_system_id": "", # ?????
"create_uid": "", # ????
"create_name": "", # ?????
"address_data": [
{
"address_data": []
}
# 发票地址不为空,加入发票地址信息
if len(company_address) != 0:
json_map["address_data"].append({
"source_id": "tax_id_" + str(tax_id),
"source_code": user_sn,
"address_type": "发票地址",
"address": company_address
},
{
})
# 收票地址不为空,加入收票地址信息
if len(tax_detail_address) != 0:
json_map["address_data"].append({
"source_id": "consignee_address_" + str(tax_id),
"source_code": user_sn,
"address_type": "收票地址",
"address": tax_detail_address
},
{
})
# 客户地址信息列表不为空 加入客户地址信息
for i in range(len(user_detail_address_list)):
if len(user_detail_address_list[i]) == 0:
continue
json_map["address_data"].append({
"source_id": "user_address_" + str(tax_id),
"source_code": user_sn,
"address_type": "客户地址",
"address": ""
}
]
}
"address": user_detail_address_list[i]
})
print(json_map)
post_data_to_update_address(json_map)
print("-------------------------liexin已更新!--------------------------------")
......@@ -148,8 +167,10 @@ def crm():
}
]
}
if len(com_addr):
if len(com_addr) == 0:
json_map["address_data"] = []
print(json_map)
continue
post_data_to_update_address(json_map)
print("-------------------------crm已更新!--------------------------------")
cursor.close()
......@@ -162,4 +183,4 @@ def post_data_to_update_address(data: dict):
if __name__ == '__main__':
crm()
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