/// <summary>
        /// 获取当前人员有效的优惠券
        /// </summary>
        /// <param name="memid"></param>
        /// <returns></returns>
        public IList <DicCouponsEntity> GetCouponsByMem(int memid)
        {
            IList <DicCouponsEntity> listresult = new List <DicCouponsEntity>();
            IList <MemCouponsEntity> list       = MemCouponsDA.Instance.GetCanUseCoupons(memid);

            if (list != null && list.Count > 0)
            {
                foreach (MemCouponsEntity entity in list)
                {
                    DicCouponsEntity en = DicCouponsBLL.Instance.GetDicCoupons(entity.CouponsId);
                    listresult.Add(en);
                }
            }
            return(listresult);
        }
Beispiel #2
0
        /// <summary>
        /// 插入一条记录到表DicCoupons,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。
        /// 该方法提供给界面等UI层调用
        /// </summary>
        /// <param name="dicCoupons">要添加的DicCoupons数据实体对象</param>
        public int AddDicCoupons(DicCouponsEntity dicCoupons)
        {
            if (dicCoupons.Id > 0)
            {
                return(UpdateDicCoupons(dicCoupons));
            }
            else if (string.IsNullOrEmpty(dicCoupons.Name))
            {
                return((int)CommonStatus.ADD_Fail_Empty);
            }

            else if (DicCouponsBLL.Instance.IsExist(dicCoupons))
            {
                return((int)CommonStatus.ADD_Fail_Exist);
            }
            else
            {
                return(DicCouponsDA.Instance.AddDicCoupons(dicCoupons));
            }
        }
Beispiel #3
0
 /// <summary>
 /// 更新一条DicCoupons记录。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="dicCoupons">待更新的实体对象</param>
 /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param>
 public int UpdateDicCoupons(DicCouponsEntity dicCoupons)
 {
     return(DicCouponsDA.Instance.UpdateDicCoupons(dicCoupons));
 }
Beispiel #4
0
 /// <summary>
 /// 判断对象是否存在
 /// </summary>
 /// <param name="dicEnum"></param>
 /// <returns></returns>
 public bool IsExist(DicCouponsEntity dicCoupons)
 {
     return(DicCouponsDA.Instance.ExistNum(dicCoupons) > 0);
 }
Beispiel #5
0
        /// <summary>
        /// 根据主键获取一个DicCoupons实体记录。
        /// 该方法提供给其他实体的业务逻辑层(Logic)方法调用
        /// </summary>
        /// <returns>DicCoupons实体</returns>
        /// <param name="columns">要返回的列</param>
        public DicCouponsEntity GetDicCoupons(int id, bool iscache = true)
        {
            DicCouponsEntity entity = new DicCouponsEntity();

            if (iscache)
            {
                string _cachekey = "GetDicCoupons" + id;
                object obj       = MemCache.GetCache(_cachekey);
                if (obj == null)
                {
                    entity = DicCouponsDA.Instance.GetDicCoupons(id);
                    if (entity != null && entity.Id > 0)
                    {
                        if (entity.ClassId > 0)
                        {
                            entity.ClassName = ClassesFoundBLL.Instance.GetClassesFound(entity.ClassId).Name;
                        }
                        else
                        {
                            entity.ClassName = "不限";
                        }
                        if (entity.BrandId > 0)
                        {
                            entity.BrandName = ClassesFoundBLL.Instance.GetClassesFound(entity.BrandId).Name;
                        }
                        else
                        {
                            entity.BrandName = "不限";
                        }
                    }
                    MemCache.AddCache(_cachekey, entity);
                }
                else
                {
                    entity = (DicCouponsEntity)obj;
                }
            }
            else
            {
                entity = DicCouponsDA.Instance.GetDicCoupons(id);
                if (entity != null && entity.Id > 0)
                {
                    if (entity.ClassId > 0)
                    {
                        entity.ClassName = ClassesFoundBLL.Instance.GetClassesFound(entity.ClassId).Name;
                    }
                    else
                    {
                        entity.ClassName = "不限";
                    }
                    if (entity.BrandId > 0)
                    {
                        entity.BrandName = ClassesFoundBLL.Instance.GetClassesFound(entity.BrandId).Name;
                    }
                    else
                    {
                        entity.BrandName = "不限";
                    }
                }
            }
            return(entity);
        }
