Example #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)
Example #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