Пример #1
0
 def userModify(self, wsbody):
     formdata = Storage()
     formdata.customer_id = self.get_ws_attr(wsbody, 'userCode')
     formdata.realname = self.get_ws_attr(wsbody, 'realName')
     formdata.install_address = self.get_ws_attr(wsbody, 'installAddress')
     formdata.ip_address = self.get_ws_attr(wsbody, 'ipAddress')
     formdata.mobile = self.get_ws_attr(wsbody, 'mobile')
     formdata.idcard = self.get_ws_attr(wsbody, 'idcard')
     account = self.db.query(models.TrAccount).filter_by(
         customer_id=formdata.customer_id).first()
     if not account:
         return self.send_wsresp('userModify',
                                 code=Codes.ERROR_NOT_EXIST,
                                 error=u'用户不存在')
     formdata.account_number = account.account_number
     formdata.user_concur_number = account.user_concur_number
     formdata.bind_vlan = account.bind_vlan
     formdata.bind_mac = account.bind_mac
     formdata.account_desc = account.account_desc
     customer = self.db.query(models.TrCustomer).get(formdata.customer_id)
     customer.realname = formdata.realname
     customer.address = formdata.install_address
     customer.mobile = formdata.mobile
     customer.idcard = formdata.idcard
     manager = AccountService(self.db, self.aes)
     ret = manager.update(formdata)
     if not ret:
         self.send_wsresp('userModify',
                          code=Codes.ERROR_UNKNOWN,
                          error=manager.last_error)
     else:
         self.send_wsresp('userModify', code=Codes.SUCCESS)
Пример #2
0
 def userReg(self, wsbody):
     formdata = Storage()
     formdata.node_id = self.get_ws_attr(wsbody, 'areaCode')
     formdata.area_id = self.get_ws_attr(wsbody, 'courtyardCode', defval='')
     formdata.customer_id = self.get_ws_attr(wsbody, 'userName', notnull=True)
     formdata.account_number = self.get_ws_attr(wsbody, 'userName', notnull=True)
     formdata.password = self.get_ws_attr(wsbody, 'password', notnull=True)
     formdata.realname = self.get_ws_attr(wsbody, 'realName')
     formdata.product_id = self.get_ws_attr(wsbody, 'productCode', notnull=True)
     formdata.expire_date = self.get_ws_attr(wsbody, 'authEndDate', notnull=True)
     formdata.address = self.get_ws_attr(wsbody, 'installAddress')
     formdata.ip_address = self.get_ws_attr(wsbody, 'ipAddress')
     formdata.mobile = self.get_ws_attr(wsbody, 'mobile')
     formdata.idcard = self.get_ws_attr(wsbody, 'idcard')
     formdata.fee_value = 0
     formdata.giftdays = 0
     formdata.giftflows = 0
     formdata.agency_id = None
     formdata.charge_code = None
     formdata.months = 0
     formdata.status = 1
     formdata.builder_name = None
     formdata.customer_desc = 'BOSS\xe5\xbc\x80\xe9\x80\x9a\xe8\xb4\xa6\xe5\x8f\xb7'
     account = self.db.query(models.TrAccount).get(formdata.account_number)
     if account:
         return self.send_wsresp('userReg', code=Codes.ERROR_ALREADY_EXIST, UserCode='', error=u'\u7528\u6237\u5df2\u7ecf\u5b58\u5728')
     else:
         cmanager = CustomerAdd(self.db, self.aes)
         ret = cmanager.add(formdata)
         if not ret:
             self.send_wsresp('userReg', code=Codes.ERROR_UNKNOWN, UserCode='', error=cmanager.last_error)
         else:
             self.send_wsresp('userReg', code=Codes.SUCCESS, UserCode=formdata.account_number.strip())
         return
Пример #3
0
 def new_ticket(online):
     _datetime = datetime.datetime.now()
     _starttime = datetime.datetime.strptime(online.acct_start_time, '%Y-%m-%d %H:%M:%S')
     session_time = (_datetime - _starttime).seconds
     stop_time = _datetime.strftime('%Y-%m-%d %H:%M:%S')
     ticket = Storage()
     ticket.id = utils.get_uuid()
     ticket.account_number = (online.account_number,)
     ticket.acct_session_id = (online.acct_session_id,)
     ticket.acct_start_time = (online.acct_start_time,)
     ticket.nas_addr = (online.nas_addr,)
     ticket.framed_ipaddr = (online.framed_ipaddr,)
     ticket.acct_session_time = (session_time,)
     ticket.acct_stop_time = (stop_time,)
     ticket.sync_ver = tools.gen_sync_ver()
     return ticket
Пример #4
0
 def userPasswordUpdate(self, wsbody):
     formdata = Storage()
     formdata.customer_id = self.get_ws_attr(wsbody, 'userCode')
     formdata.password = self.get_ws_attr(wsbody, 'password')
     account = self.db.query(models.TrAccount).filter_by(
         customer_id=formdata.customer_id).first()
     if not account:
         return self.send_wsresp('userPasswordUpdate',
                                 code=Codes.ERROR_NOT_EXIST,
                                 error=u'用户不存在')
     formdata.account_number = account.account_number
     manager = AccountService(self.db, self.aes)
     ret = manager.password(formdata)
     if not ret:
         self.send_wsresp('userPasswordUpdate',
                          code=Codes.ERROR_UNKNOWN,
                          error=manager.last_error)
     else:
         self.send_wsresp('userPasswordUpdate', code=Codes.SUCCESS)
Пример #5
0
 def userProductModify(self, wsbody):
     customer_id = self.get_ws_attr(wsbody, 'userCode', notnull=True)
     account = self.db.query(models.TrAccount).filter_by(customer_id=customer_id).first()
     if not account:
         return self.send_wsresp('userReg', code=Codes.ERROR_NOT_EXIST, error=u'\u7528\u6237\u4e0d\u5b58\u5728')
     formdata = Storage()
     formdata.account_number = account.account_number
     formdata.product_id = self.get_ws_attr(wsbody, 'productCode', notnull=True)
     formdata.add_value = 0
     formdata.expire_date = account.expire_date
     formdata.balance = 0
     formdata.time_length = 0
     formdata.flow_length = 0
     formdata.operate_desc = u'SOAPAPI userProductModify'
     manager = AccountChange(self.db, self.aes)
     if not manager.change(formdata):
         self.send_wsresp('userProductModify', code=Codes.ERROR_UNKNOWN, error=manager.last_error)
     else:
         self.send_wsresp('userProductModify', code=Codes.SUCCESS)
Пример #6
0
 def updatePolicy(self, wsbody):
     formdata = Storage()
     formdata.customer_id = self.get_ws_attr(wsbody, 'userCode')
     formdata.domain = self.get_ws_attr(wsbody, 'domainCode')
     formdata.bind_mac = self.get_ws_attr(wsbody, 'bindMac')
     formdata.bind_vlan = self.get_ws_attr(wsbody, 'bindVlan')
     formdata.user_concur_number = self.get_ws_attr(wsbody, 'concurNumber')
     account = self.db.query(models.TrAccount).filter_by(
         customer_id=formdata.customer_id).first()
     if not account:
         return self.send_wsresp('updatePolicy',
                                 code=Codes.ERROR_NOT_EXIST,
                                 error=u'用户不存在')
     formdata.account_number = account.account_number
     manager = AccountService(self.db, self.aes)
     ret = manager.update(formdata)
     if not ret:
         self.send_wsresp('updatePolicy',
                          code=Codes.ERROR_UNKNOWN,
                          error=manager.last_error)
     else:
         self.send_wsresp('updatePolicy', code=Codes.SUCCESS)