Beispiel #1
0
    def update_used_subtract(self, param):
        """
		更新状态 相减
		:param param:
		:return:
		"""
        _db = None
        try:
            if not param:
                self.logger.info("【添加/更新账号使用量】请求参数为为空,流程结束")
            """查询数据"""
            _db = MySqlHelper()
            count = _db.count(
                used_of_count_sql.count,
                (param.get("usedOfContent"), param.get("usedType"),
                 param.get("start"), param.get("end")))
            if count <= 0:
                return True
            result = _db.update(
                used_of_count_sql.update_used_subtract,
                (param.get("usedOfContent"), param.get("usedType"),
                 param.get("start"), param.get("end")))

            _db.end()
            return result
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【添加/更新账号使用量】保存异常信息为:%s" %
                              traceback.format_exc())
        return False
Beispiel #2
0
    def update(self, param=None):
        """
		更新数据
		:param param:
		:return:
		"""
        _db = None
        try:
            BusinessUtil.delete_redis_by_key(
                busi_config.SERVER_CONFIG_REDIS_KEY)
            if param is None:
                self.logger.info("【更新服务器】请求参数为空,流程结束")
                return False
            _db = MySqlHelper()
            _db.begin()
            count = _db.update(server_conf_sql.update, param)
            _db.end()
            return count
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【更新服务器】更新异常,事务回滚,异常信息为:%s" %
                              traceback.format_exc())
        return False
Beispiel #3
0
    def insert_update(self, param):
        """
		添加或更新数据
		:param param:
		:return:
		"""
        _db = None
        try:
            if not param:
                self.logger.info("【添加/更新营销数据】请求参数为为空,流程结束")
            """查询数据"""
            _db = MySqlHelper()
            count = _db.count(marketing_data_sql.count,
                              (param.get("batchCode"), param.get("mobile"),
                               param.get("email")))
            if count > 0:
                result = _db.update(
                    marketing_data_sql.update_insert,
                    (param.get("subBatchCode"), param.get("batchCode"),
                     param.get("mobile"), param.get("email")))
            else:
                result = _db.insert_one(
                    marketing_data_sql.insert,
                    (param.get("batchCode"), param.get("subBatchCode"),
                     param.get("mobile"), param.get("email")))
            _db.end()
            return result
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【添加/更新营销数据】保存异常信息为:%s" % traceback.format_exc())
        return False
Beispiel #4
0
    def update_all_status_valid(self):
        """
		更新所有账号为有效
		:return:
		"""
        _db = None
        try:
            _db = MySqlHelper()
            """更新当前账号 将所有数据转化为1"""
            _db.update(send_email_account_sql.update_all_status_valid)
            _db.end()
            return True
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【变更轮换账号】变更异常信息为:%s" % traceback.format_exc())
        return False
	def update(self, param=None):
		"""
		文件读取记录更新
		:param param:
		:return:
		"""
		_db = None
		try:
			_db = MySqlHelper()
			_db.begin()
			count = _db.update(file_read_record_sql.update, param)
			_db.end()
			return count
		except Exception as e:
			if _db:
				_db.isEnd = 2
				_db.end()
			self.logger.error("【文件读取记录】更新异常,事务回滚,异常信息为:%s" % traceback.format_exc())
		return False
Beispiel #6
0
    def update(self, param):
        """
		更新发送邮箱账号
		:return:
		"""
        _db = None
        try:
            if not param:
                self.logger.info("【更新发送邮箱账号】请求参数为为空,流程结束")
                return False
            _db = MySqlHelper()
            result = _db.insert_one(send_email_account_sql.update, param)
            _db.end()
            return result
        except Exception as e:
            _db.isEnd = 2
            _db.end()
            self.logger.error("【更新发送邮箱账号】更新异常信息为:%s" % traceback.format_exc())
        return False
Beispiel #7
0
	def update(self, param):
		"""
		更新代理服务器
		:return:
		"""
		_db = None
		try:
			if not param:
				self.logger.info("【更新代理服务器】请求参数为为空,流程结束")
				return False
			_db = MySqlHelper()
			result = _db.insert_one(proxy_server_conf_sql.update, param)
			_db.end()
			return result
		except Exception as e:
			if _db:
				_db.isEnd = 2
				_db.end()
			self.logger.error("【更新代理服务器】更新异常信息为:%s" % traceback.format_exc())
		return False
Beispiel #8
0
    def update_used_count(self, param):
        """
		更新账号使用量
		:return:
		"""
        _db = None
        try:
            if not param:
                self.logger.info("【更新账号使用量】请求参数为为空,流程结束")
                return False
            _db = MySqlHelper()
            result = _db.update(used_of_count_sql.update_used_count, param)
            _db.end()
            return result
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【更新账号使用量】更新异常信息为:%s" % traceback.format_exc())
        return False
Beispiel #9
0
    def update(self, param):
        """
		更新原始营销数据
		:return:
		"""
        _db = None
        try:
            if not param:
                self.logger.info("【更新原始营销数据】请求参数为为空,流程结束")
                return False
            _db = MySqlHelper()
            result = _db.update(primary_data_sql.update, param)
            _db.end()
            return result
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【更新原始营销数据】更新异常信息为:%s" % traceback.format_exc())
        return False
