def report_bi_sdk_login(self, eventId, user_id, appId, clientId, bindId, fail_reason, devId=None): # fmt = "I I H H I I 32s 40s B B H" # | | | | | | | | | | └- fail_reason # | | | | | | | | | └- province # | | | | | | | | └- phonetype # | | | | | | | └- bindid # | | | | | | └- devid # | | | | | └- ipAddr # | | | | └- clientId 客户端终端的ID # | | | └- appId 客户端登录时产生的appId # | | └- gameId 后端服务操作时使用的gameId # | └- userId 事件产生的用户 # └- eventId 事件ID user_id = int(user_id) appId = int(appId) gameId = self.__ctx__.Const.SDK_GAMEID from tyframework.context import TyContext _, clientId = self.__ctx__.BiUtils.getClientIdNum(clientId, None, gameId, user_id) if user_id: if not devId: devId = TyContext.UserSession.get_session_deviceid(user_id) phoneType = TyContext.UserSession.get_session_phone_type(user_id) else: devId = '' phoneType = 3 ipAddrs = TyContext.RunHttp.get_client_ip() prov, _ = TyContext.UserSession.get_session_zipcode(user_id, client_ip=ipAddrs) province = prov / 10000 if prov != 1 else prov ipAddr = TyContext.IPAddress(ipAddrs)._ip assert (isinstance(eventId, (int, long))) assert (isinstance(user_id, (int, long))) assert (isinstance(gameId, (int, long))) assert (isinstance(appId, (int, long))) assert (isinstance(clientId, (int, long))) assert (isinstance(ipAddr, (int, long))) assert (isinstance(devId, basestring)) assert (isinstance(bindId, basestring)) assert (isinstance(phoneType, (int, long))) assert (isinstance(province, (int, long))) assert (isinstance(fail_reason, (int, long))) self.__ctx__.ftlog.debug('report_bi_sdk_login->', eventId, user_id, gameId, appId, clientId, ipAddr, devId, bindId, phoneType, province, fail_reason) self.__ctx__.ftlog.info('sdk_login_userip', user_id, ipAddrs) return self.report_bi(user_id, 'sdk_login', 'IIHHII32s40sBBH', eventId, user_id, gameId, appId, clientId, ipAddr, devId, bindId, phoneType, province, fail_reason)
def _is_networkip_restricted(cls, clientid, fromip): TyContext.ftlog.debug('_is_networkip_restricted clientid', clientid, 'fromip', fromip) if not clientid or not fromip: TyContext.ftlog.error('_is_networkip_restricted True ' 'clientid or fromip is blank') return True limit_ipnetworks_dict = TyContext.Configure.get_global_item_json( 'newuser.ipnetwork.limit', {}) limit_ipnetworks = limit_ipnetworks_dict.get(clientid, []) TyContext.ftlog.debug('_is_networkip_restricted clientid', clientid, 'limit_ipnetworks', limit_ipnetworks) if not limit_ipnetworks: return False fromipAddr = TyContext.IPAddress(fromip) for ipnetwork in limit_ipnetworks: if fromipAddr in TyContext.IPNetwork(ipnetwork): TyContext.ftlog.info('_is_networkip_restricted clientid ', clientid, 'fromip', fromip, 'ipnetwork', ipnetwork, 'restricted') return True return False
def report_bi_sdk_buy(self, eventid, userid, appid, clientid, orderid, shortid='', deliver_orderid='', prodid=0, diamondid=0, sub_event=0, prod_price=0, charge_price=0, succ_price=0, paytype=0, sub_paytype='', third_prodid='', third_orderid='', third_appid='', ipaddr=0, mobile='', phonetype=3, province=1): ''' 字段定义: eventid(4)|tyid(4)|gameid(2)|appid(2)|clientid(4)| orderid(14)|shortid(6)|deliver_orderid(25)|prodid(2)|diamondid(2)| sub_event(1)|prod_price(4)|charge_price(4)|succ_price(4)| paytype(2)|sub_paytype(10)| third_prodid(32)|third_orderid(32)|third_appid(32)| ipaddr(4)|mobile(11)|phonetype(1)|province(1) 这些字段总长度:203字节 各字段释义: event_type: 支付事件。与其他event统一编码,占4字节。 CREATE CLIENT_FINISHED CLIENT_CANCELED REQUEST_OK REQUEST_RETRY REQUEST_ERROR CALLBACK_OK CALLBACK_FAIL DELIVER_OK DELIVER_FAIL INTERNAL_ERR tyid: userid gameid: gameid (998 for SDK) appid: application id (e.g. 6 for 地主) clientid: clientid as a number,统一编码为2 bytes整形 orderid: platformOrderid, 支付订单后,14位长字符串 shortid: 某些情况下由orderid转换而成的6位长的短订单号 deliver_orderid: 由发货系统生成的发货单号 prodid: 商品ID,统一编码 diamondid: 钻石ID,与商品统一编码 sub_event: 子事件。可有可无。有的时候表示对应event_type的子事件。 如event_type为CLIENT_CANCEL时,它表示取消的具体原因。 又如event_type为INTERNAL_ERR时,它表示错误的具体原因。 具体编码数值待定。 prod_price: 商品标价,单位:钻石数 charge_price: 充值金额,单位:元 succ_price: 成功金额,单位:元 paytype: 支付方式。统一编码为2 bytes整形 sub_paytype: 子支付类型。对应支付方式有子支付方式的情况。 如使用小米支付有银行卡、充值卡等不同的子支付方式。暂定10字节字符串。 third_prodid: 第三方所定义的商品ID,暂定32位字符串。用于对账。 third_orderid: 第三方流水号,暂定32位字符串。用于对账。 third_appid: 第三方应用ID,暂定32位字符串。用于分应用统计与对账。 ipaddr: 4位IP地址 mobile: 11位手机号码 phonetype: 1位运营商类别(0/1/2分别表示移动、联通、电信) province: 1位省份编码(邮政编码最高2位) ''' # fmt = "I I H H I 14s 6s 25s H H B I f f H 10s 32s 32s 32s I 11s B B" # | | | | | | | | | | | | | | | | | | | | | | | # | | | | | | | | | | | | | | | | | | | | | | └- province # | | | | | | | | | | | | | | | | | | | | | └- phonetype # | | | | | | | | | | | | | | | | | | | | └- mobile # | | | | | | | | | | | | | | | | | | | └- ipaddr # | | | | | | | | | | | | | | | | | | └- third_appid # | | | | | | | | | | | | | | | | | └- third_orderid # | | | | | | | | | | | | | | | | └- third_prodid # | | | | | | | | | | | | | | | └- sub_paytype # | | | | | | | | | | | | | | └- paytype # | | | | | | | | | | | | | └- succ_price # | | | | | | | | | | | | └- charge_price # | | | | | | | | | | | └- prod_price # | | | | | | | | | | └- sub_event # | | | | | | | | | └- diamondid # | | | | | | | | └- prodid # | | | | | | | └- deliver_orderid # | | | | | | └- shortid # | | | | | └- orderid # | | | | └- clientId 客户端终端的ID # | | | └- appId 客户端登录时产生的appId # | | └- gameId 后端服务操作时使用的gameId # | └- userId 事件产生的用户 # └- eventId 事件ID self.__ctx__.ftlog.debug( 'report_bi_sdk_buy->', eventid, userid, appid, clientid, orderid, shortid, deliver_orderid, prodid, diamondid, sub_event, prod_price, charge_price, succ_price, paytype, sub_paytype, third_prodid, third_orderid, third_appid, ipaddr, mobile, phonetype, province) userid = int(userid) appid = int(appid) gameid = self.__ctx__.Const.SDK_GAMEID from tyframework.context import TyContext _, clientid = self.__ctx__.BiUtils.getClientIdNum(clientid, None, appid, userid) ip = TyContext.IPAddress(ipaddr)._ip prov = province / 10000 if province != 1 else province if prodid: prodid = self.__ctx__.BiUtils.productIdToNumber(appid, prodid) else: prodid = 0 if diamondid: diamondid = self.__ctx__.BiUtils.productIdToNumber(gameid, diamondid) else: diamondid = 0 assert (isinstance(eventid, (int, long))) assert (isinstance(userid, (int, long))) assert (isinstance(gameid, (int, long))) assert (isinstance(appid, (int, long))) assert (isinstance(clientid, (int, long))) assert (isinstance(orderid, basestring)) assert (isinstance(shortid, basestring)) assert (isinstance(deliver_orderid, basestring)) assert (isinstance(prodid, (int, long))) assert (isinstance(diamondid, (int, long))) assert (isinstance(sub_event, (int, long))) assert (isinstance(prod_price, (int, long))) assert (isinstance(charge_price, (float, int, long))) assert (isinstance(succ_price, (float, int, long))) assert (isinstance(paytype, (int, long))) assert (isinstance(sub_paytype, basestring)) assert (isinstance(third_prodid, basestring)) assert (isinstance(third_orderid, basestring)) assert (isinstance(third_appid, basestring)) assert (isinstance(ip, (int, long))) assert (isinstance(mobile, basestring)) assert (isinstance(prov, (int, long))) assert (isinstance(phonetype, (int, long))) return self.report_bi( userid, 'sdk_buy', 'IIHHI14s6s25sHHBIffH10s32s32s32sI11sBB', eventid, userid, gameid, appid, clientid, orderid, shortid, deliver_orderid, prodid, diamondid, sub_event, prod_price, charge_price, succ_price, paytype, sub_paytype, third_prodid, third_orderid, third_appid, ip, mobile, phonetype, prov)