當前位置: 首頁>>代碼示例>>Python>>正文


Python Method.getMssqlConn方法代碼示例

本文整理匯總了Python中sellcard.common.Method.getMssqlConn方法的典型用法代碼示例。如果您正苦於以下問題:Python Method.getMssqlConn方法的具體用法?Python Method.getMssqlConn怎麽用?Python Method.getMssqlConn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sellcard.common.Method的用法示例。


在下文中一共展示了Method.getMssqlConn方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: query

# 需要導入模塊: from sellcard.common import Method [as 別名]
# 或者: from sellcard.common.Method import getMssqlConn [as 別名]
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,代碼行數:32,代碼來源:cards2.py

示例2: statusTo1

# 需要導入模塊: from sellcard.common import Method [as 別名]
# 或者: from sellcard.common.Method import getMssqlConn [as 別名]
def statusTo1(request):
    if request.method == 'GET':
        operator = request.session.get('s_uid', '')
        shopcode = request.session.get('s_shopcode', '')
        roleid = request.session.get("s_roleid", '')
        rates = request.session.get('s_rates')

        # 在服務端session中添加key認證,避免用戶重複提交表單
        token = 'allow'  # 可以采用隨機數
        request.session['postToken'] = token
        return render(request, 'card/manage/changeStatus.html', locals())

    if request.method == 'POST':
        u_name = request.session.get('s_uname')
        # 檢測session中Token值,判斷用戶提交動作是否合法
        Token = request.session.get('postToken', default=None)
        # 獲取用戶表單提交的Token值
        userToken = request.POST.get('postToken', '')
        if userToken != Token:
            raise MyError('表單重複提交,刷新頁麵後,重試!')

        cardList = request.POST.get('cardList')
        cardList = json.loads(cardList)
        cardCount = len(cardList)
        cardList = "'"+"','".join(cardList)+"'"
        cardList.replace('"',"'")
        res = {}
        conn = mth.getMssqlConn()
        cur = conn.cursor()
        try:
            conn.autocommit(False)
            sql = "UPDATE Guest SET mode = 1 WHERE cardno in ("+cardList+") AND detail=new_amount AND mode=7"
            cur.execute(sql)
            resUpdate = cur.rowcount
            if resUpdate != cardCount:
                raise MyError('更新失敗。原因:更新數據條數與提交數據不符!')
            conn.commit()
            res['status'] = 1
            ActionLog.objects.create(
                action='掛售卡激活', u_name=u_name,cards_in=json.dumps(cardList),
                add_time=datetime.datetime.now()
            )
            del request.session['postToken']
        except Exception as e:
            conn.rollback()
            res['status'] = 0
            if hasattr(e,'value'):
                res['msg'] = e.value
            ActionLog.objects.create(
                action='掛售卡解掛', u_name=u_name,cards_in=json.dumps(cardList),add_time=datetime.datetime.now(), err_msg=e
            )
        finally:
            cur.close()
            conn.close()
            return HttpResponse(json.dumps(res))
開發者ID:KGPython,項目名稱:kggroup,代碼行數:57,代碼來源:changeStatus.py

示例3: getGoodsList

# 需要導入模塊: from sellcard.common import Method [as 別名]
# 或者: from sellcard.common.Method import getMssqlConn [as 別名]
def getGoodsList(goodsname, goodscode):
    """
    獲取商品列表
    :param goodsname: 商品名稱
    :param goodscode: 商品編碼
    :return:列表
    """
    conn = mth.getMssqlConn()
    cur = conn.cursor()
    sql = "select ShortName,CustomNo from Goods where name like '%{goodsname}%' and CustomNo like '%{goodscode}%'"\
        .format(goodsname=goodsname, goodscode=goodscode)
    cur.execute(sql)
    list = cur.fetchall()
    cur.close()
    conn.close()
    return list
開發者ID:KGPython,項目名稱:kggroup,代碼行數:18,代碼來源:issue.py

示例4: getInfo

# 需要導入模塊: from sellcard.common import Method [as 別名]
# 或者: from sellcard.common.Method import getMssqlConn [as 別名]
def getInfo(voucherSn):
    """
    獲取券信息
    :param voucherSn: 核銷券號
    :return:券信息
    """
    conn = mth.getMssqlConn()
    cur = conn.cursor()
    sql = u"select ShopID as shop_code," \
          u"        CouponNO," \
          u"        CouponTypeID," \
          u"        3 as type," \
          u"        StartDate as start_date," \
          u"        EndDate as end_date," \
          u"        ClearFlag," \
          u"        Value as spend" \
          u"  from MyShop_Coupon " \
          u" where CouponNO = '{voucherSn}'".format(voucherSn=voucherSn)
    cur.execute(sql)
    v_info = cur.fetchone()
    cur.close()
    conn.close()
    return v_info
開發者ID:KGPython,項目名稱:kggroup,代碼行數:25,代碼來源:balance.py

示例5: query

# 需要導入模塊: from sellcard.common import Method [as 別名]
# 或者: from sellcard.common.Method import getMssqlConn [as 別名]
def query(request):
    step = request.POST.get('step')
    if step == '1':
        orderSns = request.POST.get('orderSns')
        token = 'allow'  # 可以采用隨機數
        request.session['postToken'] = token
        return render(request,'card/borrow/back_save.html',locals())

    shopcode = request.session.get('s_shopcode','')
    cardsStr = request.POST.get('cards','')
    cards = json.loads(cardsStr)
    orderSnsStr = request.POST.get('orderSns','')
    orderSns = json.loads(orderSnsStr)

    listTotal = []
    conn = mth.getMssqlConn()
    cur = conn.cursor()
    #判斷餘額
    for obj in cards:
        sql = "select cardno,new_amount,sheetid,mode,detail,memo " \
              "from guest where cardno>='{cardStart}' and cardno<='{cardEnd}'"\
              .format(cardStart=obj['start'],cardEnd=obj['end'])
        cur.execute(sql)
        list = cur.fetchall()
        listTotal.extend(list)
    cur.close()
    conn.close()

    #去重複
    cardNoList = []
    listTotalNew = []
    for item in listTotal:
        if(item['cardno'] not in cardNoList):
            cardNoList.append(item['cardno'])
            item['detail']=float(item['detail'])
            item['new_amount']=float(item['new_amount'])
            listTotalNew.append(item)

    #判斷是否屬於借卡
    orderSnTuple = []
    for cardNo in cardNoList:
        record = OrderBorrowInfo.objects.values('card_no','order_sn').filter(order_sn__in=orderSns,card_no=cardNo)

        if not record:
            for card in listTotalNew:
                if card['cardno'] == cardNo:
                    card['is_borrow']='0'
        else:
            for card in listTotalNew:
                if card['cardno'] == cardNo:
                    card['is_borrow']='1'
                    orderSn = record[0]['order_sn']
                    if orderSn not in orderSnTuple:
                        orderSnTuple.append(orderSn)


    data = {}

    # data['listTotalNew'] = listTotalNew
    # data['orderSnTuple'] = orderSnTuple
    return HttpResponse(json.dumps(listTotalNew))
開發者ID:KGPython,項目名稱:kggroup,代碼行數:63,代碼來源:back.py


注:本文中的sellcard.common.Method.getMssqlConn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。