username@email.com
2025-05-14 99ddfbcecf0fa2881eb3a91028257eef87dab6de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.Model;
using CY.Infrastructure.Common;
using CY.BLL.EC;
using CY.BLL;
using CY.BLL.Sys;
 
namespace CY.WebForm.Pages.front
{
    //吴辉
    //礼品兑换确认
    public partial class PrizesExchange : FrontBasePage
    {
        EC_PrizeInfoBLL bll_EC_PrizeInfoBLL = null;
        EC_ExchangeRecordBLL bll_EC_ExchangeRecordBLL = null;
        Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;
        public string PrizeImg = "";
        public int? keyid = 0;
        public string Province = ""; //接收值 Request["selectProvince"].ToString2();
        public string City = "";//接收值 Request["selectCity"].ToString2();
        public string County = "";//接收值 Request["selectCounty"].ToString2();
 
        //初始化
        public PrizesExchange()
        {
            bll_EC_PrizeInfoBLL = new EC_PrizeInfoBLL();
            bll_EC_ExchangeRecordBLL = new EC_ExchangeRecordBLL();
            bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (CurrentUser == null)
            {
                Response.Redirect("/login.html?backurlCS=" + "/prizes/confirm.html?keyid=" + Request.QueryString["keyid"].Trim(',').Split(',')[0].ToInt32());
            }
            else
            {
                this.MyScore.InnerHtml = (CurrentPayAccount.Score ?? 0).ToString2();
            }
            if (!IsPostBack)
            {
                InitData();
            }
        }
 
