/// <summary> /// 支付回调/收款处理虚拟商品订单 /// </summary> public void SetVirtualItem(LoggingSessionInfo loggingSessionInfo, string orderId) { var inoutBLL = new T_InoutBLL(loggingSessionInfo); var inoutInfo = this._currentDAO.GetByID(orderId); if (inoutInfo != null) { //如果是经销商订单,付款完成后,订单状态修改成完成状态 if (inoutInfo.data_from_id == "21") { inoutInfo.Field7 = "700"; inoutInfo.status = "700"; inoutBLL.Update(inoutInfo); InoutService inoutService = new InoutService(loggingSessionInfo); T_VirtualItemTypeSettingBLL virtualItemTypeSettingBLL = new T_VirtualItemTypeSettingBLL(loggingSessionInfo); VipCardVipMappingBLL vipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); T_Inout_DetailBLL inoutDetailBLL = new T_Inout_DetailBLL(loggingSessionInfo); var VipBLL = new VipBLL(loggingSessionInfo); var inoutDetail = inoutService.GetInoutDetailInfoByOrderId(orderId).FirstOrDefault(); string itemId = inoutDetail.item_id; var virtualItemTypeSettingInfo = virtualItemTypeSettingBLL.QueryByEntity(new T_VirtualItemTypeSettingEntity() { ItemId = itemId }, null).FirstOrDefault(); if (virtualItemTypeSettingInfo != null) { int objectTypeId = int.Parse(virtualItemTypeSettingInfo.ObjecetTypeId); string objectNo = vipCardVipMappingBLL.BindVirtualItem(inoutInfo.vip_no, inoutInfo.VipCardCode, "", objectTypeId); //将卡/券的编号保存到订单明细 T_Inout_DetailEntity inoutDetailEntity = inoutDetailBLL.GetByID(inoutDetail.order_detail_id); if (inoutDetailEntity != null) { inoutDetailEntity.Field10 = objectNo; inoutDetailBLL.Update(inoutDetailEntity); } } //将Col48至为1 var VipData = VipBLL.GetByID(inoutInfo.vip_no); if (VipData != null) { VipData.Col48 = "1"; VipBLL.Update(VipData); } // 判断客户是否是符合潜在经销商条件 var isCan = VipBLL.IsSetVipDealer(inoutInfo.vip_no); if (isCan) { new RetailTraderBLL(loggingSessionInfo).CreatePrepRetailTrader(loggingSessionInfo, inoutInfo.vip_no); // 创建潜在经销商 } } } }
/// <summary> /// 批量发货 /// </summary> /// <param name="OrderID"></param> public int BatchInvalidShip(List <InoutInfo> OrderList, string Remark, LoggingSessionInfo LoggingSessionInfo) { var UpdateOrderList = new List <InoutInfo>(); foreach (var item in OrderList) { var result = this._currentDAO.GetByID(item.order_id); if (result != null) { var Entity = new InoutInfo() { order_id = result.order_id, Field2 = item.Field2, carrier_id = item.carrier_id, status = "600", status_desc = "已发货" }; UpdateOrderList.Add(Entity); } } //更新订单状态 int Num = this._currentDAO.BatchChangeOrderStatus(UpdateOrderList); if (Num > 0) {//添加状态操作记录 var inoutStatus = new TInoutStatusBLL(LoggingSessionInfo); var vipBll = new VipBLL(LoggingSessionInfo); var inoutService = new Inout3Service(LoggingSessionInfo); var CommonBLL = new CommonBLL(); foreach (var itemes in UpdateOrderList) { var info = new TInoutStatusEntity() { InoutStatusID = Guid.Parse(Utils.NewGuid()), OrderID = itemes.order_id, CustomerID = LoggingSessionInfo.ClientID, Remark = Remark, OrderStatus = 600, StatusRemark = "订单状态从未发货变为已发货[操作人:" + LoggingSessionInfo.CurrentUser.User_Name + "]" }; //执行 inoutStatus.Create(info); #region 发送微信模板消息 //获取订单 var OerderInfoData = this._currentDAO.GetByID(itemes.order_id); if (OerderInfoData != null) { //获取会员信息 var vipInfo = vipBll.GetByID(OerderInfoData.vip_no); if (vipInfo != null) { //物流公司 itemes.carrier_name = "";//inoutService.GetCompanyName(itemes.carrier_id); // CommonBLL.SentShipMessage(itemes, vipInfo.WeiXinUserId, itemes.vip_no, LoggingSessionInfo); new SendOrderSendMsgBLL().SentShipMessage(itemes, vipInfo.WeiXinUserId, itemes.vip_no, LoggingSessionInfo); } } #endregion } // Num = UpdateOrderList.Count(); } return(Num); }
/// <summary> /// 取消订单(Api和后台通用) /// </summary> /// <param name="orderId"></param> /// <param name="userType">0=会员;1=后台用户</param> /// <param name="loggingSessionInfo"></param> public void SetCancelOrder(string orderId, int userType, LoggingSessionInfo loggingSessionInfo) { var vipBll = new VipBLL(loggingSessionInfo); //会员业务实例化 var inoutDetailBLL = new Inout3Service(loggingSessionInfo); //订单业务实例化 var refundOrderBll = new T_RefundOrderBLL(loggingSessionInfo); //退货业务实例化 var inoutBll = new T_InoutBLL(loggingSessionInfo); //订单业务实例化 PanicbuyingEventBLL panicbuyingEventBLL = new PanicbuyingEventBLL(loggingSessionInfo); //活动订单业务实例化 T_SuperRetailTraderItemMappingBLL superRetailTraderItemMappingBll = new T_SuperRetailTraderItemMappingBLL(loggingSessionInfo); //分销商业务实例化 //获取订单详情 var inoutInfo = inoutBll.GetInoutInfo(orderId, loggingSessionInfo); //处理积分、余额、返现和优惠券 vipBll.ProcSetCancelOrder(loggingSessionInfo.ClientID, inoutInfo.order_id, inoutInfo.vip_no); //获取订单明细 var inoutDetailList = inoutDetailBLL.GetInoutDetailInfoByOrderId(inoutInfo.order_id, loggingSessionInfo.ClientID); #region 处理退款业务 if (inoutInfo != null) { //if (inoutInfo.Field1 == "1" && (inoutInfo.actual_amount - inoutInfo.DeliveryAmount) > 0)//已付款,并且实付款-运费>0 if (inoutInfo.Field1 == "1" && inoutInfo.actual_amount > 0)//已付款,并且实付款>0,未发货所以不用减运费 { #region 新增退货单(默认状态为确认收货) var salesReturnBLL = new T_SalesReturnBLL(loggingSessionInfo); var historyBLL = new T_SalesReturnHistoryBLL(loggingSessionInfo); T_SalesReturnEntity salesReturnEntity = null; T_SalesReturnHistoryEntity historyEntity = null; var userBll = new T_UserBLL(loggingSessionInfo); //店员BLL实例化 VipEntity vipEntity = null; //会员信息 salesReturnEntity = new T_SalesReturnEntity(); salesReturnEntity.SalesReturnNo = DateTime.Now.ToString("yyyyMMddHHmmssfff"); salesReturnEntity.VipID = loggingSessionInfo.UserID; salesReturnEntity.ServicesType = 1; //退货 salesReturnEntity.DeliveryType = 1; //快递送回; salesReturnEntity.OrderID = inoutInfo.order_id; var inoutDetailInfo = inoutDetailList.FirstOrDefault(); if (inoutDetailInfo != null) { salesReturnEntity.ItemID = inoutDetailInfo.item_id; salesReturnEntity.SkuID = inoutDetailInfo.sku_id; } salesReturnEntity.Qty = 0; salesReturnEntity.ActualQty = 0; if (inoutInfo != null) { salesReturnEntity.UnitID = inoutInfo.sales_unit_id; //salesReturnEntity.UnitName = para.UnitName; //salesReturnEntity.UnitTel = para.UnitTel; salesReturnEntity.Address = inoutInfo.Field4; salesReturnEntity.Contacts = inoutInfo.Field14 != null ? inoutInfo.Field14 : ""; salesReturnEntity.Phone = inoutInfo.Field6 != null ? inoutInfo.Field6 : ""; } salesReturnEntity.Reason = "取消订单"; //if (inoutInfo.actual_amount - inoutInfo.DeliveryAmount > 0) if (inoutInfo.actual_amount > 0) { salesReturnEntity.Status = 6; //已完成(待退款) } else { salesReturnEntity.Status = 7; //已完成(已退款) } salesReturnEntity.CustomerID = loggingSessionInfo.ClientID; salesReturnBLL.Create(salesReturnEntity); string userName = string.Empty; //操作人姓名 if (userType == 0) //会员操作 { vipEntity = vipBll.GetByID(loggingSessionInfo.UserID); userName = vipEntity != null ? vipEntity.VipName : ""; } else//后台用户操作 { userName = loggingSessionInfo.CurrentUser.User_Name; } historyEntity = new T_SalesReturnHistoryEntity() { SalesReturnID = salesReturnEntity.SalesReturnID, OperationType = 14, OperationDesc = "取消订单", OperatorID = loggingSessionInfo.UserID, HisRemark = "取消订单", OperatorName = userName, OperatorType = userType //0=会员;1=管理用户 }; historyBLL.Create(historyEntity); #endregion #region 新增退款单 //if (inoutInfo.actual_amount - inoutInfo.DeliveryAmount > 0) if (inoutInfo.actual_amount > 0) { T_RefundOrderEntity refundOrderEntity = new T_RefundOrderEntity() { RefundNo = DateTime.Now.ToString("yyyyMMddhhmmfff"), VipID = inoutInfo.vip_no, SalesReturnID = salesReturnEntity.SalesReturnID, //ServicesType = 1,//退货 DeliveryType = 1,//快递送回 ItemID = inoutDetailInfo.item_id, SkuID = inoutDetailInfo.sku_id, Qty = 0, ActualQty = 0, UnitID = inoutInfo.sales_unit_id, //salesReturnEntity.UnitName = para.UnitName; //salesReturnEntity.UnitTel = para.UnitTel; Address = inoutInfo.Field4, Contacts = inoutInfo.Field14, Phone = inoutInfo.Field6, OrderID = inoutInfo.order_id, PayOrderID = inoutInfo.paymentcenter_id, RefundAmount = inoutInfo.total_amount, ConfirmAmount = inoutInfo.total_amount, //ActualRefundAmount = inoutInfo.actual_amount - inoutInfo.DeliveryAmount,//实退金额=实付款-运费 ActualRefundAmount = inoutInfo.actual_amount,//实退金额=实付款 Points = inoutInfo.pay_points == null ? 0 : Convert.ToInt32(inoutInfo.pay_points), ReturnAmount = inoutInfo.ReturnAmount, Amount = inoutInfo.VipEndAmount, Status = 1,//待退款 CustomerID = loggingSessionInfo.ClientID }; refundOrderBll.Create(refundOrderEntity); } #endregion } } #endregion //普通订单库存处理 if (inoutInfo.order_reason_id == "2F6891A2194A4BBAB6F17B4C99A6C6F5") { inoutBll.SetStock(orderId, inoutDetailList, 2, loggingSessionInfo); } //团购抢购订单库存处理 if (inoutInfo.order_reason_id == "CB43DD7DD1C94853BE98C4396738E00C" || inoutInfo.order_reason_id == "671E724C85B847BDA1E96E0E5A62055A") { panicbuyingEventBLL.SetEventStock(orderId, inoutDetailList.ToList()); } //砍价订单库存处理 if (inoutInfo.order_reason_id == "096419BFDF394F7FABFE0DFCA909537F") { panicbuyingEventBLL.SetKJEventStock(orderId, inoutDetailList.ToList()); } //超级分销商库存处理 if (inoutInfo.data_from_id == "35" || inoutInfo.data_from_id == "36") { superRetailTraderItemMappingBll.DeleteSuperRetailTraderItemStock(inoutDetailList.ToList()); } }
public bool SetEventWXPush(LEventsEntity eventInfo, string WeiXin, string OpenId, string VipId, string msgUrl, out string strError, string AuthUrl, int iRad) { try { MarketSendLogBLL logServer = new MarketSendLogBLL(this.CurrentUserInfo); Random rad = new Random(); if (eventInfo == null || eventInfo.ModelId == null || eventInfo.ModelId.Equals("")) { strError = "获取信息不全,缺少模板。"; return(false); } #region WEventUserMappingBLL eventUserMapping = new WEventUserMappingBLL(CurrentUserInfo); int eventPersonCount = 0; eventPersonCount = eventUserMapping.GetEventSignInCount(eventInfo.EventID); #endregion WApplicationInterfaceBLL wAServer = new WApplicationInterfaceBLL(this.CurrentUserInfo); var wxArray = wAServer.QueryByEntity(new WApplicationInterfaceEntity { WeiXinID = WeiXin , IsDelete = 0 , CustomerId = this.CurrentUserInfo.CurrentUser.customer_id }, null); if (wxArray == null || wxArray.Length == 0 || wxArray[0].AppID == null || wxArray[0].AppID.Equals("")) { strError = "不存在对应的微信帐号"; return(false); } else { WApplicationInterfaceEntity wxInfo = wxArray[0]; WX.CommonBLL server = new WX.CommonBLL(); JIT.CPOS.BS.Entity.WX.SendMessageEntity sendMessageInfo = new Entity.WX.SendMessageEntity(); WMaterialTextBLL wTextServer = new WMaterialTextBLL(this.CurrentUserInfo); IList <WMaterialTextEntity> textlist = new List <WMaterialTextEntity>(); textlist = wTextServer.GetMaterialTextListByModelId(eventInfo.ModelId); if (textlist != null && textlist.Count > 0 && textlist[0].TextId != null) { #region VipBLL vipServer = new VipBLL(CurrentUserInfo); VipEntity vipInfo = vipServer.GetByID(VipId); sendMessageInfo.msgtype = "news"; sendMessageInfo.touser = OpenId; List <JIT.CPOS.BS.Entity.WX.NewsEntity> newsList = new List <JIT.CPOS.BS.Entity.WX.NewsEntity>(); foreach (var info in textlist) { JIT.CPOS.BS.Entity.WX.NewsEntity newsInfo = new Entity.WX.NewsEntity(); newsInfo.title = info.Title; if (vipInfo != null && !vipInfo.VIPID.Equals("")) { newsInfo.description = info.Author.Replace("#VIPNAME#", vipInfo.VipName); } else { newsInfo.description = info.Author; } newsInfo.description = newsInfo.description.Replace("#PERSONCOUNT#", Convert.ToString(eventPersonCount)); //string url = info.OriginalUrl; //JIT.Utility.Log.Loggers.Debug(new DebugLogInfo() //{ // Message = string.Format("处理原文链接出错:{0},url:{1};Status:{2};",) //}); if (info.OriginalUrl != null && !info.OriginalUrl.Equals("") && vipInfo.Status != null && !vipInfo.Status.ToString().Equals("")) { if (vipInfo.Status.Equals(1) && info.OriginalUrl.IndexOf("Fuxing") > 0) { newsInfo.description = info.Text; } else { } } if (info.OriginalUrl.IndexOf("?") > 0) { newsInfo.url = info.OriginalUrl + "&rnd=" + rad.Next(1000, 100000) + ""; } else { string goUrl = info.OriginalUrl + "?1=1&applicationId=" + wxInfo.ApplicationId + "&eventId=" + eventInfo.EventID + "&openId=" + OpenId + "&userId=" + VipId + ""; goUrl = HttpUtility.UrlEncode(goUrl); newsInfo.url = AuthUrl + "OnlineClothing/go.htm?customerId=" + this.CurrentUserInfo.CurrentUser.customer_id + "&applicationId=" + wxInfo.ApplicationId + "&openId=" + OpenId + "&userId=" + VipId + "&backUrl=" + goUrl + ""; } //OnlineClothing/go.htm?customerId=" + customerId + "&openId=" + OpenId + "&userId=" + vipId + "&backUrl=" + HttpUtility.UrlEncode(goUrl) + ""; newsInfo.picurl = info.CoverImageUrl; newsList.Add(newsInfo); } sendMessageInfo.articles = newsList; #endregion #region 发送日志 MarketSendLogEntity logInfo1 = new MarketSendLogEntity(); logInfo1.LogId = BaseService.NewGuidPub(); logInfo1.IsSuccess = 1; logInfo1.MarketEventId = eventInfo.EventID; logInfo1.SendTypeId = "2"; logInfo1.Phone = iRad.ToString(); if (sendMessageInfo.ToJSON().ToString().Length > 2000) { logInfo1.TemplateContent = sendMessageInfo.ToJSON().ToString().Substring(1, 1999); } else { logInfo1.TemplateContent = sendMessageInfo.ToJSON().ToString(); } logInfo1.VipId = VipId; logInfo1.WeiXinUserId = OpenId; logInfo1.CreateTime = System.DateTime.Now; logServer.Create(logInfo1); #endregion } var ResultEntity = server.SendMessage(sendMessageInfo, wxInfo.AppID, wxInfo.AppSecret, this.CurrentUserInfo, true); #region Jermyn20140110 处理复星年会的座位信息,是临时的 //FStaffBLL staffServer = new FStaffBLL(this.CurrentUserInfo); //bool bReturn = staffServer.SetStaffSeatsPush(VipId, eventInfo.EventID, out strError); //MarketSendLogEntity logInfo2 = new MarketSendLogEntity(); //logInfo2.LogId = BaseService.NewGuidPub(); //logInfo2.IsSuccess = 1; //logInfo2.MarketEventId = eventInfo.EventID; //logInfo2.SendTypeId = "2"; //logInfo2.TemplateContent = strError; //logInfo2.Phone = iRad.ToString(); //logInfo2.VipId = VipId; //logInfo2.WeiXinUserId = OpenId; //logInfo2.CreateTime = System.DateTime.Now; //logServer.Create(logInfo2); #endregion strError = "ok"; return(true); } } catch (Exception ex) { strError = ex.ToString(); return(false); } }
/// <summary> /// 关注或者注册日志 /// </summary> /// <param name="strCTWEventId">主题活动标识</param> /// <param name="strVipId">注册操作的vipid</param> /// <param name="strFocusVipId">关注操作的vipid</param> public void CTWRegOrFocusLog(string strCTWEventId, string strRegVipId, string strFocusVipId, LoggingSessionInfo loggingSession, string strType) { string strVipId = string.Empty; if (strType == "Reg") { strVipId = strRegVipId; } if (strType == "Focus") { strVipId = strFocusVipId; } BaseService.WriteLogWeixin(" 创意仓库日志:" + strCTWEventId + "+" + strVipId + "+" + strType); try { int intResult = this._currentDAO.IsExistsLog(strCTWEventId, strVipId, strType, loggingSession.ClientID); if (intResult == 0) { T_LEventsRegVipLogEntity entityRegVipLog = new T_LEventsRegVipLogEntity(); entityRegVipLog.BusTypeCode = "CTW"; entityRegVipLog.ObjectId = strCTWEventId; entityRegVipLog.RegVipId = strRegVipId; entityRegVipLog.FocusVipId = strFocusVipId; entityRegVipLog.CustomerId = loggingSession.ClientID; this._currentDAO.Create(entityRegVipLog); //触点奖励 ContactEventBLL bllContactEvent = new ContactEventBLL(loggingSession); var entityContact = bllContactEvent.QueryByEntity(new ContactEventEntity() { EventId = strCTWEventId, IsDelete = 0, IsCTW = 1, ContactTypeCode = strType }, null).SingleOrDefault(); if (entityContact != null) { LPrizesBLL bllPrize = new LPrizesBLL(loggingSession); var prize = DataTableToObject.ConvertToList <LPrizesEntity>(bllPrize.GetCouponTypeIDByEventId(entityContact.ContactEventId.ToString()).Tables[0]).FirstOrDefault(); if (prize != null) { CouponBLL bllCoupon = new CouponBLL(loggingSession); if (prize.PrizeTypeId == "Coupon") { bllCoupon.CouponBindVip(strVipId, prize.CouponTypeID, entityContact.ContactEventId.ToString(), strType); } if (prize.PrizeTypeId == "Point") { #region 调用积分统一接口 var salesReturnBLL = new T_SalesReturnBLL(loggingSession); VipIntegralBLL bllVipIntegral = new VipIntegralBLL(loggingSession); var vipBLL = new VipBLL(loggingSession); var vipInfo = vipBLL.GetByID(strVipId); string strIntegralSourceID = string.Empty; switch (entityContact.ContactTypeCode.ToString().TrimEnd()) { case "Reg": strIntegralSourceID = "2"; break; case "Focus": strIntegralSourceID = "3"; break; case "Share": strIntegralSourceID = "28"; break; default: strIntegralSourceID = "22"; break; } var IntegralDetail = new VipIntegralDetailEntity() { Integral = prize.Point, IntegralSourceID = strIntegralSourceID, ObjectId = entityContact.ContactEventId.ToString() }; //变动前积分 string OldIntegral = (vipInfo.Integration ?? 0).ToString(); //变动积分 string ChangeIntegral = (IntegralDetail.Integral ?? 0).ToString(); var vipIntegralDetailId = bllVipIntegral.AddIntegral(ref vipInfo, null, IntegralDetail, null, loggingSession); //发送微信积分变动通知模板消息 if (!string.IsNullOrWhiteSpace(vipIntegralDetailId)) { var CommonBLL = new CommonBLL(); CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, loggingSession); } #endregion } //LPrizeWinnerEntity entityPrizeWinner = new LPrizeWinnerEntity() //{ // PrizeWinnerID = Guid.NewGuid().ToString(), // VipID = strVipId, // PrizeID = prize.PrizesID, // PrizeName = prize.PrizeName, // PrizePoolID = entityPrizePool == null ? "" : entityPrizePool.PrizePoolsID, // CreateBy = this.CurrentUserInfo.UserID, // CreateTime = DateTime.Now, // IsDelete = 0 //}; //bllPrizeWinner.Create(entityPrizeWinner); } } } } catch (Exception ex) { BaseService.WriteLogWeixin(" 创意仓库日志:" + ex.ToString() + "+"); } }
/// <summary> /// 发送微信消息 /// </summary> /// <param name="VipId">用户标识</param> /// <param name="EventId">活动标识</param> /// <param name="strError">错误提示</param> /// <returns></returns> public bool SetEventVipSeatPush(string VipId, string EventId, out string strError) { strError = "成功."; #region //1.判断用户是否关注过活动 WEventUserMappingBLL eventServer = new WEventUserMappingBLL(this.CurrentUserInfo); var eventList = eventServer.QueryByEntity(new WEventUserMappingEntity { UserID = VipId , IsDelete = 0 , EventID = EventId }, null); if (eventList == null || eventList.Length == 0) { #region WEventUserMappingEntity eventUserMappingInfo = new WEventUserMappingEntity(); eventUserMappingInfo.Mapping = Common.Utils.NewGuid(); eventUserMappingInfo.EventID = EventId; eventUserMappingInfo.UserID = VipId; eventServer.Create(eventUserMappingInfo); #endregion } #endregion #region //2.判断用户是否注册 VipBLL vipServer = new VipBLL(this.CurrentUserInfo); VipEntity vipInfo = new VipEntity(); vipInfo = vipServer.GetByID(VipId); if (vipInfo == null || vipInfo.VIPID.Equals("")) { strError = "用户不存在"; return(false); } #endregion else { #region EventVipEntity eventVipInfo = new EventVipEntity(); var eventVipList = _currentDAO.QueryByEntity(new EventVipEntity { Phone = vipInfo.Phone , IsDelete = 0 }, null); if (eventVipList == null || eventVipList.Length == 0) { strError = "没有合适的员工."; return(false); } else { eventVipInfo = eventVipList[0]; } #endregion LEventsEntity lEventsEntity = new LEventsEntity(); lEventsEntity = new LEventsBLL(this.CurrentUserInfo).GetByID(EventId); //string message = "尊贵的" + eventVipInfo.VipName + "先生/女士:\r\n 诚挚地欢迎您参加复星集团2014年全球工作会议,本次会议将于8:30正式开始。请您至5楼静安大宴会厅" + eventVipInfo.Seat + "区域就坐,或参见胸卡背面提示."; string message = new WMaterialWritingBLL(this.CurrentUserInfo).GetWMaterialWritingByModelId(EventId).Content; message = ReplaceTemplate(message, eventVipList[0], vipInfo, lEventsEntity); //组织消息 string code = JIT.CPOS.BS.BLL.WX.CommonBLL.SendWeixinMessage(message, VipId, this.CurrentUserInfo, vipInfo); switch (code) { case "103": strError = "未查询到匹配的公众账号信息"; break; case "203": strError = "发送失败"; break; default: break; } } return(true); }