<!--#include file="../Start.asp"-->
<!--#include file="Channel_Config.asp"-->
<!--#include file="../Include/PowerEasy.Cache.asp"-->
<!--#include file="../Include/PowerEasy.Channel.asp"-->
<!--#include file="../Include/PowerEasy.Common.Front.asp"-->
<!--#include file="../Include/PowerEasy.OrderFlow.asp"-->
<%
'**************************************************************
' Software name: PowerEasy SiteWeaver
' Web: http://www.powereasy.net
' Copyright (C) 2005－2008 佛山市动易网络科技有限公司 版权所有
'**************************************************************

'判断是否需要注册
If UserLogined = False And EnableGuestBuy = False Then
    Response.Write XmlText_Class("ShowTips_GuestBuy", "<br><br><p align='center'>请先<a href='../User/User_Login.asp'>登录</a>！</p>")
    Response.End
End If

ContacterName = PE_HTMLEncode(Trim(Request("ContacterName")))
Address = PE_HTMLEncode(Trim(Request("Address")))
ZipCode = PE_HTMLEncode(Trim(Request("ZipCode")))
Phone = PE_HTMLEncode(Trim(Request("Phone")))
Email = PE_HTMLEncode(Trim(Request("Email")))
Mobile = PE_HTMLEncode(Trim(Request("Mobile")))
AgentName = PE_HTMLEncode(Trim(Request("AgentName")))
PaymentType = Trim(Request("PaymentType"))
DeliverType = Trim(Request("DeliverType"))
NeedInvoice = Trim(Request("NeedInvoice"))
InvoiceContent = PE_HTMLEncode(Trim(Request("InvoiceContent")))
Remark = PE_HTMLEncode(Trim(Request("Remark")))
If ContacterName = "" Then
    FoundErr = True
    ErrMsg = ErrMsg & "<li>请输入收货人姓名！</li>"
End If
If Address = "" Then
    FoundErr = True
    ErrMsg = ErrMsg & "<li>请输入收货人地址！</li>"
End If
If ZipCode = "" Then
    FoundErr = True
    ErrMsg = ErrMsg & "<li>请输入收货人邮编！</li>"
Else
    If Not IsNumeric(ZipCode) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>邮编格式错误！</li>"
    End If
End If
If Phone = "" Then
    FoundErr = True
    ErrMsg = ErrMsg & "<li>请输入收货人电话！</li>"
Else
    If IsValidPhone(Phone) = False Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>收货人电话格式错误！</li>"
    End If
End If
If Not IsNumeric(Mobile) And Mobile <> "" Then
    FoundErr = True
    ErrMsg = ErrMsg & "<li>收货人手机格式错误！</li>"
End If
If Email = "" Then
    FoundErr = True
    ErrMsg = ErrMsg & "<li>请输入收货人Email！</li>"
Else
    If IsValidEmail(Email) = False Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>收货人Email有错误！</li>"
    End If
End If
If PaymentType = "" Then
    FoundErr = True
    ErrMsg = ErrMsg & "<li>请指定付款方式！</li>"
Else
    PaymentType = PE_CLng(PaymentType)
    Set rsPaymentType = Conn.Execute("select * from PE_PaymentType where TypeID=" & PaymentType & "")
    If rsPaymentType.BOF And rsPaymentType.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>找不到指定的付款方式！</li>"
    Else
        PaymentTypeName = rsPaymentType("TypeName")
        If rsPaymentType("Intro") <> "" Then
            PaymentTypeName = PaymentTypeName & "<font color='red'>（" & rsPaymentType("Intro") & "）</font>"
        End If
        Discount_Payment = rsPaymentType("Discount")
    End If
    Set rsPaymentType = Nothing
End If
If DeliverType = "" Then
    FoundErr = True
    ErrMsg = ErrMsg & "<li>请指定送货方式！</li>"
Else
    DeliverType = PE_CLng(DeliverType)
    Set rsDeliverType = Conn.Execute("select * from PE_DeliverType where TypeID=" & DeliverType & "")
    If rsDeliverType.BOF And rsDeliverType.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>找不到指定的送货方式！</li>"
    Else
        DeliverTypeName = rsDeliverType("TypeName")
        If rsDeliverType("Intro") <> "" Then
            DeliverTypeName = DeliverTypeName & "<font color='red'>（" & rsDeliverType("Intro") & "）</font>"
        End If
        ChargeType = PE_CDbl(rsDeliverType("ChargeType"))
        ReleaseType = PE_CLng(rsDeliverType("ReleaseType"))
        MinMoney1 = PE_CDbl(rsDeliverType("MinMoney1"))
        ReleaseCharge = PE_CDbl(rsDeliverType("ReleaseCharge"))
        MinMoney2 = PE_CDbl(rsDeliverType("MinMoney2"))
        MaxCharge = PE_CDbl(rsDeliverType("MaxCharge"))
        MinMoney3 = PE_CDbl(rsDeliverType("MinMoney3"))
        Charge_Min = PE_CDbl(rsDeliverType("Charge_Min"))
        Charge_Max = PE_CDbl(rsDeliverType("Charge_Max"))
        Charge_Percent = PE_CDbl(rsDeliverType("Charge_Percent"))

    End If
    Set rsDeliverType = Nothing
