Beispiel #1
0
        private ActionResult ProcessDeletePdsFromCart()
        {
            #region 购物车
            VWShoppingCartInfo shoppingCart = SessionUtil.GetCartSession();
            #endregion

            string callback     = QueryString.SafeQ("callback");//jsonp回调函数
            string prodetailids = QueryString.SafeQ("pdids", 8000);
            int    num          = QueryString.IntSafeQ("Num");

            if (string.IsNullOrEmpty(prodetailids))
            {
                return(Content(callback + "({\"Status\":\"请选择需要删除的商品\"});"));
            }
            else
            {
                List <int> pdidslist = new List <int>();

                string[] pdisattr = prodetailids.Split(',');
                foreach (string str in pdisattr)
                {
                    pdidslist.Add(StringUtils.GetDbInt(str));
                }
                ShoppingCartProcessor.RemoveCartItems(shoppingCart, pdidslist);
                return(Content(callback + "({\"Status\":\"OK\"});"));
            }
        }
Beispiel #2
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));
        }