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);
|
}
|
}
|
}
|
}
|