/// <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()); } }
/// <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() + "+"); } }