Beispiel #6
0
        /// <summary>
        /// 生成真实订单
        /// </summary>
        /// <returns></returns>
        public string CreateOrder()
        {
            ResultObj _result       = new ResultObj();
            int       _resultstatus = (int)CommonStatus.Fail;
            long      _preordercode = FormString.LongIntSafeQ("preordercode");
            int       _addressid    = FormString.IntSafeQ("addressid");
            //int _paytype = FormString.IntSafeQ("paytype");
            int _systype = FormString.IntSafeQ("systype");

            if (_systype == 0)
            {
                _systype = (int)SystemType.B2B;
            }
            string _remark      = FormString.SafeQ("remark");
            string acceptername = FormString.SafeQ("acceptername");
            int    province     = FormString.IntSafeQ("province");
            int    city         = FormString.IntSafeQ("city");
            string address      = FormString.SafeQ("address", 500);
            string mobilephone  = FormString.SafeQ("mobilephone");
            int    jifen        = FormString.IntSafeQ("jifen");
            int    memcouponid  = FormString.IntSafeQ("memcouponid");
            int    expressid    = FormString.IntSafeQ("expressid");
            int    ordertype    = FormString.IntSafeQ("ordertype", -1);

            if (jifen % 100 != 0)
            {
                jifen = jifen / 100 * 100;
            }
            if (jifen > 0 && !AssetBLL.Instance.CheckIntegralEnough(memid, jifen))
            {
                jifen = 0;
            }
            int billtype = FormString.IntSafeQ("billtype");
            OrderBillBasicEntity _billentity = new OrderBillBasicEntity();

            _billentity.BillType = billtype;
            if (billtype == (int)BillType.Normal)
            {
                string title = FormString.SafeQ("billtitle", 200);
                _billentity.CompanyName = title;
            }
            else if (billtype == (int)BillType.VAT)
            {
                _billentity.BillId = FormString.IntSafeQ("billvatid");

                MemBillVATEntity _mementity = MemBillVATBLL.Instance.GetMemBillVAT(memid);
                //if (_mementity.Status != 1)
                //{
                //    resultstatus = (int)CommonStatus.BillVATNoCheck;
                //    _result.Status = resultstatus;
                //    return JsonJC.ObjectToJson(_result);
                //}
                _billentity.ReceiverName     = FormString.SafeQ("billvatrename");
                _billentity.ReceiverPhone    = FormString.SafeQ("billvatrephone");
                _billentity.ReceiverProvince = FormString.IntSafeQ("billvatreprovince");
                _billentity.ReceiverCity     = FormString.IntSafeQ("billvatrecity");
                _billentity.ReceiverAddress  = FormString.SafeQ("billvatreaddress", 300);
                _billentity.CompanyName      = _mementity.CompanyName;
                _billentity.CompanyPhone     = _mementity.CompanyPhone;
                _billentity.CompanyCode      = _mementity.CompanyCode;
                _billentity.CompanyBank      = _mementity.CompanyBank;
                _billentity.CompanyAddress   = _mementity.CompanyAddress;
                _billentity.BankAccount      = _mementity.BankAccount;
                _billentity.Status           = _mementity.Status;
            }


            VWOrderEntity _vworder = OrderDetailPreTempBLL.Instance.GetVWOrderByTempCode(_preordercode);

            if (ordertype != -1)
            {
                _vworder.OrderType = ordertype;
            }
            _vworder.OrderStyle = (int)OrderStyleEnum.Normal;


            _vworder.DisCountFee = _vworder.DisCountFee;
            decimal tempprice = _vworder.PreDisCountPrice - _vworder.DisCountFee;

            if (tempprice > 1)
            {
                decimal jifenamt = OrderCommonBLL.Instance.GetJiFenAmt(jifen);
                _vworder.Integral    = jifen;
                _vworder.IntegralFee = jifenamt;
                tempprice            = tempprice - jifenamt;
            }
            else
            {
                _vworder.Integral    = 0;
                _vworder.IntegralFee = 0;
            }
            if (memcouponid > 0)
            {
                MemCouponsEntity couponen = MemCouponsBLL.Instance.GetCouponByMemCouponId(memid, memcouponid);
                if (couponen != null && couponen.Id == memcouponid && couponen.EndTime > DateTime.Now)
                {
                    DicCouponsEntity dicen = couponen.DicCoupons;
                    if (dicen.CouponType == (int)CouponTypeEnum.Money && dicen.MinimumReqAmount < tempprice)
                    {
                        _vworder.MemCouponsId = memcouponid;
                        _vworder.CouponsFee   = dicen.CouponValue;
                        tempprice             = tempprice - dicen.CouponValue;
                    }
                }
            }
            _vworder.ActPrice = tempprice;
            //_vworder.PayType = _paytype;
            _vworder.ExpressCom = expressid;

            _vworder.Remark   = _remark;
            _vworder.MemId    = memid;
            _vworder.MemLevel = member.MemGrade;
            _vworder.IsStore  = member.IsStore;
            //if (_paytype == (int)PayType.OutLine)
            //{
            //    _vworder.PayConfirmCode = StringUtils.GetRandomString(12);
            //}
            //if (billtype == 1)
            //{
            //    _vworder.BillType = (int)BillType.Normal;
            //}
            //else if (billtype == 2)
            //{
            //    _vworder.BillType = (int)BillType.VAT;
            //}
            OrderAddressEntity _address = new OrderAddressEntity();

            _address.CityId       = city;
            _address.AccepterName = acceptername;
            _address.ProvinceId   = province;
            _address.Address      = address;
            _address.MobilePhone  = mobilephone;
            //_vworder.AcceptAddress = _address;
            if (_vworder.ActPrice >= 1)
            {
                List <int> listpdids      = new List <int>();
                string     productdetails = "";
                if (_vworder != null && _vworder.Details != null && _vworder.Details.Count > 0)
                {
                    foreach (VWOrderDetailEntity ordetailentity in _vworder.Details)
                    {
                        listpdids.Add(ordetailentity.ProductDetailId);
                        productdetails += "|" + ordetailentity.ProductDetailId.ToString() + "_" + ordetailentity.Num.ToString();
                    }
                    if (productdetails != "")
                    {
                        productdetails = productdetails.TrimStart('|');
                        if (ProductStyleBLL.Instance.ProductsEnough(productdetails))
                        {
                            string ordercode = OrderBLL.Instance.CreateOrder(_vworder, _address, _billentity);
                            if (!string.IsNullOrEmpty(ordercode))
                            {
                                //IList<OrderDetailEntity> _listproduct = OrderDetailBLL.Instance.GetOrderDetailAllByOrder(memid, StringUtils.GetDbLong(ordercode), false);
                                //foreach (OrderDetailEntity _entity in _listproduct)
                                //{
                                //    productdetails += "|" + _entity.ProductDetailId.ToString() + "_" + _entity.Num.ToString();
                                //}
                                if (productdetails != "")
                                {
                                    if (ProductStyleBLL.Instance.ProductsToOrder(productdetails) > 0)
                                    {
                                        VWShoppingCartInfo ShoppingCartentity = ShoppingCartProcessor.GetShoppingCart();
                                        ShoppingCartProcessor.RemoveCartItems(ShoppingCartentity, listpdids);
                                        //if (_vworder.PayType == (int)PayType.WeChat)
                                        //{
                                        _result.Obj = ordercode;
                                        //}
                                        //else
                                        //{

                                        //    _result.Obj = ordercode;
                                        //}
                                        _result.Status = (int)CommonStatus.Success;

                                        return(JsonJC.ObjectToJson(_result));
                                    }
                                    else
                                    {
                                        _result.Status = (int)CommonStatus.ProductLess;
                                        _result.Obj    = "";
                                        return(JsonJC.ObjectToJson(_result));
                                    }
                                }
                                else
                                {
                                    _result.Status = (int)CommonStatus.Success;
                                    _result.Obj    = ordercode;
                                    return(JsonJC.ObjectToJson(_result));
                                }
                            }
                        }
                        else
                        {
                            _result.Status = (int)CommonStatus.ProductLess;
                            _result.Obj    = "";
                            return(JsonJC.ObjectToJson(_result));
                        }
                    }
                }
            }
            _result.Status = (int)CommonStatus.Fail;
            _result.Obj    = "";
            return(JsonJC.ObjectToJson(_result));
        }