        //数据绑定
        public void InitData()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["keyid"]) && Request.QueryString["keyid"].Trim(',').Split(',')[0].ToInt32() > 0)
            {
 
                EC_PrizeInfo m_EC_PrizeInfo = bll_EC_PrizeInfoBLL.getOnePrizeInfo(Request.QueryString["keyid"].Trim(',').Split(',')[0].ToInt32());
                if (m_EC_PrizeInfo == null || m_EC_PrizeInfo.IsUsed == false || m_EC_PrizeInfo.AllCount <= m_EC_PrizeInfo.ExchangedCount)
                {
                    JavaScript.MessageBox("此礼品不存在或已下架", this);
                    m_EC_PrizeInfo = new EC_PrizeInfo();
                }
                else if (CurrentUser == null || CurrentUser.MemberId == null)
                {
                    JavaScript.MessageBox("您尚未登录", this);
                    m_EC_PrizeInfo = new EC_PrizeInfo();
                }
                else
                {
                    keyid = m_EC_PrizeInfo.Keyid;
                    this.spanPrizeName.InnerText = m_EC_PrizeInfo.PrizeName;
                    this.spanNeedScore.InnerText = m_EC_PrizeInfo.NeedIntegral.ToString2();
                    this.spanPrizeAddress.InnerText = m_EC_PrizeInfo.PrizeReciveAddress.Address;
                    this.spanWorkTime.InnerText = m_EC_PrizeInfo.PrizeReciveAddress.WorkTime;
 
                    this.txtRecivePeople.Value = CurrentUser.Name;
                    this.txtReciveAddress.Value = CurrentMemberExtend.DetailedAddress;
                    this.txtReciveEmail.Value = CurrentMemberExtend.Email;
                    this.txtRecivePhone.Value = string.IsNullOrEmpty(CurrentMemberExtend.PhoneNum) ? CurrentMemberExtend.MobileNum : CurrentMemberExtend.PhoneNum;
                    this.txtRecivePostNum.Value = CurrentMemberExtend.Postcode;
 
                    Province = CurrentUser.Province;
                    City = CurrentUser.City;
                    County = CurrentUser.County;
                }
            }
            else
            {
                Response.Redirect("/prizes/list.html");
            }
        }
 
        //确认提交事件
        protected void btn_submit_sure(object sender, EventArgs e)
        {
            try
            {
                EC_PrizeInfo m_EC_PrizeInfo = bll_EC_PrizeInfoBLL.getOnePrizeInfo(Request.QueryString["keyid"].Trim(',').Split(',')[0].ToInt32());
                if (m_EC_PrizeInfo == null || m_EC_PrizeInfo.IsUsed == false || m_EC_PrizeInfo.AllCount <= m_EC_PrizeInfo.ExchangedCount)
                {
                    JavaScript.MessageBox("此礼品不存在或已下架", this);
                    m_EC_PrizeInfo = new EC_PrizeInfo();
                }
                else if (CurrentUser == null || CurrentUser.MemberId == null)
                {
                    JavaScript.MessageBox("您尚未登录", this);
                }
                else if (m_EC_PrizeInfo.NeedIntegral > CurrentPayAccount.Score)
                {
                    JavaScript.MessageBox("积分不足", this);
                }
                else
                {
                    EC_ExchangeRecord m_EC_ExchangeRecord = new EC_ExchangeRecord();
                    switch (this.selReciveType.Value)
                    {
                        case "上门自取":
                            m_EC_ExchangeRecord.AssociateAddress = "上门领取时间:" + this.ReciveDate.Value + "    领取地址:" + m_EC_PrizeInfo.PrizeReciveAddress.Address + "   工作时间" + m_EC_PrizeInfo.PrizeReciveAddress.WorkTime;
                            break;
                        case "快递":
                            m_EC_ExchangeRecord.AssociateAddress = "收货人:" + Request["txtRecivePeople"].ToString2() + ";收货地址:" + Request["selectProvince"].ToString2() + Request["selectCity"].ToString2() + Request["selectCounty"].ToString2() + Request["txtReciveAddress"].ToString2() + ";邮政编码:" + Request["txtRecivePostNum"].ToString2() + ";电子邮箱:" + Request["txtReciveEmail"].ToString2() + ";联系电话:" + Request["txtRecivePhone"].ToString2();
                            break;
                        default:
                            break;
                    }
                    m_EC_ExchangeRecord.AllUseIntegral = m_EC_PrizeInfo.NeedIntegral;
                    m_EC_ExchangeRecord.ExchangeCount = 1;
                    m_EC_ExchangeRecord.ExchangeStatus = "0";
                    m_EC_ExchangeRecord.ExchangeTime = DateTime.Now;
                    m_EC_ExchangeRecord.LastUpdateTime = DateTime.Now;
                    m_EC_ExchangeRecord.MemberId = CurrentUser.MemberId;
                    m_EC_ExchangeRecord.Operator = CurrentUser.ShortName;
                    m_EC_ExchangeRecord.PrizeId = m_EC_PrizeInfo.Keyid;
                    m_EC_ExchangeRecord.ReciveInfo = "";
                    m_EC_ExchangeRecord.RecivePeople = "";
                    m_EC_ExchangeRecord.Remark = "";
                    m_EC_ExchangeRecord.ShippingMethod = this.selReciveType.Value;
                    m_EC_ExchangeRecord.UseIntegral = m_EC_PrizeInfo.NeedIntegral;
 
                    m_EC_PrizeInfo.ExchangedCount += 1;
 
                    Pay_PaymentAccount m_Pay_PaymentAccount = CurrentPayAccount;
                    m_Pay_PaymentAccount.Score -= m_EC_PrizeInfo.NeedIntegral;
                    m_Pay_PaymentAccount.LockScore += m_EC_PrizeInfo.NeedIntegral;
 
                    Pay_ScoreRecord m_Pay_ScoreRecord = new Pay_ScoreRecord();
                    m_Pay_ScoreRecord.CreateTime = DateTime.Now;
                    m_Pay_ScoreRecord.PayId = CurrentPayAccount.Keyid;
                    m_Pay_ScoreRecord.Remark = "";
                    m_Pay_ScoreRecord.ResidualScore = m_Pay_PaymentAccount.Score;
                    m_Pay_ScoreRecord.TradingName = "积分兑换";
                    m_Pay_ScoreRecord.TradingScore = m_EC_PrizeInfo.NeedIntegral;
                    m_Pay_ScoreRecord.TradingState = -1;//已完成
                    m_Pay_ScoreRecord.TradingType = -1;//收入
 
                    if (bll_EC_ExchangeRecordBLL.InserModel(m_EC_ExchangeRecord, m_EC_PrizeInfo, m_Pay_PaymentAccount, m_Pay_ScoreRecord))
                    {
                        Response.Redirect("/prizes/success.html?type=" + m_EC_ExchangeRecord.ShippingMethod);
                    }
                    else
                    {
                        JavaScript.MessageBox("兑换失败", this);
                    }
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("兑换失败", this);
            }
        }
    }
}