소스 검색

文件更新

ClownHe 1 년 전
부모
커밋
b7d92531b7
1개의 변경된 파일32개의 추가작업 그리고 3개의 파일을 삭제
  1. 32 3
      cppc_python脚本/服务器脚本/daily_script_python_yun/dianwutong_shops_info.py

+ 32 - 3
cppc_python脚本/服务器脚本/daily_script_python_yun/dianwutong_shops_info.py

@@ -491,16 +491,41 @@ def selectAllShopProvinceCityDistrictName(app_id,token,store_id):
 # 查询平台门店上线时间
 def selectPlateShopUptime(db,shop_id):
     cursor = db.cursor()
-    sql = f'SELECT `日期` FROM shop_daily_operation_data_app WHERE `门店id` = {shop_id} AND `有效单量` > 0 ORDER BY `日期`;'
+    sql = f'SELECT `日期` FROM shop_daily_operation_data_app WHERE `门店id` = {int(shop_id)} AND `有效单量` > 0 ORDER BY `日期`;'
     cursor.execute(sql)
     try:
-        uptime = cursor.fetchall()[0][0]
+        uptime = cursor.fetchall()[0][0].strftime ("%Y-%m-%d")
     except:
         uptime = 'null'
     cursor.close()
 
     return uptime
 
+def selectPlateShopUptimeOrStoreProvinceCityDistrictName(json_in):
+    try:
+        mode = json_in['mode']
+        id = json_in['id']
+        if mode == 'shop_id':
+            host = 'clownted.top'
+            passwd = '111???clown'
+            db_name = 'jxb-h'
+            port = 10036
+            db = linkTomySql(host, passwd, db_name, port)
+            memo = selectPlateShopUptime(db, id)
+            db.close()
+            result = 'ok'
+        elif mode == 'store_id':
+            app_id, token = getToken()
+            memo = selectAllShopProvinceCityDistrictName(app_id, token, id)
+            result = 'ok'
+        else:
+            result = 'error'
+            memo = 'input_error'
+    except Exception as e:
+        result = 'error'
+        memo = 'nofund_error'
+    json_out = {'result': result, 'memo': memo}
+    return json_out
 
 if __name__ == '__main__':
     # handleDWTshopInfo ()
@@ -540,4 +565,8 @@ if __name__ == '__main__':
         uptime = selectPlateShopUptime(db, shop_id)
         print(uptime)
     if 1==1:
-        print(getToken())
+        url = 'http://clownted.top:63307/searchPlateShopUptimeOrStoreProvinceCityDistrictName'
+        json_in = {'mode':'store_id','id':'7039071139418873856'}
+        r = requests.post(url,json=json_in).text
+        # r = selectPlateShopUptimeOrStoreProvinceCityDistrictName(json_in)
+        print(r)