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


Python common.Method类代码示例

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


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

示例1: login

def login(request):
    user_name = mtu.getReqVal(request,"user_name","").strip()
    password = mtu.getReqVal(request,"password","").strip()
    vcode = mtu.getReqVal(request,"vcode","").strip()
    try:
        vcode2 = request.session["s_vcode"]
    except:
        vcode2 = ""

    response_data = {}
    try:
        if vcode == vcode2:
            # 查询用户信息
            user = AdminUser.objects.get(user_name=user_name,is_enable='0')
            upwd = user.password
            password = mtu.md5(password)
            shop_code=user.shop_code
            rates = DiscountRate.objects.values('val_min','val_max','discount_rate').filter(shopcode=shop_code)

            discLevelList = Shops.objects.values('disc_level').filter(shop_code=shop_code)
            discLevel = ''
            if len(discLevelList)>0:
                discLevel = discLevelList[0]['disc_level']
            rateList=[]
            for rate in rates:
                item={}
                item['val_min']=float(rate['val_min'])
                item['val_max']=float(rate['val_max'])
                item['discount_rate']=float(rate['discount_rate'])
                rateList.append(item)

            if upwd == password:
                request.session["s_uname"] = user.user_name
                request.session["s_unameChinese"] = user.name
                request.session["s_roleid"] = user.role_id
                request.session["s_shopid"] = user.shop_id
                request.session["s_shopcode"] = user.shop_code
                request.session["s_depart"] = user.depart
                request.session["s_uid"] = user.id
                request.session["s_rates"] = rateList
                request.session["disc_level"] = discLevel

                #售卡前台
                response_data['homeurl'] = cts.URL_HOME[0]

                request.session["homeurl"] = response_data['homeurl']

                # 查询菜单权限
                purlist = findNavByRcode(user.role_id)
                request.session["s_umenu"] = getMenu(purlist)
                response_data['status'] = "0"
            else:
                response_data['status'] = "2"
        else:
            response_data['status'] = "3"
    except Exception as e:
        print(e)
        response_data['status'] = "1"

    return HttpResponse(json.dumps(response_data), content_type="application/json")
开发者ID:KGPython,项目名称:kggroup,代码行数:60,代码来源:login.py

示例2: index

def index(request):
    if request.method == 'POST':
        operator = str(request.session.get('s_uid', ''))
        shopcode = request.session.get('s_shopcode', '')

        today = datetime.datetime.today().replace(hour=23,minute=59,second=59)
        monthFirstDay = datetime.datetime.today().replace(day=1,hour=0,minute=0,second=0,microsecond=0)
        start = request.POST.get('start')
        if not start:
            start = monthFirstDay
        end = request.POST.get('end')
        endStr = datetime.datetime.strptime(end,'%Y-%m-%d')+datetime.timedelta(1)
        if not end:
            end = today
        buyerName = (mth.getReqVal(request,"buyerName","")).strip()
        #售卡数据
        queryWhereSale1 = " and b.buyer_name='"+buyerName+"'" if buyerName else ''
        queryWhereSale2 = " and b.add_time >='{start}' and b.add_time <='{end}' ".format(start=start, end=endStr)
        conn = mth.getMysqlConn()
        cur = conn.cursor()
        sqlSale="select a.pay_value,b.order_sn,b.operator_id,b.add_time,b.buyer_name,b.buyer_tel,b.paid_amount, " \
                " IFNULL(c.pay_value, 0) as credit_value, a.pay_id " \
            " from order_payment_info as a ,orders as b " \
            " left join (select sum(p.pay_value) as pay_value, p.order_id from order_payment_credit p group by p.order_id) as c " \
            " on b.order_sn = c.order_id " \
            " where a.order_id=b.order_sn and a.pay_id in (4, 3) and a.is_pay != '1' and b.shop_code ='"+shopcode+"'"+queryWhereSale1+queryWhereSale2
        cur.execute(sqlSale)
        listSale = cur.fetchall()

        cur.close()
        conn.close()

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

