本文整理汇总了Python中sellcard.common.Method.setOrderSn方法的典型用法代码示例。如果您正苦于以下问题:Python Method.setOrderSn方法的具体用法?Python Method.setOrderSn怎么用?Python Method.setOrderSn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sellcard.common.Method
的用法示例。
在下文中一共展示了Method.setOrderSn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import setOrderSn [as 别名]
def save(request):
operator = request.session.get('s_uid','')
shopCode = request.session.get('s_shopcode','')
depart = request.session.get('s_depart','')
#入卡列表
cardListInStr = request.POST.get('cardListIn','')
cardListIn = json.loads(cardListInStr)
#入卡合计
totalNumIn = request.POST.get('totalNumIn',0)
totalValIn = request.POST.get('totalValIn',0.00)
#出卡列表
cardListOutStr = request.POST.get('cardListOut','')
cardListOut = json.loads(cardListOutStr)
#出卡合计
totalNumOut = request.POST.get('totalNumOut',0)
totalValOut = request.POST.get('totalValOut',0.00)
#优惠卡列表
discListStr = request.POST.get('discList','')
discList = json.loads(discListStr)
#优惠返现
discCash = request.POST.get('discCash',0.00)
#优惠返点金额
disc = request.POST.get('disc',0.00)
# 优惠返点比率
disRate = request.POST.get('disRate',0.00)
#优惠补差
discPay = request.POST.get('discPay',0.00)
#折扣授权码
discCode = request.POST.get('discCode','')
# 支付方式
payStr = request.POST.get('payStr', '')
payList = json.loads(payStr)
hjsStr = request.POST.get('hjsStr', '')
# 黄金手卡号列表
hjsList = []
if len(hjsStr) > 0:
hjsStr = hjsStr[0:len(hjsStr) - 1]
hjsList = hjsStr.split(',')
#买卡人信息
buyerName = (request.POST.get('buyerName','')).strip()
buyerPhone = (request.POST.get('buyerPhone','')).strip()
order_sn = ''
res = {}
try:
# 检测session中Token值,判断用户提交动作是否合法
Token = request.session.get('postToken', default=None)
# 获取用户表单提交的Token值
userToken = request.POST.get('postToken', '')
if userToken != Token:
raise MyError('表单重复提交,刷新页面后,重试!')
with transaction.atomic():
order_sn = 'C'+mth.setOrderSn(OrderChangeCard)
created_time=datetime.datetime.today()
cardIsStoreList = []
cardCommonList = []
#1、更新cardInventory中入库卡数据
for card in cardListIn:
queryCard = CardInventory \
.objects \
.filter(card_status='2', card_action='0', card_no=card['cardId'], card_value=F('card_blance'))
cardInventory = queryCard.values('is_store').first()
is_store = 0
if cardInventory:
is_store = cardInventory['is_store']
if is_store:
cardIsStoreList.append(card)
status = '7'
action = '0'
else:
cardCommonList.append(card)
status = '1'
action = '1'
resUpdate = resSave = 0
#处理老卡换入
if not cardInventory:
obj = CardInventory \
.objects \
.create(card_no=card['cardId'], card_value=card['cardVal'], card_status='1', card_action='1',
card_addtime=datetime.datetime.now(), shop_code=shopCode,
is_store=0, card_blance=card['cardVal'])
resSave = obj.id
else:
resUpdate = queryCard.update(card_status=status, card_action=action, shop_code=shopCode)
if (resUpdate == 0 and resSave == 0):
raise MyError(card['cardId'] + '状态更新失败')
#2、保存支付信息
isThird = False
payDiscDict = mth.getPayDiscDict()
ChangePaymentList = []
for pay in payList:
#.........这里部分代码省略.........
示例2: saveOrder
# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import setOrderSn [as 别名]
def saveOrder(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','')
#售卡列表
cardStr = request.POST.get('cardStr','')
cardList = json.loads(cardStr)
#赠卡列表
YcardStr = request.POST.get('YcardStr','')
YcardList = json.loads(YcardStr)
Ycash = request.POST.get('Ycash','')
#支付方式
payStr = request.POST.get('payStr','')
payList = json.loads(payStr)
# hjsStr = request.POST.get('hjsStr','')
#黄金手卡号列表
# hjsList=[]
# if len(hjsStr)>0:
# hjsStr = hjsStr[0:len(hjsStr)-1]
# hjsList = hjsStr.split(',')
#合计信息
totalVal = 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 = request.POST.get('Ybalance',0.00)
#买卡人信息
buyerName = request.POST.get('buyerName','')
buyerPhone = request.POST.get('buyerPhone','')
buyerCompany = request.POST.get('buyerCompany','')
res = {}
try:
# 检测session中Token值,判断用户提交动作是否合法
Token = request.session.get('postToken', default=None)
# 获取用户表单提交的Token值
userToken = request.POST.get('postToken', '')
if userToken != Token:
raise MyError('表单重复提交,刷新页面后,重试!')
with transaction.atomic():
order_sn = 'S'+mth.setOrderSn()
isThird = False
#保存OrderPaymentInfo
payDiscDict = mth.getPayDiscDict()
oderPaymentList = []
for pay in payList:
orderPay = OrderPaymentInfo()
orderPay.order_id = order_sn
orderPay.pay_id = pay['payId']
#处理混合支付的优惠
is_pay = 1
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'])
#.........这里部分代码省略.........
示例3: save
# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import setOrderSn [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))
示例4: saveOrder
# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import setOrderSn [as 别名]
def saveOrder(request):
operator = request.session.get('s_uid','')
shopcode = request.session.get('s_shopcode','')
depart = request.session.get('s_depart','')
#售卡列表
cardStr = request.POST.get('cardsStr','')
cardList = json.loads(cardStr)
#合计信息
outTotalVal = request.POST.get('outTotalVal',0.00)
discVal = request.POST.get('discVal',0.00)
discPay = request.POST.get('discPay',0.00)
remark = request.POST.get('remarks','')
#买卡人信息
buyerName = request.POST.get('buyerName','')
buyerPhone = request.POST.get('buyerPhone','')
buyerCompany = request.POST.get('buyerCompany','')
order_sn = ''
res = {}
try:
# 检测session中Token值,判断用户提交动作是否合法
Token = request.session.get('postToken', default=None)
# 获取用户表单提交的Token值
userToken = request.POST.get('postToken', '')
if userToken != Token:
raise MyError('表单重复提交,刷新页面后,重试!')
with transaction.atomic():
order_sn = 'S'+mtu.setOrderSn()
#order_info表
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 = '2'
orderInfoList.append(orderInfo)
OrderInfo.objects.bulk_create(orderInfoList)
#order_payment_info表
orderPay = OrderPaymentInfo()
orderPay.order_id = order_sn
orderPay.pay_id = 1
orderPay.is_pay = '1'
orderPay.pay_value = float(discPay)
orderPay.save()
#orders表
order = Orders()
order.buyer_name = buyerName
order.buyer_tel = buyerPhone
order.buyer_company = buyerCompany
order.total_amount = float(outTotalVal)
order.paid_amount = float(discPay)
order.disc_amount = float(discVal)
order.diff_price = float(discPay)
order.y_cash =0
order.shop_code = shopcode
order.depart = depart
order.operator_id = operator
order.action_type = '5'
order.add_time = datetime.datetime.now()
order.order_sn = order_sn
order.remark = remark
order.save()
#更新
cardIdList = []
for card in cardList:
cardIdList.append(card['cardId'])
cardNum = len(cardIdList)
resCard = CardInventory.objects.filter(card_no__in=cardIdList,card_status='1',is_store='0').update(card_status=2,card_action='0')
if resCard!= cardNum:
raise MyError('CardInventory状态更新失败')
# 更新Guest
updateConfList = []
updateConfList.append({'ids': cardIdList, 'mode': '1', 'count': cardNum})
resGuest = mtu.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(action='实物团购返点',u_name=request.session.get('s_uname'),cards_out=cardStr,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(action='实物团购返点',u_name=request.session.get('s_uname'),cards_out=cardStr,add_time=datetime.datetime.now(),err_msg=e)
return HttpResponse(json.dumps(res))
示例5: sentOrderSave
# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import setOrderSn [as 别名]
def sentOrderSave(request):
orderSn = 'G'+mth.setOrderSn(CardReceive)
cardStr = request.POST.get('list','')
cards = json.loads(cardStr)
shop = request.POST.get('shop','')
person = request.POST.get('person','')
saleType = request.POST.get('saleType','')
res = {}
try:
# 检测session中Token值,判断用户提交动作是否合法
Token = request.session.get('postToken', default=None)
# 获取用户表单提交的Token值
userToken = request.POST.get('postToken', '')
if userToken != Token:
raise MyError('表单重复提交,刷新页面后,重试!')
with transaction.atomic():
receive = CardReceive()
receive.rec_sn = orderSn
receive.shop_code = shop
receive.rec_name = person
receive.add_time = datetime.datetime.now()
receive.save()
cardList = []
for card in cards:
if card['cardType']=='无面值':
card['cardType'] = ''
obj = ReceiveInfo()
obj.rec_id = orderSn
obj.card_id_start = card['start'].strip()
obj.card_id_end = card['end'].strip()
obj.card_nums = card['subTotal']
obj.card_value = card['cardType']
obj.save()
#CardInventory写入卡信息
for i in range(int(card['start']),int(card['end'])+1):
diff = len(card['start'])-len(str(int(card['start'])))
prefix = ''
for j in range(diff):
prefix +='0'
item = CardInventory()
item.order_sn = orderSn
item.is_store = saleType
item.card_no = prefix+str(i)
item.card_value = card['cardType']
item.card_action = '1'
item.card_status = '1'
item.shop_code = shop
item.card_blance='0.00'
item.card_addtime=datetime.datetime.now()
cardList.append(item)
CardInventory.objects.bulk_create(cardList)
res['status']='1'
ActionLog.objects.create(action='信息部发卡',u_name=request.session.get('s_uname'),cards_out=cardStr,add_time=datetime.datetime.now())
del request.session['postToken']
except Exception as e:
print(e)
if hasattr(e,'value'):
res['msg'] = e.value
res['status']='0'
ActionLog.objects.create(action='信息部发卡',u_name=request.session.get('s_uname'),cards_out=cardStr,add_time=datetime.datetime.now(),err_msg=e)
return HttpResponse(json.dumps(res))
示例6: save
# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import setOrderSn [as 别名]
def save(request):
operator = request.session.get('s_uid','')
shopcode = request.session.get('s_shopcode','')
depart = request.session.get('s_depart','')
actionType = request.POST.get('actionType','')
#借卡单号列表
orderSnList = request.POST.get('orderSnList[]','')
orderBorrow = OrderBorrow.objects.filter(order_sn=orderSnList)
if not orderBorrow.count():
return {'status':0,'msg':'此订单不存在'}
buyer = orderBorrow.values('borrow_name', 'borrow_depart', 'borrow_phone').first()
#未退还卡列表
cardList = OrderBorrowInfo.objects.values('card_no','card_balance').filter(order_sn=orderSnList,is_back=None)
#赠卡列表
YcardStr = request.POST.get('YcardStr','')
YcardList = json.loads(YcardStr)
Ycash = request.POST.get('Ycash',0.00)
#支付方式
payStr = request.POST.get('payStr','')
payList = json.loads(payStr)
# 黄金手卡号列表
# hjsStr = request.POST.get('hjsStr','')
# hjsList=[]
# if len(hjsStr)>0:
# hjsStr = hjsStr[0:len(hjsStr)-1]
# hjsList = hjsStr.split(',')
#合计信息
totalVal = 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 = request.POST.get('Ybalance',0.00)
order_sn = ''
res = {}
try:
# 检测session中Token值,判断用户提交动作是否合法
Token = request.session.get('postToken', default=None)
# 获取用户表单提交的Token值
userToken = request.POST.get('postToken', '')
if userToken != Token:
raise MyError('表单重复提交,刷新页面后,重试!')
with transaction.atomic():
order_sn = 'S'+mth.setOrderSn()
payDiscDict = mth.getPayDiscDict()
isThird = False
paymentList = []
for pay in payList:
orderPay = OrderPaymentInfo()
orderPay.order_id = order_sn
orderPay.pay_id = pay['payId']
# 处理混合支付的优惠
is_pay = 1
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)
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'])
#.........这里部分代码省略.........
示例7: save
# 需要导入模块: from sellcard.common import Method [as 别名]
# 或者: from sellcard.common.Method import setOrderSn [as 别名]
def save(request):
operator = request.session.get('s_uid','')
shopcode = request.session.get('s_shopcode','')
#售卡列表
cardStr = request.POST.get('cardStr','')
cardList = json.loads(cardStr)
#合计信息
totalNum = request.POST.get('totalNum',0)
totalVal = request.POST.get('totalVal',0.00)
#借卡人信息
borrowDepart = (request.POST.get('borrowDepart','')).strip()
borrowName = (request.POST.get('borrowName','')).strip()
borrowDepartCode = (request.POST.get('borrowDepartCode','')).strip()
borrowPhone = (request.POST.get('borrowPhone','')).strip()
order_sn = ''
res = {}
try:
# 检测session中Token值,判断用户提交动作是否合法
Token = request.session.get('postToken', default=None)
# 获取用户表单提交的Token值
userToken = request.POST.get('postToken', '')
if userToken != Token:
raise MyError('表单重复提交,刷新页面后,重试!')
with transaction.atomic():
order_sn = 'B'+mth.setOrderSn(OrderBorrow)
infoList = []
for card in cardList:
orderInfo = OrderBorrowInfo()
orderInfo.order_sn = order_sn
orderInfo.card_no = card['cardId']
orderInfo.card_type = card['cardVal']
orderInfo.card_balance = card['cardVal']
infoList.append(orderInfo)
OrderBorrowInfo.objects.bulk_create(infoList)
order = OrderBorrow()
order.borrow_name = borrowName
order.borrow_depart = borrowDepart
order.borrow_depart_code = borrowDepartCode
order.borrow_phone= borrowPhone
order.shopcode = shopcode
order.operator = operator
order.order_val = float(totalVal)
order.order_num = totalNum
order.add_time = datetime.datetime.now()
order.is_paid = '0'
order.order_sn = order_sn
order.save()
#更新卡状态
cardIdList = []
for card in cardList:
cardIdList.append(card['cardId'])
cardNum = len(cardIdList)
resCard = CardInventory.objects.filter(card_no__in=cardIdList,card_status='1',is_store='0')\
.update(card_status='2',card_action='0')
if resCard != cardNum:
raise MyError('CardInventory状态更新失败!')
# 更新Guest
updateConfList = []
updateConfList.append({'ids': cardIdList, 'mode': '1', 'count': cardNum})
resGuest = mth.updateCard(updateConfList)
if resGuest['status'] == 0:
raise MyError(resGuest['msg'])
res["status"] = 1
res["urlRedirect"] = '/kg/sellcard/fornt/borrow/sale/info/?orderSn='+order_sn
ActionLog.objects.create(action='借卡-售卡',u_name=request.session.get('s_uname'),cards_out=cardStr,add_time=datetime.datetime.now())
del request.session['postToken']
except Exception as e:
print(e)
res["status"] = 0
if hasattr(e,'value'):
res['msg'] = e.value
ActionLog.objects.create(action='借卡-售卡',u_name=request.session.get('s_uname'),cards_out=cardStr,add_time=datetime.datetime.now(),err_msg=e)
return HttpResponse(json.dumps(res))