Ejemplo n.º 1
0
 private static bool SaveOrder(SysCompany company, SysMemberItem mItem, SysCompanyItem cItem, SysMember user, out string message)
 {
     message = string.Empty;
     //Order order = new Order
     //{
     //    OrderCode = OrderBLL.GetOrderCode(company),
     //    OrderCard = string.Empty,
     //    OrderDate = DateTime.Now,
     //    OrderDateDeliver = DateTime.Now,
     //    OrderDateUpload = DateTime.Now,
     //    OrderMemberID = user.Id,
     //    OrderMemo = string.Empty,
     //    OrderProduct = "优惠消费",
     //    OrderQty = 0,
     //    OrderRateSale = 0,
     //    OrderRate = 0,
     //    OrderPoint = 0,
     //    OrderSellerID = company.Id,
     //    OrderStatus = 1,
     //    OrderSum = cItem.ItemSum,
     //    OrderSumOk = cItem.ItemSum,
     //    OrderPay = 0,
     //    OrderPayCash = 0,
     //    OrderPayPoint = mItem.ItemPoint,
     //    OrderType = (int)OrderType.CompanyItem
     //};
     TransactionScope ts = new TransactionScope( );
     SharedDbConnectionScope ss = new SharedDbConnectionScope( );
     try
     {
         //order.Save( );
         //if (mItem.ItemPoint.HasValue && mItem.ItemPoint.Value > 0)
         //{
         //    new Payment
         //    {
         //        PaymentCode = order.OrderCode,
         //        PaymentCompanyID = company.Id,
         //        PaymentDate = order.OrderDate,
         //        PaymentEmail = string.Empty,
         //        PaymentMemberID = user.Id,
         //        PaymentMemo = string.Format("{0}抢购{1}的优惠项目,并且使用{2}个积分抵扣", user.MemberPhoneNumber, company.CompanyName, -mItem.ItemPoint.Value),
         //        PaymentOrderID = order.Id,
         //        PaymentStatus = 1,
         //        PaymentSum = -mItem.ItemPoint.Value,
         //        PaymentType = (int)PaymentType.CompanyItem
         //    }.Save( );
         //}
         //如果是联盟商家则更新积分状态
         CompanyType companyType = Formatter.ToEnum<CompanyType>(company.CompanyType);
         Payment p = Payment.FetchByID(mItem.PaymentID.Value);
         if (p != null)
         {
             p.PaymentStatus = 1;
             p.Save( );
         }
         mItem.ItemStatus = (int)MemberCompanyItemStatus.Completed;
         mItem.SetDate = DateTime.Now;
         mItem.Save( );
         cItem.ItemUsed = Utilities.ToInt(cItem.ItemUsed) + 1;
         cItem.Save( );
         OrderBLL.UpdateBalance( );
         ts.Complete( );
         message = string.Format("结算成功,{0}使用{1}个积分购得{2}", user.MemberFullname, mItem.ItemPoint, cItem.ItemTitle);
         return true;
     }
     catch (Exception ex)
     {
         message = ex.Message;
         return false;
     }
     finally
     {
         ss.Dispose( );
         ts.Dispose( );
     }
 }
Ejemplo n.º 2
0
        public static bool CancelCompanyItem(SysMember user, SysCompanyItem companyItem, SysMemberItem memberItem, out string message)
        {
            message = string.Empty;
            if (companyItem == null || user == null || memberItem == null)
            {
                message = "参数错误!";
                goto lbl_end;
            }
            if (companyItem.IsCanDel.HasValue && companyItem.IsCanDel.Value != 1)
            {
                message = "本单不支持退订";
                goto lbl_end; ;
            }
            if (memberItem.ItemStatus == (int)MemberCompanyItemStatus.Completed)
            {
                message = "此单你已经消费 ,不能再退订";
                goto lbl_end;
            }
            TransactionScope ts = null;
            SharedDbConnectionScope ss = null;
            try
            {
                ts = new TransactionScope( );
                ss = new SharedDbConnectionScope( );

                if (memberItem.PaymentID.HasValue)
                    Payment.Delete(memberItem.PaymentID.Value);
                SysMemberItem.Delete(memberItem.ItemID);
                companyItem.ItemClicked = companyItem.ItemClicked.Value - 1;
                companyItem.Save( );
                ts.Complete( );

                message = "退订成功";
                return true;
            }
            catch (Exception ex)
            {
                message = ex.Message;
                Logging.Log("CompanyItemBLL->CancelCompanyItem", ex, true);
            }
            finally
            {
                ss.Dispose( );
                ts.Dispose( );
            }
            lbl_end:
            return false;
        }
