using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace LYFZ.Software.MainBusiness.MembershipManage
{
public class MemberPublicClass
{
static LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
static LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL.BLL_ErpCustomer();
static LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
static LYFZ.BLL.BLL_SMSTemplates smsTemplates = new BLL.BLL_SMSTemplates();
static LYFZ.BLL.BLL_ErpCustomerGroup ctgpbll = new BLL.BLL_ErpCustomerGroup();
static LYFZ.BLL.BLL_ErpMemberCardPoints mcpsbll = new BLL.BLL_ErpMemberCardPoints();
static LYFZ.BLL.BLL_ErpMemberCardViceCard mcvbll = new BLL.BLL_ErpMemberCardViceCard();
static LYFZ.BLL.BLL_ErpMemberCardPointsLOG mcpslogbll = new BLL.BLL_ErpMemberCardPointsLOG();
static LYFZ.BLL.BLL_ErpMemberCardOperateLOG mcopLogbll = new BLL.BLL_ErpMemberCardOperateLOG();
static string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
///
/// 本地分店ID
///
static string strInfoID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
#region 使用积分副卡给主卡积分
///
/// 副卡使用绑定主卡客户到订单去做转介绍
///
/// 副卡编号
/// 订单号
/// 使用时间
///
public static List ViceCardUse_MainCardPoints(string StrMcvNumber, ref Model.SMSParameters sparameters, string StrOrdNumber, DateTime strTime)
{
List clist = new List();
LYFZ.Model.Model_ErpMemberCardViceCard modelMcv = mcvbll.GetModel("Mvc_ViceNumber", StrMcvNumber);
modelMcv.Mvc_Status = "2";
modelMcv.Mvc_UpdateDateTime = strTime;
modelMcv.Mvc_UpdateName = StrUserID;
clist.Add(mcvbll.GetUpdateCommandInfo(modelMcv));
LYFZ.Model.Model_ErpMemberCard modelMc = mcbll.GetModel("Mc_Number", modelMcv.Mvc_Number);
LYFZ.Model.Model_ErpMemberCardOperateLOG modelOPLog = new Model.Model_ErpMemberCardOperateLOG();
modelOPLog.mcol_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
modelOPLog.mcol_Number = modelMcv.Mvc_Number;
modelOPLog.mcol_Type = "4";
modelOPLog.mcol_Remark = "副卡消费订单" + StrOrdNumber;
modelOPLog.mcol_CreateDatetime = strTime;
modelOPLog.mcol_CreateName = StrUserID;
clist.Add(mcopLogbll.GetAddCommandInfo(modelOPLog));
LYFZ.Model.Model_ErpOrder modelOrder = orbll.GetModel("Ord_Number", StrOrdNumber);
modelOrder.Ord_CustomerSource = "朋友介绍";
modelOrder.Ord_UpdateDateTime = strTime;
modelOrder.Ord_UpdateName = StrUserID;
clist.Add(orbll.GetUpdateCommandInfo(modelOrder));
LYFZ.Model.Model_ErpCustomerGroup modelGroup = ctgpbll.GetModel("GP_OrderNumber", StrOrdNumber);
modelGroup.GP_CustomerSource = "朋友介绍";
modelGroup.GP_IntroducerCustomerID = modelMc.Mc_CustomerNumber;
modelGroup.GP_UpdateDatetime = strTime;
modelGroup.GP_UpdateName = StrUserID;
clist.Add(ctgpbll.GetUpdateCommandInfo(modelGroup));
//LYFZ.Model.Model_ErpCustomer modelClient = ctbll.GetModel("Cus_CustomerNumber",modelMc.Mc_CustomerNumber);// modelGroup.GP_IntroducerCustomerID);
LYFZ.Model.Model_ErpMemberCardPointsLOG modelPointsIntrLOG = new Model.Model_ErpMemberCardPointsLOG();
int IntPointsIntr = LYFZ.BLL.BLL_ErpMemberCard.GetPoints_AgoPeriod(LYFZ.EnumPublic.MemberPointsType.txtReferral_RMB, modelOrder.Ord_SeriesPrice, strInfoID, modelGroup.GP_IntroducerCustomerID);
LYFZ.Model.Model_ErpMemberCardPoints modelPoints2 = mcpsbll.GetModel("Mcps_Number", modelMc.Mc_Number);
modelPointsIntrLOG.MPlg_OriginalPoints = modelPoints2.Mcps_AvailablePoints;
modelPoints2.Mcps_TotalPoints = modelPoints2.Mcps_TotalPoints + IntPointsIntr;
modelPoints2.Mcps_AvailablePoints = modelPoints2.Mcps_AvailablePoints + IntPointsIntr;
modelPoints2.Mcps_UpdateDateTime = strTime;
modelPoints2.Mcps_UpdateName = StrUserID;
clist.Add(mcpsbll.GetUpdateCommandInfo(modelPoints2));
string StrCusName = "";
DataTable dt = orbll.GetView_Custom("tb_ErpCustomer inner join tb_ErpMemberCard on Mc_CustomerNumber = Cus_CustomerNumber Left Join tb_ErpCustomerGroupMembers on GM_CustomerID = Cus_CustomerNumber Left Join tb_ErpCustomerGroup on GP_CustomerGroupID = GM_CustomerGroupID", StrWhere: "GP_OrderNumber = '" + StrOrdNumber + "'", ShowColumnName: "Cus_Name,Mc_CustomerNumber,Mc_CradNumber").Tables[0];
if (dt.Rows.Count > 0)
{ StrCusName = dt.Rows[0]["Cus_Name"].ToString().Trim(); }
modelPointsIntrLOG.MPlg_DividedShop = LYFZ.BLL.OrderPayment_Member.StrInfoID;
modelPointsIntrLOG.MPlg_Number = modelPoints2.Mcps_Number;
modelPointsIntrLOG.MPlg_Type = "3";
modelPointsIntrLOG.MPlg_ExistingPoints = modelPoints2.Mcps_AvailablePoints;
modelPointsIntrLOG.MPlg_UsePoints = IntPointsIntr;
modelPointsIntrLOG.MPlg_RedeemArticle = "";
modelPointsIntrLOG.MPlg_RedeemAmount = 0;
modelPointsIntrLOG.MPlg_OrderNumber = modelOrder.Ord_SinceOrderNumber.Trim() != "" ? modelOrder.Ord_SinceOrderNumber.Trim() : modelOrder.Ord_Number;
modelPointsIntrLOG.MPlg_ViceCardNumber = "";
modelPointsIntrLOG.MPlg_Remark = "你介绍" + StrCusName + "来订单,您朋友使用副卡消费,副卡号" + modelMcv.Mvc_ViceCardNumber + ",订单号:" + modelPointsIntrLOG.MPlg_OrderNumber + "付款,获得积分:" + IntPointsIntr;
modelPointsIntrLOG.MPlg_CreateDatetime = strTime;
modelPointsIntrLOG.MPlg_CreateName = StrUserID;
clist.Add(mcpslogbll.GetAddCommandInfo(modelPointsIntrLOG));
if (IntPointsIntr > 0)
{
sparameters.CurrentSpendingMemberID = dt.Rows[0]["Mc_CustomerNumber"].ToString().Trim();
sparameters.CardNumber = dt.Rows[0]["Mc_CradNumber"].ToString().Trim();
sparameters.XXT = strTime;
sparameters.TEXT = "您朋友持积分副卡" + modelMcv.Mvc_ViceCardNumber + "来订单,获得" + IntPointsIntr + "积分";
sparameters.ReferralsBonusPoints = IntPointsIntr;
sparameters.AvailablePoints = modelPoints2.Mcps_AvailablePoints;
//激活积分有效期
clist.AddRange(LYFZ.BLL.OrderPayment_Member.PointsChangeAutoValidity(modelMc.Mc_Number, modelMc.Mc_CradNumber));
}
return clist;
}
#endregion
}
}