Exemplo n.º 1
0
 def myorder(
         self,
         token,
         status=0,
         page=1,
         keyword='',
         limit=15):  # status -1全部,-2待付款,0待发货,1已发货待收货,4已完成,5已关闭,想要调用发货函数建议0
     url = 'https://hotfix.shuixiongkeji.net/app/MrdRetailOrder?status={0}&page={1}&keyword={2}&limit={3}'.format(
         status, page, keyword, limit)
     headers = {"cookie": "token=" + token}
     res = requests.get(url, headers=headers).json()
     if (res['data']['data'] == []):
         print('没有数据')
     else:
         # 取到列表第一个商品
         sub_order_id = res['data']['data'][0]['sub_order_id']
         daily_sale_order_short_no = res['data']['data'][0][
             'daily_sale_order_short_no']
         dailysale_order_price = res['data']['data'][0][
             'dailysale_order_price']
         sql = 'SELECT * FROM sub_orders WHERE id=%d; ' % sub_order_id
         #order_id
         sql_sub_order_id = Mysql().sqlclien(sql)[0][1]
         threa_order_status = 'SELECT d.status,s.status,o.status FROM daily_sale_orders d LEFT JOIN sub_orders s ON d.order_id=s.order_id LEFT JOIN orders o ON d.order_id=o.id WHERE d.order_id=%d;' % sql_sub_order_id
         order_status_total = Mysql().sqlclien(threa_order_status)
         print('商品信息:' + '订单号: ' + str(daily_sale_order_short_no) + '  ' +
               '价格; ' + str(dailysale_order_price) + ' ' +
               'sub_order_status: ' + str(order_status_total[0][1]) + ' ' +
               'daily_sale_orders_status: ' +
               str(order_status_total[0][0]) + ' ' + 'order_status: ' +
               str(order_status_total[0][2]))
     return sub_order_id, sql_sub_order_id
Exemplo n.º 2
0
 def fahuo(self, token, short_no, sub_order_id, express_num):
     url = Common.first_url() + 'seller/UnifyDeliverGoods'
     headers = {'Content-Type': "application/json", 'Authorization': token}
     data = {
         "orders": [{
             "delivery_name": "申通快递",
             "delivery_no": "3714219852419",
             "short_no": short_no,
             "sub_order_id": sub_order_id,
             "express_num": express_num
         }]
     }
     data1 = json.dumps(data)
     res = requests.post(url, data1, headers=headers)
     if (res.status_code == 200):
         print('发货信息' + str(res.json()))
         return res.status_code
     else:
         print('发货信息' + str(res.json()))
     sql = 'SELECT * FROM sub_orders WHERE id=%d; ' % sub_order_id
     sql_sub_order_id = Mysql().sqlclien(sql)[0][1]
     threa_order_status = 'SELECT d.status,s.status,o.status FROM daily_sale_orders d LEFT JOIN sub_orders s ON d.order_id=s.order_id LEFT JOIN orders o ON d.order_id=o.id WHERE d.order_id=%d;' % sql_sub_order_id
     order_status_total = Mysql().sqlclien(threa_order_status)
     print('sub_order_status: ' + str(order_status_total[0][1]) + ' ' +
           'daily_sale_orders_status: ' + str(order_status_total[0][0]) +
           ' ' + 'order_status: ' + str(order_status_total[0][2]))
Exemplo n.º 3
0
def rate_i15(region_id, apn):
    dic = {}
    mysql = Mysql()
    mysql.query('select count(1) from wl_c_ps_rate where count_0 = 1')
    dic['count'] = mysql.result()
    mysql.query(
        'select apn,time_start,time_end,count_0 from wl_c_ps_rate where count_0 = 1 limit 10'
    )
    dic['data'] = mysql.result()
    mysql.close()
    result_json = json.dumps(dic, cls=CJsonEncoder)
    return result_json
Exemplo n.º 4
0
def main():
    mysql = Mysql(params['host'], user='******', database='mychat')
    myclient = Client(params['host'], params['port'])
    root = tk.Tk()
    root.title('Mychat')
    LoginPage(root, myclient, mysql)
    root.mainloop()
