def get_interact_service_list(account_id): """ 到互动平台查询服务列表 """ payload = { 'account_id': account_id, } try: logger.info('get_wx_service_list from interact:') logger.info(payload) remote_response = requests.post(urljoin(get_interact_sys_address(), '/api/mobile/service/list'), data=payload, timeout=10) except Exception as e: logger.exception(e) return response200({ 'c': ERR_FAIL[0], 'm': ERR_FAIL[1], 'd': u'调用互动平台失败' }) logger.info('netagent return response:') logger.info(remote_response) return remote_response
def api_invite_parent1(request): dict_resp = auth_check(request, "POST", check_login=False) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: parent_id = request.POST.get("parent_id", "") parent = get_parentbyid(parent_id) user = parent.account mobile = request.POST.get("mobile", "") fullname = request.POST.get("fullname", "") sex = request.POST.get("sex", "") address = request.POST.get("address", "") # student_list_json = request.POST.get("student_list_json", "") messagecode = request.POST.get("messagecode", "") school_id = parent.school_id relation = request.POST.get("relation", "") dict_resp = agents.api_invite_parent1(user, school_id, mobile, address, fullname, sex, relation, messagecode) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def sendsms(mobile): """ 发送短信 """ payload = { 'pkg_name': 'applications.mail.services', 'function_name': 'send_message', 'parameter': json.dumps({ 'mobile': mobile, }, ensure_ascii=False) } try: logger.info('sendsms to netagent:') logger.info(payload) remote_response = _netagent_remote_call(payload) except Exception as e: logger.exception(e) return response200({ 'c': ERR_FAIL[0], 'm': ERR_FAIL[1], 'd': u'调用网络代理平台失败' }) logger.info('netagent return response:') logger.info(remote_response) return remote_response
def api_bind_parent(request): dict_resp = auth_check(request, "POST", check_login=False) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: mobile = request.POST.get("mobile", "") fullname = request.POST.get("fullname", "") sex = request.POST.get("sex", "") address = request.POST.get("address", "") student_list_json = request.POST.get("student_list_json", "") messagecode = request.POST.get("messagecode", "") openid = request.POST.get("openid", "") school_id = request.POST.get("sid", "") class_id = request.POST.get("class_id", "") only_check = request.POST.get("only_check", "") dict_resp = agents.api_bind_parent(openid, school_id, class_id, mobile, address, fullname, sex, student_list_json, messagecode, only_check=only_check) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def api_parent_qrcode(request): dict_resp = auth_check(request, "GET", check_login=True) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: cur_type_user = get_type_current_user(request.user) if not isinstance(cur_type_user, Parent): raise BusinessException(ERR_WX_USE_PARENT) parent_id = request.GET.get("parent_id", "") school_id = request.GET.get("sid", "") if not parent_id: cur_type_user = get_type_current_user(request.user) if not isinstance(cur_type_user, Parent): raise BusinessException(ERR_WX_USE_PARENT) parent_id = cur_type_user.id school_id = cur_type_user.school_id cur_domain = get_cur_domain(request) dict_resp = agents.api_parent_qrcode(cur_domain, school_id, parent_id) # dictResp = paging_with_request(request, dict_resp) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def wx_mod_debugstatus(request): debug_status = request.POST.get("debug_status", "") try: result = agents.wx_mod_debugstatus(debug_status) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message) log_response(request, result) return response200(result)
def wx_service_list(request): dict_resp = auth_check(request, "GET", check_login=True) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: dict_resp = agents.get_wx_service_list(request.user) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def update_weixin_global_access_token(request): school_id = request.GET.get("sid", "") weixin_app_id = request.GET.get("appid", "") try: weixinschool = get_weixin_school(school_id, weixin_app_id) globalaccesstokeninfo = agents.update_weixin_global_access_token( weixinschool) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message) log_response(request, globalaccesstokeninfo) return response200(globalaccesstokeninfo)
def get_weixin_global_access_token(request): log_request(request) school_id = request.GET.get("sid", "") weixin_app_id = request.GET.get("appid", "") try: weixinschool = get_weixin_school(school_id, weixin_app_id) cur_access_token = agents.get_weixin_global_access_token(weixinschool) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message) log_response(request, cur_access_token) return response200(cur_access_token)
def api_add_child_by_parent(request): dict_resp = auth_check(request, "POST", check_login=True) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: student_list_json = request.POST.get("student_list_json", "") dict_resp = agents.api_add_child_by_parent(request.user, student_list_json) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def api_fh_qrcode(request): dict_resp = auth_check(request, "GET", check_login=False) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: cur_domain = get_cur_domain(request) dict_resp = agents.api_fh_qrcode(cur_domain) # dictResp = paging_with_request(request, dict_resp) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def api_send_parent_bind_messagecode(request): dict_resp = auth_check(request, "GET", check_login=False) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: mobile = request.GET.get("mobile", "") dict_resp = agents.api_send_bind_messagecode(mobile, check_account_exist=False, check_user_bind=False) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def api_get_accountopenid(request): # 避免传入数据过大,本接口使用POST方式 dict_resp = auth_check(request, "POST", check_login=False) if dict_resp != {}: return HttpResponse(json.dumps(dict_resp, ensure_ascii=False), content_type="application/json") try: account_id_list = request.POST.get("account_id_list", "") school_id = request.POST.get("sid", "") dict_resp = agents.api_get_accountopenid(account_id_list, school_id) return response200(dict_resp) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message)
def wx_get_jsconfig(request): log_request(request) school_id = request.POST.get("sid", "") if not school_id: # 不传sid就必须登陆。 dictResp = auth_check(request, "POST", check_login=True) if dictResp != {}: return HttpResponse(json.dumps(dictResp, ensure_ascii=False), content_type="application/json") school_id = request.user.school.id weixin_app_id = request.POST.get("appid", "") url = request.POST.get("url", "") try: weixinschool = get_weixin_school(school_id, weixin_app_id) result = agents.wx_get_jsconfig(weixinschool, url) except Exception as ex: logger.exception(ex) return response_exception(ex, ex.message) log_response(request, result) return response200(result)