Example #1
0
        /// <summary>
        /// 获取会员折扣
        /// </summary>
        /// <returns></returns>
        public decimal GetVipDiscount()
        {
            decimal vipDiscount = 10;    //会员折扣
            //判断是否启用会员折扣
            var basicSettingBLL = new CustomerBasicSettingBLL(CurrentUserInfo);
            var vipBLL          = new VipBLL(CurrentUserInfo);
            //var sysVipCardGradeBLL = new SysVipCardGradeBLL(CurrentUserInfo);
            var vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo);
            var vipCardBLL           = new VipCardBLL(CurrentUserInfo);
            var vipCardRuleBLL       = new VipCardRuleBLL(CurrentUserInfo);
            //string vipDiscountSetting = basicSettingBLL.GetSettingValueByCode("VipCardGradeSalesPreferentia");
            //if (!string.IsNullOrEmpty(vipDiscountSetting))
            //{
            //    if (int.Parse(vipDiscountSetting) > 0)//启用
            //    {
            //        var vipInfo = vipBLL.GetByID(CurrentUserInfo.UserID);
            //        if (vipInfo != null)
            //        {
            //            if (vipInfo.VipLevel>0)
            //            {
            //                //获取会员等级折扣
            //                var sysVipCardGradeInfo = sysVipCardGradeBLL.GetByID(vipInfo.VipLevel);
            //                if (sysVipCardGradeInfo != null)
            //                    vipDiscount = sysVipCardGradeInfo.SalesPreferentiaAmount.Value;
            //            }
            //        }
            //    }
            //}
            var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
            {
                VIPID = CurrentUserInfo.UserID
            }, null).FirstOrDefault();

            if (vipCardMappingInfo != null)
            {
                var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity()
                {
                    VipCardID = vipCardMappingInfo.VipCardID
                }, null).FirstOrDefault();
                if (vipCardInfo != null)
                {
                    var vipCardRuleInfo = vipCardRuleBLL.QueryByEntity(new VipCardRuleEntity()
                    {
                        VipCardTypeID = vipCardInfo.VipCardTypeID
                    }, null).FirstOrDefault();
                    if (vipCardRuleInfo != null && vipCardRuleInfo.CardDiscount > 0)
                    {
                        vipDiscount = vipCardRuleInfo.CardDiscount == null ? 10 : (vipCardRuleInfo.CardDiscount.Value / 10);
                    }
                }
            }
            return(vipDiscount);
        }
Example #2
0
        /// <summary>
        /// 返现处理
        /// </summary>
        /// <param name="vipInfo">会员信息</param>
        /// <param name="unitInfo">门店信息</param>
        /// <param name="detailInfo">余额变更明细</param>
        /// <param name="tran">事务</param>
        /// <param name="loggingSessionInfo">登录信息</param>
        /// <param name="amountSourceId"></param>
        public string AddReturnAmount(VipEntity vipInfo, t_unitEntity unitInfo, VipAmountEntity vipAmountInfo, ref VipAmountDetailEntity detailInfo, SqlTransaction tran, LoggingSessionInfo loggingSessionInfo)
        {
            string vipAmountDetailId       = string.Empty;//变更明细ID
            var    vipAmountDao            = new VipAmountBLL(loggingSessionInfo);
            var    vipAmountDetailDao      = new VipAmountDetailBLL(loggingSessionInfo);
            var    customerBasicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo);

            //获取返现有效期
            int cashValidPeriod     = 2; //默认为1,业务处理时会减去1
            var cashValidPeriodInfo = customerBasicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity()
            {
                SettingCode = "CashValidPeriod", CustomerID = loggingSessionInfo.ClientID
            }, null).FirstOrDefault();

            if (cashValidPeriodInfo != null)
            {
                cashValidPeriod = int.Parse(cashValidPeriodInfo.SettingValue);
            }

            //var vipAmountInfo = vipAmountDao.GetByID(vipId);
            try
            {
                if (vipAmountInfo == null)  //无账户数据
                {
                    vipAmountInfo = new VipAmountEntity
                    {
                        VipId                  = vipInfo.VIPID,
                        VipCardCode            = vipInfo.VipCode,
                        BeginAmount            = 0,
                        InAmount               = 0,
                        OutAmount              = 0,
                        EndAmount              = 0,
                        TotalAmount            = 0,
                        BeginReturnAmount      = 0,
                        InReturnAmount         = detailInfo.Amount,
                        OutReturnAmount        = 0,
                        ReturnAmount           = detailInfo.Amount,
                        ImminentInvalidRAmount = 0,
                        InvalidReturnAmount    = 0,
                        ValidReturnAmount      = detailInfo.Amount,
                        TotalReturnAmount      = detailInfo.Amount,
                        IsLocking              = 0,
                        CustomerID             = loggingSessionInfo.ClientID
                    };
                    vipAmountDao.Create(vipAmountInfo, tran);
                }
                else
                {
                    if (detailInfo.Amount > 0)
                    {
                        vipAmountInfo.InReturnAmount    = (vipAmountInfo.InReturnAmount == null ? 0 : vipAmountInfo.InReturnAmount.Value) + detailInfo.Amount;
                        vipAmountInfo.TotalReturnAmount = (vipAmountInfo.TotalReturnAmount == null ? 0 : vipAmountInfo.TotalReturnAmount.Value) + detailInfo.Amount;
                    }
                    else
                    {
                        vipAmountInfo.OutReturnAmount = (vipAmountInfo.OutReturnAmount == null ? 0 : vipAmountInfo.OutReturnAmount.Value) + System.Math.Abs(detailInfo.Amount.Value);
                    }
                    vipAmountInfo.ValidReturnAmount = (vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value) + detailInfo.Amount;
                    vipAmountInfo.ReturnAmount      = (vipAmountInfo.ReturnAmount == null ? 0 : vipAmountInfo.ReturnAmount.Value) + detailInfo.Amount;

                    vipAmountDao.Update(vipAmountInfo);
                }
                //创建变更记录
                var vipamountDetailBll    = new VipAmountDetailBLL(loggingSessionInfo);
                var vipAmountDetailEntity = new VipAmountDetailEntity
                {
                    VipAmountDetailId = Guid.NewGuid(),
                    VipId             = vipInfo.VIPID,
                    VipCardCode       = vipInfo.VipCode,
                    UnitID            = unitInfo != null ? unitInfo.unit_id : "",
                    UnitName          = unitInfo != null ? unitInfo.unit_name : "",
                    Amount            = detailInfo.Amount,
                    UsedReturnAmount  = 0,
                    Reason            = detailInfo.Reason,
                    Remark            = detailInfo.Remark,
                    EffectiveDate     = DateTime.Now,
                    DeadlineDate      = Convert.ToDateTime((DateTime.Now.Year + cashValidPeriod - 1) + "-12-31 23:59:59 "),//失效时间,
                    AmountSourceId    = detailInfo.AmountSourceId,
                    ObjectId          = detailInfo.ObjectId,
                    CustomerID        = loggingSessionInfo.ClientID
                };
                vipamountDetailBll.Create(vipAmountDetailEntity, tran);

                vipAmountDetailId = vipAmountDetailEntity.VipAmountDetailId.ToString();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw new APIException(ex.ToString())
                      {
                          ErrorCode = 121
                      };
            }
            return(vipAmountDetailId);
        }
        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);
        }
