|
/**
|
* MyOrder.aspx.cs
|
*
|
* 功 能: 我的订单(会员功能)
|
* 类 名: MyOrder
|
*
|
* Ver 变更日期 负责人 变更内容
|
* ───────────────────────────────────
|
* V0.01 2013-5-10 9:50 吴崎均 初版
|
*
|
*
|
*
|
*
|
*/
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Web;
|
using System.Web.UI;
|
using System.Web.UI.WebControls;
|
using CY.BLL.EC;
|
using CY.Model;
|
using CY.BLL.Sys;
|
using CY.Infrastructure.Common;
|
using CY.BLL;
|
using System.Configuration;
|
|
namespace CY.WebForm.Pages.business
|
{
|
/// <summary>
|
/// 订单列表界面类
|
/// </summary>
|
public partial class MyOrder : BasePage
|
{
|
|
EC_OrderBasicBLL _eC_OrderBasicBLL = null;
|
EC_MemberBasicBLL _eC_MemberBasicBLL = null;
|
LF_OrderFileBLL _lF_OrderFileBLL = null;
|
|
public string strUploadFileURL
|
{
|
get
|
{
|
return ConfigurationManager.AppSettings["UploadFileURL"];
|
}
|
}
|
|
/// <summary>
|
/// 初始化构造
|
/// </summary>
|
public MyOrder()
|
{
|
_eC_OrderBasicBLL = new EC_OrderBasicBLL();
|
_eC_MemberBasicBLL = new EC_MemberBasicBLL();
|
_lF_OrderFileBLL = new LF_OrderFileBLL();
|
}
|
|
/// <summary>
|
/// 加载事件
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
protected void Page_Load(object sender, EventArgs e)
|
{
|
try
|
{
|
switch (Request["Target"])
|
{
|
case "AcceptOrder":
|
//Accept();
|
break;
|
case "ChangeState":
|
//ChangeOrderState();
|
break;
|
case "BatchDelete":
|
CY.WebForm.cs.WebUtil.DeleteData(_eC_OrderBasicBLL.DeleteDataByIds, CurrentUser.ShortName);//调用通用删除方法
|
break;
|
|
default:
|
Page_Load_Default();
|
return;
|
}
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
Response.Clear();
|
Response.Write("-1");
|
}
|
|
|
Response.End();
|
|
}
|
|
/// <summary>
|
/// 更新状态
|
/// </summary>
|
private void UpdataState(int stateId)
|
{
|
|
Response.Clear();
|
if (1 == stateId || 2 == stateId)
|
{
|
HttpContext.Current.Response.Write(-2);
|
return;
|
}
|
string paramValue = HttpContext.Current.Request["ids"];
|
//string stateStr=HttpContext.Current.Request["state"];
|
string remark = string.Format("{0}", Request["remark"]);
|
int? tempId;
|
//tempId = string.IsNullOrEmpty(stateStr)?null:MyConvert.ConvertToInt32(stateStr);
|
if (string.IsNullOrEmpty(paramValue)/*||!tempId.HasValue*/)
|
{
|
HttpContext.Current.Response.Write(-2);
|
return;
|
}
|
else
|
{
|
}
|
|
//int stateId=tempId.Value;
|
string[] splitResult = paramValue.Split(',');
|
int i = -1;
|
|
List<EC_OrderOperate> oprates = new List<EC_OrderOperate>();
|
while (++i < splitResult.Length)
|
{
|
tempId = MyConvert.ConvertToInt32(splitResult[i]);
|
|
if (!tempId.HasValue)
|
{
|
HttpContext.Current.Response.Write(-2);
|
return;
|
}
|
else
|
{
|
}
|
oprates.Add(new EC_OrderOperate()
|
{
|
OperateType = stateId,
|
OrderId = tempId.Value,
|
Operator = CurrentUser.ShortName,
|
Remark = remark
|
});
|
}
|
|
HttpContext.Current.Response.Write((_eC_OrderBasicBLL.UpdateOrderState(oprates.ToArray()) ? 1 : 0));
|
}
|
|
/// <summary>
|
/// 改变订单状态(暂时不启用)
|
/// </summary>
|
private void ChangeOrderState()
|
{
|
Response.Clear();
|
string idsStr = Request["ids"];
|
string stateIdStr = Request["stateId"];
|
string remark = string.Format("{0}", Request["remark"]);
|
int? stateId = string.IsNullOrEmpty(stateIdStr) ? null : MyConvert.ConvertToInt32(stateIdStr);
|
if (string.IsNullOrEmpty(idsStr) || !stateId.HasValue)
|
{
|
Response.Write("-2");
|
return;
|
}
|
else
|
{
|
}
|
string[] ids = idsStr.Split(',');
|
|
int i = -1;
|
int? tempId = null;
|
List<EC_OrderOperate> operaters = new List<EC_OrderOperate>();
|
while (++i < ids.Length)
|
{
|
tempId = string.IsNullOrEmpty(ids[i]) ? null : MyConvert.ConvertToInt32(ids[i]);
|
if (!tempId.HasValue)
|
{
|
operaters = null;
|
break;
|
}
|
else
|
{
|
}
|
|
operaters.Add(new EC_OrderOperate()
|
{
|
OrderId = tempId.Value,
|
Operator = CurrentUser.ShortName,
|
OperateType = stateId.Value,
|
Remark = remark
|
});
|
|
}
|
if (null == operaters)
|
{
|
Response.Write("-2");
|
return;
|
}
|
else
|
{
|
}
|
|
Response.Write(_eC_OrderBasicBLL.UpdateOrderState(operaters.ToArray()) ? "1" : "0");
|
}
|
|
/// <summary>
|
/// 默认执行方法
|
/// </summary>
|
private void Page_Load_Default()
|
{
|
UCPager1.AspNetPager.PageChanged += AspNetPager_PageChanged;
|
btn_Search.Click += btn_Search_Click;
|
txtCommission.Value = CY.Config.WebInfo.Instance.FirmOrderAgencyFee;
|
if (!IsPostBack && !IsCallback)
|
{
|
Sys_DictionaryBLL _sys_DictionaryBLL = new Sys_DictionaryBLL();//字典业务逻辑操作类对象
|
SysInquiry_PrintingTypeBLL _sysInquiry_PrintingTypeBLL = new SysInquiry_PrintingTypeBLL();//印刷业务类型业务逻辑操作类对象
|
|
selPrintTypes.DataSource = _sysInquiry_PrintingTypeBLL.SelectUsedModles();
|
selPrintTypes.DataBind();
|
|
|
selPrintTypes.Items.Add(new ListItem("所有", ""));
|
selPrintTypes.Value = "";
|
|
selPayType.DataSource = _sys_DictionaryBLL.GetDataByType("EC_支付方式");
|
selPayType.DataTextField = "Name";
|
selPayType.DataValueField = "MeanValue";
|
selPayType.DataBind();
|
selPayType.Items.Insert(0, new ListItem("所有", ""));
|
|
selPayStates.DataSource = _sys_DictionaryBLL.GetDataByType("EC_订单支付状态");
|
selPayStates.DataTextField = "Name";
|
selPayStates.DataValueField = "MeanValue";
|
selPayStates.DataBind();
|
selPayStates.Items.Insert(0, new ListItem("所有", ""));
|
|
selOrderStates.DataSource = _sys_DictionaryBLL.GetDataByType("EC_订单状态");
|
selOrderStates.DataBind();
|
selOrderStates.Items.Insert(0, new ListItem("所有", ""));
|
|
//初次数据加载
|
btn_Search_Click(btn_Search, new EventArgs());
|
}
|
}
|
|
#region 查询
|
|
/// <summary>
|
/// 搜索按钮点击事件
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btn_Search_Click(object sender, EventArgs e)
|
{
|
Dictionary<int, object> searchParam = new Dictionary<int, object>();
|
|
SetParamValue(searchParam, 0, CurrentUser.MemberId);
|
SetParamValue(searchParam, 2, this.txtOrderId.Value.Trim());
|
SetParamValue(searchParam, 4, this.txtBeginData.Value.Trim());
|
SetParamValue(searchParam, 5, this.txtEndDate.Value.Trim());
|
SetParamValue(searchParam, 6, this.selPrintTypes.Value);
|
SetParamValue(searchParam, 8, this.selOrderStates.Value);
|
SetParamValue(searchParam, 9, this.selPayStates.Value);
|
SetParamValue(searchParam, 14, this.selPayType.SelectedValue);
|
SetParamValue(searchParam, 17, this.txtSellerName.Value.Trim());
|
SearchParam = searchParam;
|
UCPager1.AspNetPager.CurrentPageIndex = 1;//重置页数
|
//再次查询
|
AspNetPager_PageChanged(UCPager1.AspNetPager, new EventArgs());
|
}
|
|
|
/// <summary>
|
/// 设置查询参数方法
|
/// </summary>
|
/// <param name="target">设置目标</param>
|
/// <param name="key">键</param>
|
/// <param name="value">值</param>
|
private static void SetParamValue(Dictionary<int, object> target, int key, object value)
|
{
|
if (string.IsNullOrEmpty(string.Format("{0}", value)))
|
return;
|
else
|
{
|
}
|
|
if (target.ContainsKey(key))
|
{
|
target[key] = value;
|
}
|
else
|
{
|
target.Add(key, value);
|
}
|
}
|
|
|
/// <summary>
|
/// 分页事件
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void AspNetPager_PageChanged(object sender, EventArgs e)
|
{
|
//UCPager1.AspNetPager.PageSize = 3;
|
|
Infrastructure.Query.Pagination pagination = new Infrastructure.Query.Pagination()
|
{
|
PageSize = UCPager1.AspNetPager.PageSize,
|
PageIndex = UCPager1.AspNetPager.CurrentPageIndex
|
};
|
IEnumerable<EC_OrderBasic> result = _eC_OrderBasicBLL.SelectModelPage(pagination, SearchParam);
|
rptData.DataSource = result;
|
rptData.DataBind();
|
|
UCPager1.AspNetPager.RecordCount = pagination.RecordCount;
|
}
|
|
|
|
/// <summary>
|
/// 查询参数
|
/// </summary>
|
private Dictionary<int, object> SearchParam
|
{
|
get
|
{
|
return ViewState["SearchParam"] as Dictionary<int, object>;
|
}
|
set
|
{
|
ViewState["SearchParam"] = value;
|
}
|
}
|
|
/// <summary>
|
/// 是否可以操作
|
/// </summary>
|
/// <param name="keyid"></param>
|
/// <param name="orderState"></param>
|
/// <param name="opType"></param>
|
/// <returns></returns>
|
public bool IsCanOpearte(object keyidObj, object orderTypeObj, object payStateObj, object orderStateObj, object opTypeObj)
|
{
|
bool isCan = false;
|
int keyid = (int)keyidObj;
|
int orderState = (int)orderStateObj;
|
string opType = (string)opTypeObj;
|
int payState = (int)payStateObj;
|
int orderType = (int)orderTypeObj;
|
|
//冻结订单
|
if (orderState == -2)
|
{
|
return false;
|
}
|
|
//判断是否是自动外协订单
|
bool isOutOrder = _eC_OrderBasicBLL.IsOutOrder(keyid);
|
if (isOutOrder)
|
{
|
return false;
|
}
|
|
|
if (orderType >= 1)
|
{
|
if (opType == "支付" && orderType == 1)
|
{
|
isCan = true;
|
}
|
else
|
{
|
switch (opType)
|
{
|
case "收货":
|
if (orderState <= 0 || payState != -1)
|
{
|
isCan = false;
|
}
|
else
|
{
|
isCan = true;
|
}
|
break;
|
default:
|
isCan = false;
|
break;
|
}
|
}
|
}
|
else
|
{
|
if (orderState == 1 && opType != "支付" && opType != "撤单")
|
{
|
isCan = false;
|
}
|
else
|
{
|
switch (opType)
|
{
|
case "支付":
|
if (orderState <= 0)
|
{
|
isCan = false;
|
}
|
else
|
{
|
if (payState == -1)
|
{
|
isCan = false;
|
}
|
else
|
{
|
isCan = true;
|
}
|
}
|
break;
|
case "撤单":
|
if (orderState >= 4 || orderState <= 0)
|
{
|
isCan = false;
|
}
|
else
|
{
|
isCan = true;
|
}
|
break;
|
case "延期":
|
if (orderState <= 0)
|
{
|
isCan = false;
|
}
|
else
|
{
|
isCan = true;
|
}
|
break;
|
case "评价":
|
if (orderState == 1)
|
{
|
isCan = false;
|
}
|
else
|
{
|
isCan = true;
|
}
|
break;
|
case "投诉":
|
isCan = true;
|
break;
|
case "收货":
|
if (orderState <= 0 || payState != -1)
|
{
|
isCan = false;
|
}
|
else
|
{
|
isCan = true;
|
}
|
break;
|
default:
|
isCan = false;
|
break;
|
}
|
}
|
}
|
if (opType == "上传")
|
{
|
EC_OrderBasic _eC_OrderBasicModel = null;
|
EC_MemberBasic _eC_MemberBasic = null;
|
_eC_OrderBasicModel = _eC_OrderBasicBLL.SelectModelById(keyid);
|
|
if (_eC_OrderBasicModel.OutId > 0)
|
{
|
_eC_OrderBasicModel = _eC_OrderBasicBLL.SelectModelById(Convert.ToInt32(_eC_OrderBasicModel.OutId));
|
}
|
|
if (_eC_OrderBasicModel != null)
|
{
|
_eC_MemberBasic = _eC_MemberBasicBLL.GetMemberByMemberId(_eC_OrderBasicModel.SellerId);
|
}
|
|
if (_eC_MemberBasic != null && _eC_MemberBasic.MemberId != Guid.Empty)
|
{
|
isCan = true;
|
}
|
else
|
{
|
isCan = false;
|
}
|
}
|
return isCan;
|
}
|
|
/// <summary>
|
/// 是否已经操作
|
/// </summary>
|
/// <param name="keyid"></param>
|
/// <param name="orderState"></param>
|
/// <param name="opType"></param>
|
/// <returns></returns>
|
public bool IsOpearted(object keyidObj, object orderTypeObj, object payStateObj, object orderStateObj, object opTypeObj)
|
{
|
bool isOpearted = false;
|
int keyid = (int)keyidObj;
|
int orderState = (int)orderStateObj;
|
string opType = (string)opTypeObj;
|
int payState = (int)payStateObj;
|
int orderType = (int)orderTypeObj;
|
switch (opType)
|
{
|
case "支付":
|
if (payState == -1)
|
{
|
isOpearted = true;
|
}
|
else
|
{
|
isOpearted = false;
|
}
|
break;
|
case "撤单":
|
if (orderState == 0)
|
{
|
isOpearted = true;
|
}
|
else
|
{
|
isOpearted = false;
|
}
|
break;
|
case "收货":
|
if (orderState == -1)
|
{
|
isOpearted = true;
|
}
|
else
|
{
|
isOpearted = false;
|
}
|
break;
|
case "上传":
|
EC_OrderBasic _eC_OrderBasicModel = null;
|
LF_OrderFile _lF_OrderFile = null;
|
_eC_OrderBasicModel = _eC_OrderBasicBLL.SelectModelById(keyid);
|
if (_eC_OrderBasicModel != null)
|
{
|
if (_eC_OrderBasicModel.OutId > 0)
|
{
|
_lF_OrderFile = _lF_OrderFileBLL.GetModel(Convert.ToInt32(_eC_OrderBasicModel.OutId));
|
|
}
|
else
|
{
|
_lF_OrderFile = _lF_OrderFileBLL.GetModel(keyid);
|
}
|
|
if (_lF_OrderFile != null)
|
{
|
isOpearted = true;
|
}
|
else
|
{
|
isOpearted = false;
|
}
|
|
}
|
break;
|
default:
|
isOpearted = false;
|
break;
|
}
|
|
return isOpearted;
|
}
|
|
#endregion
|
|
}
|
}
|