Beispiel #10
0
    def insert(self, param):
        """
		添加发送记录
		:param param:
		:return:
		"""
        _db = None
        try:
            if not param:
                self.logger.info("【保存发送记录】请求参数为为空,流程结束")
                return False
            _db = MySqlHelper()
            result = _db.insert_one(send_record_sql.insert, param)
            _db.end()
            return result
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【保存发送记录】保存异常信息为:%s" % traceback.format_exc())
        return False
Beispiel #11
0
    def insert_more(self, param):
        """
		添加营销数据
		:param param:
		:return:
		"""
        _db = None
        try:
            if not param:
                self.logger.info("【保存营销数据】请求参数为为空,流程结束")
                return False
            _db = MySqlHelper()
            result = _db.insert_more(marketing_data_sql.insert, param)
            _db.end()
            return result
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【保存营销数据】保存异常信息为:%s" % traceback.format_exc())
        return False
Beispiel #12
0
    def insert_more(self, param):
        """
		添加账号使用量
		:param param:
		:return:
		"""
        _db = None
        try:
            if not param:
                self.logger.info("【保存账号使用量】请求参数为为空,流程结束")
                return False
            _db = MySqlHelper()
            result = _db.insert_more(used_of_count_sql.insert, param)
            _db.end()
            return result
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【保存账号使用量】保存异常信息为:%s" % traceback.format_exc())
        return False
Beispiel #13
0
    def insert(self, param):
        """
		添加数据
		:param param:
		:return:
		"""
        _db = None
        try:
            if not param:
                self.logger.info("【保存黑白名单】请求参数为为空,流程结束")
                return False
            _db = MySqlHelper()
            result = _db.insert_one(black_white_roll_call_sql.insert, param)
            _db.end()
            return result
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【保存黑白名单】保存异常信息为:%s" % traceback.format_exc())
        return False
Beispiel #14
0
    def search_and_update_account(self, server_ip, account_reopen_time):
        """
		变更轮换账号
		:param server_ip:
		:param account_reopen_time:
		:return:
		"""
        _db = None
        try:
            _db = MySqlHelper()
            """设置当前日期"""
            timeStr = str(
                time.strftime('%Y-%m-%d', time.localtime(time.time())))
            # start = "%s 00:00:00" % timeStr
            # end = "%s 23:59:59" % timeStr
            #result = _db.fetch_all(send_email_account_sql.search_and_update_account, (server_ip, start, end))
            """更新当前账号 将所有数据转化为3"""
            #_db.update(send_email_account_sql.update_status, (3, 1, server_ip))
            """查询锁定账号"""
            result = _db.fetch_all(
                send_email_account_sql.search_lock_account_for_user_name,
                (timeStr, account_reopen_time, timeStr))
            # if not result:
            # 	"""查询锁定账号"""
            # 	result = _db.fetch_all(send_email_account_sql.search_lock_account, (timeStr, account_reopen_time))
            """存在数据 则更新"""
            if result:
                for item in result:
                    _db.update(send_email_account_sql.update_user_name,
                               (1, item.get("userName")))
            _db.end()
            return True
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【变更轮换账号】变更异常信息为:%s" % traceback.format_exc())
        return False
Beispiel #15
0
    def insert_update_more(self, result):
        """
		添加或更新数据
		:param result:
		:return:
		"""
        _db = None
        try:
            if not result:
                self.logger.info("【添加/更新营销数据】请求参数为为空,流程结束")
            """查询数据"""
            _db = MySqlHelper()
            for param in result:
                param["subBatchCode"] = BusinessUtil.get_uniqu_time()
                count = _db.count(marketing_data_sql.count,
                                  (param.get("batchCode"), param.get("mobile"),
                                   param.get("email")))
                if count > 0:
                    result = _db.update(
                        marketing_data_sql.update_insert,
                        (param.get("subBatchCode"),
                         int(param.get("status", "0")), param.get("batchCode"),
                         param.get("mobile"), param.get("email")))
                else:
                    result = _db.insert_one(
                        marketing_data_sql.insert,
                        (param.get("originalBatchCode"),
                         param.get("batchCode"), param.get("subBatchCode"),
                         param.get("mobile"), param.get("email"),
                         int(param.get("status", "0"))))
            _db.end()
            return result
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【添加/更新营销数据】保存异常信息为:%s" % traceback.format_exc())
        return False
Beispiel #16
0
    def insert_format(self, result):
        """
		添加收取记录
		:param result:
		:return:
		"""
        _db = None
        try:
            if not result:
                self.logger.info("【保存收取记录】请求参数为为空,流程结束")
                return False
            _db = MySqlHelper()
            for item in result:
                insert_format = pop_record_sql.insert_format.format(**item)
                _db.insert_one(insert_format)
            _db.end()
            return True
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【保存收取记录】保存异常信息为:%s" % traceback.format_exc())
        return False
Beispiel #17
0
    def update_by_policy(self, sql):
        """
		通过策略更新对应数据
		:param sql:
		:return:
		"""
        _db = None
        try:
            if not sql:
                self.logger.info("【更新策略】请求参数为为空,流程结束")
            _db = MySqlHelper()
            """判断是更新还是插入"""
            if sql.upper().find("INSERT"):
                result = _db.insert_one(sql)
            else:
                result = _db.update(sql)
            _db.end()
            return result
        except Exception as e:
            if _db:
                _db.isEnd = 2
                _db.end()
            self.logger.error("【更新策略】保存异常信息为:%s" % traceback.format_exc())
        return False