コード例 #1
0
ファイル: dbutil.py プロジェクト: sengeiou/webchat
    def wx_msg(self, wx_msg_type):
        try:
            wx_msg = t_wx_msg.objects.filter(
                wx_msg_type__exact=wx_msg_type).values()
            for wx_msg_values in wx_msg:
                wx_msg_dict = dict(
                    wx_msg_type=wx_msg_values['wx_msg_type'],
                    wx_msg_value=wx_msg_values['wx_msg_value'],
                    wx_msg_keyword=wx_msg_values['wx_msg_keyword'])
                wx_msg_dict = wx_msg_dict
        except BaseException as e:
            logger.error(e)
            wx_msg_dict = 0

        return json.dumps(wx_msg_dict)
コード例 #2
0
ファイル: dbutil.py プロジェクト: sengeiou/webchat
    def wx_secret(self, wx_appname):
        try:
            wx_secret = t_wx_secret.objects.filter(
                wx_appname__exact=wx_appname).values()
            for wx_values in wx_secret:
                wx_secret_dict = dict(wx_appname=wx_values['wx_appname'],
                                      wx_appid=wx_values['wx_appid'],
                                      wx_secret=wx_values['wx_secret'],
                                      wx_token=wx_values['wx_token'])
                wx_secret_dict = wx_secret_dict
        except BaseException as e:
            logger.error(e)
            wx_secret_dict = 0

        return json.dumps(wx_secret_dict)
コード例 #3
0
ファイル: dbutil.py プロジェクト: sengeiou/webchat
    def tb_secret(self, tb_field):
        try:
            tb_secret = t_tb_secret.objects.filter(
                tb_appname__exact=self.tb_appname).values()
            for tb_values in tb_secret:
                tb_secret_dict = dict(tb_appname=tb_values['tb_appname'],
                                      tb_appid=tb_values['tb_appid'],
                                      tb_secret=tb_values['tb_secret'],
                                      tb_token=tb_values['tb_token'])
                tb_secret_dict = tb_secret_dict
        except BaseException as e:
            logger.error(e)
            tb_secret_dict = 0

        secret = tb_secret_dict.get(tb_field)

        return secret
コード例 #4
0
def search_Shop(search_keyword, cat):
    req = top.api.TbkDgMaterialOptionalRequest("gw.api.taobao.com", port=80)

    req.set_app_info(top.appinfo(appkey=str(tb_appid), secret=str(tb_secret)))

    req.start_dsr = 30000
    req.page_size = 100
    req.page_no = 1
    req.platform = 2
    # req.end_tk_rate=1234
    # req.start_tk_rate=1234
    # req.end_price=10
    # req.start_price=10
    req.is_overseas = "false"
    req.is_tmall = "false"
    req.sort = "total_sales_des"
    # req.itemloc="杭州"
    req.cat = cat
    req.q = search_keyword
    req.material_id = 2836
    req.has_coupon = "true"
    # req.ip="13.2.33.4"
    req.adzone_id = 186710703
    req.need_free_shipment = "true"
    req.need_prepay = "true"
    req.include_pay_rate_30 = "true"
    req.include_good_rate = "true"
    req.include_rfd_rate = "true"
    req.npx_level = 1
    # req.end_ka_tk_rate=1234
    # req.start_ka_tk_rate=1234
    # req.device_encrypt="MD5"
    # req.device_value="xxx"
    # req.device_type="IMEI"
    try:
        resp = req.getResponse()
        # respshop= resp.get("tbk_dg_material_optional_response").get("result_list").get("map_data")
        # print(len(respshop))
        # for  shop in  len(resp):

        # print(resp)
    except Exception as e:
        logger.error(e)

    return resp
コード例 #5
0
def pw_conversion(url, shop_map_url):
    req = top.api.TbkTpwdCreateRequest("eco.taobao.com", port=443)
    req.set_app_info(top.appinfo(appkey=str(tb_appid), secret=str(tb_secret)))

    req.user_id = "849382036"
    req.text = "乐迪园优惠"
    req.url = url
    req.logo = shop_map_url
    req.ext = "{}"
    try:
        resp = req.getResponse()
        resp = resp.get("tbk_tpwd_create_response").get("data").get("model")
        print(resp)
    except Exception as e:
        logger.error(e)
        resp = 0

    return resp
