Exemple #1
0
 /// <summary>
 /// 根据盟友ID,获取盟友的现金券列表
 /// </summary>
 /// <param name="userId">The user identifier.</param>
 /// <returns>List&lt;CashCouponModel&gt;.</returns>
 public static List <CashCouponModel> GetEnableCashCouponListByUserId(int userId)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.GetEnableCashCouponListByUserId(userId));
     }
 }
Exemple #2
0
 /// <summary>
 /// 获得现金卷列表
 /// </summary>
 /// <param name="shopId"></param>
 /// <returns></returns>
 public static List <CashCouponModel> getEnabledCashCouponList(int shopId)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.getEnabledCashCouponList(shopId));
     }
 }
Exemple #3
0
 /// <summary>
 /// 获得优惠卷发送列表
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public static List <CouponSendModel> getCouponSendList(int userId)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.getCouponSendList(userId));
     }
 }
Exemple #4
0
 /// <summary>
 /// 根据用户ID和优惠券ID,获取优惠券记录ID
 /// </summary>
 /// <param name="userId">The user identifier.</param>
 /// <param name="couponId">The coupon identifier.</param>
 /// <returns>System.Int32.</returns>
 public static CashCouponLogModel GetCashCouponLogIDByUserID(int userId, int couponId)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.GetCashCouponLogIDByUserID(userId, couponId));
     }
 }
Exemple #5
0
 /// <summary>
 ///判断用户是否已转发
 /// </summary>
 /// <param name="userId">The user identifier.</param>
 /// <param name="couponId">The coupon identifier.</param>
 /// <returns>true if [is send coupon by user identifier] [the specified user identifier]; otherwise, false.</returns>
 public static bool IsSendCouponByUserId(int userId, int couponId)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.IsSendCouponByUserId(userId, couponId));
     }
 }
Exemple #6
0
 /// <summary>
 /// 设置优惠券启用和禁用
 /// </summary>
 /// <param name="couponId">The coupon identifier.</param>
 /// <returns>true if XXXX, false otherwise.</returns>
 public static bool SetCouponEnable(int couponId)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.SetCouponEnable(couponId));
     }
 }
Exemple #7
0
 /// <summary>
 /// 删除现金券
 /// </summary>
 /// <param name="couponId">The coupon identifier.</param>
 /// <returns>true if XXXX, false otherwise.</returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public static bool DeleteCashCoupon(int couponId)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.DeleteCashCoupon(couponId));
     }
 }
Exemple #8
0
 /// <summary>
 /// 修改现金券
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns>true if XXXX, false otherwise.</returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public static bool UpdateCashCoupon(CashCouponModel model)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.UpdateCashCoupon(model));
     }
 }
Exemple #9
0
 /// <summary>
 /// 删除优惠券
 /// </summary>
 /// <param name="couponNo">The coupon no.</param>
 /// <param name="couponId">The coupon identifier.</param>
 /// <param name="userId">The user identifier.</param>
 /// <returns>System.Boolean.</returns>
 public static bool DeleteUserCashCoupon(string couponNo, int couponId, int userId)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.DeleteUserCashCoupon(couponNo, couponId, userId));
     }
 }
Exemple #10
0
 /// <summary>
 /// 创建用户现金券(盟主分享现金券时调用)
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns>true if XXXX, false otherwise.</returns>
 public static int CreateUserCashCouponLog(CashCouponLogModel model)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.CreateUserCashCouponLog(model));
     }
 }
Exemple #11
0
 /// <summary>
 /// 更新现金券的领取记录
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns>true if XXXX, false otherwise.</returns>
 public static bool UpdateUserCashCouponGetLog(CashCouponLogModel model)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.UpdateUserCashCouponGetLog(model));
     }
 }
Exemple #12
0
 /// <summary>
 /// 获取优惠券信息
 /// </summary>
 /// <param name="couponId">The coupon identifier.</param>
 /// <param name="isValid">是否只获取有效的优惠券</param>
 /// <returns>CashCouponModel.</returns>
 public static CashCouponModel GetModel(int couponId, bool isValid = false)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.GetModel(couponId, isValid));
     }
 }
Exemple #13
0
 /// <summary>
 /// 我的现金券数量
 /// </summary>
 /// <param name="userId">The user identifier.</param>
 /// <returns>System.Int32.</returns>
 public static int GetMyCashCouponCount(int userId)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.GetMyCashCouponCount(userId));
     }
 }
