Beispiel #1
0
def new_order_model(poi_id, poi_name, poi_phone, poi_address, order_id, order_stuff, order_price, order_topay, customer_name, customer_phone, customer_address):
	if order_price == '':
		order_price = 0
	# 生成订单详情
	detail = Detail(order_id=order_id, phone=str(poi_phone), name=poi_name, address=poi_address, stuff=order_stuff, 
		customer_name=customer_name, customer_phone=str(customer_phone), customer_address=customer_address,
		total_price=order_price, to_pay=str(order_topay))
	detail.save()
	poi = Merchant.objects.get(id=poi_id)
	# 生成配送编号
	now = int(time.time())
	randdigit = random.randint(0, 10)
	deliver_id = str(now)+str(randdigit)
	# 生成相关站点
	stations = Station.objects.all()
	# 商家最近
	poi_location = getLocation(poi_address)
	poi_nearest = getNearestStation(poi_location, stations)
	# 收货人最近
	customer_location = getLocation(customer_address)
	customer_nearest = getNearestStation(customer_location, stations)
	# 插入订单表
	order=Order(deliver_id=deliver_id, poi_id=poi_id, poi_nearest_id=poi_nearest,
				customer_nearest_id=customer_nearest, order_detail=detail, order_status=ORDER_STATUS['ordered'])
	order.save()	
	
	return order
Beispiel #2
0
def order_new(request):
    if request.method == 'POST':  # 如果ajax请求
        response_data = {}
        poi_id = request.REQUEST.get('poiId')
        poi_name = request.REQUEST.get('poiName')
        poi_phone = request.REQUEST.get('poiPhone')
        poi_address = request.REQUEST.get('poiAddress')
        order_stuff = request.REQUEST.get('orderStuff')
        order_id = request.REQUEST.get('orderId')
        order_price = request.REQUEST.get('orderPrice')
        order_remark = request.REQUEST.get('remark', '')
        if order_price == '':
            order_price = 0
        order_topay = request.REQUEST.get('orderTopay')
        customer_name = request.REQUEST.get('customerName')
        customer_phone = request.REQUEST.get('customerPhone')
        customer_address = request.REQUEST.get('customerAddress')
        # 生成订单详情
        detail = Detail(order_id=order_id,
                        phone=poi_phone,
                        name=poi_name,
                        address=poi_address,
                        stuff=order_stuff,
                        customer_name=customer_name,
                        customer_phone=customer_phone,
                        customer_address=customer_address,
                        total_price=order_price,
                        to_pay=order_topay,
                        remark=order_remark)
        detail.save()
        poi = Merchant.objects.get(id=poi_id)
        # 生成配送编号
        now = int(time.time())
        randdigit = random.randint(0, 100)
        deliver_id = str(now) + str(randdigit)
        # 生成相关站点
        stations = Station.objects.all()
        # 商家最近
        poi_location = getLocation(poi_address)
        if poi.nearest_station is None:
            poi_nearest = getNearestStation(poi_location, stations)
        else:
            poi_nearest = poi.nearest_station_id
        # 收货人最近
        customer_location = getLocation(customer_address)
        customer_nearest = getNearestStation(customer_location, stations)
        # 插入订单表
        order = Order(deliver_id=deliver_id,
                      poi_id=poi_id,
                      poi_nearest_id=poi_nearest,
                      customer_nearest_id=customer_nearest,
                      order_detail=detail,
                      order_status=ORDER_STATUS['ordered'])
        order.save()
        response_data['code'] = 0
        response_data['data'] = deliver_id
        return HttpResponse(json.dumps(response_data),
                            content_type="application/json")
Beispiel #3
0
def new_order_model(poi_id,
                    poi_name,
                    poi_phone,
                    poi_address,
                    order_id,
                    order_stuff,
                    order_price,
                    order_topay,
                    customer_name,
                    customer_phone,
                    customer_address,
                    remark=''):
    if order_price == '':
        order_price = 0
    # 生成订单详情
    detail = Detail(order_id=order_id,
                    phone=str(poi_phone),
                    name=poi_name,
                    address=poi_address,
                    stuff=order_stuff,
                    customer_name=customer_name,
                    customer_phone=str(customer_phone),
                    customer_address=customer_address,
                    total_price=order_price,
                    to_pay=str(order_topay),
                    remark=remark)
    detail.save()
    poi = Merchant.objects.get(id=poi_id)
    # 生成配送编号
    now = int(time.time())
    randdigit = random.randint(0, 100)
    deliver_id = str(now) + str(randdigit)
    # 生成相关站点
    stations = Station.objects.all()
    # 商家最近 todo:直接关联最近站点
    poi_location = getLocation(poi_address)
    poi_nearest = getNearestStation(poi_location, stations)
    print customer_address + str(poi_nearest)
    # 收货人最近
    customer_location = getLocation(customer_address)
    customer_nearest = getNearestStation(customer_location, stations)
    print customer_address + str(customer_nearest)
    # 插入订单表
    order = Order(deliver_id=deliver_id,
                  poi_id=poi_id,
                  poi_nearest_id=poi_nearest,
                  customer_nearest_id=customer_nearest,
                  order_detail=detail,
                  order_status=ORDER_STATUS['ordered'])
    order.save()

    return order
Beispiel #4
0
def order_new(request):
	if request.method == 'POST': # 如果ajax请求
		response_data = {}
		poi_id = request.REQUEST.get('poiId')
		poi_name = request.REQUEST.get('poiName')
		poi_phone = request.REQUEST.get('poiPhone')
		poi_address = request.REQUEST.get('poiAddress')
		order_stuff = request.REQUEST.get('orderStuff')
		order_id = request.REQUEST.get('orderId')
		order_price = request.REQUEST.get('orderPrice')
		if order_price == '':
			order_price = 0
		order_topay = request.REQUEST.get('orderTopay')
		customer_name = request.REQUEST.get('customerName')
		customer_phone = request.REQUEST.get('customerPhone')
		customer_address = request.REQUEST.get('customerAddress')
		# 生成订单详情
		detail = Detail(order_id=order_id, phone=poi_phone, name=poi_name, address=poi_address, stuff=order_stuff, 
			customer_name=customer_name, customer_phone=customer_phone, customer_address=customer_address,
			total_price=order_price, to_pay=order_topay)
		detail.save()
		poi = Merchant.objects.get(id=poi_id)
		# 生成配送编号
		now = int(time.time())
		randdigit = random.randint(0, 10)
		deliver_id = str(now)+str(randdigit)
		# 生成相关站点
		stations = Station.objects.all()
		# 商家最近
		poi_location = getLocation(poi_address)
		poi_nearest = getNearestStation(poi_location, stations)
		# 收货人最近
		customer_location = getLocation(customer_address)
		customer_nearest = getNearestStation(customer_location, stations)
		# 插入订单表
		order=Order(deliver_id=deliver_id, poi_id=poi_id, poi_nearest_id=poi_nearest,
					customer_nearest_id=customer_nearest, order_detail=detail, order_status=ORDER_STATUS['ordered'])
		order.save()
		response_data['code'] = 0
		response_data['data'] = deliver_id
		return HttpResponse(json.dumps(response_data), content_type="application/json")