/// <summary> /// 入充值订单队列 /// </summary> /// <param name="loggingSessionInfo"></param> /// <param name="orderInfo"></param> public void SetRedisToRechargeOrder(LoggingSessionInfo loggingSessionInfo, RechargeOrderEntity orderInfo) { var response = RedisOpenAPI.Instance.CCRechargeOrder().SetRechargeOrder(new CC_Order { CustomerID = loggingSessionInfo.ClientID, OrderId = orderInfo.OrderID.ToString(), OrderInfo = orderInfo.JsonSerialize() }); if (response.Code == ResponseCode.Fail) { //直接计算 RechargeOrderBLL rechargeOrderBll = new RechargeOrderBLL(loggingSessionInfo); rechargeOrderBll.CalculateRechargeOrder(loggingSessionInfo, orderInfo); } }
protected override SetRechargeOrderRD ProcessRequest(APIRequest <SetRechargeOrderRP> pRequest) { SetRechargeOrderRP rp = pRequest.Parameters; SetRechargeOrderRD rd = new SetRechargeOrderRD(); var rechargeOrderBll = new RechargeOrderBLL(CurrentUserInfo); TUnitExpandBLL serviceUnitExpandBll = new TUnitExpandBLL(CurrentUserInfo); var vipBll = new VipBLL(CurrentUserInfo); var vipCardVipMappingBll = new VipCardVipMappingBLL(CurrentUserInfo); var vipCardBll = new VipCardBLL(CurrentUserInfo); var sysVipCardTypeBll = new SysVipCardTypeBLL(CurrentUserInfo); var vipCardUpgradeRuleBll = new VipCardUpgradeRuleBLL(CurrentUserInfo); //获取会员信息 VipEntity vipInfo; string userId = ""; //微信 if (pRequest.ChannelId == "2") { vipInfo = vipBll.GetByID(pRequest.UserID); UnitService unitServer = new UnitService(CurrentUserInfo); rp.UnitId = unitServer.GetUnitByUnitTypeForWX("OnlineShopping", null).Id; //获取在线商城的门店标识 } //掌柜App else { vipInfo = vipBll.GetByID(rp.VipId); userId = pRequest.UserID; } string OrderDesc = "ReRecharge"; //"升级","充值" int? VipCardTypeId = null; //会员卡类型 decimal returnAmount = 0; //赠送金额 //会员卡类型条件 List <IWhereCondition> complexConditionOne = new List <IWhereCondition> { }; //获取会员与会员卡关系表 var vipCardVipMappingEntity = vipCardVipMappingBll.QueryByEntity(new VipCardVipMappingEntity() { CustomerID = CurrentUserInfo.ClientID, VIPID = vipInfo.VIPID }, null).FirstOrDefault(); //该会员有会员卡 if (vipCardVipMappingEntity != null) { //获取该会员会员卡信息 var vipCardEntity = vipCardBll.QueryByEntity(new VipCardEntity() { CustomerID = CurrentUserInfo.ClientID, VipCardID = vipCardVipMappingEntity.VipCardID }, null).FirstOrDefault(); //获取该会员卡类型 var sysVipCardTypeEntity = sysVipCardTypeBll.GetByID(vipCardEntity.VipCardTypeID); VipCardTypeId = vipCardEntity.VipCardTypeID; //获取会员卡的会员活动 var rechargeStrategyBLL = new RechargeStrategyBLL(CurrentUserInfo); var RechargeActivityDS = rechargeStrategyBLL.GetRechargeActivityList(CurrentUserInfo.ClientID, VipCardTypeId.ToString(), 3); var RechargeStrategy = new RechargeStrategyInfo(); if (RechargeActivityDS != null && RechargeActivityDS.Tables[0].Rows.Count > 0) { var RechargeStrategyList = DataTableToObject.ConvertToList <RechargeStrategyInfo>(RechargeActivityDS.Tables[0]); //获取与充值金额最接近的活动 RechargeStrategy = RechargeStrategyList.Where(n => n.RechargeAmount <= rp.ActuallyPaid).OrderByDescending(n => n.RechargeAmount).FirstOrDefault(); if (RechargeStrategy != null) { //梯度 if (RechargeStrategy.RuleType == "Step") { //赠送金额 = 会员活动梯度设置赠送金额 returnAmount = RechargeStrategy.GiftAmount; } //叠加 if (RechargeStrategy.RuleType == "Superposition") { //赠送金额与满赠条件金额比例 decimal discount = RechargeStrategy.GiftAmount / RechargeStrategy.RechargeAmount; //赠送金额 = 充值金额 * (设置赠送金额 / 设置满赠条件金额) returnAmount = rp.ActuallyPaid * RechargeStrategy.GiftAmount / RechargeStrategy.RechargeAmount; } } } //获取等级高的会员卡类型条件 complexConditionOne.Add(new MoreThanCondition() { FieldName = "VipCardLevel", Value = sysVipCardTypeEntity.VipCardLevel, IncludeEquals = false }); complexConditionOne.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); } //该会员没有会员卡 else { //获取所有的会员卡类型条件 complexConditionOne.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); } var sysVipCardTypeList = sysVipCardTypeBll.Query(complexConditionOne.ToArray(), null).ToList(); if (sysVipCardTypeList == null) { throw new APIException("没有建立会员体系") { ErrorCode = 200 }; } //获取会员卡类型升级规则 List <IWhereCondition> complexConditionTwo = new List <IWhereCondition> { }; complexConditionTwo.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); complexConditionTwo.Add(new EqualsCondition() { FieldName = "IsRecharge", Value = 1 }); var vipCardUpgradeRuleList = vipCardUpgradeRuleBll.Query(complexConditionTwo.ToArray(), null); //将升级卡规则和可升级的会员卡匹配 var vipCardTypeDetailList = vipCardUpgradeRuleList.Join(sysVipCardTypeList, n => n.VipCardTypeID, m => m.VipCardTypeID, (n, m) => new { n, m }).OrderByDescending(t => t.m.VipCardLevel).ToList(); //判断是否满充值条件 bool isUpgrade = false; for (int i = 0; i < vipCardTypeDetailList.Count; i++) { //实付金额 >= 可升级金额 if (vipCardTypeDetailList[i].n.OnceRechargeAmount <= rp.ActuallyPaid) { isUpgrade = true; VipCardTypeId = vipCardTypeDetailList[i].n.VipCardTypeID ?? 0; break; } } if (isUpgrade) { OrderDesc = "Upgrade"; //升级 } //充值订单 var rechargeOrderEntity = new RechargeOrderEntity() { OrderID = Guid.NewGuid(), OrderNo = serviceUnitExpandBll.GetUnitOrderNo(), OrderDesc = OrderDesc, VipID = vipInfo.VIPID, VipCardNo = vipInfo.VipCode, UnitId = rp.UnitId, UserId = userId, TotalAmount = rp.ActuallyPaid, ActuallyPaid = rp.ActuallyPaid, PosSourceName = rp.PosSourceName, ReturnAmount = returnAmount, PayerID = vipInfo.VIPID, Status = 0, CustomerID = CurrentUserInfo.ClientID, VipCardTypeId = VipCardTypeId }; rechargeOrderBll.Create(rechargeOrderEntity); rd.orderId = rechargeOrderEntity.OrderID.ToString(); //支付完成 if (rp.PayStatus == 1) { //获取门店信息 t_unitBLL unitBLL = new t_unitBLL(CurrentUserInfo); t_unitEntity unitInfo = null; if (!string.IsNullOrEmpty(rechargeOrderEntity.UnitId)) { unitInfo = unitBLL.GetByID(rechargeOrderEntity.UnitId); } //充值 rechargeOrderBll.Recharge(rechargeOrderEntity, vipInfo, unitInfo, ""); } return(rd); }
protected override GetReceiveAmountOrderRD ProcessRequest(APIRequest <GetReceiveAmountOrderRP> pRequest) { GetReceiveAmountOrderRP rp = pRequest.Parameters; GetReceiveAmountOrderRD rd = new GetReceiveAmountOrderRD(); ReceiveAmountOrderBLL receiveAmountOrderBll = new ReceiveAmountOrderBLL(CurrentUserInfo); var couponUseBll = new CouponUseBLL(CurrentUserInfo); var couponBll = new CouponBLL(CurrentUserInfo); var paymentBll = new T_Payment_TypeBLL(CurrentUserInfo); //收款业务 if (rp.Type == 1) { if (!string.IsNullOrEmpty(rp.TimeStamp)) { var receiveAmountOrderEntity = receiveAmountOrderBll.QueryByEntity(new ReceiveAmountOrderEntity() { TimeStamp = rp.TimeStamp }, null).FirstOrDefault(); if (receiveAmountOrderEntity != null) { rd.TotalAmount = receiveAmountOrderEntity.TotalAmount ?? 0; rd.PayPoints = receiveAmountOrderEntity.PayPoints ?? 0; rd.AmountAcctPay = receiveAmountOrderEntity.AmountAcctPay ?? 0; rd.PayStatus = receiveAmountOrderEntity.PayStatus; rd.VipId = receiveAmountOrderEntity.VipId; rd.TransAmount = (receiveAmountOrderEntity.TransAmount ?? 0) - (receiveAmountOrderEntity.AmountAcctPay ?? 0); rd.OrderNo = receiveAmountOrderEntity.OrderNo; rd.vipDiscount = receiveAmountOrderEntity.VipDiscount ?? 100; //优惠券使用 var couponUseEntity = couponUseBll.QueryByEntity(new CouponUseEntity() { OrderID = receiveAmountOrderEntity.OrderId.ToString() }, null).FirstOrDefault(); if (couponUseEntity != null) { var couponEntity = couponBll.GetByID(couponUseEntity.CouponID); if (couponEntity != null) { rd.CouponName = couponEntity.CoupnName; var couponTypeBll = new CouponTypeBLL(CurrentUserInfo); var couponTypeEntity = couponTypeBll.GetByID(couponEntity.CouponTypeID); rd.CouponAmount = couponTypeEntity.ParValue ?? 0; } } //支付方式 var paymentEntity = paymentBll.GetByID(receiveAmountOrderEntity.PayTypeId); if (paymentEntity != null) { rd.PayTypeName = paymentEntity.Payment_Type_Name; } } else { throw new APIException("没有找到此订单") { ErrorCode = 200 }; } } else { //收款订单 if (!string.IsNullOrEmpty(rp.OrderId)) { var receiveAmountOrderEntity = receiveAmountOrderBll.GetByID(rp.OrderId); rd.TotalAmount = receiveAmountOrderEntity.TotalAmount ?? 0; rd.PayPoints = receiveAmountOrderEntity.PayPoints ?? 0; rd.AmountAcctPay = receiveAmountOrderEntity.AmountAcctPay ?? 0; rd.PayStatus = receiveAmountOrderEntity.PayStatus; rd.TransAmount = (receiveAmountOrderEntity.TransAmount ?? 0) - (receiveAmountOrderEntity.AmountAcctPay ?? 0); rd.OrderNo = receiveAmountOrderEntity.OrderNo; rd.vipDiscount = receiveAmountOrderEntity.VipDiscount ?? 100; //优惠券使用 var couponUseEntity = couponUseBll.QueryByEntity(new CouponUseEntity() { OrderID = rp.OrderId }, null).FirstOrDefault(); if (couponUseEntity != null) { var couponEntity = couponBll.GetByID(couponUseEntity.CouponID); if (couponEntity != null) { rd.CouponName = couponEntity.CoupnName; var couponTypeBll = new CouponTypeBLL(CurrentUserInfo); var couponTypeEntity = couponTypeBll.GetByID(couponEntity.CouponTypeID); rd.CouponAmount = couponTypeEntity.ParValue ?? 0; } } //支付方式 var paymentEntity = paymentBll.GetByID(receiveAmountOrderEntity.PayTypeId); if (paymentEntity != null) { rd.PayTypeName = paymentEntity.Payment_Type_Name; } } } } //充值业务 if (rp.Type == 2) { var rechargeOrderBll = new RechargeOrderBLL(CurrentUserInfo); var rechargeOrderEntity = rechargeOrderBll.GetByID(rp.OrderId); if (rechargeOrderEntity != null) { rd.PayStatus = rechargeOrderEntity.Status.ToString(); rd.VipId = rechargeOrderEntity.VipID; rd.ReturnAmount = rechargeOrderEntity.ReturnAmount ?? 0; } else { throw new APIException("没有找到此订单") { ErrorCode = 200 }; } } //订单业务 if (rp.Type == 3) { var inoutBll = new T_InoutBLL(CurrentUserInfo); var inoutEntity = inoutBll.GetByID(rp.OrderId); if (inoutEntity != null) { rd.PayStatus = inoutEntity.Field1; rd.VipId = inoutEntity.vip_no; } else { throw new APIException("没有找到此订单") { ErrorCode = 200 }; } } return(rd); }
protected override GetVipCardTypeVirtualItemRD ProcessRequest(DTO.Base.APIRequest <GetVipCardTypeVirtualItemRP> pRequest) { var rd = new GetVipCardTypeVirtualItemRD(); var para = pRequest.Parameters; LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID); var vipBLL = new VipBLL(loggingSessionInfo); var vipIntegralBLL = new VipIntegralBLL(loggingSessionInfo); var sysVipCardTypeBLL = new SysVipCardTypeBLL(loggingSessionInfo); var vipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); var vipCardBLL = new VipCardBLL(loggingSessionInfo); var vipCardRuleBLL = new VipCardRuleBLL(loggingSessionInfo); var vipT_InoutBLL = new T_InoutBLL(loggingSessionInfo); List <VipCardUpgradeRewardInfo> VipCardUpgradeRewardList = new List <VipCardUpgradeRewardInfo>(); List <VipCardTypeRelateInfo> VipCardTypeRelateList = new List <VipCardTypeRelateInfo>(); //获取当前会员卡等级 VipEntity VipInfo = null; int? CurVipCardLevel = 0; //处理会员开卡礼信息 var VipCardUpgradeRewardInfoList = sysVipCardTypeBLL.GetCardUpgradeRewardList(loggingSessionInfo.ClientID); //定义卡体系信息 DataSet VipCardTypeSystemInfoList = null; string strVipID = string.Empty; switch (para.ApplicationType) { //为1是微信,为2时表示APP请求 case "1": //微信 strVipID = pRequest.UserID; break; case "2": //APP strVipID = para.VipID; //获取会员信息 break; } VipInfo = vipBLL.GetByID(strVipID);//获取会员信息 if (VipInfo != null) { rd.HeadImgUrl = VipInfo.HeadImgUrl == null ? "" : VipInfo.HeadImgUrl; var vipIntegralInfo = vipIntegralBLL.QueryByEntity(new VipIntegralEntity() { VipID = strVipID, VipCardCode = VipInfo.VipCode }, null).FirstOrDefault(); if (vipIntegralInfo != null)//获取当前会员积分 { rd.Integration = vipIntegralInfo.ValidIntegral != null ? vipIntegralInfo.ValidIntegral.Value : 0; } //获取会员卡等级相关信息 var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VIPID = strVipID, CustomerID = loggingSessionInfo.ClientID }, new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } }).FirstOrDefault(); if (vipCardMappingInfo != null) { var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity() { VipCardID = vipCardMappingInfo.VipCardID, VipCardStatusId = 1 }, null).FirstOrDefault(); if (vipCardInfo != null) { var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { VipCardTypeID = vipCardInfo.VipCardTypeID }, null).FirstOrDefault(); if (vipCardTypeInfo != null)//获取当前会员卡等级信息 { rd.VipCardTypeName = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : ""; rd.VipCardLevel = vipCardTypeInfo.VipCardLevel; CurVipCardLevel = vipCardTypeInfo.VipCardLevel; } } } else { var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { VipCardLevel = 1, CustomerID = loggingSessionInfo.ClientID }, null).FirstOrDefault(); if (vipCardTypeInfo != null) { rd.VipCardTypeName = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : ""; rd.VipCardLevel = vipCardTypeInfo.VipCardLevel != null ? vipCardTypeInfo.VipCardLevel : 1; CurVipCardLevel = vipCardTypeInfo.VipCardLevel != null ? vipCardTypeInfo.VipCardLevel : 1; } } //获取会员消费金额 decimal VipConsumptionInfo = vipT_InoutBLL.GetVipSumAmount(strVipID); if (VipConsumptionInfo > 0) { rd.VipConsumptionAmount = Convert.ToDecimal(VipConsumptionInfo).ToString("0.00"); } else { rd.VipConsumptionAmount = "0"; } //获取卡等级相关信息(会员卡等级信息、升级条件、基本权益关联虚拟商品) VipCardTypeSystemInfoList = sysVipCardTypeBLL.GetVipCardTypeVirtualItemList(loggingSessionInfo.ClientID, CurVipCardLevel, para.ApplicationType, VipInfo.VIPID); } if (VipCardTypeSystemInfoList != null && VipCardTypeSystemInfoList.Tables[0].Rows.Count > 0) { int flag = 0;//定义下面开卡礼能否进行展示(0=不进,1=进) if (VipCardUpgradeRewardInfoList != null && VipCardUpgradeRewardInfoList.Tables[0].Rows.Count > 0) { flag = 1; //获取开卡礼信息 为之后筛选数据使用 VipCardUpgradeRewardList = DataTableToObject.ConvertToList <VipCardUpgradeRewardInfo>(VipCardUpgradeRewardInfoList.Tables[0]); } var dt = VipCardTypeSystemInfoList.Tables[0]; foreach (DataRow dr in dt.Rows) { var DataInfo = new VipCardTypeRelateInfo(); //VipCardTypeRelateList = new List<VipCardTypeRelateInfo>(); DataInfo.VipCardType = new VipCardTypeInfo(); //会员卡体系 DataInfo.VipCardUpgradeRule = new VipCardUpgradeRuleInfo(); //会员卡升级规则 DataInfo.VipCardRule = new VipCardRuleInfo(); //会员卡基本体系 DataInfo.VipCardUpgradeRewardList = new List <VipCardUpgradeRewardInfo>(); //var VipCardTypeData = new VipCardTypeInfo(); //给会员卡等级赋值 DataInfo.VipCardType.VipCardTypeID = Convert.ToInt32(dr["VipCardTypeID"]); DataInfo.VipCardType.VipCardLevel = Convert.ToInt32(dr["VipCardLevel"]); DataInfo.VipCardType.VipCardTypeName = dr["VipCardTypeName"].ToString(); DataInfo.VipCardType.PicUrl = dr["PicUrl"].ToString(); DataInfo.VipCardType.IsPrepaid = Convert.ToInt32(dr["IsPrepaid"]); DataInfo.VipCardType.IsOnlineSales = Convert.ToInt32(dr["IsOnlineSales"]); DataInfo.VipCardType.ItemID = dr["ItemID"].ToString(); DataInfo.VipCardType.SkuID = dr["SkuID"].ToString(); int cardStatus = 0; //获取卡状态购买信息 0=没购买,1=已购买 pRequest.UserID if (DataInfo.VipCardType.IsPrepaid != 1)//非可储值类型关联订单 { cardStatus = vipT_InoutBLL.GetVirtualItemStatus(loggingSessionInfo.ClientID, strVipID, DataInfo.VipCardType.SkuID); } else//可储值类型关联充值订单 { var RechargeOrderBll = new RechargeOrderBLL(loggingSessionInfo); var RechargeOrderInfo = RechargeOrderBll.QueryByEntity(new RechargeOrderEntity() { OrderDesc = "Upgrade", VipID = strVipID, VipCardTypeId = DataInfo.VipCardType.VipCardTypeID, Status = 1 }, null).FirstOrDefault(); if (RechargeOrderInfo != null)//如果为空需要在订单表里查找下记录 { cardStatus = 1; } else { cardStatus = vipT_InoutBLL.GetVirtualItemStatus(loggingSessionInfo.ClientID, strVipID, DataInfo.VipCardType.SkuID); } } DataInfo.VipCardType.Status = cardStatus; //var VipCardUpgradeRuleData = new VipCardUpgradeRuleInfo(); DataInfo.VipCardUpgradeRule.VipCardTypeID = Convert.ToInt32(dr["VipCardTypeID"]); DataInfo.VipCardUpgradeRule.VipCardUpgradeRuleId = dr["VipCardUpgradeRuleId"].ToString(); DataInfo.VipCardUpgradeRule.IsPurchaseUpgrade = Convert.ToInt32(dr["IsPurchaseUpgrade"]); DataInfo.VipCardUpgradeRule.IsExtraMoney = Convert.ToInt32(dr["IsExtraMoney"]); DataInfo.VipCardUpgradeRule.Prices = Convert.ToDecimal(dr["Prices"]); DataInfo.VipCardUpgradeRule.ExchangeIntegral = Convert.ToInt32(dr["ExchangeIntegral"]); DataInfo.VipCardUpgradeRule.IsRecharge = Convert.ToInt32(dr["IsRecharge"]); DataInfo.VipCardUpgradeRule.OnceRechargeAmount = Convert.ToDecimal(dr["OnceRechargeAmount"]); DataInfo.VipCardUpgradeRule.IsBuyUpgrade = Convert.ToInt32(dr["IsBuyUpgrade"]); DataInfo.VipCardUpgradeRule.BuyAmount = Convert.ToDecimal(dr["BuyAmount"]); DataInfo.VipCardUpgradeRule.OnceBuyAmount = Convert.ToDecimal(dr["OnceBuyAmount"]); //var VipCardRuleData = new VipCardUpgradeRuleInfo(); DataInfo.VipCardRule.VipCardTypeID = Convert.ToInt32(dr["VipCardTypeID"]); DataInfo.VipCardRule.RuleID = Convert.ToInt32(dr["RuleID"]); DataInfo.VipCardRule.CardDiscount = Convert.ToDecimal(dr["CardDiscount"]); DataInfo.VipCardRule.PaidGivePercetPoints = Convert.ToDecimal(dr["PaidGivePercetPoints"]); DataInfo.VipCardRule.PaidGivePoints = Convert.ToDecimal(dr["PaidGivePoints"]); if (flag == 1)//当flag=1的时候进行开卡礼的展示 { DataInfo.VipCardUpgradeRewardList = VipCardUpgradeRewardList.Where(m => m.VipCardTypeID == Convert.ToInt32(dr["VipCardTypeID"])).Select( t => new VipCardUpgradeRewardInfo() { CardUpgradeRewardId = t.CardUpgradeRewardId, VipCardTypeID = t.VipCardTypeID, CouponTypeID = t.CouponTypeID, CouponNum = t.CouponNum, CouponName = t.CouponName, ValidityPeriod = t.BeginTime == null ? ("领取后" + (t.ServiceLife == 0 ? "1天内有效" : t.ServiceLife.ToString() + "天内有效")) : (t.BeginTime.Value.ToString("yyyy-MM-dd") + "至" + t.EndTime.Value.ToString("yyyy-MM-dd")), BeginTime = t.BeginTime, EndTime = t.EndTime, BeginTimeDate = t.BeginTime == null ? "" : t.BeginTime.Value.ToString("yyyy年MM月dd日"), EndTimeDate = t.EndTime == null ? "" : t.EndTime.Value.ToString("yyyy年MM月dd日"), ServiceLife = t.ServiceLife, CouponDesc = t.CouponDesc, ParValue = t.ParValue }).ToList(); } VipCardTypeRelateList.Add(DataInfo); } rd.VipCardTypeItemList = VipCardTypeRelateList; } return(rd); }
/// <summary> /// 微信扫码支付 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> protected override ScanWxPayRD ProcessRequest(DTO.Base.APIRequest <ScanWxPayRP> pRequest) { var rd = new ScanWxPayRD(); var par = pRequest.Parameters; try { //获取登录信息,数据库的一些链接与基础信息 LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.OpenID); var rechargeOrderBLL = new RechargeOrderBLL(loggingSessionInfo); decimal appOrderAmount = 0; //实际支付金额 if (par.PaymentScenarios == 1) //根据支付场景区分对应的订单表获取实际支付金额 { //直充订单支付金额 var rechargeOrderInfo = rechargeOrderBLL.GetByID(par.OrderId); if (rechargeOrderInfo != null) { appOrderAmount = rechargeOrderInfo.ActuallyPaid.Value; } } else { var inout = new T_InoutBLL(loggingSessionInfo); //售卡订单支付金额 var inoutOrderInfo = inout.GetByID(par.OrderId); if (inoutOrderInfo != null) { appOrderAmount = inoutOrderInfo.actual_amount.Value; } } //交易中心请求参数 var para = new { PayChannelID = par.ChannelID, AppOrderID = par.OrderId, AppOrderTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"), AppOrderAmount = ToInt(appOrderAmount * 100), AppOrderDesc = par.OrderDesc, Currency = 1, MobileNO = par.Mobile, ReturnUrl = string.Empty, DynamicID = string.Empty, DynamicIDType = string.Empty, Paras = new Dictionary <string, object>(), OpenId = pRequest.OpenID, ClientIP = Utils.GetHostAddress(), PaymentMode = par.PaymentMode }; var request = new { AppID = 1, ClientID = pRequest.CustomerID, UserID = pRequest.UserID, Parameters = para }; //Json参数准备 string pUrlPath = ConfigurationManager.AppSettings["paymentcenterUrl"]; string jsonString = string.Format("action=CreateOrder&request={0}", request.ToJSON()); Loggers.Debug(new DebugLogInfo() { Message = "创建订单到交易中心,请求地址:" + pUrlPath + ",请求参数:" + jsonString }); string httpResponse = HttpHelper.SendHttpRequest(pUrlPath, jsonString); Loggers.Debug(new DebugLogInfo() { Message = string.Format("交易中心返回结果:{0}", httpResponse.ToJSON()) }); //反序列化 var payres = httpResponse.DeserializeJSONTo <RespCreateOrder>(); if (payres.ResultCode == 0) { //根据微信返回的CodeUrl生成二维码 string currentDomain = ConfigurationManager.AppSettings["website_WWW"].ToString(); string sourcePath = HttpContext.Current.Server.MapPath("/Images/qrcode2.jpg"); string targetPath = HttpContext.Current.Server.MapPath("/file/images/"); var payQrCodeUrl = Utils.GenerateQRCodeWx(payres.Datas.QrCodeUrl, currentDomain, sourcePath, targetPath); //生成二维码方法 rd.QrCodeUrl = payQrCodeUrl; } } catch (Exception ex) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("交易中心代码异常信息:{0}", ex.Message + ";堆栈信息:" + ex.StackTrace) }); } return(rd); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var OrderID = context.Request["OrderID"]; var OrderStatus = context.Request["OrderStatus"]; var CustomerID = context.Request["CustomerID"]; var UserID = context.Request["UserID"]; var ChannelID = context.Request["ChannelID"]; var SerialPay = context.Request["SerialPay"]; try { if (string.IsNullOrEmpty(OrderID) || string.IsNullOrEmpty(OrderStatus) || string.IsNullOrEmpty(CustomerID) || string.IsNullOrEmpty(UserID) || string.IsNullOrEmpty(ChannelID)) { throw new Exception("参数不全:OrderID,OrderStatus,CustomerID,UserID"); } else { if (OrderStatus == "2") { //支付成功,更新卡的支付状态 //OrderID就是VIPCardID // //var rp = pRequest.DeserializeJSONTo<APIRequest<SetVipCardRP>>(); //if (string.IsNullOrEmpty(rp.Parameters.PayID)) //{ // throw new APIException("缺少参数【PayID】或参数值为空") { ErrorCode = 135 }; //} var loggingSessionInfo = Default.GetBSLoggingSession(CustomerID, UserID); //会员 var vipBll = new VipBLL(loggingSessionInfo); var vipAmountBll = new VipAmountBLL(loggingSessionInfo); var vipCardVipMappingBll = new VipCardVipMappingBLL(loggingSessionInfo); //支付 var tPaymentTypeCustomerMappingBll = new TPaymentTypeCustomerMappingBLL(loggingSessionInfo); var tPaymentTypeBll = new T_Payment_TypeBLL(loggingSessionInfo); var paymentDetailBll = new T_Payment_detailBLL(loggingSessionInfo); //门店 var unitBLL = new t_unitBLL(loggingSessionInfo); //商品订单支付 //更新积分和状态 //var loggingSessionInfo = Default.GetBSLoggingSession(CustomerID, "1"); var inoutBll = new T_InoutBLL(loggingSessionInfo);//订单业务对象实例化 var trrBll = new T_RewardRecordBLL(loggingSessionInfo); //辨别打赏订单 var rewardOrderPrefix = "REWARD|"; if (OrderID.Contains(rewardOrderPrefix)) { OrderID = OrderID.Substring(rewardOrderPrefix.Length, OrderID.Length - rewardOrderPrefix.Length); var trrEntity = trrBll.GetByID(OrderID); trrEntity.PayStatus = 2; trrEntity.LastUpdateTime = DateTime.Now; trrEntity.LastUpdateBy = loggingSessionInfo.UserID; trrBll.Update(trrEntity); #region 员工余额变更--需要独立出来处理 var userAmountBll = new VipAmountBLL(loggingSessionInfo); //作为员工余额使用 var employeeId = trrEntity.RewardedOP; var rewardAmount = trrEntity.RewardAmount == null ? 0 : (decimal)trrEntity.RewardAmount; //转为非null的decimal类型 //门店 var unitService = new UnitService(loggingSessionInfo); var unitInfo = unitService.GetUnitByUser(CustomerID, employeeId).FirstOrDefault();//获取员工所属门店 var tran = userAmountBll.GetTran(); using (tran.Connection)//事务 { try { var userAmountEntity = userAmountBll.GetByID(trrEntity.RewardedOP); if (userAmountEntity == null) { //创建 userAmountEntity = new VipAmountEntity { VipId = employeeId,//员工ID VipCardCode = string.Empty, BeginAmount = 0, InAmount = rewardAmount, OutAmount = 0, EndAmount = rewardAmount, TotalAmount = rewardAmount, BeginReturnAmount = 0, InReturnAmount = 0, OutReturnAmount = 0, ReturnAmount = 0, ImminentInvalidRAmount = 0, InvalidReturnAmount = 0, ValidReturnAmount = 0, TotalReturnAmount = 0, IsLocking = 0, CustomerID = CustomerID }; userAmountBll.Create(userAmountEntity, tran);//创建员工余额表 } else { //修改 if (rewardAmount > 0) { userAmountEntity.InAmount = (userAmountEntity.InAmount == null ? 0 : userAmountEntity.InAmount.Value) + rewardAmount; userAmountEntity.TotalAmount = (userAmountEntity.TotalAmount == null ? 0 : userAmountEntity.TotalAmount.Value) + rewardAmount; } else { userAmountEntity.OutAmount = (userAmountEntity.OutAmount == null ? 0 : userAmountEntity.OutAmount.Value) + Math.Abs(rewardAmount); } userAmountEntity.EndAmount = (userAmountEntity.EndAmount == null ? 0 : userAmountEntity.EndAmount.Value) + rewardAmount; userAmountBll.Update(userAmountEntity, tran);//更新余额 } var vipamountDetailBll = new VipAmountDetailBLL(loggingSessionInfo); var vipAmountDetailEntity = new VipAmountDetailEntity { VipAmountDetailId = Guid.NewGuid(), VipCardCode = string.Empty, VipId = employeeId,//员工ID UnitID = unitInfo != null ? unitInfo.unit_id : string.Empty, UnitName = unitInfo != null ? unitInfo.Name : string.Empty, Amount = rewardAmount, UsedReturnAmount = 0, EffectiveDate = DateTime.Now, DeadlineDate = Convert.ToDateTime("9999-12-31 23:59:59"), AmountSourceId = "26", Reason = "Reward", CustomerID = CustomerID }; vipamountDetailBll.Create(vipAmountDetailEntity, tran); //创建余额详情 tran.Commit(); //提交事务 } catch (Exception ex) { tran.Rollback(); Loggers.Debug(new DebugLogInfo() { Message = "异常-->支付成功回调时更新会员打赏金额出错(PayNotify.ashx):" + ex }); } } #endregion if (trrEntity != null) { context.Response.Write("SUCCESS"); } else { context.Response.Write("FAIL"); } return; } //获取会员信息 var vipInfo = vipBll.GetByID(loggingSessionInfo.UserID); //支付信息 Bear //var tPaymentTypeCustomerMappingEntity = tPaymentTypeCustomerMappingBll.QueryByEntity(new TPaymentTypeCustomerMappingEntity(){ChannelId = ChannelID,CustomerId = loggingSessionInfo.ClientID },null).FirstOrDefault(); var paymentTypeList = tPaymentTypeBll.GetAll(); var tPaymentType = paymentTypeList.ToList() .Find(t => t.Payment_Type_Code == "WXJS"); //var tPaymentType = tPaymentTypeBll.GetByID(tPaymentTypeCustomerMappingEntity.PaymentTypeID); //获取订单信息 var inoutInfo = inoutBll.GetByID(OrderID); if (inoutInfo != null) { var bll = new TInOutStatusNodeBLL(loggingSessionInfo); string msg; if (!bll.SetOrderPayment(OrderID, out msg, ChannelID, SerialPay)) //if (!bll.SetOrderPayment(OrderID, out msg, ChannelID)) { throw new Exception(msg); } else if (string.IsNullOrEmpty(inoutInfo.Field17) && string.IsNullOrEmpty(inoutInfo.Field18)) { #region 发送订单支付成功微信模板消息 var SuccessCommonBLL = new CommonBLL(); //SuccessCommonBLL.SentPaymentMessage(inoutInfo, vipInfo.WeiXinUserId,vipInfo.VIPID, loggingSessionInfo); new SendOrderPaySuccessMsgBLL().SentPaymentMessage(inoutInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, loggingSessionInfo); #endregion Loggers.Debug(new DebugLogInfo() { Message = "调用SetOrderPayment方法更新订单成功" }); } //获取订单信息,根据Field3==1判断,如果是ALD订单,则调用ALD接口更新ALD订单的状态 #region 更新ALD状态 //var orderbll = new InoutService(loggingSessionInfo); //var orderInfo = orderbll.GetInoutInfoById(OrderID); //if (orderInfo.Field3 == "1") //{ // Loggers.Debug(new DebugLogInfo() { Message = string.Format("更新O2OMarketing订单状态成功[OrderID={0}].", OrderID) }); // //更新阿拉丁的订单状态 // JIT.CPOS.Web.OnlineShopping.data.DataOnlineShoppingHandler.ALDChangeOrderStatus aldChangeOrder = new data.DataOnlineShoppingHandler.ALDChangeOrderStatus(); // if (string.IsNullOrEmpty(orderInfo.vip_no)) // throw new Exception("会员ID不能为空,OrderID:" + OrderID); // aldChangeOrder.MemberID = new Guid(orderInfo.vip_no); // aldChangeOrder.SourceOrdersID = OrderID; // aldChangeOrder.Status = int.Parse(orderInfo.status); // aldChangeOrder.IsPaid = true; // JIT.CPOS.Web.OnlineShopping.data.DataOnlineShoppingHandler.ALDChangeOrderStatusRequest aldRequest = new data.DataOnlineShoppingHandler.ALDChangeOrderStatusRequest(); // aldRequest.BusinessZoneID = 1;//写死 // aldRequest.Locale = 1; // aldRequest.UserID = new Guid(orderInfo.vip_no); // aldRequest.Parameters = aldChangeOrder; // var url = ConfigurationManager.AppSettings["ALDGatewayURL"]; // var postContent = string.Format("Action=ChangeOrderStatus&ReqContent={0}", aldRequest.ToJSON()); // Loggers.Debug(new DebugLogInfo() { Message = "通知ALD更改状态:" + postContent }); // var strAldRsp = HttpWebClient.DoHttpRequest(url, postContent); // var aldRsp = strAldRsp.DeserializeJSONTo<JIT.CPOS.Web.OnlineShopping.data.DataOnlineShoppingHandler.ALDResponse>(); // if (!aldRsp.IsSuccess()) // { // Loggers.Debug(new DebugLogInfo() { Message = string.Format("更新阿拉丁订单状态失败[Request ={0}][Response={1}]", aldRequest.ToJSON(), strAldRsp) }); // } //} #endregion #region 格力推送通知 //try //{ // GLServiceOrderBLL glsobll = new GLServiceOrderBLL(loggingSessionInfo); // if (glsobll.ValidateGree(CustomerID, "cpos_bs_lj"))//先写死 // glsobll.GreePushPaymentOorder(CustomerID, OrderID, loggingSessionInfo); //} //catch (Exception ex) //{ // Loggers.Debug(new DebugLogInfo() { Message = string.Format("付款推送评价师傅链接失败[OrderID={0}].", OrderID) }); //} #endregion #region ALD生活服务处理 //var rechargeBll = new RechargeStrategyBLL(loggingSessionInfo); //var vipAmountBll = new VipAmountBLL(loggingSessionInfo); //var couponBll = new CouponBLL(loggingSessionInfo); //var vipCouponMappingBll = new VipCouponMappingBLL(loggingSessionInfo); //var unitBll = new UnitBLL(loggingSessionInfo); //DataSet dsOrderInfo = rechargeBll.GetInoutOrderItems(OrderID); //int itemSort = 0; //商品业务分类 //string skuId = string.Empty; //商品SkuId //string vipId = string.Empty; //会员ID //string itemId = string.Empty;//商品ID //string couponId = string.Empty;//优惠券ID //if (dsOrderInfo.Tables[0].Rows.Count > 0) //{ // //if (dsOrderInfo.Tables[0].Rows[0]["ItemSort"] != DBNull.Value && Convert.ToString(dsOrderInfo.Tables[0].Rows[0]["ItemSort"]) != "0") // itemSort = int.Parse(dsOrderInfo.Tables[0].Rows[0]["ItemSort"].ToString()); // switch (itemSort) // { // case 2://充 // #region 充值金额处理 // VipAmountDetailBLL vipAmountDetailBll = new VipAmountDetailBLL(loggingSessionInfo); // List<IWhereCondition> complexCondition = new List<IWhereCondition> { }; // complexCondition.Add(new EqualsCondition() { FieldName = "ObjectId", Value = OrderID }); // var vipAmountDetal = vipAmountDetailBll.Query(complexCondition.ToArray(), null); // if (vipAmountDetal.Count() == 0)//确认没有多次执行回调 // { // ////查询 // //RechargeStrategyEntity[] rechargeList = rechargeBll.Query(complexCondition.ToArray(), lstOrder.ToArray()); // skuId = dsOrderInfo.Tables[0].Rows[0]["SkuId"].ToString(); // //RechargeStrategyEntity rechargeEntity = rechargeBll.GetByID(skuId); // DataSet dsSkuPirce = unitBll.GetSkuPirce(skuId); // decimal salePrice = 0;//购买金额 // decimal returnCash = 0;//奖励金额 // if (dsSkuPirce.Tables[0].Rows.Count > 0) // { // salePrice = Convert.ToDecimal(dsSkuPirce.Tables[0].Rows[0]["SalesPrice"].ToString()); // returnCash = Convert.ToDecimal(dsSkuPirce.Tables[0].Rows[0]["ReturnCash"].ToString()); // InoutService server = new InoutService(loggingSessionInfo); // #region 充值金额 // var tran = server.GetTran(); // using (tran.Connection)//事物 // { // try // { // //充值金额 // vipAmountBll.AddVipEndAmount(UserID, salePrice, tran, "4", OrderID, loggingSessionInfo);//4=充值 // tran.Commit(); // } // catch (Exception) // { // tran.Rollback(); // throw; // } // } // #endregion // #region 奖励金额 // var tran2 = server.GetTran(); // using (tran2.Connection)//事物 // { // try // { // //奖励金额 // vipAmountBll.AddVipEndAmount(UserID, returnCash, tran2, "6", OrderID, loggingSessionInfo);//6=奖励金额 // tran2.Commit(); // } // catch (Exception) // { // tran2.Rollback(); // throw; // } // } // #endregion // } // } // #endregion // break; // case 3://券 // #region 券类商品绑定到会员 // itemId = dsOrderInfo.Tables[0].Rows[0]["ItemId"].ToString(); // vipId = dsOrderInfo.Tables[0].Rows[0]["VipId"].ToString(); // couponId = couponBll.GetCouponByItemId(itemId); // if (!string.IsNullOrEmpty(couponId)) // { // VipCouponMappingEntity coupon = new VipCouponMappingEntity // { // VIPID = vipId, // CouponID = couponId, // }; // vipCouponMappingBll.Create(coupon); // } // #endregion // break; // default: // break; // } //} #endregion #region 订单与分润关系处理 add by Henry 2014-10-10 //var orderSubBll = new OrderOrderSubRunObjectMappingBLL(loggingSessionInfo); //dynamic o = orderSubBll.SetOrderSub(CustomerID, OrderID); //Type t = o.GetType(); //var Desc = t.GetProperty("Desc").GetValue(o, null).ToString(); //var IsSuccess = t.GetProperty("IsSuccess").GetValue(o, null).ToString(); //if (int.Parse(IsSuccess.ToString()) == 0) //失败 // Loggers.Debug(new DebugLogInfo() { Message = string.Format("订单与分润关系处理失败:{0}", Desc) }); #endregion CustomerBasicSettingBLL customerBasicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo); string AfterPaySetStock = customerBasicSettingBll.GetSettingValueByCode("AfterPaySetStock"); if (AfterPaySetStock == "1") { var inoutServiceBLL = new InoutService(loggingSessionInfo); var inoutDetailList = inoutServiceBLL.GetInoutDetailInfoByOrderId(OrderID); inoutBll.SetStock(OrderID, inoutDetailList, 1, loggingSessionInfo); } ///超级分销商订单入队列 if (inoutInfo.data_from_id == "35" || inoutInfo.data_from_id == "36") { BS.BLL.RedisOperationBLL.Order.SuperRetailTraderOrderBLL bllSuperRetailTraderOrder = new BS.BLL.RedisOperationBLL.Order.SuperRetailTraderOrderBLL(); bllSuperRetailTraderOrder.SetRedisToSuperRetailTraderOrder(loggingSessionInfo, inoutInfo); } //购卡 if (!string.IsNullOrEmpty(inoutInfo.Field17) && !string.IsNullOrEmpty(inoutInfo.Field18)) { //更新订单状态 inoutInfo = inoutBll.GetByID(OrderID); inoutInfo.Field7 = "700"; inoutInfo.status = "700"; inoutInfo.status_desc = "已完成"; inoutInfo.Field10 = "已完成"; inoutBll.Update(inoutInfo); //会员卡升级 vipCardVipMappingBll.BindVirtualItem(vipInfo.VIPID, vipInfo.VipCode, inoutInfo.sales_unit_id, Convert.ToInt32(inoutInfo.Field18), orderId: inoutInfo.order_id); //分润计算 RedisSalesVipCardOrderBLL redisSalesVipCardOrderBll = new RedisSalesVipCardOrderBLL(); redisSalesVipCardOrderBll.SetRedisSalesVipCardOrder(loggingSessionInfo, inoutInfo); //售卡处理积分、返现、佣金[完成订单] new SendOrderRewardMsgBLL().OrderReward(inoutInfo, loggingSessionInfo, null);//存入到缓存 } else { //订单入队列 RedisCalculateVipConsumeForUpgrade redisCalculateVipConsumeForUpgrade = new RedisCalculateVipConsumeForUpgrade(); redisCalculateVipConsumeForUpgrade.SetVipConsumeForUpgradeList(loggingSessionInfo, inoutInfo); } // add by liangx 2016-09-27 获取订单中的虚拟商品 start CouponTypeBLL couponTypeBLL = new CouponTypeBLL(loggingSessionInfo); RedisVipMappingCouponBLL redisVipMappingCouponBLL = new RedisVipMappingCouponBLL(); var couponTypes = couponTypeBLL.GetVirtualItemCouponTypes(inoutInfo.order_id); if (couponTypes.Any()) { redisVipMappingCouponBLL.SetVipMappingCoupon(couponTypes, "", couponTypes.FirstOrDefault().VipId, "PayVirtualItem"); } // add by liangx 2016-09-27 获取订单中的虚拟商品 end //获取门店信息 t_unitEntity unitInfo = null; if (!string.IsNullOrEmpty(inoutInfo.sales_unit_id)) { unitInfo = unitBLL.GetByID(inoutInfo.sales_unit_id); } //入支付明细表 var paymentDetail = new T_Payment_detailEntity() { Payment_Id = Guid.NewGuid().ToString(), Inout_Id = inoutInfo.order_id, UnitCode = unitInfo == null ? "" : unitInfo.unit_code, Payment_Type_Id = tPaymentType.Payment_Type_Id, Payment_Type_Code = tPaymentType.Payment_Type_Code, Payment_Type_Name = tPaymentType.Payment_Type_Name, Price = inoutInfo.actual_amount, Total_Amount = inoutInfo.total_amount, Pay_Points = inoutInfo.pay_points, CustomerId = loggingSessionInfo.ClientID }; paymentDetailBll.Create(paymentDetail); List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; complexCondition.Add(new EqualsCondition() { FieldName = "Inout_Id", Value = inoutInfo.order_id }); var paymentDetailList = paymentDetailBll.Query(complexCondition.ToArray(), null); try { var msgRabbitMQ = new EventContract { Operation = OptEnum.Create, EntityType = EntityTypeEnum.Order, Id = inoutInfo.order_id }; var service = new EventService(); service.PublishMsg(msgRabbitMQ); foreach (var detail in paymentDetailList) { var paymentMQ = new EventContract { Operation = OptEnum.Create, EntityType = EntityTypeEnum.OrderPayment, Id = detail.Payment_Id }; service.PublishMsg(paymentMQ); } } catch (Exception) { throw new Exception("RabbitMQ Error"); } } else//充值订单 { var rechargeOrderBll = new RechargeOrderBLL(loggingSessionInfo); var vipamountDetailBll = new VipAmountDetailBLL(loggingSessionInfo); var rechargeOrderInfo = rechargeOrderBll.GetByID(OrderID); if (rechargeOrderInfo != null) { //获取门店信息 t_unitEntity unitInfo = null; if (!string.IsNullOrEmpty(rechargeOrderInfo.UnitId)) { unitInfo = unitBLL.GetByID(rechargeOrderInfo.UnitId); } //充值 rechargeOrderBll.Recharge(rechargeOrderInfo, vipInfo, unitInfo, tPaymentType.Payment_Type_Id); //入支付明细表 var paymentDetail = new T_Payment_detailEntity() { Payment_Id = Guid.NewGuid().ToString(), Inout_Id = rechargeOrderInfo.OrderID.ToString(), UnitCode = unitInfo == null ? "" : unitInfo.unit_code, Payment_Type_Id = tPaymentType.Payment_Type_Id, Payment_Type_Code = tPaymentType.Payment_Type_Code, Payment_Type_Name = tPaymentType.Payment_Type_Name, Price = rechargeOrderInfo.ActuallyPaid, Total_Amount = rechargeOrderInfo.TotalAmount, Pay_Points = rechargeOrderInfo.PayPoints, CustomerId = loggingSessionInfo.ClientID }; paymentDetailBll.Create(paymentDetail); } else { var receiveAmountOrderBll = new ReceiveAmountOrderBLL(loggingSessionInfo); var receiveAmountOrderEntity = receiveAmountOrderBll.GetByID(OrderID); //更新订单状态 if (receiveAmountOrderEntity != null) { VipIntegralBLL vipIntegralBll = new VipIntegralBLL(loggingSessionInfo); //更新订单 receiveAmountOrderEntity.PayStatus = "10"; // Bear //receiveAmountOrderEntity.PayTypeId = tPaymentTypeCustomerMappingEntity.PaymentTypeID; receiveAmountOrderEntity.PayTypeId = tPaymentType.Payment_Type_Id; receiveAmountOrderEntity.PayDatetTime = DateTime.Now; receiveAmountOrderBll.Update(receiveAmountOrderEntity); //获取门店信息 t_unitEntity unitInfo = null; if (!string.IsNullOrEmpty(receiveAmountOrderEntity.ServiceUnitId)) { unitInfo = unitBLL.GetByID(receiveAmountOrderEntity.ServiceUnitId); } //使用过积分,处理积分 if (receiveAmountOrderEntity.PayPoints != 0 && receiveAmountOrderEntity.PayPoints != null) { string sourceId = "20"; //积分抵扣 var IntegralDetail = new VipIntegralDetailEntity() { Integral = -Convert.ToInt32(receiveAmountOrderEntity.PayPoints), IntegralSourceID = sourceId, ObjectId = receiveAmountOrderEntity.OrderId.ToString() }; if (IntegralDetail.Integral != 0) { //变动前积分 string OldIntegral = (vipInfo.Integration ?? 0).ToString(); //变动积分 string ChangeIntegral = (IntegralDetail.Integral ?? 0).ToString(); var vipIntegralDetailId = vipIntegralBll.AddIntegral(ref vipInfo, unitInfo, IntegralDetail, loggingSessionInfo); //发送微信积分变动通知模板消息 if (!string.IsNullOrWhiteSpace(vipIntegralDetailId)) { var CommonBLL = new CommonBLL(); CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, loggingSessionInfo); } } } //if (receiveAmountOrderEntity.CouponUsePay != 0 || receiveAmountOrderEntity.CouponUsePay != null) //{ // //更新使用记录 // var couponUseBll = new CouponUseBLL(loggingSessionInfo); // var couponUseEntity = new CouponUseEntity() // { // CouponUseID = Guid.NewGuid(), // CouponID = rp.CouponId, // VipID = vipInfo.VIPID, // UnitID = rp.UnitId, // OrderID = orderId.ToString(), // Comment = "商城使用电子券", // CustomerID = CurrentUserInfo.ClientID, // CreateBy = CurrentUserInfo.UserID, // CreateTime = DateTime.Now, // LastUpdateBy = CurrentUserInfo.UserID, // LastUpdateTime = DateTime.Now, // IsDelete = 0 // }; // couponUseBll.Create(couponUseEntity); // var couponBll = new CouponBLL(CurrentUserInfo); // var couponEntity = couponBll.GetByID(rp.CouponId); // //更新CouponType数量 // var conponTypeBll = new CouponTypeBLL(CurrentUserInfo); // var conponTypeEntity = conponTypeBll.QueryByEntity(new CouponTypeEntity() { CouponTypeID = new Guid(couponEntity.CouponTypeID), CustomerId = CurrentUserInfo.ClientID }, null).FirstOrDefault(); // conponTypeEntity.IsVoucher += 1; // conponTypeBll.Update(conponTypeEntity); // //停用该优惠券 // couponEntity.Status = 1; // couponBll.Update(couponEntity); //} //处理余额 if (receiveAmountOrderEntity.AmountAcctPay != null && receiveAmountOrderEntity.AmountAcctPay != 0) { var vipAmountDetailBll = new VipAmountDetailBLL(loggingSessionInfo); var vipAmountEntity = vipAmountBll.QueryByEntity(new VipAmountEntity() { VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode }, null).FirstOrDefault(); if (vipAmountEntity != null) { var detailInfo = new VipAmountDetailEntity() { Amount = -receiveAmountOrderEntity.AmountAcctPay, AmountSourceId = "1", ObjectId = receiveAmountOrderEntity.OrderId.ToString() }; var vipAmountDetailId = vipAmountBll.AddVipAmount(vipInfo, unitInfo, ref vipAmountEntity, detailInfo, loggingSessionInfo); if (!string.IsNullOrWhiteSpace(vipAmountDetailId)) {//发送微信账户余额变动模板消息 var CommonBLL = new CommonBLL(); CommonBLL.BalanceChangedMessage(receiveAmountOrderEntity.OrderNo, vipAmountEntity, detailInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, loggingSessionInfo); } } } //收款订单积分奖励 vipIntegralBll.OrderReward(receiveAmountOrderEntity, null); var paymentDetail = new T_Payment_detailEntity() { Payment_Id = Guid.NewGuid().ToString(), Inout_Id = receiveAmountOrderEntity.OrderId.ToString(), UnitCode = unitInfo == null ? "" : unitInfo.unit_code, Payment_Type_Id = tPaymentType.Payment_Type_Id, Payment_Type_Code = tPaymentType.Payment_Type_Code, Payment_Type_Name = tPaymentType.Payment_Type_Name, Price = receiveAmountOrderEntity.TransAmount, Total_Amount = receiveAmountOrderEntity.TotalAmount, Pay_Points = receiveAmountOrderEntity.PayPoints, CustomerId = loggingSessionInfo.ClientID }; paymentDetailBll.Create(paymentDetail); } } } context.Response.Write("SUCCESS"); } } } catch (Exception ex) { Loggers.Exception(new ExceptionLogInfo(ex)); context.Response.Write("ERROR:" + ex.Message); } }