async def clearData(**kwargs): db = kwargs.get("db") logger.info("清理数据开始...") async with MysqlPool().get_conn.atomic_async(): r1 = await db.execute(Order.delete().where( Order.createtime <= UtilTime().today.shift(days=-15).timestamp)) r2 = await db.execute(CashoutList.delete().where( CashoutList.createtime <= UtilTime().today.shift( days=-15).timestamp)) r3 = await db.execute(BalList.delete().where( BalList.createtime <= UtilTime().today.shift(days=-15).timestamp)) logger.info("清理Order{}条,CashoutList{}条,BalList{}条".format(r1, r2, r3)) logger.info("清理数据结束...")
async def getCp(self,**kwargs): self.cp = await self.db.get(Cp, id=self.pk) self.ut = UtilTime() self.ispc = kwargs.get("ispc",None) await self.getTerm(kwargs.get("autoid",None),kwargs.get("next_autoid",None)) await self.save()
async def post(self, *args, **kwargs): # 重庆时时彩 termnumber = 59 ut = UtilTime() today = ut.arrow_to_string(format_v="YYYYMMDD") tomorrow = ut.arrow_to_string(ut.today.shift(days=1), format_v="YYYYMMDD") data = {} tomorrow_first_next = "" for i in range(termnumber): term = "%s0%02d" % (tomorrow, i + 1) if i == 0: tomorrow_first_next = term if i == termnumber - 1: nextterm = "today" else: nextterm = "%s0%02d" % (tomorrow, i + 2) data[term] = nextterm await self.redis.hset("term_cqssc", format(tomorrow), json.dumps({"term": data})) data = {} for i in range(termnumber): term = "%s0%02d" % (today, i + 1) if i == termnumber - 1: nextterm = tomorrow_first_next else: nextterm = "%s0%02d" % (today, i + 2) data[term] = nextterm await self.redis.hset("term_cqssc", format(today), json.dumps({"term": data})) return None
async def post(self, *args, **kwargs): ut = UtilTime() runTime = ut.today.shift(minutes=int(self.application.settings.get("ordertime",30))) self.scheduler.add_job(order_handler, 'date', run_date=runTime.datetime, kwargs={ "url":"{}/order/OrderCanleSys".format(self.application.settings.get("busiserver")), "data":{ "orderid": self.data.get("orderid", None) } }) return None
async def post(self, *args, **kwargs): obj = self.data['obj'] self.scheduler.add_job( msgmass_run, 'date', run_date=UtilTime().timestamp_to_arrow(obj['sendtime']).datetime, id='MsgMass_Job_{}'.format(obj['id']), kwargs={ "url": "{}/v1/api/wechat/AccMsgMass_Send".format( self.application.settings.get("busiServer")), "data": { "data": { "id": obj['id'], } } })
async def put(self, *args, **kwargs): obj = self.data['obj'] try: self.scheduler.remove_job('MsgMass_Job_{}'.format(obj['id'])) except apscheduler.jobstores.base.JobLookupError: pass self.scheduler.add_job( msgmass_run, 'date', run_date=UtilTime().timestamp_to_arrow(obj['sendtime']).datetime, id='MsgMass_Job_{}'.format(obj['id']), kwargs={ "url": "{}/v1/api/wechat/AccMsgMass_Send".format( self.application.settings.get("busiServer")), "data": { "data": { "id": obj['id'], } } })
async def post(self, *args, **kwargs): # try: # obj = await self.db.get(AccMsgCustomer,id=self.data['id']) # except AccMsgCustomer.DoesNotExist: # raise PubErrorCustom("拒绝访问!") obj = self.data['obj'] self.scheduler.add_job( msgcustomer_run, 'date', run_date=UtilTime().timestamp_to_arrow(obj['sendtime']).datetime, id='MsgCustomer_Job_{}'.format(obj['id']), kwargs={ "url": "{}/v1/api/wechat/AccMsgCustomer_Send".format( self.application.settings.get("busiServer")), "data": { "data": { "id": obj['id'], } } })
async def post(self, *args, **kwargs): ut = UtilTime() runTime = ut.today.shift(seconds=5) for item in json.loads(self.data['obj']['listids']): print(runTime.datetime) self.scheduler.add_job( follow_run, 'date', run_date=runTime.datetime, kwargs={ "url": "{}/v1/api/wechat/AccFollow_Send".format( self.application.settings.get("busiServer")), "data": { "data": { "listid": item, "nickname": self.data.get("nickname"), "openid": self.data.get("openid"), "accid": self.data.get("accid") } } }) if self.data['obj']['send_limit'].split(",")[1] == 'H': runTime = runTime.shift( hours=int(self.data['obj']['send_limit'].split(",")[0])) elif self.data['obj']['send_limit'].split(",")[1] == 'M': runTime = runTime.shift( minutes=int(self.data['obj']['send_limit'].split(",")[0])) elif self.data['obj']['send_limit'].split(",")[1] == 'S': runTime = runTime.shift( seconds=int(self.data['obj']['send_limit'].split(",")[0])) return None
async def post(self, *args, **kwargs): ut = UtilTime() start = self.data['obj']['quiet'].split("-")[0] end = self.data['obj']['quiet'].split("-")[1] s = ut.arrow_to_string(format_v="HH:mm") if start <= s <= end: logger.info("处于安静时间{},{}".format(self.data['obj']['quiet'], s)) return None else: pass t = self.data['obj']['nosend_limit'].split(',')[0] u = self.data['obj']['nosend_limit'].split(',')[1] createtime = ut.today if u == 'H': runTime = createtime.shift(hours=int(t)) elif u == 'M': runTime = createtime.shift(minutes=int(t)) elif u == 'S': runTime = createtime.shift(seconds=int(t)) else: return None if self.data['obj']['send_type'] == '0': self.scheduler.add_job( reply_run, 'date', run_date=runTime.datetime, kwargs={ "url": "{}/v1/api/wechat/AccReply_Send".format( self.application.settings.get("busiServer")), "data": { "data": { "obj": self.data['obj'], "send_type": '1', "listids": self.data['obj']['listids'], "nickname": self.data.get("nickname"), "openid": self.data.get("openid"), "accid": self.data.get("accid"), "createtime": createtime.timestamp } } }) elif self.data['obj']['send_type'] == '1': for item in json.loads(self.data['obj']['listids']): print(runTime.datetime) self.scheduler.add_job( reply_run, 'date', run_date=runTime.datetime, kwargs={ "url": "{}/v1/api/wechat/AccReply_Send".format( self.application.settings.get("busiServer")), "data": { "data": { "obj": self.data['obj'], "send_type": '2', "listids": [item], "nickname": self.data.get("nickname"), "openid": self.data.get("openid"), "accid": self.data.get("accid"), "createtime": createtime.timestamp } } }) if self.data['obj']['send_limit'].split(",")[1] == 'H': runTime = runTime.shift(hours=int( self.data['obj']['send_limit'].split(",")[0])) elif self.data['obj']['send_limit'].split(",")[1] == 'M': runTime = runTime.shift(minutes=int( self.data['obj']['send_limit'].split(",")[0])) elif self.data['obj']['send_limit'].split(",")[1] == 'S': runTime = runTime.shift(seconds=int( self.data['obj']['send_limit'].split(",")[0])) elif self.data['obj']['send_type'] == '2': self.scheduler.add_job( reply_run, 'date', run_date=runTime.datetime, kwargs={ "url": "{}/v1/api/wechat/AccReply_Send".format( self.application.settings.get("busiServer")), "data": { "data": { "obj": self.data['obj'], "send_type": '0', "listids": self.data['obj']['listids'], "nickname": self.data.get("nickname"), "openid": self.data.get("openid"), "accid": self.data.get("accid"), "createtime": createtime.timestamp } } }) return None
async def ordercode(self): t = UtilTime().arrow_to_string(format_v="YYYYMMDDHHmmss") self.key = t res = "TC%s%03d"%(self.key,await self.redis.incr(self.key)) await self.redis.expire(self.key,10) return res