Exemplo n.º 5
0
def city_query(dict1):
    dic = {}
    mysql = Mysql()
    if dict1['city'] == 'all':
        mysql.query('select rb_id,rb_name from sys_region_base')
    else:
        mysql.query('select rb_id,rb_name from sys_region_base where rb_name = "%s"' % dict1['city'])
    dic['data'] = mysql.result()
    mysql.close()
    dic['status'] = '0'
    dic['fields'] = 'region_id,地市'
    result_json = json.dumps(dic,cls=CJsonEncoder)
    return result_json
Exemplo n.º 6
0
def insert():

    mysql = Mysql()
    sqlAll = "insert into taobaoSale(`itemId`,`link`,`title`,`subtitle`,`intro`,`imagePath`,`staticImgPath`,`imagePaths`,`sellPrice`,`price`,`itemUrl`,`descUrl`,`planUrl`,`ulandUrl`,`historySales`,`viewCount`,`sellerId`,`sellerType`,`sellerName`,`flagShip`,`certIcon`,`cpId`,`cpPrice`,`cpSpare`,`cpCount`,`cpTotal`,`cpCondition`,`cpLimit`,`cpStarts`,`cpExpired`,`cpLevel`,`cpUrl`,`gold`,`ju`,`qiang`,`freeExpress`,`freeExpressBack`,`commission`,`cgold`,`goodRatePercentage`,`dx`,`is_brand`) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
    cate = ['7', '2', '1', '9', '8', '5', '10', '4', '6', '3', '99']

    for cateid in cate:
        print cateid

        i = 1
        while True:
            print '------当前进度--------:第%s页' % i
            param = dataSource.getData(i, cateid, mysql)
            i = i + 1
            if param == ['none']:
                print '--------当前%s页为终结页' % (i - 1)
                break
            else:
                try:
                    result = mysql.insertMany(sqlAll, param)
                    mysql.end()
                except IntegrityError:
                    print '--------warn当前%s页出现异常' % i
                    continue
                finally:
                    # 续1s
                    time.sleep(1)
    mysql.dispose()

    global timer
    timer = threading.Timer(43200, insert)
    timer.start()
Exemplo n.º 7
0
 def testRowCount(self):
     print("Running")
     mql = Mysql()
     mql.populate()
     count = 0
     #while True:
     count += 1
     self.failIf(mql.rowcount() != 5)
     res = mql.call_test_proc()
     self.failIf(res[0][0] != 'test proc')
     print "Executed test {0} times".format(count)
     time.sleep(5)
     count += 1
     self.failIf(mql.rowcount() != 5)
     res = mql.call_test_proc()
     self.failIf(res[0][0] != 'test proc')
     print "Executed test {0} times".format(count)
Exemplo n.º 8
0
 def indexshowping(self,token):
     url='https://hotfix.shuixiongkeji.net/app/MrdGetDailySale'
     headers = {
         "cookie": "token=" + token
     }
     # res=Http.get(url,None,token)
     # resjson=json.loads(res.text)
     res=requests.get(url,headers=headers)
     print(res.json())
     product_id=res.json()['data']['products'][0]['product_id']
     price=res.json()['data']['products'][0]['price']
     id = res.json()['data']['products'][0]['id']# 首页第几个商品,0,1,....
     if(id!=None):
         sql = "SELECT * FROM products WHERE id=%d;" % product_id
     else:
         print('悟空图还没有商品')
     exesql=Mysql().sqlclien(sql)
     businessid=exesql[0][1]
     stock=exesql[0][16]
     if(res.status_code==200):
          return id,product_id,price,businessid,stock
     else:
       print('请求错误'+res.json())
Exemplo n.º 9
0
def active_query(dict1):
    dict_tb = {'15':'wl_c_active_make_i15','60':'wl_c_active_make_h1','1440':'wl_c_active_make_d1'}
    dic = {}
    mysql = Mysql()
    mysql.query('select rb_name from sys_region_base where rb_id = %s' % dict1['region_id'])
    dic['city'] = mysql.result()
    dic['status'] = '0'
    dic['fields'] = '结束时间,活跃用户数'
    if 'time_start' in dict1.keys():
        mysql.query('select time_end,active_total from %s \
        where  region_id = %s and apn = "%s" \
        and time_end >= "%s" and time_end <= "%s"' \
        % (dict_tb.get(dict1['type']),dict1['region_id'],dict1['apn'],dict1['time_start'],dict1['time_end']))
    else:
        mysql.query('select time_end,active_total from %s \
        where region_id = %s and apn = "%s" \
        and time_end = "%s"' % (dict_tb.get(dict1['type']),dict1['region_id'],dict1['apn'],dict1['time_end']))
    dic['data'] = mysql.result()
    mysql.close()
    result_json = json.dumps(dic,cls=CJsonEncoder)
    return result_json