コード例 #6
0
def search_Shop(search_keyword):
    req = top.api.TbkDgItemCouponGetRequest("gw.api.taobao.com", port=80)
    req.set_app_info(top.appinfo(appkey=str(tb_appid), secret=str(tb_secret)))
    # req.set_app_info(top.appinfo(appkey="25244012",secret="7abdc920daf305056ee20105d4eaed35"))
    req.adzone_id = 186710703
    req.platform = 2
    # req.cat="16,18"
    req.page_size = 10000
    # req.q=search_keyword
    req.page_no = 1
    try:
        resp = req.getResponse()
        # print(resp)
    except Exception as e:
        logger.error(e)
        resp = 0

    return resp
コード例 #7
0
ファイル: tb_change_tbkey.py プロジェクト: sengeiou/webchat
def change_Key(search_keyword):
    req = top.api.TbkTpwdCreateRequest("eco.taobao.com", port=443)
    req.set_app_info(top.appinfo(appkey=str(tb_appid), secret=str(tb_secret)))
    shop = dict(search_Shop(search_keyword))
    shopitem = shop.get("tbk_dg_item_coupon_get_response")
    shop_tbk_coupon = shopitem["results"]["tbk_coupon"][0]
    shop_tbk_coupon_url = shop_tbk_coupon.get("coupon_click_url")
    shop_pict_url = shop_tbk_coupon.get("pict_url")
    shop_title = shop_tbk_coupon.get("title")
    req.user_id = "849382036"
    req.text = shop_title
    req.url = shop_tbk_coupon_url
    req.logo = shop_pict_url
    req.ext = "{}"
    try:
        resp = req.getResponse()
        key = resp.get("tbk_tpwd_create_response").get("data").get("model")
        resp = dict(tb_key=key, shop_title=req.text)

    except Exception as e:
        logger.error(e)
        resp = 0

    return resp
コード例 #8
0
ファイル: wx_interactive.py プロジェクト: sengeiou/webchat
def autoreply(request):
    try:
        print(request)
        print(request.body)
        webData = request.body
        xmlData = etree.fromstring(webData)
        print(xmlData)
        # msg_type = "text"
        msg_type = xmlData.find('MsgType').text
        ToUserName = xmlData.find('ToUserName').text
        FromUserName = xmlData.find('FromUserName').text
        CreateTime = xmlData.find('CreateTime').text
        wx_res_Content = xmlData.find('Content').text
        # MsgType = xmlData.find('MsgType').text
        # MsgId = xmlData.find('MsgId').text
        toUser = FromUserName
        fromUser = ToUserName
        if msg_type == 'text':
            # content = "您好,欢迎来到Python大学习!希望我们可以一起进步!"
            if change_Key(msg_type) == 0:
                content = wx_msg(msg_type)
                replyMsg = TextMsg(toUser, fromUser, content)
                print("卡券调用失败")
                logger.error("卡券调用失败")
            else:
                content = change_Key(wx_res_Content)
                replyMsg = TextMsg(toUser, fromUser, content)
                logger.info("返回卡券成功!!")

            return replyMsg.send()
        elif msg_type == 'event':
            event = xmlData.find('Event').text
            if event == 'subscribe':
                # content = "欢迎欢迎 热烈欢迎"
                content = wx_msg(msg_type)
                replyMsg = TextMsg(toUser, fromUser, content)
                return replyMsg.send()

        elif msg_type == 'image':
            content = "图片已收到,谢谢"
            replyMsg = TextMsg(toUser, fromUser, content)
            return replyMsg.send()
        elif msg_type == 'voice':
            content = "语音已收到,谢谢"
            replyMsg = TextMsg(toUser, fromUser, content)
            return replyMsg.send()
        elif msg_type == 'video':
            content = "视频已收到,谢谢"
            replyMsg = TextMsg(toUser, fromUser, content)
            return replyMsg.send()
        elif msg_type == 'shortvideo':
            content = "小视频已收到,谢谢"
            replyMsg = TextMsg(toUser, fromUser, content)
            return replyMsg.send()
        elif msg_type == 'location':
            content = "位置已收到,谢谢"
            replyMsg = TextMsg(toUser, fromUser, content)
            return replyMsg.send()
        else:
            msg_type == 'link'
            content = "链接已收到,谢谢"
            replyMsg = TextMsg(toUser, fromUser, content)
            return replyMsg.send()
    except Exception as Argment:
        return Argment