/// <summary>
        /// 检查null 值
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static object CheckNull(object obj)
        {
            object result = obj;

            if (obj != null && obj is String)
            {
                try
                {
                    var val  = obj.ToString();
                    var iVal = MCvHelper.To <int>(val, -1);
                    if (iVal == -1)
                    {
                        var verifyStrs = new string[] { "NULL", "_" };
                        if (!verifyStrs.Contains(val.ToUpper()))
                        {
                            result = val;
                        }
                        else
                        {
                            result = string.Empty;
                        }
                    }
                }
                catch
                {
                }
            }
            return(result);
        }
 /// <summary>
 /// 获取购物车商品数量
 /// </summary>
 /// <param name="token"> </param>
 /// <param name="channelId"></param>
 /// <param name="uid"></param>
 /// <param name="user_id"> </param>
 /// <returns></returns>
 public int GetShoppingCartGoodsNum(string token, int channelId, string uid, int user_id)
 {
     using (var holycaDb = new HolycaEntities())
     {
         var queryTxt = from c in holycaDb.Sale_ShoppingCart
                        where c.intChannelID == channelId &&
                        c.intIsDelete == 0
                        select c;
         if (user_id > 0)
         {
             queryTxt = queryTxt.Where(w => w.intUserID == user_id);
         }
         else if (!string.IsNullOrEmpty(token))
         {
             queryTxt = queryTxt.Where(w => w.vchGuid == token);
         }
         else
         {
             return(0);
         }
         try
         {
             var result = queryTxt.Sum(c => (int?)c.intBuyCount);
             return(MCvHelper.To <int>(result, 0));
         }
         catch
         {
             return(-1);
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 订单汇总信息
        /// </summary>
        /// <param name="norMalShoppingCart">购物车列表</param>
        /// <param name="channelId">区域ID</param>
        /// <param name="userId">用户id</param>
        /// <param name="payId">支付id</param>
        /// <param name="logisticsId">配送id</param>
        /// <param name="cityId">城市id</param>
        /// <returns></returns>
        public static OrderSumaryEntity SummaryOrderInfo(List <ShoppingCartEntity> norMalShoppingCart, int channelId, int userId, int payId, int logisticsId, int cityId)
        {
            var result = new OrderSumaryEntity();

            try
            {
                result.TotalScore    = norMalShoppingCart.Sum(c => c.intScore * c.intBuyCount);
                result.TotalGoodsFee = norMalShoppingCart.Sum(c => c.intBuyCount * c.numSalePrice);
                result.TotalWeight   = norMalShoppingCart.Sum(c => c.intBuyCount * c.intWeight ?? 0);
                result.TotalOriginal = norMalShoppingCart.Sum(c => c.intBuyCount * c.numOrgPrice);
                result.TotalFreight  =
                    BaseDataBLL.GetLogisticsInfo(
                        channelId,
                        userId,
                        MCvHelper.To <int>(cityId, 0),
                        payId, logisticsId,
                        result.TotalWeight, result.TotalGoodsFee).info;
                result.TotalDiscountFee = result.TotalGoodsFee -
                                          result.TotalOriginal;
                result.TotalOrderFee = result.TotalFreight +
                                       result.TotalGoodsFee -
                                       result.TotalDiscountFee;
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Order.订单汇总信息, null, "", ex);
            }
            return(result);
        }
        /// <summary>
        /// 获取购物车总金额
        /// </summary>
        /// <param name="user_id"></param>
        /// <param name="guid"></param>
        /// <param name="channelId"> </param>
        /// <returns></returns>
        public decimal GetShoppingTotal(int user_id, string guid, int channelId)
        {
            decimal result = 0;

            using (var holycaDb = new HolycaEntities())
            {
                if (user_id > 0 || !string.IsNullOrEmpty(guid))
                {
                    var queryTxt = from a in holycaDb.Sale_ShoppingCart where a.intChannelID == channelId && a.intIsDelete == 0 select a;
                    if (user_id > 0)
                    {
                        queryTxt = queryTxt.Where(w => w.intUserID == user_id);
                    }
                    else if (!string.IsNullOrEmpty(guid))
                    {
                        queryTxt = queryTxt.Where(w => w.vchGuid == guid);
                    }
                    try
                    {
                        result = MCvHelper.To <decimal>(queryTxt.Sum(s => (decimal?)(s.intBuyCount * s.numSalePrice)), 0);
                    }
                    catch
                    {
                        result = -1;
                    }
                }
            }
            return(result);
        }
        /// <summary>
        /// 获取 系统权限列表
        /// </summary>
        /// <returns></returns>
        public static List <ItemMethodVerify> GetSystemPermissionList()
        {
            var result         = new List <ItemMethodVerify>();
            var manageDal      = DALFactory.Manage();
            var permissionList = manageDal.GetSystemPermissionList();

            if (permissionList.Any())
            {
                permissionList.ForEach(item =>
                {
                    try
                    {
                        result.Add(new ItemMethodVerify
                        {
                            MethodName         = item.MethodName,
                            IsVerfiyPemissions = MCvHelper.To(item.IsVerfiyPemissions, false),
                            IsVerifyData       = MCvHelper.To(item.IsVerifyData, false),
                            IsVerifySystemId   = MCvHelper.To(item.IsVerifySystemId, false),
                            IsVerifyToken      = MCvHelper.To(item.IsVerifyToken, false),
                            IsEnableCache      = MCvHelper.To(item.IsEnableCache, false)
                        });
                    }
                    catch
                    {
                    }
                });
            }
            return(result);
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        public BaseWcfService()
        {
            var httpContext = HttpContext.Current;

            if (httpContext != null)
            {
                var args = httpContext.Request.Url.Segments;
                for (var i = 0; i < args.Length; i++)
                {
                    args[i] = ValidateUtility.CheckNull(args[i].Trim(new char[] { '/', '\\', ' ' })).ToString();
                }
                if (args.Length >= 8)
                {
                    SystemType = MCvHelper.To <SystemType>(args[3]);
                    Token      = MCvHelper.To <string>(args[4]);
                    Guid       = MCvHelper.To <string>(args[5]);
                    UserId     = MCvHelper.To <int>(args[6]);
                    Uid        = MCvHelper.To <string>(args[7]);
                }
                else
                {
                    MLogManager.Error(MLogGroup.WcfService.构造函数, "", "wcf 服务基类 构造函数初始化 ,uri参数错误");
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// 获取商品图片列表
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="uid"></param>
        /// <param name="gid"></param>
        /// <returns></returns>
        public static MResultList <ProductImg> GetGoodsPicList(string sid, string uid, int gid)
        {
            var result = new MResultList <ProductImg>(true);

            try
            {
                var goods = DALFactory.Goods();
                var list  = goods.GetGoodsPicList(gid);
                list.ForEach(picInfo =>
                {
                    try
                    {
                        result.list.Add(new ProductImg
                        {
                            id         = picInfo.intPicID,
                            product_id = picInfo.intProductID,
                            url        = FormatProductPicUrl(picInfo.vchPicURL),
                            position   = MCvHelper.To <int>(picInfo.vchPicType, 0),
                            created    = picInfo.dtAddTime
                        });
                    }
                    catch
                    { }
                });
                result.status = MResultStatus.Success;
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExecutionError;
                result.msg    = "查询商品列表数据出错!";
            }

            return(result);
        }
Beispiel #8
0
 /// <summary>
 /// 同步订单信息到 BBHome
 /// </summary>
 /// <param name="orderCode"></param>
 /// <returns></returns>
 public bool SyncOrderInfoToBBHome(string orderCode)
 {
     using (var db = new HolycaEntities())
     {
         var objectParameter = new ObjectParameter("result", DbType.Int32);
         db.Up_Syn_ToBBHome_Now(orderCode, objectParameter);
         return(MCvHelper.To <int>(objectParameter.Value, -1) != -1);
     }
 }
        /// <summary>
        /// 合并购物车商品
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="channelId"></param>
        /// <param name="uid"></param>
        /// <param name="userID"></param>
        /// <returns></returns>
        public static bool MergeShoppingCartGoods(string guid, int channelId, string uid, int userID)
        {
            var result           = false;
            var mergeSuccessGids = new List <int>();
            var shoppingCart     = DALFactory.ShoppingCartDal();

            //guid 的 购物车数据
            var guidList = shoppingCart.GetShoppingCartProductInfosByUserIDGuidChannelID(0, guid, channelId);
            //userId 的 购物车数据
            var userIdList = shoppingCart.GetShoppingCartProductInfosByUserIDGuidChannelID(userID, "", channelId);

            if (guidList != null && guidList.Any())
            {
                //userId 的 所有商品id
                var gidListByUserId = new List <int>();
                //获取 userId 的 所有商品id
                userIdList.ForEach(item => gidListByUserId.Add(item.intProductID));

                guidList.ForEach(item =>
                {
                    try
                    {
                        var insertResult = InsertShoppingCart(MCvHelper.To <int>(channelId),
                                                              "",
                                                              item.vchGuid,
                                                              userID + "",
                                                              uid,
                                                              item.intAreaID + "",
                                                              item.intProductID + "",
                                                              item.intBuyCount + "");

                        //删除已经合并的 购物车商品
                        if (shoppingCart.DeleteShoppingCartByProductIdUserID(item.intShopCartID))
                        {
                            mergeSuccessGids.Add(item.intProductID);
                        }
                    }
                    catch
                    {
                    }
                });
            }
            if (mergeSuccessGids.Count > 0)
            {
                result = true;
            }

            return(result);
        }
Beispiel #10
0
 /// <summary>
 /// 计算运费
 /// </summary>
 /// <param name="weight"></param>
 /// <param name="deliveId"></param>
 /// <param name="cityId"></param>
 /// <returns></returns>
 public decimal GetCarriage(long weight, int deliveId, int cityId)
 {
     using (var db = new HolycaEntities())
     {
         decimal result        = 0;
         var     objectParams  = new System.Data.Objects.ObjectParameter("intcarriage", DbType.Int32);
         var     carriage      = db.Up_ShopCart_GetCarriage((int)weight, deliveId, cityId, objectParams);
         var     upOutPutValue = MCvHelper.To <int>(objectParams.Value, 0);
         if (upOutPutValue > 0)
         {
             result = upOutPutValue / 100;
         }
         return(result);
     }
 }
        public MResult <ItemGoodsDetails> GetGoodsInfo(string sid, string token, string guid, string user_id, string uid, string gid)
        {
            var result = new MResult <ItemGoodsDetails>(true);

            try
            {
                var iGid = MCvHelper.To <int>(gid);
                result = GoodsBLL.GetGoodsInfo(base.SystemType.ToString(), base.Uid, (int)base.SystemType, iGid);
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "处理数据出错!";
            }
            return(result);
        }
        public MResult RemoveShoppingCartByScId(string sid, string token, string guid, string user_id, string uid, string shoppingcarid)
        {
            var result = new MResult();

            try
            {
                var shoppcartId = MCvHelper.To <int>(shoppingcarid);
                result = ShoppingCartBll.DeleteShoppingCartByProductIdUserID(shoppcartId);
            }
            catch (Exception)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "处理数据出错!";
            }
            return(result);
        }
        public MResultList <ItemRegion> GetRegionList(string sid, string token, string guid, string user_id, string uid, string parentid)
        {
            var result = new MResultList <ItemRegion>();

            try
            {
                var parentId = MCvHelper.To <int>(parentid);
                result = BaseDataBLL.GetRegionList(parentId);
            }
            catch (Exception)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "处理数据出错!";
            }
            return(result);
        }
        public MResult <AddressEntity> GetAddressInfo(string sid, string token, string guid, string user_id, string uid, string address_id)
        {
            var result = new MResult <AddressEntity>();

            try
            {
                var addressId = MCvHelper.To <int>(address_id);
                result = MemberBLL.GetAddressInfo(addressId);
            }
            catch (Exception)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "处理数据出错!";
            }

            return(result);
        }
        public MResult SetDefaultAddress(string sid, string token, string guid, string user_id, string uid, string address_id)
        {
            var result = new MResult();

            try
            {
                var addressId = MCvHelper.To <int>(address_id);
                result = MemberBLL.SetDefaultAddress(UserId, addressId);
            }
            catch (Exception)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "处理数据出错!";
            }

            return(result);
        }
Beispiel #16
0
        /// <summary>
        /// 递归商品分类
        /// </summary>
        /// <param name="sType"> </param>
        /// <param name="pid"> </param>
        /// <param name="goodsCategoryList"></param>
        /// <returns></returns>
        public static List <ItemGoodsCategory> RecursiveGoodsCategory(SystemType sType, int pid, List <Web_Pdt_Type> goodsCategoryList)
        {
            var result = new List <ItemGoodsCategory>();

            if (goodsCategoryList.Any())
            {
                var level1List = goodsCategoryList.FindAll(item => item.intCateFather == pid);
                if (!level1List.Any())
                {
                    return(result);
                }

                foreach (var level1Info in level1List)
                {
                    var level1Entity = new ItemGoodsCategory();
                    level1Entity.id = level1Info.intCateID;

                    #region 判断系统
                    if (sType == SystemType.MobileWebSite)
                    {
                        level1Entity.name = level1Info.vchCateName;
                    }
                    else if (sType == SystemType.WebSite)
                    {
                        level1Entity.name = level1Info.vchWebShowName;
                    }
                    else
                    {
                        level1Entity.name = level1Info.vchCateName;
                    }
                    #endregion

                    level1Entity.pid = MCvHelper.To <int>(level1Info.intCateFather, 0);

                    var level2List = goodsCategoryList.FindAll(item => item.intCateFather == level1Info.intCateID);
                    if (level2List.Any())
                    {
                        level1Entity.child = RecursiveGoodsCategory(sType, level1Info.intCateID, goodsCategoryList);
                    }

                    result.Add(level1Entity);
                }
            }
            return(result);
        }
        public MResultList <ItemPay> GetPayMentList(string sid, string token, string guid, string user_id, string uid, string regionid)
        {
            var result = new MResultList <ItemPay>();

            try
            {
                var regionId = MCvHelper.To <int>(regionid);
                result = MCacheManager.UseCached <MResultList <ItemPay> >(
                    string.Format("GetPayList_{0}_{1}", sid, regionid),
                    MCaching.CacheGroup.BaseData, () => BaseDataBLL.GetPaymentList((int)SystemType, regionId));
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "处理数据出错!";
            }
            return(result);
        }
Beispiel #18
0
        public MResult <string> OrderPayment(string sid, string token, string guid, string user_id, string uid, string ocode, string payid)
        {
            var result = new MResult <string>();

            try
            {
                var payId = MCvHelper.To <int>(payid, 0);

                result = PaymentBLL.OrderPayment(SystemType, UserId, uid, ocode, payId);
            }
            catch (Exception ex)
            {
                result.status = Core.Enums.MResultStatus.ExceptionError;
                result.msg    = "处理数据出错!";
            }

            return(result);
        }
        public MResultList <ItemPay> GetPayList(string sid, string token, string guid, string user_id, string uid,
                                                string paygroupid)
        {
            var result = new MResultList <ItemPay>();

            try
            {
                var paygroupId = MCvHelper.To <int>(paygroupid);
                result = BaseDataBLL.GetPayList(SystemType, paygroupId);
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "处理数据出错!";
            }

            return(result);
        }
        public MResult SetShoppingCartGoodsNum(string sid, string token, string guid, string user_id, string uid, string shoppingcarid, string gid, string num)
        {
            var result = new MResult();

            try
            {
                var Gid         = MCvHelper.To <int>(gid);
                var shoppcartId = MCvHelper.To <int>(shoppingcarid);
                var Num         = MCvHelper.To <int>(num);
                result = ShoppingCartBll.SetShoppingCartGoodsNum(UserId, guid, shoppcartId, Gid, Num);
            }
            catch (Exception)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "处理数据出错!";
            }
            return(result);
        }
        public MResultList <ItemOrder> GetOrdersList(string sid, string token, string guid, string user_id, string uid, string begintime, string endtime)
        {
            var result = new MResultList <ItemOrder>();

            try
            {
                var begimTime = MCvHelper.To <DateTime>(begintime, DateTime.Now.AddMonths(-1));
                var endTime   = MCvHelper.To <DateTime>(endtime, DateTime.Now);

                result = OrderBLL.GetOrdersList((int)SystemType, Uid, UserId, begimTime, endTime);
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "处理数据出错!";
            }

            return(result);
        }
        public MResultList <ProductImg> GetGoodsPicList(string sid, string token, string guid, string user_id, string uid, string gid)
        {
            var result = new MResultList <ProductImg>(true);

            try
            {
                var iGid = MCvHelper.To <int>(gid);
                result = MCacheManager.UseCached <MResultList <ProductImg> >(
                    string.Format("GetGoodsPicList{0}_{1}", sid, gid),
                    MCaching.CacheGroup.Goods,
                    () => GoodsBLL.GetGoodsPicList(sid, uid, iGid));
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "处理图片列表数据出错!";
            }

            return(result);
        }
        /// <summary>
        /// 获取 配置文件 AppSettings 节点的值
        /// </summary>
        /// <param name="key">配置文件的Key</param>
        /// <param name="def">如果不存在</param>
        /// <returns></returns>
        public static T GetAppSettingsValue <T>(string key, params T[] def)
        {
            object val = null;

            try
            {
                if (Config.AppSettings.Settings.AllKeys.Contains(key))
                {
                    val = Config.AppSettings.Settings[key].Value;
                }
                else if (def.Length > 0)
                {
                    if (AddAppSettings(key, def[0].ToString()))
                    {
                        val = def[0];
                    }
                }
            }
            catch (Exception ex)
            {
                MLogManager.Error(MLogGroup.Other.配置文件操作, null, string.Format("获取 配置文件 AppSettings 节点 {0}={1}", key, def[0]), ex);
            }
            return(MCvHelper.To <T>(val));
        }
        public MResultList <ItemGoods> GetGoodsList(string sid, string token, string guid, string user_id, string uid, string bid, string cid, string age, string price, string sort, string page, string size)
        {
            var result = new MResultList <ItemGoods>(true);

            try
            {
                var brandId    = MCvHelper.To <int>(bid);
                var categoryId = MCvHelper.To <int>(cid);
                var pIndex     = MCvHelper.To <int>(page);
                var pSize      = MCvHelper.To <int>(size);
                var channelId  = MCvHelper.To <SystemType>(sid);

                result = MCacheManager.UseCached <MResultList <ItemGoods> >(
                    string.Format("GetGoodsList_{0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}_{8}", sid, user_id, bid, cid, age, price, sort, page, size),
                    MCaching.CacheGroup.Goods, () => GoodsBLL.GetGoodsList(sid, uid, (int)channelId, categoryId, brandId, age, price, sort, pSize, pIndex));
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "处理数据出错!";
            }

            return(result);
        }
Beispiel #25
0
 /// <summary>
 /// 更新订单所有状态
 /// </summary>
 /// <param name="orderList"></param>
 public void UpdateOrderAllStatus(ref List <Sale_Order> orderList)
 {
     if (orderList != null && orderList.Any())
     {
         try
         {
             var oCodes = new List <string>();
             orderList.ForEach(item => oCodes.Add(item.vchOrderCode));
             var orderStatusList = GetOrderAllStatusByOrderCodes(oCodes);
             orderList.ForEach(item =>
             {
                 var orderAllStatus = orderStatusList.Find(o => o.OrderCode == item.vchOrderCode);
                 if (orderAllStatus != null && !string.IsNullOrEmpty(orderAllStatus.OrderCode))
                 {
                     item.intPayState   = MCvHelper.To(orderAllStatus.PayStatus, 0);
                     item.intOrderState = MCvHelper.To(orderAllStatus.OrderStatus, 1);
                 }
             });
         }
         catch (Exception)
         {
         }
     }
 }
Beispiel #26
0
        /// <summary>
        /// 获取订单商品列表
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="uid"></param>
        /// <param name="userId"></param>
        /// <param name="orderCode"></param>
        /// <returns></returns>
        public static MResultList <ItemOrderGoods> GetOrderGoodsList(int sid, string uid, int userId, string orderCode)
        {
            var result = new MResultList <ItemOrderGoods>(true);

            try
            {
                #region 参数判断
                if (userId <= 0)
                {
                    result.status = MResultStatus.ParamsError;
                    result.msg    = "用户标识错误!";
                }
                if (string.IsNullOrEmpty(orderCode))
                {
                    result.status = MResultStatus.ParamsError;
                    result.msg    = "订单标识错误!";
                }
                #endregion

                var orderDal  = DALFactory.Order();
                var memberDal = DALFactory.Member();

                var memberInfo = memberDal.GetMemberInfo(userId);
                if (memberInfo == null || memberInfo.membNo <= 0)
                {
                    result.status = MResultStatus.Undefined;
                    result.msg    = "用户不存在!";
                }
                var clusterId = MCvHelper.To(memberInfo.clusterId, 1);

                var orderGoodsList = orderDal.GetOrderGoodsList(userId, orderCode, clusterId);
                if (orderGoodsList.Any())
                {
                    orderGoodsList.ForEach(item =>
                    {
                        var goodsItem = new ItemOrderGoods()
                        {
                            gid         = item.intProductID,
                            title       = item.vchProductName,
                            price       = item.numSalePrice,
                            num         = item.intQty,
                            total       = item.numTotalAmount,
                            pic_url     = GoodsBLL.FormatProductPicUrl(item.PicUrl),
                            score       = item.intScores,
                            marketprice = MCvHelper.To <decimal>(item.numStandarPrice, item.numSalePrice),
                            productcode = item.vchProductPrinted
                        };
                        result.list.Add(goodsItem);
                    });
                    result.status = MResultStatus.Success;
                }
                else
                {
                    result.status = MResultStatus.Undefined;
                    result.msg    = "没有数据!";
                }
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExecutionError;
                MLogManager.Error(MLogGroup.Order.获取订单信息, null, "获取订单信息", ex);
            }

            return(result);
        }
Beispiel #27
0
        /// <summary>
        /// 获取订单信息
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="uid"></param>
        /// <param name="userId"></param>
        /// <param name="orderCode"></param>
        /// <returns></returns>
        public static MResult <ItemOrderDetails> GetOrderinfo(int sid, string uid, int userId, string orderCode)
        {
            var result = new MResult <ItemOrderDetails>();

            try
            {
                #region 参数判断
                if (userId <= 0)
                {
                    result.status = MResultStatus.ParamsError;
                    result.msg    = "用户标识错误!";
                }
                if (string.IsNullOrEmpty(orderCode))
                {
                    result.status = MResultStatus.ParamsError;
                    result.msg    = "订单标识错误!";
                }
                #endregion

                var orderDal    = DALFactory.Order();
                var baseDataDal = DALFactory.BaseData();

                var orderInfo = orderDal.GetOrderInfo(userId, orderCode);
                if (orderInfo != null && orderInfo.OrderNo > 0)
                {
                    orderInfo.PayType = orderInfo.PayId == 0 ? "货到付款" : "在线支付";

                    orderInfo.InvoiceType = (int)(string.IsNullOrEmpty(orderInfo.InvoiceTitle)
                                                 ? Invoice.TitleType.NoNeed
                                                 : orderInfo.InvoiceTitle.StartsWith("个人")
                                                       ? Invoice.TitleType.Personal
                                                       : Invoice.TitleType.Company);
                    orderInfo.PayStatus = orderInfo.PayStatusId == 2 ? "已付款" : "未付款";
                    #region 订单状态
                    string orderStatus;
                    switch (orderInfo.OrderStatusId)
                    {
                    case 0: orderStatus = "付款未审核"; break;

                    case 1: orderStatus = "未确定"; break;

                    case 4: orderStatus = "客户已确认"; break;

                    case 5: orderStatus = "生成配货单"; break;

                    case 7: orderStatus = "已出库"; break;

                    case 20: orderStatus = "完成"; break;

                    default:
                        orderStatus = "未知"; break;
                    }
                    #endregion
                    orderInfo.OrderStatus = orderStatus;

                    var invoiceCategory = MCvHelper.To <int>(orderInfo.InvoiceCategory, 0);

                    result.info = new ItemOrderDetails
                    {
                        oid             = orderInfo.OrderNo,
                        ocode           = orderInfo.OrderCode,
                        status          = orderInfo.OrderStatus,
                        addr            = orderInfo.AddressInfo,
                        province        = orderInfo.Provinces,
                        city            = orderInfo.City,
                        county          = orderInfo.County,
                        contact_name    = orderInfo.Consignee,
                        invoicecategory = invoiceCategory,
                        invoicetitle    = orderInfo.InvoiceTitle,
                        phone           = orderInfo.Phone,
                        titletype       = orderInfo.InvoiceType,
                        mobile          = orderInfo.Mobile,
                        paytype         = orderInfo.PayType,
                        paytypeid       = orderInfo.PayId,
                        statusid        = orderInfo.OrderStatusId,
                        zip             = orderInfo.Zip,
                        paystatus       = orderInfo.PayStatus,
                        paystatusid     = orderInfo.PayStatusId,
                        deliverytype    = orderInfo.DeliveryType
                    };
                    result.status = MResultStatus.Success;
                }
                else
                {
                    result.status = MResultStatus.Undefined;
                    result.msg    = "没有数据!";
                }
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExecutionError;
                MLogManager.Error(MLogGroup.Order.获取订单信息, null, "获取订单信息", ex);
            }

            return(result);
        }
        /// <summary>
        /// 获取运费总额
        /// </summary>
        /// <param name="channelId"></param>
        /// <param name="userId"> </param>
        /// <param name="cityId"></param>
        /// <param name="payId"></param>
        /// <param name="deliverId"> </param>
        /// <param name="totalWeight"></param>
        /// <param name="orderTotal"> </param>
        /// <returns></returns>
        public static MResult <decimal> GetLogisticsInfo(int channelId, int userId, int cityId, int payId, int deliverId, long totalWeight, decimal orderTotal)
        {
            var result = new MResult <decimal>(true);

            try
            {
                var baseDataDal  = DALFactory.BaseData();
                var deliveryInfo = baseDataDal.GetDeliverInfo(deliverId);

                if (MCvHelper.To <byte>(deliveryInfo.intIsCarriage, 0) == 1)
                {
                    //上门自提,先不收运费
                    if (deliverId == 8)
                    {
                        result.info = 0;
                    }
                    else
                    {
                        //否则根据城市id 计算运费
                        result.info = baseDataDal.GetCarriage(totalWeight, deliverId, cityId);

                        #region  中通满100元江浙免运费

                        /*
                         * if (orderTotal >= 100 && deliverId == 3)
                         * {
                         *  List<City> clist = CityArea.GetCities(10);
                         *  clist.AddRange(CityArea.GetCities(11));
                         *
                         *  if (clist.Any(c => c.RegionId == cityId))
                         *  {
                         *      result.info = 0;
                         *  }
                         * }
                         */
                        #endregion
                    }
                }
                else
                {
                    var memberDal  = DALFactory.Member();
                    var memberInfo = memberDal.GetMemberInfo(userId.ToString());

                    //选择不需要运费的送货方式则50元起送,不足50元则加5元运费
                    if (deliverId == 8)
                    {
                        result.info = 0;
                    }
                    if (orderTotal < 50 && deliverId == 1)
                    {
                        result.info = 5;
                    }

                    if (orderTotal < 100 && deliverId == 6)
                    {
                        result.info = 5;
                    }

                    //月亮太阳会员不收运费
                    if (memberInfo != null &&
                        (memberInfo.clusterId == 3 || memberInfo.clusterId == 4 || memberInfo.clusterId == 17 || memberInfo.clusterId == 18))
                    {
                        result.info = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExceptionError;
                result.msg    = "获取运费总额 错误!";
            }

            return(result);
        }
Beispiel #29
0
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="channelId"></param>
        /// <param name="uid"></param>
        /// <param name="userId"></param>
        /// <param name="orderEntity"></param>
        /// <returns></returns>
        public static MResult <ItemOrder> CreateOrder(string guid, int channelId, string uid, int userId, OrderEntity orderEntity)
        {
            var result = new MResult <ItemOrder>(true);

            try
            {
                var memberDal       = DALFactory.Member();
                var baseDataDal     = DALFactory.BaseData();
                var shoppingCartDal = DALFactory.ShoppingCartDal();
                var orderDal        = DALFactory.Order();

                var payId = MCvHelper.To <int>(orderEntity.payid, -1);

                #region 验证数据

                #region 用户是否登录
                if (userId <= 0)
                {
                    result.msg    = "请登录后再操作!";
                    result.status = MResultStatus.ParamsError;
                    return(result);
                }
                #endregion

                #region 收货地址
                if (orderEntity.addressid <= 0)
                {
                    result.msg    = "请选择收货地址!";
                    result.status = MResultStatus.ParamsError;
                    return(result);
                }
                #endregion

                #region 支付方式
                if (payId < 0)
                {
                    result.msg    = "请选择支付方式!";
                    result.status = MResultStatus.ParamsError;
                    return(result);
                }
                #endregion

                #region 配送方式
                if (orderEntity.logisticsid <= 0)
                {
                    result.msg    = "请选择配送方式!";
                    result.status = MResultStatus.ParamsError;
                    return(result);
                }
                #endregion

                #region 发票信息是否完整
                if (orderEntity.titletype == null)
                {
                    result.msg    = "请选择发票类型!";
                    result.status = MResultStatus.ParamsError;
                    return(result);
                }
                if (orderEntity.titletype != Entity.Enum.Invoice.TitleType.NoNeed)
                {
                    if (orderEntity.invoicecategory == null)
                    {
                        result.msg    = "请选择发票分类!";
                        result.status = MResultStatus.ParamsError;
                        return(result);
                    }
                    if (orderEntity.titletype == Entity.Enum.Invoice.TitleType.Company && string.IsNullOrEmpty(orderEntity.invoicetitle))
                    {
                        result.msg    = "请填写发票抬头!";
                        result.status = MResultStatus.ParamsError;
                        return(result);
                    }
                }
                #endregion

                #endregion

                var memberInfo = memberDal.GetMemberInfo(uid);

                #region 验证用户是否存在
                if (memberInfo == null || memberInfo.membNo <= 0)
                {
                    result.msg    = "该用户不存在!";
                    result.status = MResultStatus.ParamsError;
                    return(result);
                }
                #endregion

                //购物车商品数据
                List <ShoppingCartEntity> norMalShoppingCartList = null;

                #region 判断购物车是否有商品
                var shoppingCartList = shoppingCartDal.GetShoppingCartProductInfosByUserIDGuidChannelID(userId, guid, channelId);
                if (shoppingCartList == null || !shoppingCartList.Any())
                {
                    result.msg    = "购物车没有商品!";
                    result.status = MResultStatus.LogicError;
                    return(result);
                }
                norMalShoppingCartList = (from a in shoppingCartList
                                          where a.intIsDelete == 0
                                          select a).ToList();

                if (!norMalShoppingCartList.Any())
                {
                    result.msg    = "购物车没有商品!";
                    result.status = MResultStatus.LogicError;
                    return(result);
                }
                #endregion

                #region 该用户是否是黑名单
                var isExistBacklist = memberDal.CheckUserIdInBackList(userId);
                if (isExistBacklist)
                {
                    result.msg    = "您的用户出现异常,请联系我们的客服人员进行解决!";
                    result.status = MResultStatus.LogicError;
                    return(result);
                }
                #endregion

                //收货地址信息
                var addressInfo = memberDal.GetMemberAddressInfo(orderEntity.addressid);

                #region 验证收货地址
                #region 是否存在
                if (addressInfo == null || addressInfo.intAddressID <= 0 || addressInfo.intCityID <= 0 && payId <= 0 && orderEntity.logisticsid <= 0)
                {
                    result.msg    = "收货地址信息不正确!";
                    result.status = MResultStatus.ParamsError;
                    return(result);
                }
                #endregion
                #endregion

                //配送方式
                var deliverInfo = baseDataDal.GetDeliverInfo(orderEntity.logisticsid);

                #region 验证配送方式
                if (deliverInfo == null || deliverInfo.intDeliverID == 0)
                {
                    result.msg    = "验证配送方式信息不正确!";
                    result.status = MResultStatus.ParamsError;
                    return(result);
                }
                #endregion

                #region 检查商品销售区域
                var checkGoodsSaleAreaState = CheckGoodsSaleArea(norMalShoppingCartList, userId, MCvHelper.To <int>(addressInfo.intCityID), channelId);
                if (checkGoodsSaleAreaState.Any())
                {
                    result.msg    = "有部分商品不在您选择的区域内销售!";
                    result.status = MResultStatus.LogicError;
                    result.data   = String.Join(",", checkGoodsSaleAreaState.ToArray());
                    return(result);
                }
                #endregion

                var summaryOrderInfo = SummaryOrderInfo(norMalShoppingCartList, channelId, userId,
                                                        payId, orderEntity.logisticsid,
                                                        MCvHelper.To <int>(addressInfo.intCityID));

                #region 开始创建订单
                if (summaryOrderInfo != null && summaryOrderInfo.TotalGoodsFee > 0)
                {
                    var order = new Sale_Order();

                    #region 订单主表信息
                    order.dtCreateDate    = DateTime.Now;
                    order.dtSendDate      = CheckDateTime(orderEntity.posttimetype, orderEntity.logisticsid);                    //处理送货日期
                    order.intChannel      = channelId;
                    order.intCreaterID    = 555;
                    order.intDeliverID    = orderEntity.logisticsid;
                    order.intLogisticsID  = 21;
                    order.intOrderState   = 1;
                    order.intOrderType    = 1;
                    order.intPayID        = payId;
                    order.intPayState     = 0;
                    order.intStockID      = 100;
                    order.intTotalStars   = summaryOrderInfo.TotalScore;
                    order.intUserID       = userId;
                    order.numAddAmount    = 0;
                    order.numCarriage     = summaryOrderInfo.TotalFreight;
                    order.numChange       = 0;
                    order.numGoodsAmount  = summaryOrderInfo.TotalGoodsFee;
                    order.numCouponAmount = summaryOrderInfo.TotalDiscountFee;
                    order.numReceAmount   = summaryOrderInfo.TotalOrderFee;
                    order.numWeight       = summaryOrderInfo.TotalWeight;
                    order.vchSendTime     = order.dtSendDate.ToShortTimeString();
                    order.vchUserCode     = memberInfo.userCode;
                    order.vchOrderCode    = GetOrderCode();
                    #endregion

                    #region 配送信息

                    var deliver = new Sale_Order_Deliver();
                    deliver.intAddressID  = addressInfo.intAddressID;
                    deliver.intCityID     = MCvHelper.To <int>(addressInfo.intCityID, 0);
                    deliver.vchCityName   = addressInfo.vchCityName;
                    deliver.vchConsignee  = addressInfo.vchConsignee;
                    deliver.intCountyID   = MCvHelper.To <int>(addressInfo.intCountyID, 0);
                    deliver.vchCountyName = addressInfo.vchCountyName;
                    deliver.vchDetailAddr = addressInfo.vchStateName + "," + addressInfo.vchCityName + "," + addressInfo.vchCountyName + "," + addressInfo.vchDetailAddr;
                    deliver.vchHausnummer = addressInfo.vchHausnummer;
                    deliver.vchMobile     = addressInfo.vchMobile;
                    deliver.vchPhone      = addressInfo.vchPhone;
                    deliver.vchPostCode   = addressInfo.vchPostCode;
                    deliver.vchRoadName   = addressInfo.vchRoadName;
                    deliver.intStateID    = MCvHelper.To <int>(addressInfo.intStateID, 0);
                    deliver.vchStateName  = addressInfo.vchStateName;
                    deliver.vchUserMemo   = orderEntity.remark;
                    deliver.vchOrderCode  = order.vchOrderCode;

                    #endregion

                    #region 发票信息

                    var invoice = new Sale_Order_Invoice();
                    if (orderEntity.titletype != null && orderEntity.titletype != Invoice.TitleType.NoNeed)
                    {
                        if (orderEntity.titletype == Invoice.TitleType.Personal)
                        {
                            invoice.vchInvoicTitile = "个人";
                        }
                        else if (orderEntity.titletype == Invoice.TitleType.Company)
                        {
                            invoice.vchInvoicTitile = orderEntity.invoicetitle;
                        }

                        invoice.intInvoiceType = (int)orderEntity.invoicecategory;
                        invoice.intInvoiceKind = 1;
                        invoice.numAmount      = order.numReceAmount;
                        invoice.dtBillingTime  = DateTime.Now;
                        invoice.dtCreateDate   = DateTime.Now;
                        invoice.intIsBilling   = 1;
                        invoice.intIsDetail    = 0;
                        invoice.vchOrderCode   = order.vchOrderCode;
                        invoice.vchPhone       = addressInfo.vchPhone;
                        invoice.intUserID      = userId;
                    }

                    #endregion

                    #region 保存订单
                    string message;
                    result.info.oid = orderDal.SaveWebOrder(order, invoice, deliver, null, userId, guid, channelId,
                                                            MCvHelper.To <int>(memberInfo.clusterId, 0), -1, out message);
                    if (result.info.oid > 0)
                    {
                        #region 清空购物车
                        shoppingCartDal.ClearShoppingCart(userId);
                        #endregion

                        #region  步订单信息到 BBHome
                        orderDal.SyncOrderInfoToBBHome(order.vchOrderCode);
                        #endregion

                        result.status = MResultStatus.Success;

                        var payType = string.Empty;
                        if (payId == 0)
                        {
                            payType = "货到付款";
                        }
                        else if (payId == 1)
                        {
                            payType = "在线支付";
                        }
                        var postTimetype = string.Empty;
                        switch (orderEntity.posttimetype)
                        {
                        case 1:
                            postTimetype = "工作日送货";
                            break;

                        case 2:
                            postTimetype = "工作日、双休日均可送货";
                            break;

                        case 3:
                            postTimetype = "只双休日送货";
                            break;
                        }

                        result.info.ocode         = order.vchOrderCode;
                        result.info.paytype       = payType;
                        result.info.logisticstype = deliverInfo.vchDeliverName;
                        result.info.total_fee     = order.numGoodsAmount;
                        result.info.total_freight = order.numCarriage;
                        result.info.total_order   = order.numReceAmount;
                        result.info.posttimetype  = postTimetype;
                    }

                    #endregion
                }
                #endregion
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExecutionError;
                MLogManager.Error(MLogGroup.Order.创建订单, null, "", ex);
            }

            return(result);
        }
Beispiel #30
0
        /// <summary>
        /// 获取临时订单信息
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="channelId"> </param>
        /// <param name="uid"></param>
        /// <param name="userId"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public static MResult <OrderResult> GetTempOrderInfo(string guid, int channelId, string uid, int userId, OrderEntity order)
        {
            var result = new MResult <OrderResult>(true);

            try
            {
                if (order.addressid > 0)
                {
                    var memberDal       = DALFactory.Member();
                    var shoppingCartDal = DALFactory.ShoppingCartDal();
                    //获取用户选择的收货地址
                    var addressInfo = memberDal.GetMemberAddressInfo(order.addressid);
                    //判断地址是否存在,并且判断 支付方式和配送方式是否已选择
                    if (addressInfo != null && addressInfo.intCityID > 0 && order.payid != null && order.logisticsid > 0)
                    {
                        //查询该用户购物车所有商品
                        var shoppingCartList = shoppingCartDal.GetShoppingCartProductInfosByUserIDGuidChannelID(userId, guid, channelId);
                        if (shoppingCartList.Any())
                        {
                            //排除 已删除的商品
                            var notDelShoppingCart = (from a in shoppingCartList where a.intIsDelete == 0 select a).ToList();
                            if (notDelShoppingCart.Any())
                            {
                                var summaryOrderInfo = SummaryOrderInfo(notDelShoppingCart, channelId, userId, MCvHelper.To <int>(order.payid, -1), order.logisticsid,
                                                                        MCvHelper.To <int>(addressInfo.intCityID));
                                if (summaryOrderInfo != null)
                                {
                                    result.info.total_discount_fee = summaryOrderInfo.TotalDiscountFee;
                                    result.info.total_freight      = summaryOrderInfo.TotalFreight;
                                    result.info.total_goods_fee    = summaryOrderInfo.TotalGoodsFee;
                                    result.info.total_order_fee    = summaryOrderInfo.TotalOrderFee;
                                    result.info.total_original     = summaryOrderInfo.TotalOriginal;
                                    result.info.total_score        = summaryOrderInfo.TotalScore;
                                    result.info.total_weight       = summaryOrderInfo.TotalWeight;
                                }
                            }
                            else
                            {
                                result.status = Core.Enums.MResultStatus.LogicError;
                                result.msg    = "购物车没有商品!";
                            }
                        }
                        else
                        {
                            result.status = Core.Enums.MResultStatus.LogicError;
                            result.msg    = "购物车没有商品!";
                        }
                    }
                    else
                    {
                        result.status = Core.Enums.MResultStatus.LogicError;
                        result.msg    = "请选择支付方式和配送方式!";
                    }
                }
                else
                {
                    result.status = Core.Enums.MResultStatus.LogicError;
                    result.msg    = "请选择收货地址!";
                }
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExecutionError;
                MLogManager.Error(MLogGroup.Order.获取临时订单信息, null, "", ex);
            }

            return(result);
        }