def order_create(): resp = {'code': 200, 'msg': '操作成功~', 'data': {}} req = request.values type = req['type'] if 'type' in req else '' note = req['note'] if 'note' in req else '' express_address_id = int( req['express_address_id'] ) if 'express_address_id' in req and req['express_address_id'] else 0 params_goods = req['goods'] if 'goods' in req else None items = [] if params_goods: items = json.loads(params_goods) if len(items) < 1: resp['code'] = -1 resp['msg'] = '下单失败:没有选择商品~~' return jsonify(resp) member_info = g.member_info target = PayService() params = {} resp = target.create_order(member_info.id, items, params) if resp['code'] == 200 and type == "cart": CartService.delete_item(member_info.id, items) return jsonify(resp)
def orderCreate(): resp = {'code': 200, 'msg': '操作成功~', 'data': {}} req = request.values type = req['type'] if 'type' in req else '' note = req['note'] if 'note' in req else '' express_address_id = int( req['express_address_id'] ) if 'express_address_id' in req and req['express_address_id'] else 0 params_goods = req['goods'] if 'goods' in req else None items = [] if params_goods: items = json.loads(params_goods) if len(items) < 1: resp['code'] = -1 resp['msg'] = "下单失败:没有选择商品~~" return jsonify(resp) address_info = MemberAddress.query.filter_by(id=express_address_id).first() if not address_info or not address_info.status: resp['code'] = -1 resp['msg'] = "下单失败:快递地址不对~~" return jsonify(resp) member_info = g.member_info target = PayService() params = { "note": note, 'express_address_id': address_info.id, 'express_info': { 'mobile': address_info.mobile, 'nickname': address_info.nickname, "address": "%s%s%s%s" % (address_info.province_str, address_info.city_str, address_info.area_str, address_info.address) } } resp = target.create_order(member_info.id, items, params) # 如果是来源购物车的,下单成功将下单的商品去掉 if resp['code'] == 200 and type == "cart": CartService.deleteItem(member_info.id, items) return jsonify(resp)