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
def insertArea(self, wsbody): formdata = Storage() formdata.node_id = self.get_ws_attr(wsbody, 'areaCode', notnull=True) formdata.node_name = self.get_ws_attr(wsbody, 'areaName', notnull=True) formdata.node_desc = u'BOSS 接入区域' formdata.rule_id = 0 node = self.db.query(models.TrNode).get(formdata.node_id) if node: return self.send_wsresp('insertArea', code=Codes.ERROR_ALREADY_EXIST, error=u'区域已经存在') manager = NodeService(self.db, self.aes) ret = manager.add(formdata) if not ret: self.send_wsresp('insertArea', code=Codes.ERROR_UNKNOWN, error=manager.last_error) else: self.send_wsresp('insertArea', code=Codes.SUCCESS)