Exemplo n.º 1
0
        public MemCouponsEntity GetCouponByMemCouponId(int memid, int memcouponid)
        {
            MemCouponsEntity entity = MemCouponsDA.Instance.GetByMemCouponId(memid, memcouponid);

            if (entity != null && entity.Id > 0)
            {
                entity.DicCoupons = DicCouponsBLL.Instance.GetDicCoupons(entity.CouponsId);
            }
            return(entity);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 订单完成送券,送优惠券
        /// </summary>
        /// <param name="ordercode"></param>
        /// <returns></returns>
        public int ProvideCouponsByOrder(long ordercode)
        {
            int         num     = 0;
            OrderEntity orderen = OrderBLL.Instance.GetOrderByCode(ordercode);

            if (orderen != null && (orderen.Status == (int)OrderStatus.Finished))
            {
                ///获取限量乐购的总金额
                decimal totalprice = OrderDetailBLL.Instance.GetTotalPrice(ordercode, (int)ProductType.SpecialPrice);
                if (totalprice >= 200)
                {
                    int i = (int)totalprice / 200;
                    for (int j = 0; j < i; j++)
                    {
                        MemCouponsEntity memcouentity = new MemCouponsEntity();
                        memcouentity.MemId      = orderen.MemId;
                        memcouentity.CouponsId  = (int)DicCouponsEnum.Cash10_11;
                        memcouentity.CreateTime = DateTime.Now;
                        memcouentity.EndTime    = DateTime.Now.AddDays(60);
                        memcouentity.Status     = 1;
                        memcouentity.Num        = 1;
                        MemCouponsBLL.Instance.AddMemCoupons(memcouentity);
                        num++;
                    }
                }
                else if (totalprice >= 200)
                {
                    MemCouponsEntity memcouentity = new MemCouponsEntity();
                    memcouentity.MemId      = orderen.MemId;
                    memcouentity.CouponsId  = (int)DicCouponsEnum.Cash5_6;
                    memcouentity.CreateTime = DateTime.Now;
                    memcouentity.EndTime    = DateTime.Now.AddDays(60);
                    memcouentity.Status     = 1;
                    memcouentity.Num        = 1;
                    MemCouponsBLL.Instance.AddMemCoupons(memcouentity);
                    num++;
                }
                if (num > 0)
                {
                    MemGiftLogEntity gift = new MemGiftLogEntity();
                    gift.MemId     = orderen.MemId;
                    gift.CreateTme = DateTime.Now;
                    gift.Status    = 1;
                    gift.Remark    = "购物送券:Code:" + ordercode.ToString();
                    MemGiftLogBLL.Instance.AddMemGiftLog(gift);
                }
            }
            return(num);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 更新一条MemCoupons记录。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="MemCoupons">待更新的实体对象</param>
 /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param>
 public int UpdateMemCoupons(MemCouponsEntity MemCoupons)
 {
     return(MemCouponsDA.Instance.UpdateMemCoupons(MemCoupons));
 }
Exemplo n.º 4
0
 /// <summary>
 /// 插入一条记录到表MemCoupons,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="MemCoupons">要添加的MemCoupons数据实体对象</param>
 public int AddMemCoupons(MemCouponsEntity MemCoupons)
 {
     return(MemCouponsDA.Instance.AddMemCoupons(MemCoupons));
 }
Exemplo n.º 5
0
 /// <summary>
 /// 判断对象是否存在
 /// </summary>
 /// <param name="dicEnum"></param>
 /// <returns></returns>
 public bool IsExist(MemCouponsEntity MemCoupons)
 {
     return(MemCouponsDA.Instance.ExistNum(MemCoupons) > 0);
 }
Exemplo n.º 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));
        }