def captcha4forgetPwd(): ''' 发送模板短信 ''' data = request.get_data().decode("utf-8") data_json = json.loads(data) phone = data_json["phone"] captcha = random.randint(1000, 9999) try: result = RCSCLOUDAPI.sendTplSms("76d68898d8624cbba44f8cc7626c830f", phone, "@1@=%s" % captcha) # print(result) # print("_______________-",PhoneCaptcha.phone_captcha_dict) # 记录发送短信的字典,手机号为key,验证码和时间戳为值 import time startTime = int(time.time()) captchaInfo = PhoneCaptcha.query.filter_by(phone=phone).first() if (captchaInfo is None): captchaInfo = PhoneCaptcha(phone=phone, captcha=captcha, start_time=startTime) captchaInfo.save() else: captchaInfo.captcha = captcha captchaInfo.start_time = startTime captchaInfo.save() except Exception as ex: print("captcha for register Error = %s" % str(ex)) return jsonify(common.falseReturn('', '发送短信失败')) else: return jsonify(common.trueReturn('', "发送短信成功"))
def network_detection(): user = Users.get(Users, current_identity.id) user_id = user.id bind_mapping = BindMapping.query.filter(BindMapping.user_id == user_id, BindMapping.del_flag == 0).first() if bind_mapping: locker_id = bind_mapping.locker_id locker = Locker.query.filter(Locker.id == locker_id, Locker.del_flag == 0).first() if locker: locker.net = 1 locker.save() return jsonify(common.trueReturn(data="1", msg="1")) else: return jsonify(common.falseReturn(data="", msg="")) return jsonify(common.falseReturn(data="", msg=""))
def get_common_log(): user = Users.get(Users, current_identity.id) user_id = user.id bind_mapping = BindMapping.query.filter(BindMapping.user_id == user_id, BindMapping.del_flag == 0).first() if bind_mapping: locker_id = bind_mapping.locker_id clogs = LockerCommonLog.query.filter( LockerCommonLog.del_flag == 0, LockerCommonLog.locker_id == locker_id).all() result = [] for i in clogs: d = {} d['id'] = i.id d['locker_id'] = i.locker_id d['common_log'] = i.common_log d['create_time'] = time_to_chinese(i.create_time) result.append(d) return jsonify(common.trueReturn(result, msg="获取出入门记录成功")) else: return jsonify(common.falseReturn(None, msg="未获取到绑定的数据"))
def device_binding(): user = Users.get(Users, current_identity.id) user_id = user.id data = request.get_data().decode("utf-8") data_json = json.loads(data) request_id = data_json['id'] request_pwd = data_json['pwd'] locker = Locker.query.filter(Locker.del_flag == 0, Locker.mac == request_id).first() if not locker: return jsonify(common.falseReturn(msg='输入的序列号或密码错误')) if locker.lock_password == request_pwd: mapping = BindMapping() mapping.locker_id = locker.id mapping.del_flag = 0 mapping.user_id = user_id mapping.save() return jsonify(common.trueReturn(msg='绑定成功')) else: return jsonify(common.falseReturn(msg='输入的序列号或密码错误'))
def push_msg_all(): msg = '第一个msg ,测试..' # push.all(msg) # push.notification() push.audience_for_alias("smartLocker_74", "warn") return jsonify(common.trueReturn(data={}, msg='发送成功'))
def additional_beep_settings(): data = request.get_data().decode("utf-8") data_json = json.loads(data) setting_id = data_json['setting_id'] return jsonify(common.trueReturn(data="1", msg="1"))
def in_out_door_display(): data = request.get_data().decode("utf-8") data_json = json.loads(data) display = data_json['display'] return jsonify(common.trueReturn(data="1", msg="1"))
def locker_feature_confirm(): data = request.get_data().decode("utf-8") data_json = json.loads(data) feature_id = data_json["feature_id"] return jsonify(common.trueReturn(data="1", msg="1"))