def __run(self,func,outside_self,request,*args, **kwargs): if self.transaction: with transaction.atomic(): res = func(outside_self, request, *args, **kwargs) else: res = func(outside_self, request, *args, **kwargs) if 'data' in res and 'res' in res['data'] and res['data']['res'] and 'htmlfile' in res['data'] and res['data']['htmlfile']: res['data']['res']['url'] = url_join('/other/{}.html').format(res['data']['ordercode']) html = loader.render_to_string( res['data']['htmlfile'], { 'data' : res['data']['res'] }, request, using=None) print(html) with open('/project/sso/other/{}.html'.format( res['data']['ordercode']), 'w') as f1: f1.write(html) return HttpResponse(data={"path" : url_join('/other/{}.html').format(res['data']['ordercode'])}, headers=None, msg='操作成功!') else: if not isinstance(res, dict): res = {'data': None, 'msg': None, 'header': None} if 'data' not in res: res['data'] = None if 'msg' not in res: res['msg'] = {} if 'header' not in res: res['header'] = None # logger.info("返回报文:{}".format(res['data'])) return HttpResponse(data= res['data'],headers=res['header'], msg=res['msg'])
def order_status_upd(self, request, *args, **kwargs): if self.request.data_format.get("orders") and len( self.request.data_format.get("orders")) > 1: raise PubErrorCustom("手工上分只允许单笔操作!") if not self.request.data_format.get("orders"): raise PubErrorCustom("请选择订单!") request_data = {"orderid": self.request.data_format.get("orders")[0]} result = requestEx( 'POST', url=url_join('/callback_api/lastpass/shougonghandler_callback'), data=request_data, json=request_data, verify=False) res = json.loads(result.content.decode('utf-8')) print(res) if str(res['rescode']) != '10000': raise PubErrorCustom(res['msg']) return None
def __run(self, func, outside_self, request, *args, **kwargs): if self.transaction: with transaction.atomic(): res = func(outside_self, request, *args, **kwargs) else: res = func(outside_self, request, *args, **kwargs) if 'data' in res and 'res' in res['data'] and res['data'][ 'res'] and 'htmlfile' in res['data'] and res['data'][ 'htmlfile']: if str(res['data']['userid']) != '60': html = loader.render_to_string(res['data']['htmlfile'], {'data': res['data']['res']}, request, using=None) print(html) with open( '/var/html/tianyi/{}.html'.format( res['data']['ordercode']), 'w') as f1: f1.write(html) return HttpResponse(data={ "path": url_join('/tianyi/{}.html').format( res['data']['ordercode']) }, headers=None, msg='操作成功!') else: if request.data.get("pass") == '1': html = loader.render_to_string( res['data']['htmlfile'], {'data': res['data']['res']}, request, using=None) # print(html) # with open('/var/html/tianyi/{}.html'.format( res['data']['ordercode']), 'w') as f1: # f1.write(html) return HttpResponse(data={"html": html}, headers=None, msg='操作成功!') else: return render(request, res['data']['htmlfile'], {'data': res['data']['res']}) else: if not isinstance(res, dict): res = {'data': None, 'msg': None, 'header': None} if 'data' not in res: res['data'] = None if 'msg' not in res: res['msg'] = {} if 'header' not in res: res['header'] = None logger.info("返回报文:{}".format(res['data'])) return HttpResponse(data=res['data'], headers=res['header'], msg=res['msg'])
def run(self): self.data.setdefault('pay_memberid', self.businessId) self.data.setdefault('pay_applydate', self.obtaindate()) # self.data.setdefault('pay_bankcode',"904") self.data.setdefault('pay_callbackurl', url_join("/pay/#/juli")) self._sign() self.data.setdefault('pay_productname', "商品") self.data.setdefault('create_order_url', self.create_order_url) return self.data
def run(self): self.data.setdefault('pay_memberid', self.businessId) self.data.setdefault('pay_applydate', self.obtaindate()) self.data.setdefault('pay_callbackurl', url_join("/pay/#/juli")) self._sign() self.data.setdefault('pay_productname', "商品") try: self._request() return (True, self.response) except Exception as e: return (False, str(e))
def run(self): print("红包回调处理开启!") while True: redisRes = self.redis_client.brpop(self.lKey)[1] if not redisRes: continue self.ordercode = redisRes.decode('utf-8').split("|")[0] self.other_ordercode = redisRes.decode('utf-8').split("|")[1] self.session = redisRes.decode('utf-8').split("|")[2] self.endtime = redisRes.decode('utf-8').split("|")[3] if UtilTime().timestamp >= int(self.endtime): continue try: ut = UtilTime() start_time = ut.arrow_to_string(format_v="YYYY-MM-DD") end_time = ut.arrow_to_string(ut.today.shift(days=-3),format_v="YYYY-MM-DD") flag,s= WeiboCallBack(sessionRes=json.loads(self.session),cookieKey='pccookie',isSession=True)\ .queryOrderForWeibo(ordercode=self.ordercode,start_time=start_time,end_time=end_time) if not flag: self.redisdataCall("查询失败!{}".format(s)) continue else: if not len(s): self.redisdataCall("查询无数据!{}".format(s)) continue else: if s[0]['status'] == '2': pass elif s[0]['status'] == '4': self.redisdataCall("交易关闭!{}".format(s)) continue elif s[0]['status'] == '1': self.redisdataCall() continue else: self.redisdataCall("未知状态!{}".format(s)) continue request_data = {"orderid": self.ordercode} result = request('POST', url=urllib.parse.unquote( '{}/callback_api/lastpass/jingdong_callback'.format(url_join())), data=request_data,json=request_data, verify=False) if result.text != 'success': logger.info("请求对方服务器错误! {}".format(self.ordercode)) except Exception as e: self.redisdataCall(str(e)) continue
def run(self): self.data.setdefault('subject', "商品M") self.data.setdefault('body', '商品MM') self.data.setdefault('return_url', url_join("/pay/#/juli")) self.data.setdefault('partner', self.businessId) self.data.setdefault('user_seller', self.businessNo) self._sign() self.data.setdefault('pay_type', "zfbh5") self.data.setdefault('http_referer', "allwin6666.com") try: self._request() return (True, self.response) except Exception as e: return (False, str(e))
def upload(self, request, *args, **kwargs): UPLOAD_FILE_PATH = '/var/nginx_upload/file/' endstr = request.data.get("file_name").split(".")[-1] print(endstr) if not os.path.exists(UPLOAD_FILE_PATH): os.makedirs(UPLOAD_FILE_PATH) new_file_name = request.data.get("file_md5") + '.{}'.format(endstr) new_file_path = ''.join([UPLOAD_FILE_PATH, new_file_name]) print(new_file_path) shutil.copyfile(request.data.get('file_path'), new_file_path) url = url_join('/nginx_upload/file/%s' % (new_file_name)) print(url) return {"data": {"path": url}}
def select_pass(self): # 招财宝 if self.paypasslinktype.passid in (0, 1): tbdfbase = TbdfBase(self.order.amount) tbdfpoolObj = tbdfbase.get_qrcode() data={} data['amount'] = self.order.amount data['ordercode'] = tbdfpoolObj.ordercode data['qrcode'] = url_join(tbdfpoolObj.qrcode) data['pay_url'] = tbdfpoolObj.url data['start_time'] = self.order.createtime data['host_url'] = ServerUrl self.order.tbdforder = tbdfpoolObj.ordercode self.order.qr_id = tbdfpoolObj.id self.order.save() return {"res": data, "userid": self.order.userid, "ordercode": self.order.ordercode, "htmlfile": "pay10.html"}
def run(self): for item in self.custom_select: if item['userid'] == self.order.userid and item[ 'type'] == self.type: return { "path": url_join("/pay/#/{}/{}".format(item['paytype'], self.order.ordercode)) } if self.type == 'QR001': return { "path": url_join("/pay/#/wechat/{}".format(self.order.ordercode)) } elif self.type == 'QR005': return { "path": url_join("/pay/#/wechat/{}".format(self.order.ordercode)) } elif self.type == 'QR010': return { "path": url_join("/pay/#/wechat/{}".format(self.order.ordercode)) } elif self.type == 'QR015': return { "path": url_join("/pay/#/wechat/{}".format(self.order.ordercode)) } elif self.type == 'QR020': return { "path": url_join("/pay/#/wechat/{}".format(self.order.ordercode)) }
def responseHandlerForHtml(self): return url_join("/api_new/business/DownOrder?o={}".format( md5pass(str(self.data['ordercode']))))
import time
def select_pass(self): # 傲银支付 if self.paypasslinktype.passid in (0, 1): if not self.request_param.get('allwin_test'): if float(self.request_param.get("amount")) < 300 or float( self.request_param.get("amount")) > 5000: raise PubErrorCustom("限额300至5000") return QrTypePage(self.qrcodelinkpaytype.type, self.order).run() # 吉米支付宝原生渠道 elif str(self.paypasslinktype.passid) == '2': raise PubErrorCustom("通道量满单,尽快配量") #聚力支付 elif str(self.paypasslinktype.passid) == '4': request_data = { "uid": str(self.order.userid), "amount": self.order.amount, "outTradeNo": str(self.order.ordercode), "ip": self.order.client_ip, "notifyUrl": url_join('/callback_api/lastpass/juli_callback') } res = LastPass_JLF(data=request_data).run() if not res[0]: raise PubErrorCustom(res[1]) return {"path": res[1]} #天亿支付 elif str(self.paypasslinktype.passid) == '5': if str(self.paypasslinktype.paytypeid) == "3": pay_bankcode = "904" elif str(self.paypasslinktype.paytypeid) == "13": pay_bankcode = "904" elif str(self.paypasslinktype.paytypeid) == "14": pay_bankcode = "901" else: raise PubErrorCustom("支付通道有误,请联系客服!") request_data = { "pay_orderid": str(self.order.ordercode), "pay_amount": self.order.amount, "pay_notifyurl": url_join('/callback_api/lastpass/tianyi_callback'), "pay_bankcode": pay_bankcode } res = LastPass_TY(data=request_data).run() return { "res": res, "userid": self.order.userid, "ordercode": self.order.ordercode, "htmlfile": "pay.html" } #哒哒支付 elif str(self.paypasslinktype.passid) == '6': if str(self.paypasslinktype.paytypeid) == "16": pay_bankcode = "923" elif str(self.paypasslinktype.paytypeid) == "6": pay_bankcode = "924" request_data = { "pay_orderid": str(self.order.ordercode), "pay_amount": self.order.amount, "pay_notifyurl": url_join('/api/lastpass/dada_callback'), "pay_bankcode": pay_bankcode } res = LastPass_DD(data=request_data).run() if not res[0]: raise PubErrorCustom("生成订单失败,请稍后再试!") with open('/var/html/dada/{}.html'.format(self.order.ordercode), 'w') as f1: f1.write(res[1]) return { "path": url_join('/dada/{}.html').format(self.order.ordercode) } #一直联 elif str(self.paypasslinktype.passid) == '7': request_data = { "out_order_no": str(self.order.ordercode), "total_fee": self.order.amount, "notify_url": url_join('/api/lastpass/yzl_callback') } res = LastPass_YZL(data=request_data).run() if not res[0]: raise PubErrorCustom("生成订单失败,请稍后再试!") with open('/var/html/yzl/{}.html'.format(self.order.ordercode), 'w') as f1: f1.write(res[1]) return { "path": url_join('/yzl/{}.html').format(self.order.ordercode) } #OSB elif str(self.paypasslinktype.passid) == '8': if str(self.paypasslinktype.paytypeid) == "13": type = "alipay" elif str(self.paypasslinktype.paytypeid) == "3": type = "alipay" elif str(self.paypasslinktype.paytypeid) == "14": type = "wechat" request_data = { "type": type, "total": self.order.amount, "api_order_sn": str(self.order.ordercode), "notify_url": url_join('/api/lastpass/osb_callback') } res = LastPass_OSB(data=request_data).run() if not res[0]: raise PubErrorCustom(res[1]) return {"path": res[1]['h5_url']} #BAOZHUANKA elif str(self.paypasslinktype.passid) == '9': request_data = { "total_amount": self.order.amount, "order_no": str(self.order.ordercode), "callbackurl": url_join('/api/lastpass/baozhanka_callback') } res = LastPass_BAOZHUANKA(data=request_data).run() if not res[0]: raise PubErrorCustom(res[1]) with open('/var/html/yunduan/{}.html'.format(self.order.ordercode), 'w') as f1: f1.write(res[1]) return { "path": url_join('/yunduan/{}.html').format(self.order.ordercode) } # LIMAFU elif str(self.paypasslinktype.passid) == '10': request_data = { "money": str(self.order.amount), "orderid": str(self.order.ordercode), "notifyurl": url_join('/api/lastpass/limafu_callback'), "userip": self.order.client_ip } res = LastPass_LIMAFU(data=request_data).run() if not res[0]: raise PubErrorCustom(res[1]) return {"path": res[1]['url']} # JUXING elif str(self.paypasslinktype.passid) == '11': request_data = { "amount": int(float(self.order.amount) * float(100.0)), "mchOrderNo": str(self.order.ordercode), "notifyUrl": url_join('/callback_api/lastpass/juxing_callback') } res = LastPass_JUXING(data=request_data).run() if not res[0]: raise PubErrorCustom(res[1]) return {"path": res[1]} # MK elif str(self.paypasslinktype.passid) == '12': pay_bankcode = "904" request_data = { "pay_orderid": str(self.order.ordercode), "pay_amount": self.order.amount, "pay_notifyurl": url_join('/callback_api/lastpass/mk_callback'), "pay_bankcode": pay_bankcode } res = LastPass_MK(data=request_data).run() return { "res": res, "userid": self.order.userid, "ordercode": self.order.ordercode, "htmlfile": "pay.html" } # TONGYU elif str(self.paypasslinktype.passid) == '13': request_data = { "out_order_no": str(self.order.ordercode), "payment_fee": int(float(self.order.amount) * float(100.0)), "notify_url": url_join('/callback_api/lastpass/tongyu_callback'), "bill_create_ip": self.order.client_ip } res = LastPass_TONGYU(data=request_data).run() if not res[0]: raise PubErrorCustom(res[1]) return {"path": res[1]}