/// <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> /// 新订单规则 /// 取年份后两位加上月日时分,再加三维随机数 public string GetUnitOrderNo() { string ReturnOrderNo = ""; string OrderNo = GenerateOrderNo(); //检索订单号是否重复 var InoutBLL = new T_InoutBLL(this.CurrentUserInfo); var Result = InoutBLL.QueryByEntity(new T_InoutEntity() { order_no = OrderNo }, null).ToList(); if (Result.Count() > 0) { System.Threading.Thread.Sleep(1000); ReturnOrderNo = GenerateOrderNo(); } else { ReturnOrderNo = OrderNo; } return(ReturnOrderNo); }
/// <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 object GetDetailByParameters(GetPanicbuyingItemDetailReqPara para, string userId) { LoggingSessionInfo loggingSessionInfo = this.CurrentUserInfo as LoggingSessionInfo; var detail = GetByEventIDAndItemID(para.eventId, para.itemId); if (detail == null) { throw new Exception("未找到相关活动商品信息"); } #region 照片列表 var imagebll = new ObjectImagesBLL(loggingSessionInfo); var tempImageList = imagebll.GetObjectImagesByObjectId(para.itemId); var imagelist = tempImageList.Select(t => new { imageId = t.ImageId, imageUrl = t.ImageURL, imageUrlThumb = GetImageUrl(t.ImageURL, "_120"), imageUrlMiddle = GetImageUrl(t.ImageURL, "_240"), imageUrlBig = GetImageUrl(t.ImageURL, "_480") }).ToArray(); #endregion #region sku列表 var skubll = new SkuService(loggingSessionInfo); var ds = skubll.GetItemSkuListByEventId(para.itemId, para.eventId); var skulist = ds.Tables[0].AsEnumerable().Select(t => new { skuId = t["skuId"].ToString(), skuProp1 = t["skuProp1"].ToString(), skuProp2 = t["skuProp2"].ToString(), price = t["price"] is DBNull ? 0 : Double.Parse(t["price"].ToString()), salesPrice = t["salesPrice"] is DBNull ? 0 : Double.Parse(t["salesPrice"].ToString()), //price = t["price"] is DBNull ? "0" : Double.Parse(t["price"].ToString()).ToString("0.##"), //salesPrice = t["salesPrice"] is DBNull ? "0" : Double.Parse(t["salesPrice"].ToString()).ToString("0.##"), discountRate = string.IsNullOrEmpty(t["discountRate"].ToString()) ? "0" : t["discountRate"].ToString(),//折扣 integral = string.IsNullOrEmpty(t["integral"].ToString()) ? "0" : t["integral"].ToString(), //qty = Convert.ToInt32(t["qty"] is DBNull ? "0" : t["qty"]), //overQty = Convert.ToInt32(t["overQty"] is DBNull ? "0" : t["overQty"]) }).ToArray(); #endregion #region 购买用户列表 var inoutbll = new T_InoutBLL(loggingSessionInfo); var dsSalesUsers = inoutbll.GetItemEventSalesUserList(para.itemId, para.eventId); var salesUserList = dsSalesUsers.Tables[0].AsEnumerable().Select(t => new { userId = t["userId"].ToString(), imageURL = t["imageURL"].ToString() }).ToArray(); #endregion #region 门店信息 object storeInfo = null; var dsStore = inoutbll.GetEventStoreByItemAndEvent(para.itemId, para.eventId); if (dsStore.Tables[0].Rows.Count > 0) { var row = dsStore.Tables[0].Rows[0]; storeInfo = new { storeId = row["storeid"], storeName = row["storeName"], address = row["address"], imageURL = row["imageURL"], phone = row["phone"], storeCount = row["storeCount"] }; } #endregion #region 品牌信息 var dsBrand = inoutbll.GetItemBrandInfo(para.itemId); object brandInfo = null; if (dsBrand.Tables[0].Rows.Count > 0) { var row = dsBrand.Tables[0].Rows[0]; brandInfo = new { brandId = row["brandId"], brandLogoURL = row["brandLogoURL"], brandName = row["brandName"], brandEngName = row["brandEngName"] }; } #endregion #region sku信息 IList <object> skuInfoList = new List <object>(); object skuInfo = null; if (skulist.Count() > 0) { for (int i = skulist.Count() - 1; i >= 0; i--) { var sku = skulist[i]; var info = skubll.GetSkuInfoById(sku.skuId); skuInfoList.Add(new { skuId = sku.skuId, prop1DetailId = info.prop_1_id, prop2DetailId = info.prop_2_id }); if (i == 0) { skuInfo = new { skuId = sku.skuId, prop1DetailId = info.prop_1_id, prop2DetailId = info.prop_2_id }; } } } #endregion #region 属性信息 IList <prop1Info> prop1List = new List <prop1Info>(); object prop1 = null; //update by wzq 20140724 if (skulist.Count() > 0) { for (int c = skulist.Count() - 1; c >= 0; c--) { var dsProp = inoutbll.GetItemProp1List(skulist[c].skuId); //var dsProp = inoutbll.GetItemProp1List(para.itemId); if (dsProp.Tables[0].Rows.Count > 0) { prop1List.Add(dsProp.Tables[0].AsEnumerable().Select(t => new prop1Info { skuId = "" + t["skuId"], prop1DetailId = "" + t["prop1DetailId"], prop1DetailName = "" + t["prop1DetailName"], stock = Convert.ToInt32(string.IsNullOrWhiteSpace("" + t["stock"]) == true ? 0 : t["stock"]), salesCount = Convert.ToInt32(string.IsNullOrWhiteSpace("" + t["salesCount"]) == true ? 0 : t["salesCount"]) }).First()); } if (c == 0) { prop1 = dsProp.Tables[0].AsEnumerable().Select(t => new { skuId = "" + t["skuId"], prop1DetailId = "" + t["prop1DetailId"], prop1DetailName = "" + t["prop1DetailName"], stock = Convert.ToInt32(string.IsNullOrWhiteSpace("" + t["stock"]) == true ? 0 : t["stock"]), salesCount = Convert.ToInt32(string.IsNullOrWhiteSpace("" + t["salesCount"]) == true ? 0 : t["salesCount"]) }).First(); } } prop1List = prop1List.GroupBy(t => new { t.prop1DetailId, t.prop1DetailName }).Select(n => new prop1Info { skuId = n.Max(t => t.skuId), prop1DetailId = n.Key.prop1DetailId, prop1DetailName = n.Key.prop1DetailName, stock = n.Sum(t => t.stock), salesCount = n.Sum(t => t.salesCount) }).ToList(); } #endregion #region 限购处理 int canBuyCount = -1; //可购买数量 int singlePurchaseQty = GetEventItemInfo(para.eventId.ToString(), para.itemId); //活动商品限购数量 if (!string.IsNullOrEmpty(userId)) { if (singlePurchaseQty > 0) { //会员采购数量 int purchaseCount = GetVipPurchaseQty(userId, para.eventId, para.itemId); canBuyCount = singlePurchaseQty - purchaseCount; } } #endregion #region 获取商户信息 add by Henry 2014-10-10 var customerBll = new t_customerBLL(loggingSessionInfo); var customerBasicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo); t_customerEntity customerEntity = customerBll.GetByCustomerID(loggingSessionInfo.CurrentUser.customer_id); //获取商户名称 var customerInfo = new { CustomerName = customerEntity == null ? "" : customerEntity.customer_name, //商户名称 ImageURL = customerBasicSettingBll.GetSettingValueByCode("AppLogo"), //商户Logo CustomerMobile = customerBasicSettingBll.GetSettingValueByCode("CustomerMobile") }; #endregion var content = new { #region 组织属性 itemId = detail.ItemID, itemName = detail.ItemName, salesPersonCount = detail.SalesPersonCount, useInfo = detail.UseInfo, tel = detail.Tel, endTime = detail.EndTime.Value.To19FormatString(), offersTips = detail.OffersTips, prop1Name = detail.Prop1Name, prop2Name = detail.Prop2Name, itemCategoryName = detail.ItemCategoryName, itemCategoryId = detail.ItemCategoryID, itemIntroduce = detail.ItemIntroduce, itemParaIntroduce = detail.ItemParaIntroduce, //salesCount = detail.MonthSalesCount.HasValue ? detail.MonthSalesCount.Value.ToString("0.##") : "0", salesCount = detail.SalesCount, //销量 update by Henry 2014-11-12 beginLineSecond = GetBeginLineSecond(detail.BeginTime.Value), deadlineTime = detail.deadlineTime, discountRate = detail.DiscountRate == null ? 0 : Convert.ToDecimal((detail.DiscountRate / 10).Value.ToString("0.0")),//update by Henry 2014-10-20 addedTime = detail.AddTime.Value.To19FormatString(), deadlineSecond = detail.RemainingSec, beginTime = detail.BeginTime.Value.To19FormatString(), qty = detail.Qty, overQty = detail.RemainingQty, stopReason = detail.StopReason, status = detail.Status, eventId = detail.EventId, eventTypeID = detail.EventTypeID, imageList = imagelist, skuList = skulist, //数组 skuInfoList = skuInfoList, //数组 salesUserList = salesUserList, storeInfo = storeInfo, brandInfo = brandInfo, skuInfo = skuInfo, prop1List = prop1List, //数组 prop1 = prop1, //object canBuyCount = canBuyCount, singlePurchaseQty = singlePurchaseQty, serviceDescription = detail.ServiceDescription, itemSortId = detail.ItemSortId, CustomerInfo = customerInfo #endregion }; return(content); }
/// <summary> /// 订单支付成功修改状态 /// </summary> /// <param name="orderId">订单标识</param> /// <param name="strError">错误提示</param> /// <param name="ChannelId">支付渠道标识</param> /// <returns></returns> public bool SetOrderPayment(string orderId, out string strError, string ChannelId = null, string SerialPay = null) //public bool SetOrderPayment(string orderId, out string strError, string ChannelId = null) { MarketSendLogBLL logSerer = new MarketSendLogBLL(this.CurrentUserInfo); MarketSendLogEntity logInfo = new MarketSendLogEntity(); logInfo.LogId = BaseService.NewGuidPub(); logInfo.VipId = "System"; logInfo.MarketEventId = orderId; logInfo.Phone = ChannelId; logInfo.SendTypeId = "3"; try { bool bReturn = this._currentDAO.SetOrderPayment(orderId, out strError, ChannelId); if (bReturn) { //算积分 //var bll = new JIT.CPOS.BS.BLL.InoutService(this.CurrentUserInfo); //var orderInfo = bll.GetInoutInfoById(orderId); //VipIntegralBLL vipIntegralServer = new VipIntegralBLL(this.CurrentUserInfo); //Loggers.Debug(new DebugLogInfo() //{ // Message = string.Format("SetOrderPayment-参数: sourceId={0},customerId={1},vipId={2},orderId={3}", 1, this.CurrentUserInfo.CurrentUser.customer_id, orderInfo.vip_no, orderId) //}); //vipIntegralServer.ProcessPoint(1, this.CurrentUserInfo.CurrentUser.customer_id, orderInfo.vip_no, orderId); this._currentDAO.OrderPayCallBack(orderId, SerialPay, this.CurrentUserInfo.ClientID, Convert.ToInt32(ChannelId)); strError = "成功."; logInfo.TemplateContent = strError; logSerer.Create(logInfo); //记录日志 qianzhi 2014-03-17 //var inoutStatus = new TInoutStatusBLL(CurrentUserInfo); //TInoutStatusEntity info = new TInoutStatusEntity(); //info.InoutStatusID = Guid.Parse(Utils.NewGuid()); //info.OrderID = orderId; //info.CustomerID = CurrentUserInfo.CurrentLoggingManager.Customer_Id; //info.OrderStatus = 10000; //支付方式 //info.Remark = "支付成功"; //info.StatusRemark = "订单支付成功[操作人:" + CurrentUserInfo.CurrentUser.User_Name + "]"; //inoutStatus.Create(info); T_InoutBLL inoutBLL = new T_InoutBLL(this.CurrentUserInfo); inoutBLL.SetVirtualItem(CurrentUserInfo, orderId); //支付回调/收款处理虚拟商品订单 return(true); } return(bReturn); } catch (Exception ex) { strError = ex.ToString(); Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetOrderPayment-失败: {0}", strError) }); logInfo.TemplateContent = strError.Substring(0, 100); logInfo.IsSuccess = 0; logSerer.Create(logInfo); return(false); } }