Exemple #14
0
 /// <summary>
 /// 获取现金券领取记录列表
 /// </summary>
 /// <param name="couponId">The coupon identifier.</param>
 /// <param name="model">The model.</param>
 /// <returns>ResultPageModel.</returns>
 public static ResultPageModel GetUserCashCouponLogList(int couponId, SearchModel model)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         return(dal.GetUserCashCouponLogList(couponId, model));
     }
 }
Exemple #15
0
        /// <summary>
        /// 添加优惠券发送记录
        /// </summary>
        /// <param name="userId">发送人ID</param>
        /// <param name="Int32">The int32.</param>
        /// <param name="userIdentity">用户身份,0盟友  1盟主.</param>
        /// <param name="sendToUserId">接收用户ID,如果是自己转发,则为0</param>
        /// <param name="couponId">优惠券ID</param>
        /// <returns>true if XXXX, false otherwise.</returns>
        public static bool AddSendCoupon(int userId, int userIdentity, int sendToUserId, int couponId)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                using (var dal = FactoryDispatcher.CouponFactory())
                {
                    bool flag = dal.AddSendCoupon(userId, sendToUserId, couponId);

                    //如果盟主自己分享或发送给盟友,则创建现金券记录
                    if (flag && userIdentity == 1)
                    {
                        CashCouponModel couponModel = dal.GetModel(couponId);
                        if (couponModel != null)
                        {
                            int BelongOneUserId = userId;

                            int belongOneShopId = ShopLogic.GetBelongShopId(couponModel.ShopId);
                            if (belongOneShopId == 0)
                            {
                                belongOneShopId = couponModel.ShopId;
                            }

                            dal.CreateUserCashCouponLog(new CashCouponLogModel()
                            {
                                CouponId        = couponId,
                                CouponNo        = couponModel.ShopId.ToString() + StringHelper.CreateCheckCodeWithNum(10).ToLower(),
                                UserId          = sendToUserId > 0 ? sendToUserId : userId,
                                IsShare         = sendToUserId > 0 ? 0 : 1,
                                Money           = couponModel.Money,
                                StartTime       = couponModel.StartTime,
                                EndTime         = couponModel.EndTime,
                                ShopId          = couponModel.ShopId,
                                BelongOneUserId = BelongOneUserId,
                                BelongOneShopId = belongOneShopId
                            });
                        }
                    }
                    if (flag && userIdentity == 0)
                    {
                        dal.UpdateCouponShareStatus(userId, couponId);
                    }

                    scope.Complete();
                    return(flag);
                }
            }
        }
Exemple #16
0
        /// <summary>
        ///给盟友发送优惠券
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="couponId">The coupon identifier.</param>
        /// <param name="TargetIds">The target ids.</param>
        /// <returns>true if XXXX, false otherwise.</returns>
        public static bool AddSendAllyCoupon(int userId, int couponId, string[] TargetIds)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                using (var dal = FactoryDispatcher.CouponFactory())
                {
                    bool flag = dal.AddSendCoupon(userId, 0, couponId);

                    //如果盟主自己分享或发送给盟友,则创建现金券记录
                    CashCouponModel couponModel = dal.GetModel(couponId);
                    if (couponModel != null)
                    {
                        int    BelongOneUserId = userId;
                        string cpNo            = couponModel.ShopId.ToString() + StringHelper.CreateCheckCodeWithNum(10).ToLower();
                        foreach (var item in TargetIds)
                        {
                            int sendToUserId = Convert.ToInt32(item);

                            int belongOneShopId = ShopLogic.GetBelongShopId(couponModel.ShopId);
                            if (belongOneShopId == 0)
                            {
                                belongOneShopId = couponModel.ShopId;
                            }

                            dal.CreateUserCashCouponLog(new CashCouponLogModel()
                            {
                                CouponId        = couponId,
                                CouponNo        = cpNo,
                                UserId          = sendToUserId,
                                IsShare         = 0,
                                Money           = couponModel.Money,
                                StartTime       = couponModel.StartTime,
                                EndTime         = couponModel.EndTime,
                                ShopId          = couponModel.ShopId,
                                BelongOneUserId = BelongOneUserId,
                                BelongOneShopId = belongOneShopId
                            });
                        }
                    }
                    scope.Complete();
                    return(flag);
                }
            }
        }