End If
If FoundErr = True Then
    Call WriteErrMsg(ErrMsg, ComeUrl)
    Response.End
End If
If ChargeType = 1 Then
    Dim rsCity, AreaType, strProvince, strPostCode
    Set rsCity = Conn.Execute("select * from PE_City where left(PostCode,4)='" & Left(ZipCode, 4) & "'")
    If rsCity.BOF And rsCity.EOF Then
        strProvince = ""
        strPostCode = ""
    Else
        strProvince = rsCity("Province")
        strPostCode = rsCity("PostCode")
    End If
    rsCity.Close
    Set rsCity = Nothing
    
    If Left(MyPostcode, 4) = Left(ZipCode, 4) Then  '同城
        AreaType = 1
        Set rsDeliverType = Conn.Execute("select * from PE_DeliverCharge where AreaType=1 and DeliverTypeID=" & DeliverType & "")
        If Not (rsDeliverType.BOF And rsDeliverType.EOF) Then
            Charge_Min = PE_CDbl(rsDeliverType("Charge_Min"))
            Weight_Min = PE_CDbl(rsDeliverType("Weight_Min"))
            ChargePerUnit = PE_CDbl(rsDeliverType("ChargePerUnit"))
            WeightPerUnit = PE_CDbl(rsDeliverType("WeightPerUnit"))
            Charge_Max = PE_CDbl(rsDeliverType("Charge_Max"))
        End If
        Set rsDeliverType = Nothing
    Else '不同城
        If strProvince = MyProvince Then '同省
            Set rsDeliverType = Conn.Execute("select * from PE_DeliverCharge where AreaType=2 and DeliverTypeID=" & DeliverType & "")
            If Not (rsDeliverType.BOF And rsDeliverType.EOF) Then
                If FoundInArr(rsDeliverType("arrArea"), Left(strPostCode, 4), ",") = True Then '如果同区域
                    Charge_Min = PE_CDbl(rsDeliverType("Charge_Min"))
                    Weight_Min = PE_CDbl(rsDeliverType("Weight_Min"))
                    ChargePerUnit = PE_CDbl(rsDeliverType("ChargePerUnit"))
                    WeightPerUnit = PE_CDbl(rsDeliverType("WeightPerUnit"))
                    Charge_Max = PE_CDbl(rsDeliverType("Charge_Max"))
                    AreaType = 2
                    Response.Write "同区域"
                Else  '同省但不同区域
                    AreaType = 3
                End If
            Else
                AreaType = 3
            End If
            Set rsDeliverType = Nothing
            If AreaType = 3 Then                    '不同区域
                Set rsDeliverType = Conn.Execute("select * from PE_DeliverCharge where AreaType=3 and DeliverTypeID=" & DeliverType & "")
                If Not (rsDeliverType.BOF And rsDeliverType.EOF) Then
                    Charge_Min = PE_CDbl(rsDeliverType("Charge_Min"))
                    Weight_Min = PE_CDbl(rsDeliverType("Weight_Min"))
                    ChargePerUnit = PE_CDbl(rsDeliverType("ChargePerUnit"))
                    WeightPerUnit = PE_CDbl(rsDeliverType("WeightPerUnit"))
                    Charge_Max = PE_CDbl(rsDeliverType("Charge_Max"))
                End If
                Set rsDeliverType = Nothing
            End If
        Else '不同省
            AreaType = 5
            Set rsDeliverType = Conn.Execute("select * from PE_DeliverCharge where AreaType=4 and DeliverTypeID=" & DeliverType & "")
            If Not (rsDeliverType.BOF And rsDeliverType.EOF) Then
                Do While Not rsDeliverType.EOF
                    If FoundInArr(rsDeliverType("arrArea"), strProvince, ",") = True Then  '如果在指定省份列表中
                        Charge_Min = PE_CDbl(rsDeliverType("Charge_Min"))
                        Weight_Min = PE_CDbl(rsDeliverType("Weight_Min"))
                        ChargePerUnit = PE_CDbl(rsDeliverType("ChargePerUnit"))
                        WeightPerUnit = PE_CDbl(rsDeliverType("WeightPerUnit"))
                        Charge_Max = PE_CDbl(rsDeliverType("Charge_Max"))
                        AreaType = 4
                        Exit Do
                    End If
                    rsDeliverType.MoveNext
                Loop
            End If
            Set rsDeliverType = Nothing
            If AreaType = 5 Then
                Set rsCity = Conn.Execute("select Top 1 * from PE_City where left(PostCode,2)='" & Left(ZipCode, 2) & "'")
                If Not (rsCity.BOF And rsCity.EOF) Then
                    Set rsDeliverType = Conn.Execute("select Top 1 * from PE_DeliverCharge where AreaType=4 and DeliverTypeID=" & DeliverType & "")
                    If Not (rsDeliverType.BOF And rsDeliverType.EOF) Then
                        Charge_Min = PE_CDbl(rsDeliverType("Charge_Min"))
                        Weight_Min = PE_CDbl(rsDeliverType("Weight_Min"))
                        ChargePerUnit = PE_CDbl(rsDeliverType("ChargePerUnit"))
                        WeightPerUnit = PE_CDbl(rsDeliverType("WeightPerUnit"))
                        Charge_Max = PE_CDbl(rsDeliverType("Charge_Max"))
                        AreaType = 4
                    End If
                    rsDeliverType.Close
                    Set rsDeliverType = Nothing
                End If
                rsCity.Close
                Set rsCity = Nothing
            End If
            If AreaType = 5 Then
                Set rsDeliverType = Conn.Execute("select * from PE_DeliverCharge where AreaType=5 and DeliverTypeID=" & DeliverType & "")
                If Not (rsDeliverType.BOF And rsDeliverType.EOF) Then
                    Charge_Min = PE_CDbl(rsDeliverType("Charge_Min"))
                    Weight_Min = PE_CDbl(rsDeliverType("Weight_Min"))
                    ChargePerUnit = PE_CDbl(rsDeliverType("ChargePerUnit"))
                    WeightPerUnit = PE_CDbl(rsDeliverType("WeightPerUnit"))
                    Charge_Max = PE_CDbl(rsDeliverType("Charge_Max"))
                End If
                Set rsDeliverType = Nothing
            End If
        End If
    End If
    If WeightPerUnit <= 0 Then
        WeightPerUnit = 1
    End If
