Esempio n. 1
0
 def add_providehouse_apply(self):
     """申请提交房源"""
     if is_admin():
         return TOKEN_ERROR(u'普通用户才可以申请')
     if is_tourist():
         return TOKEN_ERROR(u'请登录后申请')
     data = parameter_required(
         ('phacity', 'phavillege', 'phaphone', 'phaname'), others='ignore')
     validate_phone(data.get('phaphone'))
     usid = request.user.id
     already_apply = self.strade.get_provide_appy_by_usid_village(
         usid, data.get('phavillege'))
     if already_apply:
         last_applytime = datetime.strptime(already_apply.PHAcreatetime,
                                            format_for_db)
         seconds = (datetime.now() - last_applytime).total_seconds()
         if seconds < 600:
             # 短时间内重复提交不记录
             return Success(u'申请成功, 等待管家回电')
     data['usid'] = usid
     data['PHAcreatetime'] = datetime.strftime(datetime.now(),
                                               format_for_db)
     data['PHAid'] = str(uuid.uuid4())
     self.strade.add_model('ProvideHouseApply', data)
     return Success(u'申请成功, 等待管家回电')
Esempio n. 2
0
 def cleaner_appiontment(self):
     """清洁服务预约"""
     if is_admin():
         raise TOKEN_ERROR(u'普通用户才可以预约')
     if is_tourist():
         raise TOKEN_ERROR(u'请登录后预约')
     required = ('sceid', 'uctpreviewstarttime', 'uctaddr',
                 'uctpreviewlastingtime', 'uctphone', 'uctprice',
                 'uctlocation')
     data = parameter_required(required, others='ignore')
     cleaner_exists = self.sserver.get_cleanerserver_by_sceid(
         data.get('sceid'))
     if not cleaner_exists:
         raise NOT_FOUND(u'不存在的清洁服务')
     data['uctphone'] = data.get('uctphone').strip()
     validate_phone(data.get('uctphone'))
     self._allow_starttime(data.get('uctpreviewstarttime'))
     data['uctid'] = str(uuid.uuid4())
     data['usid'] = request.user.id
     data['UCTcreatetime'] = datetime.strftime(datetime.now(),
                                               format_for_db)
     uctlocation = data.get('uctlocation')
     data['Citynum'] = BdMap(uctlocation).city_id  # 获取城市id
     modelbean_dict = self.sserver.add_model(
         'UserCleanTrade', data, ['UCTpreviewstarttime', 'UCTid'])
     modelbean_dict['name'] = cleaner_exists.SCMtitle
     return Success(u'预约成功', modelbean_dict)
Esempio n. 3
0
 def mover_appointment(self):
     """搬家预约"""
     if is_admin():
         return TOKEN_ERROR(u'普通用户才可以预约')
     if is_tourist():
         return TOKEN_ERROR(u'请登录后预约')
     required = ('smsid', 'umtstarttime', 'umtmoveoutaddr', 'umtmoveinaddr',
                 'umtmoveoutlocation', 'umtmoveinlocation', 'umtphone',
                 'umtpreviewprice')
     data = parameter_required(required, others='allow')
     # 是否存在这个服务
     mover_exsits = self.sserver.get_mover_by_smsid(data.get('smsid'))
     if not mover_exsits:
         raise NOT_FOUND(u'不存在服务{}'.format(data.get('smsid')))
     data['umtphone'] = data['umtphone'].strip()
     validate_phone(data.get('umtphone'))
     self._allow_starttime(data.get('umtstarttime'))
     data['UMTid'] = str(uuid.uuid4())
     data['usid'] = request.user.id
     data['UMTcreatetime'] = datetime.strftime(datetime.now(),
                                               format_for_db)
     umtmoveoutlocation = data.get('umtmoveoutlocation')
     data['Citynum'] = BdMap(umtmoveoutlocation).city_id
     model_bean_dict = self.strade.add_model('UserMoveTrade', data,
                                             ['UMTstarttime', 'UMTid'])
     model_bean_dict['name'] = mover_exsits.SMStitle
     return Success(u'预约成功', model_bean_dict)