Ejemplo n.º 3
0
        public static bool ClickCompanyItem(SysCompany company, SysMember user, DateTime dtDate, SysCompanyItem item, out int memberItemID, out string message)
        {
            memberItemID = 0;
            if (item == null || user == null)
            {
                message = "参数错误!";
                goto lbl_end;
            }

            if (item.ItemClicked >= item.ItemAmount)
            {
                message = "已经达到了最大可{ItemType}的数量";
                goto lbl_end;
            }
            //check ItemLimitOnce
            if (CheckCompanyItemOnceLimit(company.Id, user.Id))
            {
                message = ItemCheckResult[-3];
                goto lbl_end;
            }
            decimal userLastOrderSum = UserBLL.GetUserLastMonthOrderSum(user.Id);
            int result = CompanyItemBLL.ExecuteCheckFunc(user.Id, item.ItemID, userLastOrderSum);
            if (result < 0)
            {
                message = ItemCheckResult.ContainsKey(result) ? ItemCheckResult[result] : "你无权{ItemType}此优惠项目!";
                goto lbl_end;
            }
            //判断会员积分是否足够
            decimal point = DB.Select(SysMember.Columns.MemberBalance).From<SysMember>( )
                              .Where(SysMember.IdColumn).IsEqualTo(user.Id)
                              .ExecuteScalar<decimal>( );
            if (item.ItemPoint.HasValue && point < item.ItemPoint.Value)
            {
                message = "您的账户积分余额不足,无法{ItemType}^_^";
                goto lbl_end;
            }
            SysMemberItem data = new SysMemberItem
            {
                CompanyID = item.CompanyID,
                CompanyItemID = item.ItemID,
                ItemDate = dtDate,
                OrderDate = DateTime.Now,
                MemberID = user.Id,
                OrderSum = userLastOrderSum,
                ItemPoint = item.ItemPoint,
                ItemStatus = (int)MemberCompanyItemStatus.InProgress,
                SetDate = null,
                IsCanModifiedDate = true,
                PaymentID = 0,
                OrderID = 0
            };
            TransactionScope ts = new TransactionScope( );
            SharedDbConnectionScope ss = new SharedDbConnectionScope( );
            try
            {
                if (item.ItemPoint.HasValue && item.ItemPoint.Value > 0)
                {
                    Payment p = new Payment
                    {
                        PaymentCode = string.Empty,
                        PaymentCompanyID = item.CompanyID,
                        PaymentDate = data.OrderDate.Value,
                        PaymentEmail = string.Empty,
                        PaymentMemberID = user.Id,
                        PaymentMemo = string.Format("抢购【{0}】的优惠项目,并使用{1:0.00}个积分消费", company.CompanyName, item.ItemPoint.Value),
                        PaymentOrderID = 0,
                        PaymentStatus = 2,
                        PaymentSum = -item.ItemPoint.Value,
                        PaymentType = (int)PaymentType.CompanyItem
                    };
                    p.Save( );
                    data.PaymentID = p.Id;
                }
                data.Save( );
                item.ItemClicked = Utilities.ToInt(item.ItemClicked) + 1;
                item.Save( );
                OrderBLL.UpdateBalance( );
                ts.Complete( );
                message = "{ItemType}成功";
                memberItemID = data.ItemID;
                return true;
            }
            catch (Exception ex)
            {
                message = "{ItemType}失败:" + ex.Message;
                Logging.Log("CompanyItemBLL->ClickCompanyItem", ex, true);
            }
            finally
            {
                ss.Dispose( );
                ts.Dispose( );
            }
            lbl_end:
            return false;
        }
Ejemplo n.º 4
0
        public void Insert(int CompanyItemID,int MemberID,DateTime ItemDate,int ItemStatus,DateTime? SetDate,decimal? OrderSum,int? CompanyID,decimal? ItemPoint,int? PaymentID,bool? IsCanModifiedDate,DateTime? OrderDate,int? OrderID)
        {
            SysMemberItem item = new SysMemberItem();

            item.CompanyItemID = CompanyItemID;

            item.MemberID = MemberID;

            item.ItemDate = ItemDate;

            item.ItemStatus = ItemStatus;

            item.SetDate = SetDate;

            item.OrderSum = OrderSum;

            item.CompanyID = CompanyID;

            item.ItemPoint = ItemPoint;

            item.PaymentID = PaymentID;

            item.IsCanModifiedDate = IsCanModifiedDate;

            item.OrderDate = OrderDate;

            item.OrderID = OrderID;

            item.Save(UserName);
        }