def handleICode(self, user, icode): # 处理邀请码,奖励 #自己进入的 mailType = configs_default['mail']['type']['rookieaward'] rookieAwardType = configs_default['actAwardType']['invalid'] icodeGGL = icode if configs_default['actAwardType'].has_key(icode) and icode != 'share': icodeGGL = 'ggl' mailType = configs_default['mail']['type']['gglaward'] if Dal_User().ownActAwardFlag(user.id,icodeGGL): rookieAwardType = configs_default['actAwardType']['post'] elif configs_default['actAwardType'].has_key(icode): rookieAwardType = configs_default['actAwardType'][icode] rookieAward = configs_default['actAward'][icode] # 给新人发新手奖励 if rookieAward > 0: user.money = user.money + rookieAward kwargs = {"money": user.money} Dal_User().uqdateUser(user.id, **kwargs) Dal_User().addActAwardFlag(user.id,icodeGGL) # 邮件记录 mail = Mail() mail.uid = user.id mail.type = mailType mail.content = str(rookieAward) mail.time = Utils().dbTimeCreate() Dal_Mail().addMail(mail) Dal_User().addMails(user.id, mail.id) return rookieAwardType
def post(self): msgReq = msg_pb2.Msg() msgReq.ParseFromString(self.request.body) msgResp = msg_pb2.Msg() msgResp.type = msg_pb2.EnumMsg.Value('luckyresponse') user = Dal_User().getUser(msgReq.request.luckyRequest.nUserID) if user == None: msgResp.response.luckyResponse.nErrorCode = config_error[ 'userinvaild'] elif user.luckytime and Utils().dbTime2Number( user.luckytime) >= Utils().LastDayEndTime(): msgResp.response.luckyResponse.nErrorCode = config_error[ 'luckytimeerror'] else: msgResp.response.luckyResponse.nErrorCode = config_error['success'] #抽奖逻辑 randNum = Utils().random_index(configs_default['luckysRate']) msgResp.response.luckyResponse.nLucky = randNum luckGood = configs_default['luckys'][randNum] if luckGood['type'] == configs_default['goodType']['money']: user.money = user.money + luckGood['extra'] elif luckGood['type'] == configs_default['goodType']['gold']: user.gold = user.gold + luckGood['extra'] user.luckytime = Utils().dbTimeCreate() msgResp.response.luckyResponse.newAssets.nUserID = user.id msgResp.response.luckyResponse.newAssets.nGold = user.gold msgResp.response.luckyResponse.newAssets.nMoney = user.money kwargs = { "gold": user.gold, "money": user.money, "luckytime": user.luckytime } Dal_User().uqdateUser(user.id, **kwargs) # 邮件记录 mail = Mail() mail.uid = user.id mail.type = configs_default['mail']['type']['luckyaward'] mail.content = str(luckGood['type']) + ':' + str(luckGood['extra']) mail.time = Utils().dbTimeCreate() Dal_Mail().addMail(mail) Dal_User().addMails(mail.uid, mail.id) dataR = msgResp.SerializeToString() self.write(dataR)
def post(self): root = ElementTree.fromstring(self.request.body) node_result_code = root.find('result_code') node_return_code = root.find('return_code') attach = root.find('attach') totle_fee = root.find('total_fee') time_end = root.find('time_end') userData = str(attach.text) arrData = userData.split(';') UID = arrData[0] GID = arrData[1] Count = arrData[2] Money = arrData[3] if node_result_code.text == 'SUCCESS' and node_return_code.text == 'SUCCESS': #给支付返回结果 # returnMsg = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>"#self.createReturnXML() self.write("SUCCESS") #避免重复通知 if Dal_CZTime().getCZTime(time_end.text) != None: return # 记录支付通知结果时间 避免重复通知 czT = CZTime(time=time_end.text) Dal_CZTime().addCZTime(czT) #处理回调结果 user = Dal_User().getUser(UID) goodConfig = configs_default['goods'][GID] if goodConfig['type'] == configs_default['goodType']['money']: user.money = user.money + goodConfig['extra'] user.totalmoney = user.totalmoney + goodConfig['extra'] user.totalrmb = user.totalrmb + goodConfig['rmb'] # 检测代理充值奖励 delegater = Dal_Delegate().getDelegate(user.id) dLv = str(delegater.slevel) #原始等级 parentDelegater = Dal_Delegate().getDelegate(delegater.parent) if parentDelegater: # 对上级代理做奖励 parentUser = Dal_User().getUser(parentDelegater.id) awardPercent = configs_default['delegate']['payAwards'][ dLv] awardPay = math.ceil(goodConfig['extra'] * awardPercent) parentUser.money = parentUser.money + awardPay parentDelegater.awards = parentDelegater.awards + awardPay #给上级代理奖励的钻石 kwargs = {"money": parentUser.money} Dal_User().uqdateUser(parentUser.id, **kwargs) #上级代理获得的奖励总数 kwargs = {"awards": parentDelegater.awards} Dal_Delegate().uqdateDelegate(parentDelegater.id, **kwargs) # 邮件记录 mail = Mail() mail.uid = parentDelegater.id mail.type = configs_default['mail']['type'][ 'deleparentaward'] mail.content = str(awardPay) mail.time = Utils().dbTimeCreate() Dal_Mail().addMail(mail) Dal_User().addMails(mail.uid, mail.id) elif goodConfig['type'] == configs_default['goodType']['gold']: user.gold = user.gold + goodConfig['extra'] kwargs = { "gold": user.gold, "money": user.money, "totalmoney": user.totalmoney, "totalrmb": user.totalrmb } Dal_User().uqdateUser(user.id, **kwargs) # 充值 re = Recharge(id=None, time=Utils().dbTimeCreate(), money=Money, uid=UID, good=GID, count=Count, fromc=0) Dal_Recharge().addRecharge(re)