本文整理汇总了Python中sellcard.common.Method.updateDisCode方法的典型用法代码示例。如果您正苦于以下问题:Python Method.updateDisCode方法的具体用法?Python Method.updateDisCode怎么用?Python Method.updateDisCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sellcard.common.Method
的用法示例。
在下文中一共展示了Method.updateDisCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: saveOrder
# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import updateDisCode [as 别名]
#.........这里部分代码省略.........
if pay['payId'] =='3':
is_pay = '0'
elif pay['payId'] =='4':
is_pay = '0'
orderPay.received_time = pay['received_time']
elif pay['payId'] == '6':
isThird = True
is_pay = '0'
discountRate = payDiscDict[pay['payId']]
discountVal = Ycash = float(pay['payVal']) * float(discountRate)
elif pay['payId'] in ('7','8','10','11'):
isThird = True
discountRate = payDiscDict[pay['payId']]
discountVal = Ycash = float(pay['payVal']) * float(discountRate)
# if pay['payId'] == '9':
# isThird = True
# mth.upChangeCode(hjsList,shopcode)
orderPay.is_pay = is_pay
orderPay.pay_value = pay['payVal']
orderPay.remarks = pay['payRmarks']
oderPaymentList.append(orderPay)
OrderPaymentInfo.objects.bulk_create(oderPaymentList)
# 保存OrderInfo
orderInfoList = []
for card in cardList:
orderInfo = OrderInfo()
orderInfo.order_id = order_sn
orderInfo.card_id = card['cardId'].strip()
orderInfo.card_balance = float(card['cardVal'])
orderInfo.card_action = '0'
orderInfo.card_attr = '1'
orderInfoList.append(orderInfo)
if not isThird:
for Ycard in YcardList:
YorderInfo = OrderInfo()
YorderInfo.order_id = order_sn
YorderInfo.card_id = Ycard['cardId'].strip()
YorderInfo.card_balance = float(Ycard['cardVal'])
YorderInfo.card_action = '0'
YorderInfo.card_attr = '2'
orderInfoList.append(YorderInfo)
OrderInfo.objects.bulk_create(orderInfoList)
order = Orders()
order.buyer_name = buyerName
order.buyer_tel = buyerPhone
order.buyer_company = buyerCompany
order.total_amount = float(totalVal)+float(discountVal)
order.paid_amount = float(totalVal)+float(Ybalance)#实付款合计=售卡合计+优惠补差
order.disc_amount = discountVal#优惠合计
order.diff_price = Ybalance
order.shop_code = shopcode
order.depart = depart
order.operator_id = operator
order.action_type = actionType
order.add_time = datetime.datetime.now()
order.discount_rate = discountRate
order.order_sn = order_sn
order.y_cash = Ycash
order.save()
#获取所有出卡列表
cardListTotal = cardList+YcardList
cardIdList = []
for card in cardListTotal:
cardIdList.append(card['cardId'])
cardsNum = len(cardIdList)
# 更新kggroup内部卡状态
resCard = CardInventory.objects.filter(card_no__in=cardIdList,card_status='1',is_store='0')\
.update(card_status='2',card_action='0')
if resCard != cardsNum:
raise MyError('CardInventory状态更新失败')
#更新折扣授权码校验码状态
if disCode:
resCode = mth.updateDisCode(disCode,shopcode,order_sn)
if resCode == 0:
raise MyError('折扣授权码状态更新失败')
# 更新Guest
updateConfList = []
updateConfList.append({'ids': cardIdList, 'mode': '1', 'count': cardsNum})
resGuest = mth.updateCard(updateConfList)
if resGuest['status'] == 0:
raise MyError(resGuest['msg'])
res["status"] = 1
res["urlRedirect"] ='/kg/sellcard/fornt/cardsale/orderInfo/?orderSn='+order_sn
ActionLog.objects.create(url=path,u_name=request.session.get('s_uname'),cards_out=json.dumps(cardIdList),add_time=datetime.datetime.now())
del request.session['postToken']
except Exception as e:
if hasattr(e,'value'):
res['msg'] = e.value
res["status"] = 0
ActionLog.objects.create(url=path,u_name=request.session.get('s_uname'),add_time=datetime.datetime.now(),err_msg=e)
return HttpResponse(json.dumps(res))
示例2: save
# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import updateDisCode [as 别名]
def save(request):
path = request.path
operator = request.session.get('s_uid', '')
shopcode = request.session.get('s_shopcode', '')
depart = request.session.get('s_depart', '')
actionType = request.POST.get('actionType', '')
# 售卡列表
orderSns = request.POST.getlist('orderSns[]', '')
# 支付方式
payStr = request.POST.get('payStr', '')
payList = json.loads(payStr)
# 合计信息
totalVal = float(request.POST.get('totalVal', 0.00))
# 折扣
discountRate = float(request.POST.get('discount', 0.00)) / 100
disCode = request.POST.get('disCode', '')
discountVal = float(request.POST.get('discountVal', ''))
Ybalance = float(request.POST.get('Ybalance', 0.00))
YcardStr = request.POST.get('YcardStr', '')
YcardList = json.loads(YcardStr)
Ycash = request.POST.get('Ycash', '')
# 顾客信息
vip_person = request.POST.get('buyerName', '')
vip_tel = request.POST.get('buyerPhone', '')
vip_company = request.POST.get('buyerCompany', '')
vip_id = int(request.POST.get('vipId', ''))
order_sn = ''
res = {}
try:
Token = request.session.get('postToken', default=None)
userToken = request.POST.get('postToken', '')
if userToken != Token:
raise MyError('表单重复提交,刷新页面后,重试!')
with transaction.atomic():
order_sn = 'S' + mth.setOrderSn()
# OrderPaymentInfo
oderPaymentList, isThird, discountVal, Ycash = cardMethod.createPaymentList(payList, order_sn, discountVal, Ycash)
OrderPaymentInfo.objects.bulk_create(oderPaymentList)
# 保存OrderInfo
orderInfoList = cardMethod.createOrderInfoList([], order_sn, isThird, YcardList)
OrderInfo.objects.bulk_create(orderInfoList)
#Order
orderData = {
'buyerName': vip_person, 'buyerPhone': vip_tel, 'buyerCompany': vip_company,
'totalVal': totalVal, 'discountVal': discountVal, 'Ybalance': Ybalance,
'shopcode': shopcode, 'depart': depart, 'operator': operator, 'actionType': actionType,
'discountRate': discountRate, 'order_sn': order_sn, 'Ycash': Ycash
}
order = cardMethod.createOrder(orderData)
order.save()
# 获取所有出卡列表
cardIdList = []
for card in YcardList:
cardIdList.append(card['cardId'])
cardsNum = len(cardIdList)
# 更新kggroup内部卡状态
resCard = CardInventory.objects.filter(card_no__in=cardIdList, card_status='1', is_store='0') \
.update(card_status='2', card_action='0')
if resCard != cardsNum:
raise MyError('CardInventory状态更新失败')
# VipOrder
resVip = VipOrder.objects\
.filter(order_sn__in=orderSns,vip_id=vip_id,disc_state='1',order_state='0')\
.update(order_state='1',relate_sn = order_sn)
if resVip != len(orderSns):
raise MyError('VipOrder状态更新失败')
# 更新折扣授权码校验码状态
if disCode:
resCode = mth.updateDisCode(disCode, shopcode, order_sn)
if resCode == 0:
raise MyError('折扣授权码状态更新失败')
# 更新Guest
updateConfList = []
updateConfList.append({'ids': cardIdList, 'mode': '1', 'count': cardsNum})
resGuest = mth.updateCard(updateConfList)
if resGuest['status'] == 0:
raise MyError(resGuest['msg'])
res["status"] = 1
ActionLog.objects.create(url=path, u_name=request.session.get('s_uname'),
cards_out=json.dumps(cardIdList), add_time=datetime.datetime.now())
del request.session['postToken']
except Exception as e:
if hasattr(e, 'value'):
res['msg'] = e.value
res["status"] = 0
ActionLog.objects.create(url=path, u_name=request.session.get('s_uname'), add_time=datetime.datetime.now(),
err_msg=e)
return HttpResponse(json.dumps(res))
示例3: save
# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import updateDisCode [as 别名]
#.........这里部分代码省略.........
if pay['payId'] == '9':
isThird = True
mth.upChangeCode(hjsList, shopCode)
orderPay.pay_value = pay['payVal']
orderPay.remarks = pay['payRmarks']
ChangePaymentList.append(orderPay)
OrderChangeCardPayment.objects.bulk_create(ChangePaymentList)
#3、保存order信息
order = OrderChangeCard()
order.order_sn = order_sn
order.operator_id = operator
order.depart = depart
order.shop_code = shopCode
order.user_name = buyerName
order.user_phone = buyerPhone
order.total_in_amount = totalNumIn
order.total_in_price = totalValIn
order.total_out_amount = totalNumOut
order.total_out_price = totalValOut
order.disc_rate = disRate
order.disc = disc
order.disc_cash = discCash
order.disc_pay = discPay
order.add_time = created_time
order.save()
#4、分别创建orderInfo列表
cardOutInfoList =[]
changeCardInfoList = []
cardInIdList = []
cardCommonIdList=[]
cardIsStoreIdList = []
cardCommonInNum=cardIsStoreInNum = 0
if len(cardCommonList):
infoCommon = createChangInfoList(cardCommonList,order_sn,'1')
changeCardInfoList += infoCommon
cardCommonIdList = [card['cardId'] for card in cardCommonList]
cardInIdList += cardCommonIdList
cardCommonInNum = len(cardCommonIdList)
if len(cardIsStoreList):
infoIsStore = createChangInfoList(cardIsStoreList, order_sn,'1','2')
changeCardInfoList += infoIsStore
cardIsStoreIdList = [card['cardId'] for card in cardIsStoreList]
cardInIdList += cardIsStoreIdList
cardIsStoreInNum = len(cardIsStoreIdList)
if len(cardListOut):
infoOut = createChangInfoList(cardListOut,order_sn,'0')
changeCardInfoList += infoOut
cardOutInfoList += cardListOut
if not isThird and len(discList):
infoDisc = createChangInfoList(cardIsStoreList, discList,'0','1')
changeCardInfoList += infoDisc
cardOutInfoList += discList
#5、保存orderInfo
OrderChangeCardInfo.objects.bulk_create(changeCardInfoList)
#6、更新CardInventory出库卡状态
cardOutIdList = [card['cardId'] for card in cardOutInfoList]
cardsOutNum = len(cardOutIdList)
resCardOut = CardInventory.objects\
.filter(card_status='1',card_no__in=cardOutIdList,card_value=F('card_blance'),is_store='0')\
.update(card_status='2',card_action='0')
if resCardOut != cardsOutNum:
raise MyError('CardInventory状态更新失败')
#7、更新折扣授权码信息
if discCode:
resCode = mth.updateDisCode(discCode,shopCode,order_sn)
if resCode == 0:
raise MyError('折扣授权码状态更新失败')
# 8、更新Guest信息
updateConfList = []
updateConfList.append({'ids':cardIsStoreIdList,'mode':'7','count':cardIsStoreInNum})
updateConfList.append({'ids': cardCommonIdList, 'mode': '9', 'count': cardCommonInNum})
updateConfList.append({'ids':cardOutIdList,'mode':'1','count':cardsOutNum})
resGuest = mth.updateCard(updateConfList)
if resGuest['status']==0:
raise MyError(resGuest['msg'])
res["status"] = 1
ActionLog.objects.create(
action='换卡-单卡', u_name=request.session.get('s_uname'), cards_in=json.dumps(cardInIdList),
cards_out=json.dumps(cardOutIdList), add_time=datetime.datetime.now()
)
del request.session['postToken']
except Exception as e:
res["status"] = 0
if hasattr(e, 'value'):
res['msg'] = e.value
ActionLog.objects.create(
action='换卡-单卡', u_name=request.session.get('s_uname'),
add_time=datetime.datetime.now(), err_msg=e
)
return HttpResponse(json.dumps(res))
示例4: save
# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import updateDisCode [as 别名]
#.........这里部分代码省略.........
discountRate = payDiscDict[pay['payId']]
discountVal = Ycash = float(pay['payVal']) * float(discountRate)
orderPay.is_pay = is_pay
# if pay['payId']=='9':
# isThird = True
# mth.upChangeCode(hjsList,shopcode)
orderPay.pay_value = pay['payVal']
orderPay.remarks = pay['payRmarks']
paymentList.append(orderPay)
OrderPaymentInfo.objects.bulk_create(paymentList)
infoList = []
for card in cardList:
orderInfo = OrderInfo()
orderInfo.order_id = order_sn
orderInfo.card_id = card['card_no']
orderInfo.card_balance = float(card['card_balance'])
orderInfo.card_action = '0'
orderInfo.card_attr = '1'
infoList.append(orderInfo)
if not isThird:
for Ycard in YcardList:
YorderInfo = OrderInfo()
YorderInfo.order_id = order_sn
YorderInfo.card_id = Ycard['cardId']
YorderInfo.card_balance = float(Ycard['cardVal'])
YorderInfo.card_action = '0'
YorderInfo.card_attr = '2'
infoList.append(YorderInfo)
OrderInfo.objects.bulk_create(infoList)
order = Orders()
order.buyer_name = buyer['borrow_name']
order.buyer_tel = buyer['borrow_phone']
order.buyer_company = buyer['borrow_depart']
order.total_amount = float(totalVal)+float(discountVal)
order.paid_amount = float(totalVal)+float(Ybalance)#实付款合计=售卡合计+优惠补差
order.disc_amount = discountVal#优惠合计
order.diff_price = Ybalance
order.shop_code = shopcode
order.depart = depart
order.operator_id = operator
order.action_type = actionType
order.add_time = datetime.datetime.now()
order.discount_rate = discountRate
order.order_sn = order_sn
order.y_cash = Ycash
order.save()
#未退回卡列表 chedan
cardIdBorrowList = [card['card_no'] for card in cardList]
#优惠卡列表
cardIdDisclist = [card['cardId'] for card in YcardList]
# 更新kggroup内部优惠赠送卡状态
resCard = CardInventory.objects.filter(card_no__in=cardIdDisclist,card_status='1',is_store='0')\
.update(card_status='2',card_action='0')
if resCard != len(cardIdDisclist):
raise MyError('CardInventory状态更新失败')
#更新折扣授权码校验码状态
if disCode:
resCode = mth.updateDisCode(disCode,shopcode,order_sn)
if resCode == 0:
raise MyError('折扣授权码状态更新失败')
#更新借卡单的结算状态
resBorrow = orderBorrow.update(is_paid='1',paid_time=datetime.datetime.now(),reply_order=order_sn)
if not resBorrow:
raise MyError('OrderBorrow状态更新失败')
resBorrow2 = OrderBorrowInfo.objects.filter(order_sn=orderSnList,card_no__in=cardIdBorrowList, is_back=None).update(is_back='0')
if resBorrow2 != len(cardIdBorrowList):
raise MyError('OrderBorrowInfo数据更新失败')
# 更新ERP内部优惠赠送卡状态
if len(cardIdDisclist)>0:
# 更新Guest
updateConfList = []
updateConfList.append({'ids': cardIdDisclist, 'mode': '1', 'count': len(cardIdDisclist)})
resGuest = mth.updateCard(updateConfList)
if resGuest['status'] == 0:
raise MyError(resGuest['msg'])
res["status"] = 1
res["urlRedirect"] ='/kg/sellcard/fornt/cardsale/orderInfo/?orderSn='+order_sn
cardOutTotal = cardIdBorrowList + cardIdDisclist
ActionLog.objects.create(action='借卡-结算',u_name=request.session.get('s_uname'),cards_out=json.dumps(cardOutTotal),add_time=datetime.datetime.now())
del request.session['postToken']
except Exception as e:
res["status"] = 0
if hasattr(e,'value'):
res['msg'] = e.value
ActionLog.objects.create(action='借卡-结算',u_name=request.session.get('s_uname'),add_time=datetime.datetime.now(),err_msg=e)
return HttpResponse(json.dumps(res))