def test_AddChangeOrderPrice_Onlinepayment(self): ws = webservice() ws.login(self.UserShop2.username, self.UserShop2.password) update( 'update dlorder.dl_order_orderinfo set order_status = ? where order_no = ?', 'C011', self.UserShop2.orderNo) RstDb = select_one( 'select * from dlorder.dl_order_orderinfo where order_no = ?', self.UserShop2.orderNo) # 在线支付订单加价调用接口 ChangePriceRst = ws.changeOrderPrice( orderNo=self.UserShop2.orderNo, orderDiscountAmount='-100', orderChangeAmount=str(int(RstDb.order_retail_amount) + 100), orderStatus=RstDb.order_status) self.assertEquals(ChangePriceRst.code, 200) self.assertEquals(ChangePriceRst.model['success'], '0') # 检验订单加价后是否修改成功 RstDb1 = select_one( 'select * from dlorder.dl_order_orderinfo where order_no = ?', self.UserShop2.orderNo) self.assertEquals(RstDb1.order_amount, RstDb.order_retail_amount + 100) update( 'update dlorder.dl_order_orderinfo set order_amount = ? where order_no = ?', RstDb.order_retail_amount, self.UserShop2.orderNo)
def test_createOrderByShoppingcart_twoDealer(self): update('update dlcompany.dl_store_base_info set isCOD = ? where store_id = ?', 1,self.Merch4.storeId) ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) ws.addShoppingcar(merchId=self.Merch1.goodsId, merchCount='1', sellerId=self.Merch1.seller_store_id, sellerName=self.Merch1.sellerName) shopcart1 = Shoppingcart.find_first('where user_id = ? and goods_id = ?', self.UserShop.userId, self.Merch1.goodsId) ws.addShoppingcar(merchId=self.Merch4.goodsId, merchCount='1', sellerId=self.Merch4.seller_store_id, sellerName=self.Merch4.sellerName) shopcart2 = Shoppingcart.find_first('where user_id = ? and goods_id = ?', self.UserShop.userId, self.Merch4.goodsId) invoice = {"invoiceId":self.UserShop.invoiceId, "invoiceType":"N011","needInvoice":"0","invoiceHeader":self.UserShop.invoiceHeader} deliverAddress = {"deliverAddress":self.UserShop.deliverAddress, "deliverMobile":self.UserShop.deliverMobile, "deliverPerson":self.UserShop.deliverPerson} sellerList = [] sellerList.append({"sellerId":self.Merch1.shopcartSellerId,"sellerName":self.Merch1.sellerName,"isYijipayAccount":self.Merch1.isYijipayAccount,"codFlag":self.Merch1.codFlag, "supportVatInvoice":self.Merch1.supportVatInvoice,"comment":"createOrderByShoppingcart comment.","merchList": [{"id":shopcart1.id,"merchId":self.Merch1.goodsId,"merchBarCode":self.Merch1.productBarCode}]}) sellerList.append({"sellerId":self.Merch4.shopcartSellerId,"sellerName":self.Merch4.sellerName,"isYijipayAccount":self.Merch4.isYijipayAccount,"codFlag":"0_split_0", "supportVatInvoice":self.Merch4.supportVatInvoice,"comment":"createOrderByShoppingcart comment.","merchList": [{"id":shopcart2.id,"merchId":self.Merch4.goodsId,"merchBarCode":self.Merch4.productBarCode}]}) order = ws.createOrderByShoppingcart(payWay='2',invoice=invoice, deliverAddress=deliverAddress, sellerList=sellerList) self.assertEqual(order.model['success'], '0') # 校验订单号和交易号是否匹配 orderInfoDb = select_one('select * from dlorder.dl_order_orderinfo where pay_no = ?', order.model['createOrderInfoModel']['cashOnDeliveryModelList'][0]['paymentNo']) # 支付方式为货到付款 self.assertEqual(orderInfoDb.pay_type, '2') self.assertEqual(orderInfoDb.order_no, order.model['createOrderInfoModel']['cashOnDeliveryModelList'][0]['orderNo']) self.assertEqual(orderInfoDb.order_amount, int(order.model['createOrderInfoModel']['cashOnDeliveryModelList'][0]['price'])) # 校验订单号和交易号是否匹配 orderInfoDb = select_one('select * from dlorder.dl_order_orderinfo where pay_no = ?', order.model['createOrderInfoModel']['cashOnDeliveryModelList'][1]['paymentNo']) # 支付方式为货到付款 self.assertEqual(orderInfoDb.pay_type, '2') self.assertEqual(orderInfoDb.order_no, order.model['createOrderInfoModel']['cashOnDeliveryModelList'][1]['orderNo']) self.assertEqual(orderInfoDb.order_amount, int(order.model['createOrderInfoModel']['cashOnDeliveryModelList'][1]['price']))
def test_RestoreOriginalPrice_cashondelivery(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) RstDb = select_one( 'select * from dlorder.dl_order_orderinfo where order_no = ?', self.UserShop.orderNo) # 货到付款订单减价调用接口 ChangePriceRst = ws.changeOrderPrice( orderNo=self.UserShop.orderNo, orderDiscountAmount='100', orderChangeAmount=str(int(RstDb.order_retail_amount) - 100), orderStatus=RstDb.order_status) self.assertEquals(ChangePriceRst.code, 200) self.assertEquals(ChangePriceRst.model['success'], '0') # 检验订单减价后是否修改成功 RstDb1 = select_one( 'select * from dlorder.dl_order_orderinfo where order_no = ?', self.UserShop.orderNo) self.assertEquals(RstDb1.order_amount, RstDb.order_retail_amount - 100) #减价后恢复原价 ChangePriceRst1 = ws.changeOrderPrice(orderNo=self.UserShop.orderNo, orderDiscountAmount='0', orderChangeAmount=str( RstDb1.order_retail_amount), orderStatus=RstDb1.order_status) self.assertEquals(ChangePriceRst1.code, 200) self.assertEquals(ChangePriceRst1.model['success'], '0') #检验是否恢复原价 RstDb2 = select_one( 'select * from dlorder.dl_order_orderinfo where order_no = ?', self.UserShop.orderNo) self.assertEquals(RstDb2.order_amount, RstDb.order_amount)
def assertSnapshot(self, rsp, order, merch): orderSnapshot = select_one('select * from dlorder.dl_order_ordersnapshot where order_no = ?', order.orderNo) orderItem = select_one('select * from dlorder.dl_order_orderitem where order_no = ?', order.orderNo) self.assertEqual(rsp.model['merchSnapshot']['merchId'], orderSnapshot.merchandise_id) self.assertEqual(rsp.model['merchSnapshot']['merchNo'], merch.merchNo) self.assertEqual(rsp.model['merchSnapshot']['merchName'], merch.fullName) self.assertEqual(rsp.model['merchSnapshot']['merchCount'], str(orderItem.num)) self.assertEqual(rsp.model['merchSnapshot']['merchSpec'], merch[u'包装规格'].encode('utf-8')) self.assertEqual(rsp.model['merchSnapshot']['unitPrice'], str(float(merch.unitPrice)/100)) self.assertEqual(rsp.model['merchSnapshot']['sellerName'], merch.sellerName) self.assertEqual(rsp.model['merchSnapshot']['description'], '') self.assertEqual(rsp.model['merchSnapshot']['picUrl'], merch.picUrl) for i in range(0, len(rsp.model['merchSnapshot']['albumPicUrl'])): if i == 0: self.assertEqual(rsp.model['merchSnapshot']['albumPicUrl'][0], merch['detailPicUrl']) else : self.assertEqual(rsp.model['merchSnapshot']['albumPicUrl'][i], merch['detailPicUrl'+str(i+1)]) for i in range(0, len(rsp.model['merchSnapshot']['propertyList'])): if rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '生产商': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'生产商'].decode('utf-8')) elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '净含量': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'净含量老'].encode('utf-8') + ' ' +merch[u'净含量单位'].encode('utf-8')) # elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '净含量单位': # self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'], merch[u'净含量单位'].encode('utf-8')) elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '保质期': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'保质期'].encode('utf-8')) elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '包装规格': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'包装规格'].encode('utf-8')) elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '酒精度': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'酒精度老'].encode('utf-8') + u' 度') elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '储藏方法': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'储藏方法'].encode('utf-8')) elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '执行标准号': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'执行标准号'].encode('utf-8')) elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '生产许可证编号': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'生产许可证编号'].encode('utf-8')) elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '原料': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'原料'].encode('utf-8')) elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '适用场景': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'适用场景'].encode('utf-8')) elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '产地': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'产地'].encode('utf-8')) elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '香型': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'香型'].encode('utf-8')) elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '色泽': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'色泽'].encode('utf-8')) elif rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] == '商品类型': self.assertEqual(rsp.model['merchSnapshot']['propertyList'][i]['secondValue'].strip(), merch[u'商品类型'].encode('utf-8')) else : self.assertEqual(True,False,rsp.model['merchSnapshot']['propertyList'][i]['firstValue'] + " is not find in the excel!")
def test_AlreadypaidChangeOrderPrice_Onlinepayment(self): ws = webservice() ws.login(self.UserShop2.username, self.UserShop2.password) update( 'update dlorder.dl_order_orderinfo set order_status = ? where order_no = ?', 'C011', self.UserShop2.orderNo) RstDb = select_one( 'select * from dlorder.dl_order_orderinfo where order_no = ?', self.UserShop2.orderNo) # 从数据库中修改订单状态为已付款(C019) update( 'update dlorder.dl_order_orderinfo set order_status = ? where order_no = ?', 'C019', self.UserShop2.orderNo) ChangePriceRst = ws.changeOrderPrice( orderNo=self.UserShop2.orderNo, orderDiscountAmount='100', orderChangeAmount=str(int(RstDb.order_retail_amount) - 100), orderStatus=RstDb.order_status) # 校验已完成的订单改价失败 self.assertEquals(ChangePriceRst.model['success'], '1') update( 'update dlorder.dl_order_orderinfo set order_status = ? where order_no = ?', 'C011', self.UserShop2.orderNo)
def test_getArea_nation(self): ws = webservice() nationList = ws.getArea('0') nationDb = select_one( 'select * from dlpublic.dl_area where area_parent_code = ?', '0') self.assertEqual(nationList.code, 200) self.assertEqual(nationList.model['success'], '0') self.assertEqual(nationList.model['areaList'][0]['areaCode'], nationDb.area_code) self.assertEqual(nationList.model['areaList'][0]['areaName'], nationDb.area_name)
def test_createOrderByShoppingcart_one(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) ws.addShoppingcar(merchId=self.Merch1.goodsId, merchCount='1', sellerId=self.Merch1.seller_store_id, sellerName=self.Merch1.sellerName) shopcart = Shoppingcart.find_first('where user_id = ? and goods_id = ?', self.UserShop.userId, self.Merch1.goodsId) invoice = {"invoiceId":self.UserShop.invoiceId, "invoiceType":"N011","needInvoice":"0","invoiceHeader":self.UserShop.invoiceHeader} deliverAddress = {"deliverAddress":self.UserShop.deliverAddress, "deliverMobile":self.UserShop.deliverMobile, "deliverPerson":self.UserShop.deliverPerson} sellerList = [] sellerList.append({"sellerId":self.Merch1.shopcartSellerId,"sellerName":self.Merch1.sellerName,"isYijipayAccount":self.Merch1.isYijipayAccount,"codFlag":self.Merch1.codFlag, "supportVatInvoice":self.Merch1.supportVatInvoice,"comment":"createOrderByShoppingcart comment.","merchList": [{"id":shopcart.id,"merchId":self.Merch1.goodsId,"merchBarCode":self.Merch1.productBarCode}]}) order = ws.createOrderByShoppingcart(payWay='2',invoice=invoice, deliverAddress=deliverAddress, sellerList=sellerList) self.assertEqual(order.model['success'], '0') # 校验订单号和交易号是否匹配 orderInfoDb = select_one('select * from dlorder.dl_order_orderinfo where pay_no = ?', order.model['createOrderInfoModel']['cashOnDeliveryModelList'][0]['paymentNo']) # 支付方式为货到付款 self.assertEqual(orderInfoDb.pay_type, '2') self.assertEqual(orderInfoDb.order_no, order.model['createOrderInfoModel']['cashOnDeliveryModelList'][0]['orderNo']) self.assertEqual(orderInfoDb.order_amount, int(order.model['createOrderInfoModel']['cashOnDeliveryModelList'][0]['price'])) # 校验发票是否是提交的发票 orderInvoiceDb = select_one('select * from dlorder.dl_order_orderinvoice where pay_no = ?', order.model['createOrderInfoModel']['cashOnDeliveryModelList'][0]['paymentNo']) self.assertEqual(orderInvoiceDb.invoice_header, invoice['invoiceHeader']) # 校验收货地址是否是提交的收货地址 orderDetailDb = select_one('select * from dlorder.dl_order_orderdetail where order_no = ?', order.model['createOrderInfoModel']['cashOnDeliveryModelList'][0]['orderNo']) self.assertEqual(orderDetailDb.buyer_id, self.UserShop.companyId) self.assertEqual(orderDetailDb.receive_person, deliverAddress['deliverPerson']) self.assertEqual(orderDetailDb.receive_tel, deliverAddress['deliverMobile']) self.assertEqual(orderDetailDb.receive_address, deliverAddress['deliverAddress']) # 校验商品是否是提交的商品 orderItemDb = select_one('select * from dlorder.dl_order_orderitem where order_no = ?', order.model['createOrderInfoModel']['cashOnDeliveryModelList'][0]['orderNo']) self.assertEqual(orderItemDb.merchandise_id, self.Merch1.goodsId) self.assertEqual(orderItemDb.num, 1)
def test_AlreadCancelChangeOrderPrice_cashondelivery(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) RstDb = select_one( 'select * from dlorder.dl_order_orderinfo where order_no = ?', self.UserShop.orderNo) # 从数据库中修改订单状态为已取消(C012) update( 'update dlorder.dl_order_orderinfo set order_status = ? where order_no = ?', 'C012', self.UserShop.orderNo) ChangePriceRst = ws.changeOrderPrice( orderNo=self.UserShop.orderNo, orderDiscountAmount='100', orderChangeAmount=str(int(RstDb.order_retail_amount) - 100), orderStatus=RstDb.order_status) #校验已取消的订单改价失败 self.assertEquals(ChangePriceRst.model['success'], '1') update( 'update dlorder.dl_order_orderinfo set order_status = ? where order_no = ?', 'C020', self.UserShop.orderNo)
def assertOrderList(self, rsq, order, merch, payType='2', paymentOrderButtomList='00020', buttomList='0100001', payWay=None, receiveStatus='0'): #paymentOrder = select('select * from dlpay.dl_payment_order where pay_no = ?', order.paymentNo) #orderDetail = select('select * from dlorder.dl_order_orderdetail where order_no =', order.orderNo) orderInfo = select_one( 'select * from dlorder.dl_order_orderinfo where order_no = ?', order.orderNo) orderItem = select_one( 'select * from dlorder.dl_order_orderitem where order_no = ?', order.orderNo) flag = 0 for i in range(0, len(rsq.model['paymentOrderList'])): if rsq.model['paymentOrderList'][i][ 'paymentNo'] == order.paymentNo: self.assertEqual( rsq.model['paymentOrderList'][i]['placeOrderTime'], str(orderInfo.gmt_created)) self.assertEqual(rsq.model['paymentOrderList'][i]['payType'], payType) self.assertEqual( rsq.model['paymentOrderList'][i]['paymentOrderMerchCount'], str(orderItem.num)) self.assertEqual( rsq.model['paymentOrderList'][i]['paymentOrderTotalPrice'], str(orderItem.amount)) self.assertIsNone( rsq.model['paymentOrderList'][i]['paymentOrderButtomList']) self.assertEqual( rsq.model['paymentOrderList'][i]['paymentPayStatus'], orderInfo.pay_status) self.assertIsNone( rsq.model['paymentOrderList'][i]['payStatus2Middle']) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['orderId'], orderInfo.id) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['orderNo'], order.orderNo) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['paymentNo'], order.paymentNo) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['payType'], orderInfo.pay_type) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0]['payWay'], payWay) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['errorStatus'], '1') self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['cancelStatus'], '0') self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['receiveStatus'], receiveStatus) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['buttomList'], buttomList) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['orderStatus'], orderInfo.order_status) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['totalPrice'], str(orderInfo.order_retail_amount)) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['orderRetailAmount'], str(orderInfo.order_retail_amount)) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['isUseCoupon'], '1') self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['couponFeeCount'], '000') self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['orderMerchCount'], str(orderItem.num)) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['sellerId'], merch.sellerId) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['sellerName'], merch.sellerName) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['isYijipayAccount'], merch.isYijipayAccount) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['promotionList'], []) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['merchList'][0]['merchId'], orderItem.merchandise_id) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['merchList'][0]['merchName'], orderItem.merchandise_name) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['merchList'][0]['merchBarCode'], orderItem.merchandise_barcode) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['merchList'][0]['merchCount'], str(orderItem.num)) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['merchList'][0]['picUrl'], merch.picUrl) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['merchList'][0]['merchSpec'], merch[u'包装规格']) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['merchList'][0]['costPrice'], merch.unitPrice) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['merchList'][0]['unitPrice'], merch.unitPrice) self.assertEqual( rsq.model['paymentOrderList'][i]['orderList'][0] ['merchList'][0]['promotionType'], '-1') flag += 1 self.assertEqual(flag, 1, 'order is not found or is found twice')
def assertOrderDetail(self, rsq, order, buyer, merch, buttomList='00000100'): paymentOrder = select_one( 'select * from dlpay.dl_payment_order where pay_no = ?', order.paymentNo) orderDetail = select_one( 'select * from dlorder.dl_order_orderdetail where order_no = ?', order.orderNo) orderInfo = select_one( 'select * from dlorder.dl_order_orderinfo where order_no = ?', order.orderNo) orderItem = select_one( 'select * from dlorder.dl_order_orderitem where order_no = ?', order.orderNo) self.assertEqual(rsq.model['orderDetail']['orderId'], orderInfo.id) self.assertEqual(rsq.model['orderDetail']['orderNo'], orderInfo.order_no) self.assertEqual(rsq.model['orderDetail']['paymentNo'], orderInfo.pay_no) self.assertEqual(rsq.model['orderDetail']['placeOrderTime'], str(orderInfo.gmt_created)) self.assertEqual(rsq.model['orderDetail']['orderId'], orderInfo.id) self.assertEqual(rsq.model['orderDetail']['orderStatus'], orderInfo.order_status) self.assertEqual(rsq.model['orderDetail']['payType'], orderInfo.pay_type) if rsq.model['orderDetail']['payTime'] is None: self.assertEqual(rsq.model['orderDetail']['payTime'], None) else: self.assertEqual(rsq.model['orderDetail']['payTime'], paymentOrder.pay_time) if rsq.model['orderDetail']['payChannel'] is None: self.assertEqual(rsq.model['orderDetail']['payTime'], None) else: self.assertEqual(rsq.model['orderDetail']['payChannel'], paymentOrder.pay_channel) self.assertEqual(rsq.model['orderDetail']['sellerId'], merch.sellerId) self.assertEqual(rsq.model['orderDetail']['sellerName'], merch.sellerName) self.assertEqual(rsq.model['orderDetail']['buyerId'], buyer.companyId) self.assertEqual(rsq.model['orderDetail']['buyerName'], buyer.fullName) self.assertEqual(rsq.model['orderDetail']['errorStatus'], '1') if orderInfo.cancel_status == 'normal': self.assertEqual(rsq.model['orderDetail']['cancelStatus'], '0') else: self.assertEqual(rsq.model['orderDetail']['cancelStatus'], '1') if orderInfo.confirm_status == 'unreceive': self.assertEqual(rsq.model['orderDetail']['receiveStatus'], '0') else: self.assertEqual(rsq.model['orderDetail']['receiveStatus'], '1') self.assertEqual(rsq.model['orderDetail']['orderMerchCount'], str(orderItem.num)) self.assertEqual(rsq.model['orderDetail']['comment'], orderDetail.remarks) self.assertEqual(rsq.model['orderDetail']['totalPrice'], str(orderDetail.total_amount)) if orderInfo.order_coupon_amount == 0: self.assertEqual(rsq.model['orderDetail']['isUseCoupon'], '1') self.assertEqual(rsq.model['orderDetail']['couponFeeCount'], '0') self.assertEqual(rsq.model['orderDetail']['couponUseAmt'], '0') else: self.assertEqual(rsq.model['orderDetail']['isUseCoupon'], '0') orderCoupon = select_one( 'select * from dlorder.dl_order_ordercoupon where order_no =', order.orderNo) self.assertEqual(rsq.model['orderDetail']['couponFeeCount'], '0') self.assertEqual(rsq.model['orderDetail']['couponUseAmt'], orderCoupon.coupon_info[0]['couponAmt']) self.assertEqual(rsq.model['orderDetail']['buttomList'], buttomList) if orderInfo.order_discount_amount is None: self.assertEqual(rsq.model['orderDetail']['orderDiscountAmount'], '0') else: self.assertEqual(rsq.model['orderDetail']['orderDiscountAmount'], orderInfo.order_discount_amount) # 商品列表 self.assertEqual(rsq.model['orderDetail']['merchList'][0]['merchId'], merch.goodsId) self.assertEqual(rsq.model['orderDetail']['merchList'][0]['merchName'], merch.fullName) self.assertEqual( rsq.model['orderDetail']['merchList'][0]['merchBarCode'], merch.productBarCode) self.assertEqual( rsq.model['orderDetail']['merchList'][0]['merchCount'], str(orderItem.num)) self.assertEqual(rsq.model['orderDetail']['merchList'][0]['picUrl'], merch.picUrl) self.assertEqual(rsq.model['orderDetail']['merchList'][0]['merchSpec'], merch[u'包装规格']) self.assertEqual(rsq.model['orderDetail']['merchList'][0]['costPrice'], str(orderItem.cost_price)) self.assertEqual(rsq.model['orderDetail']['merchList'][0]['unitPrice'], str(orderItem.unit_price)) # 促销列表 if orderInfo.ispromotion == 0: self.assertEqual( rsq.model['orderDetail']['merchList'][0]['promotionType'], '-1') self.assertEqual(rsq.model['orderDetail']['promotionList'], []) else: orderPromotion = select_one( 'select * from dlorder.dl_order_promotion_detail where order_no =', order.orderNo) if orderPromotion.promotion_type == 'fulladd': self.assertEqual( rsq.model['orderDetail']['merchList']['promotionType'], '1') self.assertEqual( rsq.model['orderDetail']['promotionList']['promotionType'], '0') self.assertEqual( rsq.model['orderDetail']['promotionList'] ['promotionDetail'], orderPromotion.promotion_detail) self.assertEqual( rsq.model['orderDetail']['promotionList']['reduceValue'], '0') self.assertEqual( rsq.model['orderDetail']['promotionList']['reduceType'], '') if orderPromotion.promotion_type == 'unitdown': self.assertEqual( rsq.model['orderDetail']['merchList']['promotionType'], '2') self.assertEqual( rsq.model['orderDetail']['promotionList']['promotionType'], '1') self.assertEqual( rsq.model['orderDetail']['promotionList'] ['promotionDetail'], orderPromotion.promotion_detail) self.assertEqual( rsq.model['orderDetail']['promotionList']['reduceValue'], orderPromotion.amount) self.assertEqual( rsq.model['orderDetail']['promotionList']['reduceType'], '0') if orderPromotion.promotion_type == 'fulldown': self.assertEqual( rsq.model['orderDetail']['merchList']['promotionType'], '2') self.assertEqual( rsq.model['orderDetail']['promotionList']['promotionType'], '1') self.assertEqual( rsq.model['orderDetail']['promotionList'] ['promotionDetail'], orderPromotion.promotion_detail) self.assertEqual( rsq.model['orderDetail']['promotionList']['reduceValue'], orderPromotion.amount) self.assertEqual( rsq.model['orderDetail']['promotionList']['reduceType'], '1') # 收货地址 self.assertEqual( rsq.model['orderDetail']['deliverAddress']['deliverPerson'], orderDetail.receive_person) self.assertEqual( rsq.model['orderDetail']['deliverAddress']['deliverAddress'], orderDetail.receive_address) self.assertEqual( rsq.model['orderDetail']['deliverAddress']['deliverMobile'], orderDetail.receive_tel) # 发票 orderInvoice = select_one( 'select * from dlorder.dl_order_orderinvoice where order_no = ?', order.orderNo) self.assertEqual(rsq.model['orderDetail']['invoice']['invoiceType'], orderInvoice.invoice_type) self.assertEqual(rsq.model['orderDetail']['invoice']['invoiceHeader'], orderInvoice.invoice_header) self.assertEqual(rsq.model['orderDetail']['invoice']['companyName'], orderInvoice.company_name) self.assertEqual( rsq.model['orderDetail']['invoice']['taxpayerRegistrationNumber'], orderInvoice.invoice_number) # 订单跟踪 orderLog = select( 'select * from dlorder.dl_order_orderlog where order_no = ?', order.orderNo) self.assertEqual(len(rsq.model['orderDetail']['log']), len(orderLog)) if len(rsq.model['orderDetail']['log']) == 1: self.assertIsNotNone( rsq.model['orderDetail']['log'][0]['operationTime']) self.assertEqual( rsq.model['orderDetail']['log'][0]['operationDesc'], orderLog[0]['deal_descrip'])