def update_order_status(resp): select_data = betaDB() resp_dict = json.loads(resp, encoding="utf8") outTradeNo = resp_dict["data"]["outTradeNo"] sql = """update ysx_order.ysx_order_info a set a.order_state="2" , a.callback_time= now(),a.ORDER_AMOUNT='100',a.ORIGINAL_AMOUNT='100' where a.order_sn ="{order_sn}";""".format( order_sn=outTradeNo) select_data.execute_sql(sql) select_data.execute_close() resp = outTradeNo return resp
def joinCategoryProduct(phone,phId,resp,new_cookies): select_data = betaDB() order_sn = resp sql = """select a.order_id,a.member_id from ysx_order.ysx_order_info a where a.order_sn ="{order_sn}";""".format(order_sn=order_sn) data = select_data.execute_select(sql) order_id,member_id = data[0][0],data[0][1] phone = phone productCoursehourseId = phId accreditReason = u"测试使用" url = r"https://admin.yunshuxie.com/v1/admin/write_source/writeCourse/joinCategoryProduct.json" request_params = {"memberId":member_id,"orderId":order_id,"phone":phone, "productCoursehourseId":productCoursehourseId,"accreditReason":accreditReason} headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36"} resp = requests.post(url=url,data=request_params,headers=headers,cookies=new_cookies) resp_dict = json.loads(resp.text,encoding="utf8") if phId=="9772" or phId==9772: chanel_url = """https://admin.yunshuxie.com/v2/live_course/role/member_role_list.json?memberId=&phone={phone}&sort=memberId&order=asc&limit=10&offset=0&_=1572507705540""".format(phone=phone) chanel_resp = requests.get(url=chanel_url,headers=headers,cookies=new_cookies) chanel_resp_dict = json.loads(chanel_resp.text, encoding="utf8") moocClassId = chanel_resp_dict["rows"][0]["moocClassId"] update_order_sn_sql = """update ysx_order.ysx_wechat_service_user a set a.order_sn="{order_sn}" where a.PHONE="{phone}" and a.MOOC_CLASS_ID="{moocClassId}";""".format(order_sn=order_sn,phone=phone,moocClassId=moocClassId) select_data.execute_sql(update_order_sn_sql) select_data.execute_close() if productCoursehourseId == "9639": mzjd_sql = """select a.PRODUCT_COURSE_HOURS_IDS from ysx_order.ysx_order_item a where a.order_id={order_id};""".format(order_id=order_id) data = select_data.execute_select(mzjd_sql) phids = data[0][0].split(",") text = "" for phid in range(0,len(phids)-1): request_params = {"memberId": member_id, "orderId": order_id, "phone": phone, "productCoursehourseId": phids[phid], "accreditReason": accreditReason} resp = requests.post(url=url, data=request_params, headers=headers, cookies=new_cookies) text = resp.text resp_dict = json.loads(resp.text, encoding="utf8") if resp_dict["returnCode"] == 0 or resp_dict["returnCode"] == "0": text += "授权成功," else: text +="授权课程请求失败," return text else: request_params = {"memberId": member_id, "orderId": order_id, "phone": phone, "productCoursehourseId": productCoursehourseId, "accreditReason": accreditReason} resp = requests.post(url=url,data=request_params,headers=headers,cookies=new_cookies) resp_dict = json.loads(resp.text,encoding="utf8") if resp_dict["returnCode"] == 0 or resp_dict["returnCode"] == "0": return "授权成功" else: return "授权课程请求失败"
def bearJoinCategoryProduct(phone,phId,resp,new_cookies): select_data = betaDB() sql = """select a.order_id,a.member_id from ysx_order.ysx_order_info a where a.order_sn ="{order_sn}";""".format(order_sn=resp) data = select_data.execute_select(sql) order_id,member_id = data[0][0],data[0][1] phone = phone productCoursehourseId = phId accreditReason = u"测试使用" if phId == "9775": categoryId = "106" else: categoryId = "102" grade = "1" url = r"https://admin.yunshuxie.com/v1/elementary/joinCategoryProduct.json" request_params = {"memberId":member_id,"orderId":order_id,"phone":phone,"categoryId":categoryId,"grade":grade, "productCoursehourseId":productCoursehourseId,"accreditReason":accreditReason} headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36"} resp = requests.post(url=url,data=request_params,headers=headers,cookies=new_cookies) resp_dict = json.loads(resp.text,encoding="utf8") if resp_dict["returnCode"] == 0 or resp_dict["returnCode"] == "0": return "授权成功" else: return "授权课程请求失败"
def test_protected(): """ 绩效专用 30保护期校验 """ tiyan_order_sn = request.args.get("tiyan_order_sn") zhengshi_order_sn = request.args.get("zhengshi_order_sn") isProtected = request.args.get("isProjected") courser_day = """SELECT ymypch.COURSE_START_DATE AS courseStartDate FROM ysx_order.YSX_ORDER_INFO yoyoi INNER JOIN ysx_mooc.ysx_mooc_class_member ymymcm ON ymymcm.ORDER_ID = yoyoi.ORDER_ID INNER JOIN ysx_mooc.ysx_mooc_class ymymc ON ymymc.MOOC_CLASS_ID = ymymcm.MOOC_CLASS_ID INNER JOIN ysx_mooc.ysx_product_course_hours ymypch ON ymypch.PRODUCT_COURSE_HOURS_ID = ymymc.PRODUCT_COURSE_HOURS_ID INNER JOIN ysx_order.ysx_wechat_service_teacher_class_middle yoywstcm ON yoywstcm.MOOC_CLASS_ID = ymymc.mooc_class_id INNER JOIN ysx_order.ysx_wechat_service_teacher yoywst ON yoywst.WECHATER_TEACHER_ID = yoywstcm.wechat_service_teacher_id WHERE yoyoi.order_sn = "{tiyan_order_sn}" ;""".format( tiyan_order_sn=tiyan_order_sn) select_datas = betaDB_order() COURSE_START_DATE = select_datas.execute_select(courser_day)[0][0] if isProtected == "0": #需要保护期外数据 sql = """select timestampdiff(day, (SELECT ymypch.COURSE_START_DATE AS courseStartDate FROM ysx_order.YSX_ORDER_INFO yoyoi INNER JOIN ysx_mooc.ysx_mooc_class_member ymymcm ON ymymcm.ORDER_ID = yoyoi.ORDER_ID INNER JOIN ysx_mooc.ysx_mooc_class ymymc ON ymymc.MOOC_CLASS_ID = ymymcm.MOOC_CLASS_ID INNER JOIN ysx_mooc.ysx_product_course_hours ymypch ON ymypch.PRODUCT_COURSE_HOURS_ID = ymymc.PRODUCT_COURSE_HOURS_ID INNER JOIN ysx_order.ysx_wechat_service_teacher_class_middle yoywstcm ON yoywstcm.MOOC_CLASS_ID = ymymc.mooc_class_id INNER JOIN ysx_order.ysx_wechat_service_teacher yoywst ON yoywst.WECHATER_TEACHER_ID = yoywstcm.wechat_service_teacher_id WHERE yoyoi.order_sn = "{tiyan_order_sn}")/*体验课程开始时间*/, (select a.CALLBACK_TIME from ysx_order.ysx_order_info a where a.order_sn='{zhengshi_order_sn}' and a.ORDER_STATE='2')/*正式课程下单时间*/ )""".format(tiyan_order_sn=tiyan_order_sn, zhengshi_order_sn=zhengshi_order_sn) data = select_datas.execute_select(sql)[0][0] if data > 30: min_data_sql = """select callback_time from ysx_order.YSX_ORDER_INFO where order_sn="{zhengshi_order_sn}" and order_state="2";""".format( zhengshi_order_sn=zhengshi_order_sn) min_data = select_datas.execute_select(min_data_sql)[0][0] datas = "%s:保护期外,不做处理" % (min_data) else: add_30_days = """ select date_add( (SELECT ymypch.COURSE_START_DATE AS courseStartDate FROM ysx_order.YSX_ORDER_INFO yoyoi INNER JOIN ysx_mooc.ysx_mooc_class_member ymymcm ON ymymcm.ORDER_ID = yoyoi.ORDER_ID INNER JOIN ysx_mooc.ysx_mooc_class ymymc ON ymymc.MOOC_CLASS_ID = ymymcm.MOOC_CLASS_ID INNER JOIN ysx_mooc.ysx_product_course_hours ymypch ON ymypch.PRODUCT_COURSE_HOURS_ID = ymymc.PRODUCT_COURSE_HOURS_ID INNER JOIN ysx_order.ysx_wechat_service_teacher_class_middle yoywstcm ON yoywstcm.MOOC_CLASS_ID = ymymc.mooc_class_id INNER JOIN ysx_order.ysx_wechat_service_teacher yoywst ON yoywst.WECHATER_TEACHER_ID = yoywstcm.wechat_service_teacher_id WHERE yoyoi.order_sn = "{tiyan_order_sn}" ),interval 31 day) from dual;""".format( tiyan_order_sn=tiyan_order_sn) data = select_datas.execute_select(add_30_days)[0][0] update_sql = """update ysx_order.ysx_order_info a set a.callback_time='{tdate}' where a.order_sn='{zhengshi_order_sn}' and a.ORDER_STATE='2';""".format( tdate=data, zhengshi_order_sn=zhengshi_order_sn) update_data = betaDB() update_data.execute_sql(update_sql) update_data.execute_close() datas = "%s:保护期外+30天完成增加" % (data) else: #需要保护期内数据 sql = """select timestampdiff(day, (SELECT ymypch.COURSE_START_DATE AS courseStartDate FROM ysx_order.YSX_ORDER_INFO yoyoi INNER JOIN ysx_mooc.ysx_mooc_class_member ymymcm ON ymymcm.ORDER_ID = yoyoi.ORDER_ID INNER JOIN ysx_mooc.ysx_mooc_class ymymc ON ymymc.MOOC_CLASS_ID = ymymcm.MOOC_CLASS_ID INNER JOIN ysx_mooc.ysx_product_course_hours ymypch ON ymypch.PRODUCT_COURSE_HOURS_ID = ymymc.PRODUCT_COURSE_HOURS_ID INNER JOIN ysx_order.ysx_wechat_service_teacher_class_middle yoywstcm ON yoywstcm.MOOC_CLASS_ID = ymymc.mooc_class_id INNER JOIN ysx_order.ysx_wechat_service_teacher yoywst ON yoywst.WECHATER_TEACHER_ID = yoywstcm.wechat_service_teacher_id WHERE yoyoi.order_sn = "{tiyan_order_sn}")/*体验课程开始时间*/, (select a.CALLBACK_TIME from ysx_order.ysx_order_info a where a.order_sn='{zhengshi_order_sn}' and a.ORDER_STATE='2')/*正式课程下单时间*/ )""".format(tiyan_order_sn=tiyan_order_sn, zhengshi_order_sn=zhengshi_order_sn) data = select_datas.execute_select(sql) if data < 30: min_data_sql = """select callback_time from ysx_order.YSX_ORDER_INFO where order_sn="{zhengshi_order_sn}" and order_state="2";""".format( zhengshi_order_sn=zhengshi_order_sn) min_data = select_datas.execute_select(min_data_sql)[0][0] datas = "%s:保护期内,不做处理" % (min_data) else: add_29_days = """ select date_add( (SELECT ymypch.COURSE_START_DATE AS courseStartDate FROM ysx_order.YSX_ORDER_INFO yoyoi INNER JOIN ysx_mooc.ysx_mooc_class_member ymymcm ON ymymcm.ORDER_ID = yoyoi.ORDER_ID INNER JOIN ysx_mooc.ysx_mooc_class ymymc ON ymymc.MOOC_CLASS_ID = ymymcm.MOOC_CLASS_ID INNER JOIN ysx_mooc.ysx_product_course_hours ymypch ON ymypch.PRODUCT_COURSE_HOURS_ID = ymymc.PRODUCT_COURSE_HOURS_ID INNER JOIN ysx_order.ysx_wechat_service_teacher_class_middle yoywstcm ON yoywstcm.MOOC_CLASS_ID = ymymc.mooc_class_id INNER JOIN ysx_order.ysx_wechat_service_teacher yoywst ON yoywst.WECHATER_TEACHER_ID = yoywstcm.wechat_service_teacher_id WHERE yoyoi.order_sn = "{tiyan_order_sn}" ),interval 29 day) from dual;""".format( tiyan_order_sn=tiyan_order_sn) COURSE_START_DATE = select_datas.execute_select(courser_day)[0][0] data = select_datas.execute_select(add_29_days)[0][0] update_sql = """update ysx_order.ysx_order_info a set a.callback_time='{tdate}' where a.order_sn='{zhengshi_order_sn}' and a.ORDER_STATE='2';""".format( tdate=data, zhengshi_order_sn=zhengshi_order_sn) update_data = betaDB() update_data.execute_sql(update_sql) update_data.execute_close() datas = "%s:保护期内+课程开课事件增加29天完成" % (data) select_datas.execute_close() response = make_response( jsonify({ "code": 200, "COURSE_START_DATE": str(COURSE_START_DATE), "CALLBACK_TIME": datas })) # 返回response return response
def bearJoinCategoryProduct(phone, phId, resp, new_cookies): select_data = betaDB() sql = """select a.order_id,a.member_id from ysx_order.ysx_order_info a where a.order_sn ="{order_sn}";""".format( order_sn=resp) data = select_data.execute_select(sql) order_id, member_id = data[0][0], data[0][1] phone = phone productCoursehourseId = phId accreditReason = u"测试使用" if phId == "9775": categoryId = "106" else: categoryId = "102" grade = "1" url = r"https://admin.yunshuxie.com/v1/elementary/joinCategoryProduct.json" request_params = { "memberId": member_id, "orderId": order_id, "phone": phone, "categoryId": categoryId, "grade": grade, "productCoursehourseId": productCoursehourseId, "accreditReason": accreditReason } headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36" } resp = requests.post(url=url, data=request_params, headers=headers, cookies=new_cookies) resp_dict = json.loads(resp.text, encoding="utf8") if resp_dict["returnCode"] == 0 or resp_dict["returnCode"] == "0": return "授权成功" else: return "授权课程请求失败" # # @test.route("/ClassInCreate",methods=["GET"]) # def ClassInCreate(): # """ # Admin创建ClassIn流程启动 # :return: # """ # env_flag = request.args.get("env_flag") # env_num = request.args.get("env_num") # phone = request.args.get("phone") # developer =request.args.get("developer") # redis.set("ClassInCreate", "{'phone':'%s'}"%phone, 600) # redis.set("ClassInCreateFlag", "{'env_flag':'%s'}"%env_flag, 600) # redis.set("ClassInCreateNum", "{'env_num':'%s'}"%env_num, 600) # url = "http://uwsgi.sys.bandubanxie.com/scheduleSuite?domain=ClassIn&env_flag=%s&env_num=%s&developer=%s"%(env_flag,env_num,developer) # wctv = {} # resp = requests.get(url=url) # time.sleep(10) # value = redis.get("v1/admin/product_chapter/create_live_room.json") # wctv["schedule"] = resp.text # wctv["RoomMsg"] = value # return make_response(jsonify(wctv))