End If

CartID = ReplaceBadChar(Trim(Request.Cookies("Cart" & Site_Sn)("CartID")))
ProductList = SelectCart(CartID, 0)
PresentList = SelectCart(CartID, 1)
If ProductList = "" Then       '如果购物车为空，转入提示界面
    ShowTips_CartIsEmpty = XmlText_Class("ShowTips_CartIsEmpty", "<br><br><br><br>您好！目前您的购物车中没有任何商品，是不是<a href='ShowElite.asp'><font color='#FF0000'>继续购物</font></a>？<br><br><br><br><br><br>")
Else
    ShowTips_CartIsEmpty = ""
End If

strHtml = GetTemplate(ChannelID, 11, 0)
Call ReplaceCommon

strHtml = Replace(strHtml, "{$ContacterName}", ContacterName & "<input name='ContacterName' type='hidden' value='" & ContacterName & "'>")
strHtml = Replace(strHtml, "{$Address}", Address & "<input name='Address' type='hidden' value='" & Address & "'>")
strHtml = Replace(strHtml, "{$ZipCode}", ZipCode & "<input name='ZipCode' type='hidden' value='" & ZipCode & "'>")
strHtml = Replace(strHtml, "{$Phone}", Phone & "<input name='Phone' type='hidden' value='" & Phone & "'>")
strHtml = Replace(strHtml, "{$Email}", Email & "<input name='Email' type='hidden' value='" & Email & "'>")
strHtml = Replace(strHtml, "{$Mobile}", Mobile & "<input name='Mobile' type='hidden' value='" & Mobile & "'>")
strHtml = Replace(strHtml, "{$AgentName}", AgentName & "<input name='AgentName' type='hidden' value='" & AgentName & "'>")
strHtml = Replace(strHtml, "{$PaymentType}", PaymentTypeName & "<input name='PaymentType' type='hidden' value='" & PaymentType & "'>")
strHtml = Replace(strHtml, "{$DeliverType}", DeliverTypeName & "<input name='DeliverType' type='hidden' value='" & DeliverType & "'>")
If NeedInvoice = "Yes" Then
    InvoiceInfo = InvoiceContent
Else
    InvoiceInfo = ""
End If
InvoiceInfo = InvoiceInfo & "<input name='NeedInvoice' type='hidden' value='" & NeedInvoice & "'><input name='InvoiceContent' type='hidden' value='" & PE_ConvertBR(InvoiceContent) & "'>"
strHtml = Replace(strHtml, "{$InvoiceInfo}", InvoiceInfo)
strHtml = Replace(strHtml, "{$Remark}", Remark & "<input name='Remark' type='hidden' value='" & PE_ConvertBR(Remark) & "'>")

strHtml = Replace(strHtml, "{$ShowTips_Login}", ShowTips_Login)
strHtml = Replace(strHtml, "{$ShowTips_CartIsEmpty}", ShowTips_CartIsEmpty)

Call ReplaceUserInfo

strHtml = Replace(strHtml, "{$ShowCart}", ShowCart2(True))

Response.Write strHtml
Call CloseConn
%>
