def ops(): form = OrderOpsForm().validate() order_sn, act = form.order_sn.data, form.act.data member = Member.query.get_or_404_deleted(g.member.id, msg='指定会员不存在') order = member.orders.filter_by(order_sn=order_sn).first_or_404(msg='订单号有误, 指定订单不存在') if act == 'cancel': return OrderService().cancel_order(order) if act == 'confirm': return OrderService().confirm_order(order) return OrderException(msg='无效操作')
def pay_deadline(): now = datetime.now() date_30mins_ago = (now - timedelta(seconds=1)).timestamp() orders = Order.query.filter_by( order_status=OrderStatus.UNPAID.value).filter( Order.create_time <= date_30mins_ago).all() if not orders: app.logger.info('没有订单数据') return for item in orders: OrderService.cancel_order(item) app.logger.info('超过30分钟未支付订单已关闭')
def pay(self): # 检测订单情况 self.__check_order_valid() # 支付前,再次进行库存量检测 order_service = OrderService() status = order_service.check_order_stock(self.order_id) if not status['pass']: return status
def pay(self): # 1. 检测订单情况 self.__check_order_valid() # 2. 支付前,再次进行库存量检测 status = OrderService().check_order_stock(self.order_id) if not status['pass']: return status return self.__make_wx_pre_order(status['order_price'])
def create(): form = OrderCreateForm().validate() goods, address, type = form.goods.data, form.address.data, form.type.data resp = OrderService(goods, address, type, g.member.id).create_order() if resp and type == 'cart': member = Member.query.get_or_404_deleted(g.member.id) with db.auto_commit(): member.carts.delete() return jsonify(resp)
def info(): goods = GoodsForm().validate().goods.data foods_resp, pay_price, freight = OrderService(goods).get_order() resp = { 'food_list': foods_resp, 'pay_price': str(pay_price), 'yun_price': str(freight), 'total_price': str(pay_price + freight) } return jsonify(resp)
def place_order(): '''提交订单(管理员不能调用)''' products = OrderPlace().validate_for_api().products.data order = OrderService() status = order.palce(uid=g.user.uid, o_products=products) return Success(status)
def delivery(): '''订单发货''' order_id = OrderIDValidator().nt_data.order_id rv = OrderService.delivery(order_id) return Success(rv)
def place_order(): '''提交订单''' products = OrderPlaceValidator().validate_for_api().products.data status = OrderService().palce(uid=g.user.id, o_products=products) return Success(status)