def closeQuCan(self, params=''): now = datetime.datetime.now() inter = app.config['JOB_STATUS_CHANGES']['hours'] date_before_hours = now + datetime.timedelta(hours=int(inter)) list = PayOrder.query.filter_by( status = 1, express_status = -6 ).\ filter( PayOrder.created_time <= getFormatDate( date = date_before_hours ) ).all() if not list: app.logger.info("no data~~") return pay_target = PayService() for item in list: pay_target.confirmOrder(pay_order_id=item.id) app.logger.info("QuCan is over~~") return
def orderOps(): resp = {'code': 200, 'msg': '操作成功~', 'data': {}} req = request.values order_id = req['id'] if 'id' in req else 0 act = req['act'] if 'act' in req else '' # pay_order_info = PayOrder.query.filter_by( id = id ).first() # if not pay_order_info: # resp['code'] = -1 # resp['msg'] = "系统繁忙。请稍后再试~~" # return jsonify(resp) app.logger.info("test 1") target = PayService() if act == "take": # 确认取餐 result = target.confirmOrder(pay_order_id=order_id) if act == "express": # 确认到账——进行sale和成功回调 # pay_order_info.express_status = -6 # -6 # pay_order_info.updated_time = getCurrentDate() # db.session.add( pay_order_info ) # 修改新增售卖记录 和 销售量 result = target.addPayCallbackData(pay_order_id=order_id, type='pay', data='审核确认') app.logger.info("result is1 {}".format(result)) if act == "cancel": # 取消订单——归还库存 result = target.addPayCallbackData(pay_order_id=order_id, type='cancel', data='审核取消') if not result: app.logger.info("result is 2{}".format(result)) resp['code'] = -1 resp['msg'] = "系统繁忙。请稍后再试~~" return jsonify(resp) return jsonify(resp)