示例3: index

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,代码行数:30,代码来源:stock.py

示例4: index

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,代码行数:60,代码来源:borrowCard.py

示例5: order

def order(request):
    today = datetime.date.today()
    today = datetime.datetime.strftime(today, '%Y-%m-%d')

    shop = mth.getReqVal(request,'shop','')
    start = mth.getReqVal(request,'start',today)
    end = mth.getReqVal(request,'end',today)
    startTime = start + ' 00:00:00'
    endTime = end + ' 23:59:59'

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

    saleSql = 'select a.order_sn,a.buyer_company,b.is_pay,b.pay_value as no_pay,' \
              'c.bank_name,c.pay_value,c.pay_id,c.bank_sn,c.pay_company,c.change_time ' \
              '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=4 ' \
              'order by b.is_pay,a.order_sn' \
              .format(start=startTime, end=endTime, shop=shop)

    cur.execute(saleSql)
    saleList = cur.fetchall()
    saleData,saleTotalPay,saleTotalNoPay= mergeData(saleList)


    data = saleData
    totalPay = saleTotalPay
    totalNoPay = saleTotalNoPay
    data = sorted(data,key=itemgetter('is_pay','order_sn'),reverse=True)
    return render(request, 'report/card/nopay/order.html', locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:30,代码来源:noPay.py

示例6: order2

def order2(request):
    shops = base.findShop()
    today = datetime.date.today()
    monthFirst = str(datetime.date.today().replace(day=1))
    today = str(today)

    shop = mth.getReqVal(request, 'shop', '')
    start = mth.getReqVal(request, 'start', monthFirst)
    end = mth.getReqVal(request, 'end', today)
    startTime = start + ' 00:00:00'
    endTime = end + ' 23:59:59'
    whereShop ='a.shop_code ="'+shop+'" ' if shop  else '1=1'

    conn = mth.getMysqlConn()
    cur = conn.cursor()
    saleSql = 'select a.order_sn,a.shop_code,a.add_time,a.buyer_company,b.pay_value,b.received_time,c.change_time ' \
              ' 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 b.pay_id=4 and {whereShop}' \
              ' order by a.order_sn' \
        .format(start=startTime, end=endTime,whereShop=whereShop)

    cur.execute(saleSql)
    listSale = cur.fetchall()

    cur.close()
    conn.close()
    return render(request, 'report/card/nopay/order2.html', locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:27,代码来源:noPay.py

示例7: index

def index(request):
    shop = request.session.get('s_shopcode')
    today = str(datetime.date.today())
    couponType = mth.getReqVal(request, 'couponType', '')
    batch = mth.getReqVal(request, 'batch', '').strip()
    start = mth.getReqVal(request, 'start', today)
    end = mth.getReqVal(request, 'end', today)
    endTime = datetime.datetime.strptime(end, '%Y-%m-%d') + datetime.timedelta(1)
    page = mth.getReqVal(request, 'page', 1)

    kwargs = {}
    kwargs.setdefault('payment_type', 4)

    kwargs.setdefault('shop_code', shop)

    if couponType != '':
        kwargs.setdefault('type', couponType)

    if batch != '':
        kwargs.setdefault('batch', batch)

    if start != '':
        kwargs.setdefault('start_date__gte', start)

    if end != '':
        kwargs.setdefault('start_date__lte', endTime)

    List = KfJobsCoupon.objects.values('shop_code', 'coupon_code', 'create_user_name',
         'type', 'batch', 'start_date', 'end_date', 'values', 'range', 'pay_account',
          'credit_account').filter(credit_account__lt=F('pay_account'), **kwargs).order_by('create_date')

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

    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,'voucher/credit/List.html',locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:52,代码来源:credit.py

示例8: updatePwd

def updatePwd(request):
    data = {}
    if request.method == 'POST':

        userId =request.session["s_uid"]
        try:
            newPwd = mtu.getReqVal(request,"newPwd","")
            pwd = mtu.md5(newPwd)
            AdminUser.objects.filter(id=userId).update(password=pwd)
            data["result"] = "0"
        except Exception as e:
            print(e)

    return render(request,'restPassword.html',locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:14,代码来源:login.py

示例9: detail

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,代码行数:50,代码来源:saleGroupByShop.py

示例10: query

def query(request):
    cardsStr = request.POST.get('cards','')
    cards = json.loads(cardsStr)
    listTotal = []
    conn = mth.getMssqlConn()
    cur = conn.cursor()
    for obj in cards:
        if obj['end']:
            sql = "select cardno,new_amount,sheetid,mode,detail,memo " \
                  "from guest where cardno>='{cardStart}' and cardno<='{cardEnd}'"\
                  .format(cardStart=obj['start'],cardEnd=obj['end'])
        else:
            sql = "select cardno,new_amount,sheetid,mode,detail,memo " \
                  "from guest where cardno='{cardStart}'"\
                  .format(cardStart=obj['start'],cardEnd=obj['end'])
        cur.execute(sql)
        list = cur.fetchall()
        listTotal.extend(list)

    cardNoList = []
    listTotalNew = []
    for item in listTotal:
        if(item['cardno'] in cardNoList):
            pass
        else:
            cardNoList.append(item['cardno'])
            item['detail']=float(item['detail'])
            item['new_amount']=float(item['new_amount'])
            listTotalNew.append(item)
    return HttpResponse(json.dumps(listTotalNew))
开发者ID:KGPython,项目名称:kggroup,代码行数:30,代码来源:cards2.py

示例11: index

def index(request):
    shop = request.session.get('s_shopcode')
    vip_id = request.GET.get('vip_id')
    buyer = Vip.objects.filter(id=vip_id, status='1').values('company', 'person', 'tel', 'id').first()
    token = 'allow'
    request.session['postToken'] = token
    if request.method == 'POST':
        time_start = request.POST.get('start')
        time_end = request.POST.get('end')
        nextDay = datetime.datetime.strptime(time_end, '%Y-%m-%d') + datetime.timedelta(1)
        # kwargs = {}
        # kwargs.setdefault('vipOrders__status','1')
        # kwargs.setdefault('add_time__lte',nextDay)
        # kwargs.setdefault('add_time__gte',time_start)
        # orders = Orders.objects.filter(**kwargs)\
        #     .values('order_sn','paid_amount','add_time','buyer_name','buyer_tel','orderPays__is_pay')

        sql = '''SELECT `orders`.`order_sn`, `orders`.`paid_amount`,`orders`.`add_time`,`orders`.`buyer_name`,
                `orders`.`buyer_tel`,`order_payment_info`.`is_pay`
                FROM `orders`
                INNER JOIN `vip_order` ON (`orders`.`order_sn` = `vip_order`.`order_sn`)
                LEFT OUTER JOIN `order_payment_info` ON ( `orders`.`order_sn` = `order_payment_info`.`order_id` )
                WHERE ( `vip_order`.`disc_state` = 1 AND `vip_order`.`order_state` = 0 AND `orders`.`add_time` <= '{end}'
                AND `orders`.`add_time` >= '{start}' AND `orders`.`shop_code`='{shop}')'''\
            .format(start=time_start,end=nextDay,shop=shop)
        conn = mth.getMysqlConn()
        cur = conn.cursor()
        cur.execute(sql)
        orders = cur.fetchall()
        cur.close()
        conn.close()
    return render(request, 'vip/settlement.html', locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:32,代码来源:settlement.py

示例12: query

def query(request):
    shopCode = request.session.get('s_shopcode')

    pageNum =mtu.getReqVal(request,"pageNum","1")
    user_phone = request.POST.get("user_phone","")
    state = request.POST.get("state","")

    karrs = {}
    karrs.setdefault("state__in",[0,1])
    if user_phone:
        karrs.setdefault("user_phone__contains",user_phone)
    if state:
        karrs.setdefault("state",state)
    if shopCode:
        karrs.setdefault("shop_code",shopCode)

    order_list = OrderUpCard.objects.values("order_sn","total_amount","total_price","action_type","user_name",
                               "user_phone","state","add_time",)\
        .filter(**karrs)\
        .order_by("-order_sn")

    page = Paginator(order_list, __EACH_PAGE_SHOW_NUMBER, allow_empty_first_page=True).page(int(pageNum))
    result = {"page": page, "pageNum": str(pageNum)}
    result.setdefault("user_phone", user_phone)
    result.setdefault("state", state)
    return render(request, 'card/fill/cardFillQuery.html', result)
开发者ID:KGPython,项目名称:kggroup,代码行数:26,代码来源:view.py

示例13: save

def save(request):
    res = {}
    if request.method == 'POST':
        # 检测session中Token值,判断用户提交动作是否合法
        Token = request.session.get('postToken', default=None)
        # 获取用户表单提交的Token值
        userToken = request.POST.get('postToken', '')
        if userToken != Token:
            res["msg"] = 0
            return HttpResponse(json.dumps(res))

        shop_code = request.session.get('s_shopcode')
        name = request.POST.get('name')
        start_no = request.POST.get('start_no')
        end_no = request.POST.get('end_no')
        try:
            with transaction.atomic():
                conn = mth.getMysqlConn()
                cur = conn.cursor()
                sql = " update card_inventory set username='{name}'" \
                      " where is_store=1 and shop_code='{shop}' and username=''" \
                      " and card_no >= {start} AND card_no <= {end}"\
                    .format(start=start_no,end=end_no,name=name,shop=shop_code)
                cur.execute(sql)
                res['msg'] = 1
                del request.session['postToken']

        except Exception as e:
            print(e)
            res['msg'] = 0

    return HttpResponse(json.dumps(res))
开发者ID:KGPython,项目名称:kggroup,代码行数:32,代码来源:allocate.py

示例14: query

def query(request):
    cardsStr = request.POST.get('cards','')
    cards = json.loads(cardsStr)
    listTotal = []
    conn = mth.getMysqlConn()
    cur = conn.cursor()
    for obj in cards:
        sql = " SELECT card_no, card_value, card_blance, card_status,is_store" \
              " FROM card_inventory" \
              " WHERE (card_no >= {start} AND card_no <= {end})" \
              " ORDER BY card_no" \
            .format(start=obj['start'], end=obj['end'])
        cur.execute(sql)
        qs_card = cur.fetchall()
        listTotal.extend(qs_card)

    cardNoList = []
    listTotalNew = []
    for item in listTotal:
        if(item['card_no'] in cardNoList):
            pass
        else:
            cardNoList.append(item['card_no'])
            item['card_blance']=float(item['card_blance'])
            listTotalNew.append(item)
    cur.close()
    conn.close()
    return HttpResponse(json.dumps(listTotalNew))
开发者ID:KGPython,项目名称:kggroup,代码行数:28,代码来源:cards.py

示例15: create

def create(request):
    # 在服务端session中添加key认证,避免用户重复提交表单
    token = 'allow'  # 可以采用随机数
    request.session['postToken'] = token
    coupon_code = mth.getReqVal(request, 'coupon_code', '')
    coupon_info = KfJobsCoupon.objects.values('pay_account', 'credit_account').get(coupon_code=coupon_code)
    receivable = float(coupon_info['pay_account']) - float(coupon_info['credit_account'])
    return render(request,'voucher/credit/create.html',locals())
开发者ID:KGPython,项目名称:kggroup,代码行数:8,代码来源:credit.py


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