def gm_reward_vip(self, gid, mi, request): uid = mi.get_param('userId') rmb = mi.get_param('rmb') if not isinstance(rmb, int): return MsgPack.Error(0, 1, 'int please') if not Context.UserAttr.check_exist(uid, gid): return MsgPack.Error(0, 2, 'not exist') if rmb < 0: pay_total = Context.Data.get_game_attr_int(uid, gid, 'pay_total', 0) if pay_total < -rmb: return MsgPack.Error(0, 3, 'too much') final = FishProps.incr_pay(uid, gid, rmb, 'gm.reward') level = FishAccount.get_vip_level(uid, gid, final) mo = MsgPack(0) mo.set_param('level', level) mo.set_param('pay_total', final) return mo
def on_product_deliver(self, uid, gid, mi): orderId = mi.get_param('orderId') productId = mi.get_param('productId') payType = mi.get_param('payType') channel = mi.get_param('channel') cost = mi.get_param('cost') param = { 'orderId': orderId, 'productId': productId, 'payType': payType, 'channel': channel, 'cost': cost } Context.Log.report('product.issue: [%d, %d, %s, %s]' % (uid, gid, orderId, param)) all_product = Context.Configure.get_game_item_json( gid, 'product.config') if productId not in all_product: Context.Log.error('productId not exist', orderId, productId, all_product) return MsgPack.Error(0, 1, 'no product found') shop_config = Context.Configure.get_game_item_json(gid, 'shop.config') pipe_args = ['product_%s' % productId, 1] times = Context.Data.hincr_game(uid, gid, 'product_%s' % productId, 1) # 记录充值相关字段 pay_total = FishProps.incr_pay(uid, gid, cost, 'buy.product', orderId=orderId) today_pay_times, _ = Context.Daily.mincr_daily_data( uid, gid, 'pay_times', 1, 'pay_total', cost) is_reset_chance, is_first_double = False, False if productId in shop_config['chip']: if times == 1: is_first_double = True else: reset_choice = Context.Data.get_game_attr_int( uid, gid, 'reset_' + str(productId), 0) if reset_choice: is_reset_chance = True product = all_product[productId] if is_reset_chance: # reset chance reward = self.__rebate_reward(gid, pay_total, product['first'], channel) FishProps.issue_rewards(uid, gid, reward, 'buy.product', orderId=orderId, reset=1) Context.Data.del_game_attrs(uid, gid, 'reset_' + str(productId)) elif is_first_double: reward = self.__rebate_reward(gid, pay_total, product['first'], channel) FishProps.issue_rewards(uid, gid, reward, 'buy.product', orderId=orderId, first=1) elif productId in shop_config['card']: state, days = FishProps.incr_vip(uid, gid, 30, 'buy.product', orderId=orderId) if state == 0: # 今日未领取 sign_in = Context.Daily.get_daily_data(uid, gid, 'sign_in') if sign_in: success, left_days = FishProps.use_vip(uid, gid) if success: conf = Context.Configure.get_game_item_json( gid, 'month.card.reward') FishProps.issue_rewards(uid, gid, conf, 'month.card.reward') else: reward = self.__rebate_reward(gid, pay_total, product['content'], channel) FishProps.issue_rewards(uid, gid, reward, 'buy.product', orderId=orderId) if today_pay_times == 1: # today first pay pipe_args.append(channel + '.pay.user.count') pipe_args.append(1) pipe_args.append(channel + '.pay.user.pay_total') pipe_args.append(cost) pipe_args.append(channel + '.user.pay.times') pipe_args.append(1) if pay_total == cost: # life first pay pipe_args.append(channel + '.new.pay.user.count') pipe_args.append(1) pipe_args.append('new_pay_user') pipe_args.append(1) new_pay_user = 1 else: new_pay_user = Context.Daily.get_daily_data( uid, gid, 'new_pay_user') if new_pay_user: pipe_args.append(channel + '.new.pay.user.pay_total') pipe_args.append(cost) Context.Stat.mincr_daily_data(gid, *pipe_args) key = 'game.%d.info.hash' % gid pipe_args = [] if pay_total == cost: pipe_args.append(channel + '.pay.user.count') pipe_args.append(1) pipe_args.append(channel + '.pay.user.pay_total') pipe_args.append(cost) pipe_args.append(channel + '.user.pay.times') pipe_args.append(1) Context.RedisMix.hash_mincrby(key, *pipe_args) self.__handle_pay_effect(uid, gid, cost, today_pay_times) return MsgPack(0, {'msg': u'已到货'})