本文整理汇总了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))
示例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))
示例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
示例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
示例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))