当前位置: 首页>>代码示例>>Python>>正文


Python Method.getCityShopsCode方法代码示例

本文整理汇总了Python中sellcard.common.Method.getCityShopsCode方法的典型用法代码示例。如果您正苦于以下问题:Python Method.getCityShopsCode方法的具体用法?Python Method.getCityShopsCode怎么用?Python Method.getCityShopsCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sellcard.common.Method的用法示例。


在下文中一共展示了Method.getCityShopsCode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: index

# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import getCityShopsCode [as 别名]
def index(request):
    role_id = request.session.get('s_roleid')
    shop = request.session.get('s_shopcode')
    role = request.session.get('s_roleid')
    user = request.session.get('s_uid')

    if request.method == 'POST':
        start = request.POST.get('start', '')
        end = request.POST.get('end', '')
        endTime = datetime.datetime.strptime(end, '%Y-%m-%d').date() + datetime.timedelta(1)
        whereStr = "WHERE t.shopcode = s.shop_code AND t.add_time >='" + start + "' AND t.add_time <='" + str(endTime) + "' "

        if role in ('2', '10'):
            whereStr += " AND t.shopcode ='" + shop + "'"
        conn = mth.getMysqlConn()
        cur = conn.cursor()

        shopsCode = ''
        if role_id == '9':
            shopsCode = mth.getCityShopsCode('T')
            shopsCodeStr = "'" + "','".join(shopsCode) + "'"
            whereStr += " AND t.shopcode IN (" + shopsCodeStr + ")"
        if role_id == '8':
            shopsCode = mth.getCityShopsCode('C')
            shopsCodeStr = "'" + "','".join(shopsCode) + "'"
            whereStr += " AND t.shopcode IN (" + shopsCodeStr + ")"

        sql = """
    SELECT
    	date_format(
    		t.add_time,
    		'%Y年%m月%d日'
    	) AS create_date,
    	s.shop_name,
    	t.order_sn,
    	t.borrow_depart,
    	t.order_val * t.order_num AS borrow_account,
    	IFNULL(o.total_amount, 0) AS balance,
    	IFNULL(o.paid_amount, 0) AS actual,
    	IFNULL(o.discount_rate, 0) AS voucher,
    	t.paid_time
    FROM
    	order_borrow t
    LEFT JOIN orders o ON t.reply_order = o.order_sn,
     shops s """ + whereStr + """
    ORDER BY
    	create_date,
    	s.shop_name
            """
        cur.execute(sql)
        List = cur.fetchall()

        borrow_total = 0.00
        balance_total = 0.00
        actual_total = 0.00
        for row in List:
            borrow_total += float(row['borrow_account'])
            balance_total += float(row['balance'])
            actual_total += float(row['actual'])
    return render(request, 'report/finance/borrowCard.html', locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:62,代码来源:borrowCard.py

示例2: index

# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import getCityShopsCode [as 别名]
def index(request):
    role_id = request.session.get('s_roleid')
    shop_code = request.session.get('s_shopcode')

    kwargs = {}
    kwargs.setdefault('card_status','1')
    kwargs.setdefault('card_action','1')
    kwargs.setdefault('card_blance__gt','0')
    if role_id in ('2','10'):
        kwargs.setdefault('shop_code',shop_code)
    if role_id == '9':
        shops_code = mth.getCityShopsCode('T')
        kwargs.setdefault('shop_code__in', shops_code)
    if role_id == '8':
        shops_code = mth.getCityShopsCode('C')
        kwargs.setdefault('shop_code__in', shops_code)

    cardList = CardInventory.objects\
            .values('shop_code')\
            .filter(**kwargs)\
            .exclude(shop_code='')\
            .annotate(num=Count('card_no'),balance=Sum('card_blance'))\
            .order_by('shop_code')

    totalBalance = 0.00
    totalNum = 0
    for row in cardList:
        totalBalance += float(row['balance'])
        totalNum +=row['num']
    return render(request, 'report/card/stock/stock.html', locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:32,代码来源:stock.py

示例3: index

# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import getCityShopsCode [as 别名]
def index(request):
    shop = request.session.get('s_shopcode', '')
    role_id = request.session.get('s_roleid')
    if request.method == 'GET':
        start = str(datetime.date.today().replace(day=1))
        end = str(datetime.date.today())
        endTime = str(datetime.date.today() + datetime.timedelta(1))
    if request.method == 'POST':
        today = datetime.date.today()
        start = request.POST.get('start', today)
        end = request.POST.get('end', today)
        endTime = str(datetime.datetime.strptime(end, '%Y-%m-%d').date() + datetime.timedelta(1))

    conn = mth.getMysqlConn()
    cur = conn.cursor()
    if role_id == '1' or role_id == '6':
        shops = mth.getCityShops()
        shopsCode = mth.getCityShopsCode()
    if role_id == '9':
        shops = mth.getCityShops('T')
        shopsCode = mth.getCityShopsCode('T')
    if role_id == '8':
        shops = mth.getCityShops('C')
        shopsCode = mth.getCityShopsCode('C')
    if role_id == '10' or role_id == '2':
        shops = base.findShop(shop)
        shopsCode = [shop]

    shopsCodeStr = "'" + "','".join(shopsCode) + "'"
开发者ID:KGPython,项目名称:kggroup,代码行数:31,代码来源:reimbursement.py

示例4: detail

# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import getCityShopsCode [as 别名]
def detail(request):
    today = datetime.date.today()
    page = mth.getReqVal(request, 'page', 1)
    shop_code = request.GET.get('shop')
    pay_id = request.GET.get('pay_id')

    shop = request.session.get('s_shopcode', '')
    role_id = request.session.get('s_roleid')
    if role_id == '9':
        shopsCode = mth.getCityShopsCode('T')
        if shop_code not in shopsCode:
            return render(request, '500.html', locals())
    elif role_id == '8':
        shopsCode = mth.getCityShopsCode('C')
        if shop_code not in shopsCode:
            return render(request, '500.html', locals())
    elif role_id == '10' or role_id == '2' or role_id == '12':
        if shop != shop_code:
            return render(request, '500.html', locals())


    start = request.GET.get('start', today)
    end = request.GET.get('end', today)
    endTime = str(datetime.datetime.strptime(end, '%Y-%m-%d').date() + datetime.timedelta(1))

    conn = mth.getMysqlConn()
    cur = conn.cursor()
    if pay_id == '3':
        sql = " select a.order_sn,a.action_type,b.is_pay,b.pay_value,c.bank_name,c.bank_sn,c.pay_company" \
              " from orders as a inner join order_payment_info as b on a.order_sn = b.order_id left join order_payment_credit as c on a.order_sn = c.order_id"\
              " where a.add_time>='{start}' and a.add_time<='{end}' and a.shop_code ='{shop}' and b.pay_id=3" \
              " order by b.is_pay,a.order_sn"\
              .format(start=start, end=endTime, shop=shop_code)
    else:
        sql = " select a.order_sn,a.action_type,a.buyer_name,a.buyer_tel,a.buyer_company,b.pay_value,b.is_pay" \
              " from orders as a ,order_payment_info as b" \
              " where a.order_sn = b.order_id and a.shop_code = '{shop}' and a.add_time >= '{start}'" \
              " and a.add_time <= '{end}' and b.pay_id = '{pay}'"\
            .format(shop=shop_code,start=start,end=end,pay=pay_id)

    cur.execute(sql)
    List = cur.fetchall()

    for item in List:
        if item['pay_value']:
            item['pay_value'] = float(item['pay_value'])
        else:
            item['pay_value'] = 0

    return render(request, 'report/card/saleGroupByShop/Detail.html', locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:52,代码来源:saleGroupByShop.py

示例5: bestowed

# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import getCityShopsCode [as 别名]
def bestowed(request):
    s_shop = request.session.get('s_shopcode')
    s_role = request.session.get('s_roleid')
    s_user = request.session.get('s_uid')
    if s_role in ('1', '6'):
        shops = mth.getCityShopsCode()
    elif s_role == '9':
        shops = mth.getCityShopsCode('T')
    elif s_role == '8':
        shops = mth.getCityShopsCode('C')
    elif s_role in ('2', '10'):
        shop = s_shop
    if request.method == 'POST':
        today = str(datetime.date.today())
        start = request.POST.get('start', today)
        end = request.POST.get('end', today)
        end2 = datetime.datetime.strptime(end, '%Y-%m-%d') + datetime.timedelta(1)

        shop= ''
        if s_role in ('1', '6', '8', '9'):
            shop = request.POST.get('shop', '')
        elif s_role in ('2', '10'):
            shop = s_shop
        elif s_role in ('3', '5'):
            shop = s_shop

        kwargs = {}
        kwargs.setdefault('add_time__gte', start)
        kwargs.setdefault('add_time__lte', end2)
        kwargs.setdefault('action_type', '5')
        if shop:
            kwargs.setdefault('shop_code', shop)

        disc_list = Orders.objects.values('disc_amount','shop_code','operator_id','add_time','remark').filter(**kwargs)
        disc_total = 0
        for disc in disc_list:
            disc_total += float(disc['disc_amount'])
    if request.method == 'GET':
        pass
    return render(request, 'report/card/disc/bestowed.html', locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:42,代码来源:disc.py

示例6: index

# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import getCityShopsCode [as 别名]
def index(request):
    role_id = request.session.get('s_roleid')
    shop = request.session.get('s_shopcode')
    role = request.session.get('s_roleid')
    user = request.session.get('s_uid')

    if request.method == 'POST':
        start = request.POST.get('start','')
        end = request.POST.get('end','')
        endTime = datetime.datetime.strptime(end,'%Y-%m-%d').date() + datetime.timedelta(1)
        whereStr ="WHERE a.add_time >='"+start+"' AND a.add_time <='"+str(endTime)+"' AND a.order_sn = b.order_id "

        if role in ('2','10') :
            whereStr += " AND a.shop_code ='"+shop+"'"
        conn = mth.getMysqlConn()
        cur = conn.cursor()

        shopsCode= ''
        if role_id == '9':
            shopsCode = mth.getCityShopsCode('T')
            shopsCodeStr = "'" + "','".join(shopsCode) + "'"
            whereStr += " AND a.shop_code IN (" + shopsCodeStr + ")"
        if role_id == '8':
            shopsCode = mth.getCityShopsCode('C')
            shopsCodeStr = "'" + "','".join(shopsCode) + "'"
            whereStr += " AND a.shop_code IN (" + shopsCodeStr + ")"

        sql = "SELECT b.pay_id,SUM(b.pay_value) AS pay_value FROM orders as a,order_payment_info as b "+whereStr+" GROUP BY b.pay_id ORDER BY b.pay_id"
        cur.execute(sql)
        payList = cur.fetchall()

        nopay = "SELECT SUM(b.pay_value) AS pay_value FROM orders as a,order_payment_info as b "+whereStr+" AND a.order_sn = b.order_id AND b.is_pay='0' AND b.pay_id=4"

        cur.execute(nopay)
        nopayDict = cur.fetchone()

        payTotal = 0.00
        for row in payList:
            payTotal += float(row['pay_value'])
    return render(request, 'report/card/saleGroupByPay.html', locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:42,代码来源:saleGroupByPay.py

示例7: index

# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import getCityShopsCode [as 别名]
def index(request):
    shop = request.session.get('s_shopcode')
    role = request.session.get('s_roleid')
    shops = Shops.objects.values('shop_code','shop_name','city').order_by('shop_code')
    if role in ('1','6','7') :
        shops = shops
    elif role == '8':#承德总部财务
        shops = shops.filter(city='C')
    elif role == '9':#唐山总部财务
        shops = shops.filter(city='T')
    else:
        shops = shops.filter(shop_code=shop)
    shops_len = len(shops)
    if request.method == 'POST':
        shopcode = mth.getReqVal(request, 'shopcode', '')
        keyword = mth.getReqVal(request, 'keyword', '')
        # 表单分页参数开始
        page = mth.getReqVal(request, 'page', 1)
        show_num = mth.getReqVal(request, 'show_num', 8)
        # 表单分页参数结束

        conn = mth.getMysqlConn()
        cur = conn.cursor()
        whereStr = "WHERE t.is_store = 1 "

        if role in ('2', '10'):
            whereStr += " AND t.shop_code ='" + shop + "'"


        if shopcode != '':
            whereStr += " AND t.shop_code ='" + shopcode + "'"
        else:
            shopsCode = ''
            if role == '9':
                shopsCode = mth.getCityShopsCode('T')
                shopsCodeStr = "'" + "','".join(shopsCode) + "'"
                whereStr += " AND t.shop_code IN (" + shopsCodeStr + ")"
            if role == '8':
                shopsCode = mth.getCityShopsCode('C')
                shopsCodeStr = "'" + "','".join(shopsCode) + "'"
                whereStr += " AND t.shop_code IN (" + shopsCodeStr + ")"

        if keyword != '':
            whereStr += " AND (c.username like '%" + keyword + "%' OR c.`name` like '%" + keyword + "%')"

        sql = """
SELECT
	t.shop_code,
	s.shop_name,
	c.username as user_code,
	IFNULL(c.`name`, '未分配') AS username,
	t.card_value,
	count(t.card_no) AS account,
	sum(CASE WHEN t.card_status = 2 THEN 1 ELSE 0 END) AS out_num,
	sum(CASE WHEN t.card_status = 1 THEN 1 ELSE 0 END) AS in_num
FROM
	card_inventory t LEFT JOIN shops s ON t.shop_code = s.shop_code
	LEFT JOIN cashier_list c ON t.shop_code = c.shop_code and t.username = c.username
"""+ whereStr +"""
GROUP BY
	t.shop_code,
	s.shop_name,
	c.username,
	c.`name`,
	t.card_value
                """
        cur.execute(sql)
        List = cur.fetchall()

        # 表单分页开始
        paginator = Paginator(List, show_num)

        try:
            List = paginator.page(page)

            if List.number > 1:
                page_up = List.previous_page_number
            else:
                page_up = 1

            if List.number < List.paginator.num_pages:
                page_down = List.next_page_number
            else:
                page_down = List.paginator.num_pages

        except Exception as e:
            print(e)
            # 表单分页结束

    return render(request, 'consign/list.html', locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:92,代码来源:allocate.py

示例8: getData

# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import getCityShopsCode [as 别名]
def getData(role_id,shop,start,endTime):
    conn = mth.getMysqlConn()
    cur = conn.cursor()
    if role_id == '1' or role_id == '6':
        shops = mth.getCityShops()
        shopsCode = mth.getCityShopsCode()
    elif role_id == '9':
        shops = mth.getCityShops('T')
        shopsCode = mth.getCityShopsCode('T')
    elif role_id == '8':
        shops = mth.getCityShops('C')
        shopsCode = mth.getCityShopsCode('C')
    elif role_id == '10' or role_id == '2' or role_id == '12' or role_id == '11':
        shops = base.findShop(shop)
        shopsCode = [shop]

    shopsCodeStr = "'" + "','".join(shopsCode) + "'"
    # shopsCodeStr = "('C003')"
    # saleDiscGroupByShop = 'SELECT a.shop_code, SUM(CASE WHEN b.card_balance<= a.diff_price THEN a.y_cash+b.card_balance ELSE a.disc_amount END ) AS disc,' \
    #                       'SUM(a.y_cash) AS disc_cash,SUM(case WHEN b.card_balance<= a.diff_price THEN b.card_balance ELSE b.card_balance-a.diff_price END) AS disc_card ' \
    #                       'FROM orders AS a ' \
    #                       'LEFT JOIN (SELECT  order_id,SUM(card_balance) AS card_balance ' \
    #                       'FROM order_info WHERE card_attr="2" GROUP BY order_id,card_attr) AS b ' \
    #                       'ON b.order_id = a.order_sn ' \
    #                       'WHERE a.add_time >= "{start}" AND a.add_time <= "{end}" AND a.shop_code IN ({shopsCodeStr}) group by a.shop_code '\
    #                      .format(start=start, end=endTime,shopsCodeStr=shopsCodeStr)

    saleDiscGroupByShop = 'select shop_code,' \
                          'SUM(case when disc_amount>=y_cash then disc_amount else diff_price+disc_amount end) as disc, ' \
                          'SUM(y_cash) as disc_cash, ' \
                          'SUM(case when disc_amount>=y_cash then disc_amount-y_cash else disc_amount+diff_price-y_cash end) as disc_card ' \
                          'from orders ' \
                          'where add_time>="{start}" and add_time<="{end}" and shop_code in ({shopsCodeStr}) ' \
                          'group by shop_code ' \
                          .format(start=start, end=endTime, shopsCodeStr=shopsCodeStr)
    cur.execute(saleDiscGroupByShop)
    saleDiscList = cur.fetchall()

    salePayGroupByShop = 'select ord.shop_code,info.pay_id,info.change_time,SUM(info.pay_value) as pay_value ' \
                         'from orders as ord , order_payment_info as info ' \
                         'where ord.add_time>="{start}" and ord.add_time<="{end}" and ord.shop_code in ({shopsCodeStr})' \
                         ' and ord.order_sn = info.order_id ' \
                         'group by ord.shop_code,info.pay_id,info.change_time ' \
                        .format(start=start, end=endTime, shopsCodeStr=shopsCodeStr)
    cur.execute(salePayGroupByShop)
    salePayList = cur.fetchall()

    fillList = OrderUpCard.objects \
        .values('shop_code') \
        .filter(add_time__gte=start, add_time__lte=endTime, shop_code__in=shopsCode) \
        .annotate(fill=Sum('diff_price')) \
        .order_by('shop_code')

    # changeDiscGroupByShop = 'SELECT a.shop_code, SUM(CASE WHEN b.card_balance<= a.disc_pay THEN a.disc_cash+b.card_balance ELSE a.disc END) AS disc,' \
    #                         'SUM(a.disc_cash) AS disc_cash,SUM(case WHEN b.card_balance<= a.disc_pay THEN b.card_balance ELSE b.card_balance-a.disc_pay END) AS disc_card ' \
    #                         'FROM order_change_card AS a '\
    #                         'LEFT JOIN (SELECT  order_sn,sum(card_balance) as card_balance ' \
    #                         'FROM order_change_card_info where type="1" group by order_sn,type)'\
    #                         'AS b on b.order_sn = a.order_sn '\
    #                         'WHERE a.add_time >= "{start}" AND a.add_time <= "{end}" AND a.shop_code IN ({shopsCodeStr}) ' \
    #                         'group by a.shop_code ' \
    #                         .format(start=start, end=endTime,shopsCodeStr=shopsCodeStr)

    changeDiscGroupByShop = 'select shop_code,SUM(case when disc>=disc_cash then disc else disc_pay+disc end) as disc,' \
                            'SUM(disc_cash) as disc_cash,' \
                            'SUM(case when disc>=disc_cash then disc-disc_cash else disc+disc_pay-disc_cash end) as disc_card ' \
                            'from order_change_card ' \
                            'where add_time>="{start}" and add_time<="{end}" and shop_code in ({shopsCodeStr}) ' \
                            'group by shop_code ' \
                            .format(start=start, end=endTime, shopsCodeStr=shopsCodeStr)
    cur.execute(changeDiscGroupByShop)
    changeDiscList = cur.fetchall()
    changePayGroupByShop = 'select ord.shop_code ,info.pay_id,info.change_time,SUM(info.pay_value) as pay_value ' \
                           'from order_change_card as ord , order_change_card_payment as info ' \
                           'where ord.add_time>="{start}" and ord.add_time<="{end}" and shop_code in ({shopsCodeStr}) and ord.order_sn = info.order_id ' \
                           'group by ord.shop_code,info.pay_id,info.change_time' \
                            .format(start=start, end=endTime, shopsCodeStr=shopsCodeStr)
    cur.execute(changePayGroupByShop)
    changePayList = cur.fetchall()

    paymentsRate = Payment.objects.values('id', 'dis_rate').filter(dis_rate__gte=0)
    paymentsRateDict = {item['id']: float(item['dis_rate']) for item in paymentsRate}
    totalDict = {'discTotal': 0,
                 'discCashTotal': 0, 'total_disc_6': 0, 'total_disc_7': 0, 'total_disc_8': 0, 'total_disc_10': 0,
                 'total_disc_11': 0, 'total_disc_qita': 0, 'discCardTotal': 0,
                 'inSubTotal': 0, 'total_1': 0, 'total_2': 0, 'total_3': 0,
                 'total_4': 0, 'total_5': 0, 'total_6': 0, 'total_7': 0, 'total_8': 0, 'total_9': 0, 'total_10': 0,
                 'total_11': 0, }

    dataList = []
    for i in range(0, len(shops)):
        # shopcode = shops[i]['shop_code']
        if shops[i]['shop_code'] != 'ZBTG':
            item = {'shop_code': '',
                    'disc': 0, 'disc_6': 0, 'disc_7': 0, 'disc_8': 0, 'disc_10': 0, 'disc_11': 0, 'disc_cash': 0,
                    'disc_card': 0,
                    'inSub': 0, 'pay_1': 0, 'pay_2': 0, 'pay_3': 0, 'pay_4': 0, 'pay_5': 0, 'pay_6': 0, 'pay_7': 0,
                    'pay_8': 0,
                    'pay_9': 0, 'pay_10': 0, 'pay_11': 0, }
            item['shop_code'] = shops[i]['shop_code']
#.........这里部分代码省略.........
开发者ID:KGPython,项目名称:kggroup,代码行数:103,代码来源:saleGroupByShop.py

示例9: index

# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import getCityShopsCode [as 别名]
def index(request):
    s_shop = request.session.get('s_shopcode')
    s_role = request.session.get('s_roleid')
    s_user = request.session.get('s_uid')
    today = str(datetime.date.today())

    shops = []
    shopsCodeStr = ''
    personList = AdminUser.objects.values('id', 'name','is_enable').filter(role_id__in=('2', '3', '5','11'))
    if s_role in ('1', '6'):
        shops = mth.getCityShopsCode()
        shopsCodeStr = "'" + "','".join(shops) + "'"
        personList = personList.filter(shop_code__in=shops)
    elif s_role == '9':
        shops = mth.getCityShopsCode('T')
        shopsCodeStr = "'" + "','".join(shops) + "'"
        personList = personList.filter(shop_code__in=shops)
    elif s_role == '8':
        shops = mth.getCityShopsCode('C')
        shopsCodeStr = "'" + "','".join(shops) + "'"
        personList = personList.filter(shop_code__in=shops)
    elif s_role in ('2', '10'):
        shop = s_shop
        personList = personList.filter(shop_code=shop)

    personList = sorted(personList, key=lambda p: p["name"].encode('gb2312'))

    if request.method == 'POST':
        shop,operator = '',''
        if s_role in ('1', '6', '8', '9'):
            shop = mth.getReqVal(request, 'shop', '')
            operator = mth.getReqVal(request, 'operator', '')
        elif s_role in ('2', '10'):
            shop = s_shop
            operator = mth.getReqVal(request, 'operator', '')
        elif s_role in ('3', '5'):
            operator = s_user
            shop = s_shop
        start = mth.getReqVal(request, 'start', today)
        end = mth.getReqVal(request,'end',today)
        end2 = datetime.datetime.strptime(end, '%Y-%m-%d') + datetime.timedelta(1)

        #汇总数据
        kwargs ={}
        kwargs.setdefault('add_time__gte',start)
        kwargs.setdefault('add_time__lte',end2)
        if shop:
            kwargs.setdefault('shop_code',shop)
        if operator:
           kwargs.setdefault('operator_id',operator)
        if len(shops)>0:
            kwargs.setdefault('shop_code__in', shops)
        dataTotal = Orders.objects.filter(**kwargs).aggregate(saleTotal=Sum('paid_amount'),discTotal=Sum('disc_amount'))

        #卡面值列表
        conn = mth.getMysqlConn()
        whereStr = 'ord.order_sn=info.order_id and ord.add_time>= "'+str(start)+'" and ord.add_time<= "'+str(end2)+'" '
        if operator:
            whereStr += ' and operator_id = "'+str(operator)+'" '
        if shop:
            whereStr += ' and ord.shop_code = "'+shop+'"'
        if shopsCodeStr:
            whereStr += ' and ord.shop_code IN (' + shopsCodeStr + ')'
        sqlInfo = 'select ord.shop_code,info.card_balance, count(*) as num from order_info as info,orders as ord ' \
                  'where '+ whereStr+' group by ord.shop_code,info.card_balance'
        cur = conn.cursor()
        cur.execute(sqlInfo)
        dataInfo =cur.fetchall()

    return render(request, 'report/card/saleGroupByCardType.html', locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:72,代码来源:saleGroupByCardType.py

示例10: index

# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import getCityShopsCode [as 别名]
def index(request):
    role_id = request.session.get('s_roleid')
    s_shop = request.session.get('s_shopcode')
    s_depart = request.session.get('s_depart')
    s_user = request.session.get('s_uid')

    today = str(datetime.date.today())
    start = end = today
    actionType = 1
    shops = []
    users = AdminUser.objects.values('id', 'name','is_enable').filter(role_id__in=('2', '3','5','11'))
    if role_id in ('1','6'):
        shops = mth.getCityShopsCode()
    elif role_id == '9':
        shops = mth.getCityShopsCode('T')
    elif role_id == '8':
        shops = mth.getCityShopsCode('C')
    elif role_id in ('2', '10'):
        shops = [s_shop]
    elif role_id in ('3', '5'):
        shopcode = s_shop
        depart = s_depart
        operator = s_user
    personList = users.filter(shop_code__in=shops)
    personList = sorted(personList, key=lambda p: p["name"].encode('gb2312'))
    departs = base.findDepart()

    if request.method == 'POST':
        shop,operator,depart = '','',''
        if role_id in ('1','6','8','9'):
            shop = request.POST.get('shop','')
            depart = request.POST.get('depart', '')
            operator = request.POST.get('operator', '')
        elif  role_id in ('2','10') :
            shop = s_shop
            depart = request.POST.get( 'depart', '')
            operator = request.POST.get('operator', '')
        elif role_id in ('3','5'):
            shop = s_shop
            depart = s_depart
            operator = s_user
        actionType = request.POST.get('actionType','1')
        start = request.POST.get('start',today)
        end = request.POST.get('end',today)
        endTime = datetime.datetime.strptime(end,'%Y-%m-%d') + datetime.timedelta(1)
        page = request.POST.get('page',1)

        kwargs = {}
        if shop:
            kwargs.setdefault('shop_code',shop)
        if operator:
            kwargs.setdefault('operator_id',operator)
        if depart:
            kwargs.setdefault('depart',depart)
        kwargs.setdefault('add_time__gte',start)
        kwargs.setdefault('add_time__lte',endTime)

        resList, paidTotal, discTotal, cardCount = getData(actionType,kwargs)
        paginator = Paginator(resList,20)
        try:
            resList = paginator.page(page)
            page_next = mth.getNextPageNum(resList)
            page_prev = mth.getPrevPageNum(resList)

        except Exception as e:
            print(e)
    return render(request, 'report/card/saleGroupByOrder/index.html', locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:69,代码来源:saleGroupByOrder.py

示例11: month_pay6

# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import getCityShopsCode [as 别名]
def month_pay6(request):
    """
    移动积分赊还款
    :param request:
    :return:
    """
    shops = mth.getCityShopsCode()
    if request.method == 'POST':
        postStart = request.POST.get('start')
        if postStart<'2017-01':
            postStart = '2017-01'
        postEnd = request.POST.get('end')

        start = '{postStart}-01 00:00:00'.format(postStart=postStart)
        endTemp = datetime.datetime.strptime(postEnd,'%Y-%m')
        if endTemp.month == 12:
            end = datetime.datetime(endTemp.year+1, 1, 1)
        else:
            end = datetime.datetime(endTemp.year, endTemp.month + 1, 1)

        shop_code = request.POST.get('shop','')
        parameterShop = '1=1'
        parameterShop2 = '1=1'
        if shop_code:
            parameterShop = 'shop="{shop}"'.format(shop=shop_code)
            parameterShop2 = 'shop_code="{shop}"'.format(shop=shop_code)

        conn = mth.getMysqlConn()
        cur = conn.cursor()

        #在起始日期之前赊销,在起始日期之前未到账
        sqlBeforeNoPay = ' select sum(b.pay_value) as total' \
                         ' from orders as a, order_payment_info as b' \
                         ' where a.add_time>="2017-01-01 00:00:00" and a.add_time<="{start}" and {shop}' \
                         ' and b.pay_id =6 and a.order_sn = b.order_id' \
                        .format(start=start,shop=parameterShop2)
        cur.execute(sqlBeforeNoPay)
        beforeNoPay = cur.fetchone()
        totalNoPayBefore = beforeNoPay['total']
        totalNoPayBefore = totalNoPayBefore if totalNoPayBefore else 0
        #在起始日期之前赊销,在起始日期之后到账
        sqlBeforePaid = 'select sum(b.pay_value) as total' \
                        ' from order_payment_credit as b,orders as a ' \
                        ' where a.order_sn=b.order_id and a.add_time>="2017-01-01 00:00:00" and a.add_time<="{start}"' \
                        ' and b.change_time<="{start}" and {shop} and b.pay_id_old =6' \
                        .format(start=start, end=end, shop=parameterShop2)
        cur.execute(sqlBeforePaid)
        beforePaid = cur.fetchone()
        totalPaidBefore = beforePaid['total']
        totalPaidBefore = totalPaidBefore if totalPaidBefore else 0
        #历史累计
        totalNoPayBefore = totalNoPayBefore - totalPaidBefore

        #赊出记录
        sqlNoPay =' select a.shop_code as shop,DATE_FORMAT(a.add_time,"%Y-%m") as add_time,SUM(b.pay_value) as pay_value,0 as is_pay' \
                  ' from orders as a,order_payment_info as b' \
                  ' where a.add_time>="2017-01-01 00:00:00" and a.add_time>="{start}" and a.add_time<="{end}" and {shop}' \
                  ' and b.pay_id =6 and a.order_sn = b.order_id' \
                  ' GROUP BY a.shop_code,DATE_FORMAT(a.add_time,"%Y-%m")'\
            .format(start=start, end=end,shop=parameterShop2)
        cur.execute(sqlNoPay)
        noPayList = cur.fetchall()
        #还款记录
        sqlPaid = ' select shop,DATE_FORMAT(change_time,"%Y-%m") as change_time,sum(pay_value) as pay_value,1 is_pay' \
                  ' from order_payment_credit ' \
                  ' where change_time>="2017-01-01 00:00:00" and change_time>="{start}" and change_time<="{end}"' \
                  ' and {shop} and pay_id_old=6' \
                  ' GROUP BY shop,DATE_FORMAT(change_time,"%Y-%m")'.format(start=start, end=end,shop=parameterShop)
        cur.execute(sqlPaid)
        paidList = cur.fetchall()
        noPayList = splitDataPay6('0', noPayList, start, end)
        paidList = splitDataPay6('1', paidList, start, end)
        dataSelect = noPayList + paidList
        totalNoPay = float(totalNoPayBefore)
        if len(dataSelect) > 0:
            dataSorted = sorted(dataSelect, key=itemgetter('time'), reverse=False)
            totalPay, MonthNoPay, MonthPay, index, = 0, 0, 0, 0
            resData, monthSubTimeList = [], []

            for row in dataSorted:
                rowTimeNow = datetime.datetime.strptime(row['time'],'%Y-%m')
                if index == 0:
                    rowTimePre =rowTimeNow
                else:
                    rowTimePre = dataSorted[index - 1]['time']
                    rowTimePre = datetime.datetime.strptime(rowTimePre,'%Y-%m')
                if isNextMonth(rowTimeNow, rowTimePre):
                    yesterday = datetime.datetime(rowTimeNow.year, rowTimeNow.month, 1) + datetime.timedelta(days=-1)
                    if yesterday not in monthSubTimeList:
                        startDate = datetime.datetime.strptime(start, '%Y-%m-%d %H:%M:%S')
                        if yesterday >= startDate:
                            monthSubitem = MonthSub(MonthPay, MonthNoPay, yesterday.date())
                            resData.append(monthSubitem)
                            monthSubTimeList.append(yesterday)
                            MonthNoPay = 0
                            MonthPay = 0
                if 'is_pay' in row:
                    if row['is_pay'] == '1':
                        MonthPay += float(row['pay'])
                        totalPay += float(row['pay'])
#.........这里部分代码省略.........
开发者ID:KGPython,项目名称:kggroup,代码行数:103,代码来源:noPay.py

示例12: month_pay4

# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import getCityShopsCode [as 别名]
def month_pay4(request):
    """
    :param request:
    :return:
    """
    shops = mth.getCityShopsCode()
    if request.method == 'POST':
        postStart = request.POST.get('start')
        if postStart<'2017-06':
            postStart = '2017-06'
        postEnd = request.POST.get('end')

        start = '{postStart}-01 00:00:00'.format(postStart=postStart)
        endTemp = datetime.datetime.strptime(postEnd,'%Y-%m')
        if endTemp.month == 12:
            end = datetime.datetime(endTemp.year+1, 1, 1)
        else:
            end = datetime.datetime(endTemp.year, endTemp.month + 1, 1)

        shop_code = request.POST.get('shop','')
        parameterShop = '1=1'
        if shop_code:
            parameterShop = 'a.shop_code="{shop}"'.format(shop=shop_code)

        conn = mth.getMysqlConn()
        cur = conn.cursor()

        #在起始日期之前赊销,在起始日期之前未到账
        sqlBeforeNoPay = 'select sum(b.pay_value) as total from orders as a, order_payment_info as b' \
                         ' where a.add_time>="2017-06-01 00:00:00" and a.add_time<="{start}" and {shop}' \
                         ' and b.pay_id =4 and is_pay=0 and a.order_sn = b.order_id' \
                        .format(start=start,shop=parameterShop)
        cur.execute(sqlBeforeNoPay)
        beforeNoPay1 = cur.fetchone()
        totalNoPayBefore1 = beforeNoPay1['total']
        totalNoPayBefore1 = totalNoPayBefore1 if totalNoPayBefore1 else 0
        #在起始日期之前赊销,在起始日期之后到账
        sqlBeforeNoPay2 = 'select sum(b.pay_value) as total' \
                          ' from order_payment_credit as b LEFT JOIN orders as a ON b.order_id = a.order_sn' \
                          ' where a.add_time>="2017-06-01 00:00:00" and a.add_time<="{start}"' \
                          ' and b.change_time>="{start}" and {shop} and b.pay_id_old =4' \
                          .format(start=start, end=end, shop=parameterShop)
        cur.execute(sqlBeforeNoPay2)
        beforeNoPay2 = cur.fetchone()
        totalNoPayBefore2 = beforeNoPay2['total']
        totalNoPayBefore2 = totalNoPayBefore2 if totalNoPayBefore2 else 0
        #历史累计
        totalNoPayBefore = totalNoPayBefore1 +totalNoPayBefore2

        #赊出记录
        sqlNoPay =' select a.order_sn,a.buyer_company,a.shop_code,a.add_time,b.pay_id ,b.pay_value' \
                  ' from orders as a,order_payment_info as b' \
                  ' where a.add_time>="2017-06-01 00:00:00" and a.add_time>="{start}" and a.add_time<="{end}" and {shop}' \
                  ' and b.pay_id =4 and a.order_sn = b.order_id' \
                  ' order by a.add_time'.format(start=start, end=end,shop=parameterShop)
        cur.execute(sqlNoPay)
        noPayList = cur.fetchall()
        #还款记录
        sqlPaid = ' select a.order_sn,a.shop_code,b.pay_company,b.change_time,b.pay_id ,b.pay_value' \
                  ' from order_payment_credit as b LEFT JOIN orders as a' \
                  ' ON b.order_id = a.order_sn' \
                  ' where a.add_time>="2017-06-01 00:00:00" and b.change_time>="{start}" and {shop}' \
                  ' and b.change_time<="{end}" and b.pay_id_old=4' \
                  ' order by b.change_time'.format(start=start, end=end,shop=parameterShop)
        cur.execute(sqlPaid)
        paidList = cur.fetchall()

        noPayList = splitData('0',noPayList,start,end)
        paidList = splitData('1',paidList,start,end)
        dataSelect = noPayList + paidList
        totalNoPay = float(totalNoPayBefore)
        if len(dataSelect)>0:
            dataSorted = sorted(dataSelect, key=itemgetter('time'), reverse=False)
            totalPay,MonthNoPay,MonthPay,index, = 0,0,0,0
            resData,monthSubTimeList = [],[]

            for row in dataSorted:
                if index == 0:
                    rowTimePre = rowTimeNow
                else:
                    rowTimeNow = row['time']
                    rowTimePre = dataSorted[index-1]['time']
                if isNextMonth(rowTimeNow,rowTimePre) and (row['time'].date()+datetime.timedelta(days=-1) not in monthSubTimeList):
                    time = datetime.datetime(rowTimeNow.year,rowTimeNow.month,1)+datetime.timedelta(days=-1)
                    if time>=datetime.datetime.strptime(start,'%Y-%m-%d %H:%M:%S'):
                        monthSubitem = MonthSub(MonthPay,MonthNoPay,time)
                        resData.append(monthSubitem)
                        monthSubTimeList.append(time)
                        MonthNoPay = 0
                        MonthPay = 0
                if 'is_pay' in row:
                    if row['is_pay'] == '1':
                        MonthPay += float(row['pay'])
                        totalPay += float(row['pay'])
                        totalNoPay += -float(row['pay'])
                        row['sub'] = totalNoPay
                    else:
                        MonthNoPay += float(row['noPay'])
                        totalNoPay += float(row['noPay'])
                        row['sub'] = totalNoPay
#.........这里部分代码省略.........
开发者ID:KGPython,项目名称:kggroup,代码行数:103,代码来源:noPay.py


注:本文中的sellcard.common.Method.getCityShopsCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。