def gs_gm_sync_pay_activity_group(p, req): res_err = {'result': 1} all_new_conf, = req all_old_conf = {} try: if not check_excite_activity_status(EXCITE_PAY_ACTIVITY): return OSS_EXCITE_ACTIVITY_IS_CLOSED dataset = {} # 被修改的活动配置 openList = [] for _new_conf in all_new_conf: _old_conf = {} _old_conf['GroupID'] = int(_new_conf['group_id']) _old_conf['GroupDesc'] = _new_conf['group_desc'] _old_conf['IsOpen'] = int(_new_conf['is_open']) # 获取被修改的活动信息 dataset[_old_conf['GroupID']] = [_new_conf["group_id"], _new_conf['group_desc'], _new_conf['is_open']] all_old_conf[_old_conf["GroupID"]] = _old_conf if int(_new_conf['is_open']): openList.append(_new_conf['is_open']) # 没有修改 if openList.count(1) > 1 or len(openList) == 0: res_err = {'result': OSS_ACTIVITY_GROUP_OPEN_WRONG} return res_err if not dataset: log.info('Pay activity group oss conf no changed.') return res_err except Exception as e: log.exception() res_err['result'] = OSS_PAY_ACTIVITY_GROUP_ERROR return res_err # 更新内存中的 sysconfig sysconfig['pay_activity_group'] = all_old_conf #gw_broadcast('sync_multicast', [SYNC_MULTICATE_TYPE_9, []]) # 更新db conn = MySQLdb.connect(**sysconfig_db_conf) cursor = conn.cursor() sql_delete = "TRUNCATE table tb_pay_activity_group" cursor.execute(sql_delete) conn.commit() sql_update = "INSERT INTO tb_pay_activity_group (GroupID, GroupDesc, IsOpen) VALUES(%s, %s, %s)" cursor.executemany( sql_update, dataset.values() ) conn.commit() cursor.close() return res_err
def get_consume_activity_award(p, req): cid, [award_id] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) # 检查活动状态 1-开启或 0-关闭 _status = check_excite_activity_status( EXCITE_CONSUME_ACTIVITY ) if not _status: defer.returnValue( EXCITE_ACTIVITY_STOP_ERROR ) res_err = yield user.consume_activity_award(award_id) defer.returnValue( res_err )
def limit_fellow_randcard(p, req): cid, [rand_type] = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) # 检查活动状态 1-开启或 0-关闭 _status = check_excite_activity_status( EXCITE_LIMIT_FELLOW ) if not _status: defer.returnValue( EXCITE_ACTIVITY_STOP_ERROR ) if not hasattr(user, 'excite_activity_mgr'): user.excite_activity_mgr = GSExciteActivityMgr(user) res_err = yield user.excite_activity_mgr.limit_fellow_mgr.randcard(rand_type) defer.returnValue( res_err )
def lock_exchange_material(p, req): cid, ( exchange_id, lock_type ) = req user = g_UserMgr.getUser(cid) if not user: log.error('Can not find user. cid: {0}.'.format( cid )) defer.returnValue( CONNECTION_LOSE ) # 检查活动状态 1-开启或 0-关闭 _status = check_excite_activity_status( EXCITE_EXCHANGE_LIMITED ) if not _status: defer.returnValue( EXCITE_ACTIVITY_STOP_ERROR ) if not hasattr(user, 'excite_activity_mgr'): user.excite_activity_mgr = GSExciteActivityMgr(user) res_err = yield user.excite_activity_mgr.exchange_limited_mgr.lock_exchange_material( exchange_id, lock_type ) defer.returnValue( res_err )