from yunpian_python_sdk.model import constant as YC from yunpian_python_sdk.ypclient import YunpianClient # 初始化client,apikey作为所有请求的默认值 clnt = YunpianClient('0ebfac66e930d36dfda7447b3706d3a5') param = { YC.MOBILE: '18290026975', YC.TEXT: '【旧书搬运工】尊敬的用户:#user#,您的订单已受理,将根据您所备注的空闲时间为您配送' } r = clnt.sms().single_send(param) print(r.code(), r.msg(), r.data())
def match_order_process(): option = Setting.get_json('general_option') # match_order_cnt = option['match_order_cnt'] dollar2rmb = decimal.Decimal(option['dollar2rmb']) task = MatchOrderTask.query.filter(MatchOrderTask.status == g_match_order_task_status.UNPROCESSED).first() if task is None: return change = MatchOrderTask.query.filter(MatchOrderTask.status == g_match_order_task_status.UNPROCESSED).update( dict(status=g_match_order_task_status.PROCESSED)) if not change: return sell_list = Order.query.filter( Order.side == g_order_side.SELL, Order.status == g_order_status.PENDING) sell_list = sell_list.order_by(Order.priority.desc(), Order.created_at.asc()) i = 0 for item in sell_list: if i >= task.order_cnt: break buy_order = Order.query.filter( Order.side == g_order_side.BUY, Order.user_id != item.user_id, Order.status == g_order_status.PENDING).order_by(Order.priority.desc(), Order.created_at.asc()).first() if buy_order is None: continue change = Order.query.filter(Order.id == item.id, Order.status == g_order_status.PENDING).update( dict(status=g_order_status.MATCH)) if not change: continue change = Order.query.filter(Order.id == buy_order.id, Order.status == g_order_status.PENDING).update( dict(status=g_order_status.MATCH)) if not change: item.status = g_order_status.PENDING db.session.commit() continue usd_price = CryptoCurrency.query.filter(CryptoCurrency.currency_code == 'USDT').first().usd_price dollar = Currency.get_price() * item.amount usdt = dollar / usd_price order = MatchOrder(sell_user_id=item.user_id, buy_user_id=buy_order.user_id, sell_order_id=item.id, buy_order_id=buy_order.id, sell_number=item.number, buy_number=buy_order.number, payment_amount=dollar * dollar2rmb, payment_amount_usdt=usdt, current_price=Currency.get_price()) db.session.add(order) db.session.flush() item.match_order_id = order.id buy_order.match_order_id = order.id db.session.commit() try: if order.buy_user.order_mobile: clnt = YunpianClient('fcf725316cbb8ff1438c90ff76c6cebe') param = {YC.MOBILE: '+' + order.buy_user.order_mobile.replace(' ', ''), YC.TEXT: "【乐宝】您的订单{}已匹配成功,请尽快安排处理。".format('')} clnt.sms().single_send(param) except: pass i += 1 db.session.commit()
def sms_send_price_gap(apikey, phones, content): for phone in phones: clnt = YunpianClient(apikey) param = {YC.MOBILE: phone, YC.TEXT: content} r = clnt.sms().single_send(param)
def sms_send_price_gap(apikey,phones,content): for phone in phones: clnt = YunpianClient(apikey) param = {YC.MOBILE:phone,YC.TEXT:content} r = clnt.sms().single_send(param)
def sendMessage(telephoneNum, TEXT): client = YunpianClient('此处填入云片的apikey,需要自己去注册申请') param = {YC.MOBILE: telephoneNum, YC.TEXT: TEXT} r = client.sms().single_send(param) print(r.msg(), r.data(), r.detail(), sep='\n')
def send_sms(mobile): client = YunpianClient(apikey=API_KEY) # tpl_value = urllib.parse.urlencode({'#domain#': 'http://baas.cnfoodchain.com', '#password#': password}) # 注意此处不要用sdk中的解码方法,超级傻逼 param = {YC.MOBILE: mobile, YC.TPL_ID: '2647048', YC.TPL_VALUE: {}} result = client.sms().tpl_single_send(param) return result