Exemple #17
0
 /// <summary>
 /// 添加现金券
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns>System.Int32.</returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public static int AddCashCoupon(CashCouponModel model)
 {
     using (var dal = FactoryDispatcher.CouponFactory())
     {
         int flag = dal.AddCashCoupon(model);
         if (flag > 0)
         {
             //添加优惠券领取操作日志
             LogLogic.AddCouponLog(new LogBaseModel()
             {
                 objId         = flag,
                 UserId        = flag,
                 ShopId        = model.ShopId,
                 OperationType = 0,//0创建 1领取 2使用
                 Money         = model.Money
             });
         }
         return(flag);
     }
 }
Exemple #18
0
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="shopId">The shop identifier.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="mobile">The mobile.</param>
        /// <param name="address">The address.</param>
        /// <param name="cashNo">The cash no.</param>
        /// <param name="memo">The memo.</param>
        /// <param name="filename">The filename.</param>
        /// <param name="apiCode">The API code.</param>
        /// <returns>true if XXXX, false otherwise.</returns>
        public static bool saveOrder(int userId, int shopId, string userName, string mobile, string address, string cashNo, string memo, string filename, string fileName2, string fileName3, string fileName4, string fileName5, int cid, ref ApiStatusCode apiCode)
        {
            try
            {
                OrderModel model = new OrderModel();
                model.orderId     = createOrderNo(userId);
                model.UserId      = userId;
                model.Ct_BelongId = userId;
                model.orderTime   = DateTime.Now;
                model.Memo        = memo;
                model.OrderStatus = 0;
                model.OrderImg    = filename;
                model.OrderImg2   = fileName2;
                model.OrderImg3   = fileName3;
                model.OrderImg4   = fileName4;
                model.OrderImg5   = fileName5;
                model.SuccessImg  = model.SuccessImg2 = model.SuccessImg3 = model.SuccessImg4 = model.SuccessImg5 = "";
                model.Ct_Name     = userName;
                model.Ct_Mobile   = mobile;
                model.Ct_Address  = address;
                model.FianlAmount = 0;
                model.CreateTime  = DateTime.Now;

                //判断订单是否使用优惠券
                CashCouponLogModel coupon = null;
                int cashUserId            = 0;
                using (var dal = FactoryDispatcher.CouponFactory())
                {
                    if (!string.IsNullOrEmpty(cashNo))
                    {
                        coupon = dal.getEnableCashCouponLogModel(mobile, cashNo);
                        if (coupon != null && coupon.ID > 0)
                        {
                            if (coupon.ShopId != shopId)
                            {
                                apiCode = ApiStatusCode.非本店现金券;
                                return(false);
                            }
                            if (coupon.IsUse != 0)
                            {
                                apiCode = ApiStatusCode.现金券已使用;
                                return(false);
                            }
                            model.CashCouponAmount = coupon.Money;
                            model.CashCouponBn     = cashNo;
                            model.ShopId           = coupon.ShopId;
                            //设置订单归属用户
                            model.Ct_BelongId = coupon.UserId;
                            model.UserId      = coupon.BelongOneUserId;
                            cashUserId        = coupon.UserId;
                        }
                        else
                        {
                            apiCode = ApiStatusCode.优惠券不存在;
                            return(false);
                        }
                    }
                }
                //如果没有优惠
                if (cashUserId <= 0)
                {
                    //根据手机号或地址,查找客户
                    CustomerModel customer = cid > 0 ? CustomerLogic.getCustomerModel(cid) : CustomerLogic.getCustomerModel(mobile, address);
                    if (customer != null)
                    {
                        //设置订单归属用户
                        model.Ct_BelongId = customer.BelongOne;
                        model.UserId      = customer.BelongTwo;
                        model.ShopId      = customer.ShopId;
                        cashUserId        = customer.BelongOne;
                    }
                }
                TempBeansRecordsModel model1 = null;
                BeansRecordsModel     model2 = null;
                if (cashUserId > 0)
                {
                    using (var dal = FactoryDispatcher.UserFactory())
                    {
                        var user = dal.GetUserModel(cashUserId);
                        if (user.UserIdentity == 0)
                        {
                            model.UserId      = user.BelongOne;
                            model.Ct_BelongId = user.UserId;


                            var shopData = ShopLogic.GetShopModel(model.ShopId);
                            RewardsSettingModel rewardSettingModel = null;
                            //判断当前客户是否所属分店
                            if (shopData != null && shopData.ShopType == 2)
                            {
                                rewardSettingModel = UserLogic.GetRewardModel(model.ShopId);
                            }

                            if (rewardSettingModel != null && rewardSettingModel.OrderReward > 0)
                            {
                                //订单成交需付盟豆
                                model.MengBeans = rewardSettingModel.OrderReward;
                                //插入盟友订单成交临时奖励
                                model1            = new TempBeansRecordsModel();
                                model1.Amount     = rewardSettingModel.OrderReward;
                                model1.UserId     = cashUserId;
                                model1.LogType    = 0;
                                model1.Income     = 1;
                                model1.CreateTime = DateTime.Now;
                                model1.Status     = 0;
                                model1.Remark     = "下单";
                            }
                        }
                        else
                        {
                            model.UserId      = user.UserId;
                            model.Ct_BelongId = user.UserId;
                        }

                        //获取积分奖励配置
                        ScoreConfigModel scoreCfg = ConfigLogic.GetScoreConfig();
                        //添加盟主创建订单,奖励积分
                        if (scoreCfg.CreateOrderScore > 0 && dal.addUserIntegral(userId, scoreCfg.CreateOrderScore) > 0)
                        {
                            model2            = new BeansRecordsModel();
                            model2.Amount     = scoreCfg.CreateOrderScore;
                            model2.UserId     = userId;
                            model2.LogType    = 1;
                            model2.Income     = 1;
                            model2.Remark     = "创建订单奖励";
                            model2.OrderId    = "";
                            model2.CreateTime = DateTime.Now;
                        }
                    }
                }
                else
                {
                    using (var dal = FactoryDispatcher.UserFactory())
                    {
                        var user = dal.GetUserModel(userId);
                        model.UserId      = userId;
                        model.Ct_BelongId = userId;
                        model.ShopId      = user.ShopId;
                    }
                }
                bool flag = false;

                using (TransactionScope scope = new TransactionScope())
                {
                    using (var dal = FactoryDispatcher.OrderFactory())
                    {
                        model.BelongOneShopId = ShopLogic.GetBelongShopId(model.ShopId);
                        if (model.BelongOneShopId == 0)
                        {
                            model.BelongOneShopId = model.ShopId;
                        }
                        flag = dal.Add(model);
                    }
                    if (flag)
                    {
                        //

                        //根据手机号或地址,查找客户,修改客户状态为已生成订单
                        CustomerModel customer = cid > 0 ? CustomerLogic.getCustomerModel(cid) : CustomerLogic.getCustomerModel(mobile, address);
                        if (customer != null)
                        {
                            using (var dal = FactoryDispatcher.CustomerFactory())
                            {
                                dal.UpdateStatus(customer.ID, 4);
                            }
                        }
                        //添加
                        using (var dald = FactoryDispatcher.UserFactory())
                        {
                            if (model1 != null)
                            {
                                dald.AddTempBeansRecords(model1);
                            }

                            //添加日志
                            if (model2 != null)
                            {
                                dald.AddBeansRecords(model2);
                            }
                        }

                        //添加优惠券使用记录
                        using (var cpDal = FactoryDispatcher.CouponFactory())
                        {
                            if (coupon != null)
                            {
                                if (cpDal.UpdateUserCashCouponUseStatus(coupon.ID))
                                {
                                    //添加优惠券领取操作日志
                                    LogLogic.AddCouponLog(new LogBaseModel()
                                    {
                                        objId         = coupon.CouponId,
                                        UserId        = coupon.UserId,
                                        ShopId        = coupon.ShopId,
                                        OperationType = 2,//0创建 1领取 2使用
                                        Money         = coupon.Money
                                    });
                                }
                            }
                        }
                    }
                    scope.Complete();
                    return(flag);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Log(string.Format("saveOrder==>Message:{0},StackTrace:{1}", ex.Message, ex.StackTrace), LogHelperTag.ERROR);
                apiCode = ApiStatusCode.SERVICEERROR;
                return(false);
            }
        }