Esempio n. 4
0
 def add_staff(self):
     """添加工作人员"""
     if not is_admin():
         raise TOKEN_ERROR(u'请使用管理员登录')
     data = parameter_required(('stfname', 'stfmobiel', 'stfaddress', 'stfgender', 'stflevel'), others='allow', forbidden=('STFid', ))
     validate_phone(data.get('stfmobiel'))
     if 'stfphone' in data:
         validate_phone(data.get('stfphone'))
     data['stfid'] = str(uuid.uuid4())
     data['STFcreatetime'] = datetime.strftime(datetime.now(), format_for_db)
     self.suser.add_model('Staff', data)
     return Success(u'添加成功', {
         'stfid': data.get('stfid')
     })
Esempio n. 5
0
 def add_complaint(self):
     if is_admin():
         raise TOKEN_ERROR(u'只有普通用户才可是投诉')
     if is_tourist():
         raise TOKEN_ERROR(u'请登录后投诉')
     data = parameter_required(('usercomplainttext', 'usercomplaintaddress',
                                'usercomplaintphone'),
                               others='ignore')
     validate_phone(data.get('usercomplaintphone'))
     data['usid'] = request.user.id
     data['UserComplaintid'] = str(uuid.uuid4())
     data['UserComplaintcreatetime'] = datetime.strftime(
         datetime.now(), format_for_db)
     self.strade.add_model('UserComplaint', data)
     return Success(u'投诉成功')
Esempio n. 6
0
 def get_code(self):
     """发送验证码"""
     data = parameter_required(('phone', ))
     phone = validate_phone(data.get('phone'))
     send = Thread(target=self._async_send_code, args=(phone, ))
     send.start()
     message = u'获取成功'
     return Success(message)
Esempio n. 7
0
    def add_admin(self):
        # 添加管理员, 默认添加0级别管理员
        if not is_hign_level_admin():
            raise TOKEN_ERROR(u'需要高级管理权限')
        required = ['adname', 'adusername', 'adpassword', 'admobiel', 'ademail']
        data = parameter_required(required)
        if self.suser.get_admin_by_adusername(data.get('adusername')):
            raise PARAMS_ERROR(u'用户名重复')

        validate_phone(data.get('admobiel'))
        validate_phone(data.get('adphone'))
        validate_arg('\w+@\w+\.\w+', data.get('ademail'), u'电子邮箱格式不正确')
        data['adlevel'] = 0 or data.get('adlevel')
        if data['adlevel'] >= request.user.level:
            raise AUTHORITY_ERROR()
        data['adid'] = str(uuid.uuid4())
        data['adpassword'] = generate_password_hash(data.get('adpassword'))
        self.suser.add_model('Admin', data)
        return Success(u'添加管理员成功', {
            'adid': data.get('adid')
        })
Esempio n. 8
0
 def fixer_appiontment(self):
     """维修预约"""
     if is_admin():
         return TOKEN_ERROR(u'只有普通用户才可以预约')
     if is_tourist():
         return TOKEN_ERROR(u'请登录后预约')
     required = ('uftaddr', 'uftstarttime', 'uftphone', 'uftlocation')
     forbidden = ('usid', 'uftstatus')
     data = parameter_required(required, forbidden=forbidden)
     data['uftphone'] = data.get('uftphone').strip()
     validate_phone(data.get('uftphone'))
     self._allow_starttime(data.get('uftstarttime'))
     data['UFTid'] = str(uuid.uuid4())
     data['usid'] = request.user.id
     data['UFTcreatetime'] = datetime.strftime(datetime.now(),
                                               format_for_db)
     uftlocation = data.get('uftlocation')
     data['Citynum'] = BdMap(uftlocation).city_id  # 获取城市id
     model_bean_dict = self.sserver.add_model('UserFixerTrade', data,
                                              ['UFTid', 'UFTstarttime'])
     model_bean_dict['name'] = u'维修预约'
     return Success(u'预约成功', model_bean_dict)