Exemplo n.º 10
0
def rate_sort(dict1):
    dict_tb = {'15':'wl_c_pdp_make_i15','60':'wl_c_pdp_make_h1','1440':'wl_c_pdp_make_d1'}
    dic = {}
    mysql = Mysql()
    mysql.query('select rb_name from sys_region_base where rb_id = %s' % dict1['region_id'])
    dic['city'] = mysql.result()
    dic['status'] = '0'
    dic['fields'] = '结束时间,apn,激活成功率'
    if dict1['num'] == '0':
        mysql.query('select time_end,apn,request_rate from %s \
        where gtp_cause = 128 and region_id = %s and time_end = "%s" order by request_rate %s'\
         % (dict_tb.get(dict1['type']),dict1['region_id'],dict1['time_end'],dict1['sort']))
    else:
        mysql.query('select time_end,apn,request_rate from %s \
        where gtp_cause = 128 and region_id = %s and time_end = "%s" order by request_rate %s limit %s'\
         % (dict_tb.get(dict1['type']),dict1['region_id'],dict1['time_end'],dict1['sort'],dict1['num']))
    dic['data'] = mysql.result()
    mysql.close()
    result_json = json.dumps(dic,cls=CJsonEncoder)
    return result_json
Exemplo n.º 11
0
def traffic_sort(dict1):
    dict_tb = {'15':'wl_c_traffic_make_i15','60':'wl_c_traffic_make_h1','1440':'wl_c_traffic_make_d1'}
    dic = {}
    mysql = Mysql()
    mysql.query('select rb_name from sys_region_base where rb_id = %s' % dict1['region_id'])
    dic['city'] = mysql.result()
    dic['status'] = '0'
    dic['fields'] = '结束时间,apn,上行流量,下行流量,总流量'
    if dict1['num'] == '0':
        mysql.query('select time_end,apn,sum_ul,sum_dl,sum_total from %s \
        where region_id = %s and time_end = "%s" order by active_total %s'\
         % (dict_tb.get(dict1['type']),dict1['region_id'],dict1['time_end'],dict1['sort']))
    else:
        mysql.query('select time_end,apn,sum_ul,sum_dl,sum_total from %s \
        where region_id = %s and time_end = "%s" order by sum_total %s limit %s'\
         % (dict_tb.get(dict1['type']),dict1['region_id'],dict1['time_end'],dict1['sort'],dict1['num']))
    dic['data'] = mysql.result()
    mysql.close()
    result_json = json.dumps(dic,cls=CJsonEncoder)
    return result_json
Exemplo n.º 12
0
 def testRowCount(self):
     mql = Mysql()
     mql.populate()
     self.failIf(mql.rowcount() != 5)
Exemplo n.º 13
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 7/5 0005 17:13
# @Author  : liya
# @Site    :
# @File    : test.py
import dataSource
from sql import Mysql
import time

mysql = Mysql()

sqlAll = "insert into taobaoSale(`itemId`,`link`,`title`,`subtitle`,`intro`,`imagePath`,`staticImgPath`,`imagePaths`,`sellPrice`,`price`,`itemUrl`,`descUrl`,`planUrl`,`ulandUrl`,`historySales`,`viewCount`,`sellerId`,`sellerType`,`sellerName`,`flagShip`,`certIcon`,`cpId`,`cpPrice`,`cpSpare`,`cpCount`,`cpTotal`,`cpCondition`,`cpLimit`,`cpStarts`,`cpExpired`,`cpLevel`,`cpUrl`,`gold`,`ju`,`qiang`,`freeExpress`,`freeExpressBack`,`commission`,`cgold`,`goodRatePercentage`,`dx`,`is_brand`) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

i = 119
while i <= 708:
    param = dataSource.getData(i)
    result = mysql.insertMany(sqlAll, param)
    mysql.end()
    i = i + 1
    print i
    time.sleep(3)

mysql.dispose()
# jsonss = json.loads(jsons['list'][1:-1])
# print jsonss
Exemplo n.º 14
0
 def testRowCount(self):
     mql = Mysql()
     mql.populate()
     self.failIf(mql.rowcount() != 5)