Esempio n. 1
0
def go():
    keys = {
        'code': None,
    }
    error, params = check.simple_go(keys)

    dic = {
        'openid': '',
        'session_key': '',
        'user_id': '',
        'time_stamps_zh': []
    }

    if error is None:
        r = requests.get(
            'https://api.weixin.qq.com/sns/jscode2session?appid={}&secret={}&js_code={}&grant_type=authorization_code'
            .format(key.appId, key.AppSecret, params['code']))
        dic['openid'] = r.json()['openid']
        dic['session_key'] = r.json()['session_key']
        data = d_login.get_wx_user_id_and_coin(dic['openid'])
        dic['user_id'] = data['user_id']
        dic['coin'] = data['coin']
        dic['time_stamps_zh'] = get_time_stamps()

    if error is None:
        return c_tool.check_sort_serialize(data=dic)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 2
0
def go():
    keys = {
        'user_id': None,
        'name': None,
        'phone': None,
        'qq': None,
        'we_chat': '',
        'address': None,
        'place': None,
    }
    error, params = check.simple_go(keys)

    dic = {}

    if error is None:
        result = d_address.add_address(params)
        if result:
            dic['status'] = 'ok'
        else:
            error = '添加地址失败'

    if error is None:
        return c_tool.check_sort_serialize(data=dic)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 3
0
def go():
    keys = {
        'signature': "",
        'timestamp': "",
        'nonce': "",
        'echostr': "",
    }

    error, params = check.simple_go(keys)

    print(params)
    print("hahah")

    signature = params['signature']
    timestamp = params['timestamp']
    nonce = params['nonce']
    echostr = params['echostr']
    token = "ea0cb648197411e9a3d100163e062a02"  # 自己设置的token

    _list = [token, timestamp, nonce]
    _list.sort()
    sha1 = hashlib.sha1()
    map(sha1.update, _list)
    hashcode = sha1.hexdigest()
    # sha1加密算法

    # 如果是来自微信的请求,则回复echostr
    if hashcode == signature:
        return echostr
    else:
        return ''
Esempio n. 4
0
def go():
    keys = {
        'user_id': None,
        'address_id': None,
        'address': None,
        'place': None,
        'name': None,
        'phone': None,
        'qq': None,
        'category': None,
        'way': None,
        'time_stamp': None,
        'page_num': None,
        'coin': None,
        'we_chat': '',
        'remark': '',
    }
    error, params = check.simple_go(keys)
    if error is None:
        if dap_order.check_order(params):
            dap_order.add_order(params)
        else:
            error = '创建订单失败,印币不足'
    params.pop('_id', None)
    if error is None:
        return c_tool.check_sort_serialize(data=params)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 5
0
def go():
    keys = {
        'user_id': None,
        'money': None,
        'out_trade_no': None,
    }
    error, params = check.simple_go(keys)

    dic = {
    }

    if error is None:
        data = yy_api.dap.add_coin.get_data(params)
        r = requests.post(
            'https://api.mch.weixin.qq.com/pay/orderquery', data)
        xml = etree.fromstring(r.content)  # 进行XML解析
        total_fee = xml.find("total_fee").text
        error, _coin = yy_api.dap.add_coin.let_add_coin(params, total_fee)
        dic['coin'] = _coin

    if error is None:

        return c_tool.check_sort_serialize(data=dic)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 6
0
def go():
    keys = {}
    error, params = check.simple_go(keys)

    dic = {}

    if error is None:
        _list = pdf_api.dap.recommend.info()
        dic['result_list'] = _list
    if error is None:
        return c_tool.check_sort_serialize(data=dic)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 7
0
def go():
    keys = {}
    error, params = check.simple_go(keys)

    dic = {}

    if error is None:
        _list = wte_api.dap.random_list.get_random_list()
        dic['result_list'] = _list
    if error is None:
        return c_tool.check_sort_serialize(data=dic)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 8
0
def go():
    keys = {
        'user_id': None,
    }
    error, params = check.simple_go(keys)
    info = {'coin_num': 0}
    if error is None:
        coin_num = yy_api.dap.get_user_coin.get_coin(params)
        info['coin_num'] = coin_num

    if error is None:
        return c_tool.check_sort_serialize(data=info)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 9
0
def go():
    keys = {
        'user_id': None,
    }
    error, params = check.simple_go(keys)
    if error is None:
        order_list = dap_order.get_order_list(params)
        for order in order_list:
            order.pop('_id')
            order['ctime'] = t_tool.get_time(long(order['ctime']))
        order_list.reverse()
    if error is None:
        return c_tool.check_sort_serialize(data=order_list)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 10
0
def go():
    keys = {
        'nick_name': None,  # 昵称
        'sex': None,  # 性别 (传 1 男 传 0 女)
    }
    error, params = check.simple_go(keys)

    dic = {}

    if error is None:
        error, dic = user.add_user(params['nick_name'], params['sex'])
    if error is None:
        return c_tool.check_sort_serialize(data=dic)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 11
0
def go():
    keys = {
        'key': None,
    }
    error, params = check.simple_go(keys)

    dic = {
    }

    if error is None:
        _list = pdf_api.dap.search.key2search(params['key'])
        dic['result_list'] = _list
    if error is None:
        return c_tool.check_sort_serialize(data=dic)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 12
0
def go():
    keys = {
        'user_id': None,
        'content': None,
        'image_list': [],
    }
    error, params = check.simple_go(keys)

    dic = {}

    if error is None:
        error, dic = message.post_message(
            int(params['user_id']), str(params['content']),
            c_tool.serialize(params['image_list']), t_tool.get_ts())
    if error is None:
        return c_tool.check_sort_serialize(data=dic)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 13
0
def go():
    keys = {
        'user_id': None,
    }
    error, params = check.simple_go(keys)
    result = []
    if error is None:
        result = d_address.get_address_list(params)
        if len(result) >= 0:
            for addr in result:
                addr.pop('_id')
        else:
            error = -2, '取地址失败'

    if error is None:
        result.reverse()
        return c_tool.check_sort_serialize(data=result)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 14
0
def go():
    keys = {
        'ts': None,
    }
    error, params = check.simple_go(keys)

    dic = {
    }

    if error is None:
        ts = int(params['ts'])
        if ts == -1:
            dic['date'] = t_tool.get_time()
        else:
            dic['date'] = t_tool.get_time(ts)

    if error is None:
        return c_tool.check_sort_serialize(data=dic)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 15
0
def go():
    keys = {
        'user_id': None,
        'user_info': None,
    }
    error, params = check.simple_go(keys)

    dic = {
        'status': 'ok',
    }

    if error is None:
        bool = d_mod_user_info.set_user_info(params)
        if bool:
            dic['status'] = 'ok'
        else:
            dic['status'] = 'bad'
    if error is None:
        return c_tool.check_sort_serialize(data=dic)
    else:
        return c_tool.check_sort_serialize(msg=error)
Esempio n. 16
0
def go():
    keys = {
        'user_id': None,
        'money': None,
        'openid': None,
    }
    error, params = check.simple_go(keys)

    dic = {
    }

    if error is None:
        data, out_trade_no = yy_api.dap.recharge.get_data(params)
        dic['out_trade_no'] = out_trade_no
        r = requests.post(
            'https://api.mch.weixin.qq.com/pay/unifiedorder', data)
        xml = etree.fromstring(r.content)  # 进行XML解析
        prepay_id = xml.find("prepay_id").text
        dap.recharge.get_pay_sign(prepay_id, dic)

    if error is None:
        return c_tool.check_sort_serialize(data=dic)
    else:
        return c_tool.check_sort_serialize(msg=error)