Example #4
0
        /// <summary>
        ///保存送货到家配置信息
        /// </summary>
        /// <param name="DeliveryStrategyEntity"></param>
        /// <param name="BasicSettingEntity"></param>
        /// add by donal 2014-10-22 13:29:07
        public void SaveDeliveryStrategyAndBasicSetting(CustomerDeliveryStrategyEntity DeliveryStrategyEntity, CustomerBasicSettingEntity BasicSettingEntity, LoggingSessionInfo loggingSessionInfo, string deliveryId)
        {
            TransactionHelper tranHelper = new TransactionHelper(loggingSessionInfo);
            IDbTransaction    tran       = tranHelper.CreateTransaction();

            CustomerBasicSettingBLL basicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo);

            #region  除信息

            //此商户下送货到家信息
            CustomerDeliveryStrategyEntity[] DeliveryStrategyList = QueryByEntity(
                new CustomerDeliveryStrategyEntity
            {
                CustomerId = loggingSessionInfo.ClientID,
                DeliveryId = DeliveryStrategyEntity.DeliveryId
            },
                null
                );

            //此商户下基数设置(描述)信息
            CustomerBasicSettingEntity[] BasicSettingList = basicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity
            {
                SettingCode = "DeliveryStrategy",
                CustomerID  = loggingSessionInfo.ClientID
            },
                                                                                          null
                                                                                          );

            //除本次保存数据的此商户下送货到家信息
            CustomerDeliveryStrategyEntity[] DeliveryStrategyList_d = DeliveryStrategyList.Where(m => m.Id != DeliveryStrategyEntity.Id).ToArray();
            //除本次保存数据的此商户下基数设置(描述)信息
            CustomerBasicSettingEntity[] BasicSettingList_d = BasicSettingList.Where(m => m.SettingID != BasicSettingEntity.SettingID).ToArray();

            if (DeliveryStrategyList_d != null && DeliveryStrategyList_d.Count() > 0)
            {
                Delete(DeliveryStrategyList_d, tran);
            }
            if (BasicSettingList_d != null && BasicSettingList_d.Count() > 0)
            {
                basicSettingBLL.Delete(BasicSettingList_d, tran);
            }
            #endregion

            #region 保存

            if (DeliveryStrategyEntity.Id == null || string.IsNullOrWhiteSpace(DeliveryStrategyEntity.Id.ToString()))
            {
                DeliveryStrategyEntity.Id = Guid.NewGuid();
                Create(DeliveryStrategyEntity, tran);
            }
            else
            {
                Update(DeliveryStrategyEntity, tran);
            }

            if (BasicSettingEntity.SettingID == null || string.IsNullOrWhiteSpace(BasicSettingEntity.SettingID.ToString()))
            {
                BasicSettingEntity.SettingID = Guid.NewGuid();
                basicSettingBLL.Create(BasicSettingEntity, tran);
            }
            else
            {
                basicSettingBLL.Update(BasicSettingEntity, tran);
            }

            //修改配送方式状态
            DeliveryBLL deliveryBll = new DeliveryBLL(loggingSessionInfo);
            deliveryBll.Update(
                new DeliveryEntity()
            {
                DeliveryId = deliveryId,
                Status     = DeliveryStrategyEntity.Status
            }
                , tran
                );
            #endregion
            tran.Commit();
        }