コード例 #1
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
        /// <summary>
        /// 更新客户进店状态
        /// </summary>
        /// <param name="customerId">The customer identifier.</param>
        /// <param name="status">1进店 0未进店</param>
        /// <returns>true if XXXX, false otherwise.</returns>
        public static bool UpdateInShopStatus(int customerId, int status)
        {
            using (var dal = FactoryDispatcher.CustomerFactory())
            {
                bool flag = dal.UpdateInShopStatus(customerId, status);
                if (flag)
                {
                    var model = dal.GetModel(customerId);
                    if (model != null)
                    {
                        //RewardsSettingModel rewardSettingModel = UserLogic.GetRewardModel(model.BelongTwo);

                        //if (rewardSettingModel == null || rewardSettingModel.ShopReward <= 0) return flag;

                        //using (var dal1 = FactoryDispatcher.UserFactory())
                        //{
                        //    //给盟友加盟豆
                        //    UserLogic.addUserMoney(model.BelongOne, rewardSettingModel.ShopReward);
                        //    BeansRecordsModel model2 = new BeansRecordsModel();
                        //    model2.Amount = rewardSettingModel.ShopReward;
                        //    model2.UserId = model.BelongOne;
                        //    model2.LogType = 0;
                        //    model2.Income = 1;
                        //    model2.Remark = "进店奖励";
                        //    model2.OrderId = model.ID.ToString();
                        //    model2.CreateTime = DateTime.Now;
                        //    dal1.AddBeansRecords(model2);
                        //}
                    }
                }
                return(flag);
            }
        }
コード例 #2
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 添加客户
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int InsertCustomerInfo(CustomerModel model)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         int flag = dal.InsertCustomerInfo(model);
         BeansRecordsModel model2 = null;
         if (flag > 0)
         {
             //如果相等于,表示当前是盟主添加客户信息
             if (model.BelongOne == model.BelongTwo)
             {
                 //获取积分奖励配置
                 ScoreConfigModel scoreCfg = ConfigLogic.GetScoreConfig();
                 using (var dal1 = FactoryDispatcher.UserFactory())
                 {
                     //盟友提交客户信息,盟主奖励
                     if (scoreCfg.SubmitCustomerToMainScore2 > 0 && dal1.addUserIntegral(model.BelongOne, scoreCfg.SubmitCustomerToMainScore2) > 0)
                     {
                         model2            = new BeansRecordsModel();
                         model2.Amount     = scoreCfg.SubmitCustomerToMainScore1;
                         model2.UserId     = model.BelongTwo;
                         model2.LogType    = 1;
                         model2.Income     = 1;
                         model2.Remark     = "客户信息奖励";
                         model2.OrderId    = "";
                         model2.CreateTime = DateTime.Now;
                     }
                 }
             }
         }
         return(flag);
     }
 }
コード例 #3
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 删除客户信息
 /// </summary>
 /// <param name="customerId">The customer identifier.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public static bool DeleteCustomerInfo(int customerId)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.DeleteCustomerInfo(customerId));
     }
 }
コード例 #4
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 修改客户
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public static bool UpdateCustomerInfo(CustomerModel model)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.UpdateCustomerInfo(model));
     }
 }
コード例 #5
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 获取客户列表
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static ResultPageModel GetCustomerList(SearchModel model, int shopId, bool isvalid = true)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.GetCustomerList(model, shopId, isvalid));
     }
 }
コード例 #6
0
ファイル: CustomerLogic.cs プロジェクト: guomw/bameng
 /// <summary>
 /// 更新客户进店状态
 /// </summary>
 /// <param name="customerId">The customer identifier.</param>
 /// <param name="status">1进店 0未进店</param>
 /// <returns>true if XXXX, false otherwise.</returns>
 public static bool UpdateInShopStatus(int customerId, int status)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.UpdateInShopStatus(customerId, status));
     }
 }
コード例 #7
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 ///获取客户资源列表
 /// </summary>
 /// <param name="UserId">The user identifier.</param>
 /// <param name="pageIndex">Index of the page.</param>
 /// <param name="pageSize">Size of the page.</param>
 /// <returns>ResultPageModel.</returns>
 public static ResultPageModel GetAppCustomerResList(int UserId, int pageIndex, int pageSize)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.GetAppCustomerResList(UserId, pageIndex, pageSize));
     }
 }
コード例 #8
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 获取客户最新的一条维护信息
 /// </summary>
 /// <param name="CID"></param>
 /// <returns></returns>
 public static CustomerAssertModel GetCustomerAssertModel(int CID)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.GetCustomerAssertModel(CID));
     }
 }
コード例 #9
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 获取客户的维护信息
 /// </summary>
 /// <param name="CID">客户ID</param>
 /// <param name="pageIndex"></param>
 /// <param name="pageSize"></param>
 /// <returns></returns>
 public static ResultPageModel GetCustomerAssertList(int CID, int pageIndex, int pageSize)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.GetCustomerAssertList(CID, pageIndex, pageSize));
     }
 }
コード例 #10
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 获取用户的客户数量
 /// </summary>
 /// <param name="userId">The user identifier.</param>
 /// <param name="userIdentity">0盟友 1盟主</param>
 /// <param name="status"> 0 审核中,1已同意  2已拒绝</param>
 /// <returns>System.Int32.</returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public static int GetCustomerCount(int userId, int userIdentity, int status)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.GetCustomerCount(userId, userIdentity, status));
     }
 }
コード例 #11
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 添加客户维护信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int AddCustomerAssert(CustomerAssertModel model)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.AddCustomerAssert(model));
     }
 }
コード例 #12
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 根据手机号码和地址来查找客户信息
 /// </summary>
 /// <param name="mobile"></param>
 /// <param name="address"></param>
 /// <returns></returns>
 public static CustomerModel getCustomerModel(string mobile, string address)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.getCustomerModel(mobile, address));
     }
 }
コード例 #13
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 获取客户信息(只是单纯的客户信息)
 /// </summary>
 /// <param name="cid"></param>
 /// <returns></returns>
 public static CustomerModel getCustomerModel(int cid)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.getCustomerModel(cid));
     }
 }
コード例 #14
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 添加客户资源
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns>System.Int32.</returns>
 public static int InsertCustomerRes(CustomerResModel model)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.InsertCustomerRes(model));
     }
 }
コード例 #15
0
ファイル: CustomerLogic.cs プロジェクト: guomw/bameng
 /// <summary>
 /// 添加客户
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool InsertCustomerInfo(CustomerModel model)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.InsertCustomerInfo(model) > 0);
     }
 }
コード例 #16
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 获取客户信息
 /// </summary>
 /// <param name="customerId">The customer identifier.</param>
 /// <returns>CustomerModel.</returns>
 public static CustomerModel GetModel(int customerId)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.GetModel(customerId));
     }
 }
コード例 #17
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
 /// <summary>
 /// 判断客户是否存在
 /// </summary>
 /// <param name="mobile"></param>
 /// <param name="addr">地址</param>
 /// <returns></returns>
 public static bool IsExist(string mobile, string addr)
 {
     using (var dal = FactoryDispatcher.CustomerFactory())
     {
         return(dal.IsExist(mobile, addr));
     }
 }
コード例 #18
0
ファイル: OrderLogic.cs プロジェクト: huangliliu0917/BMeng
        /// <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);
            }
        }
コード例 #19
0
ファイル: CustomerLogic.cs プロジェクト: huangliliu0917/BMeng
        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="status">审核状态 1已同意  2已拒绝 3未生成订单  4已生成订单,5已失效</param>
        /// <param name="userId">操作人ID(此方法只有盟主操作)</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public static bool UpdateStatus(int customerId, int status, int userId)
        {
            try
            {
                using (var dal = FactoryDispatcher.CustomerFactory())
                {
                    bool flag = dal.UpdateStatus(customerId, status == 1 ? 3 : status, userId);

                    //如果客户审核同意
                    if (flag && status == 1)
                    {
                        //修改审核成功时间
                        dal.UpdateAuditTime(customerId);

                        var model = dal.GetModel(customerId);
                        if (model != null && model.BelongOne > 0)
                        {
                            //添加用户的客户量
                            UserLogic.AddUserCustomerAmount(model.BelongOne);
                            if (model.BelongOne != model.BelongTwo)
                            {
                                UserLogic.AddUserCustomerAmount(model.BelongTwo);
                            }


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

                            using (var dal1 = FactoryDispatcher.UserFactory())
                            {
                                BeansRecordsModel model2 = null;
                                if (rewardSettingModel != null && rewardSettingModel.CustomerReward > 0)
                                {
                                    //给盟友加盟豆
                                    UserLogic.addUserMoney(model.BelongOne, rewardSettingModel.CustomerReward);
                                    model2            = new BeansRecordsModel();
                                    model2.Amount     = rewardSettingModel.CustomerReward;
                                    model2.UserId     = model.BelongOne;
                                    model2.LogType    = 0;
                                    model2.Income     = 1;
                                    model2.Remark     = "客户信息奖励";
                                    model2.OrderId    = model.ID.ToString();
                                    model2.CreateTime = DateTime.Now;
                                    dal1.AddBeansRecords(model2);
                                }
                                //获取积分奖励配置
                                ScoreConfigModel scoreCfg = ConfigLogic.GetScoreConfig();
                                //审核盟友提交的客户信息
                                if (scoreCfg.SubmitCustomerToAllyScore > 0 && dal1.addUserIntegral(model.BelongOne, scoreCfg.SubmitCustomerToAllyScore) > 0)
                                {
                                    model2            = new BeansRecordsModel();
                                    model2.Amount     = scoreCfg.SubmitCustomerToAllyScore;
                                    model2.UserId     = model.BelongOne;
                                    model2.LogType    = 1;
                                    model2.Income     = 1;
                                    model2.Remark     = "客户信息奖励";
                                    model2.OrderId    = "";
                                    model2.CreateTime = DateTime.Now;
                                    dal1.AddBeansRecords(model2);
                                }
                                //盟友提交客户信息,盟主奖励
                                if (scoreCfg.SubmitCustomerToMainScore1 > 0 && dal1.addUserIntegral(model.BelongTwo, scoreCfg.SubmitCustomerToMainScore1) > 0)
                                {
                                    model2            = new BeansRecordsModel();
                                    model2.Amount     = scoreCfg.SubmitCustomerToMainScore1;
                                    model2.UserId     = model.BelongTwo;
                                    model2.LogType    = 1;
                                    model2.Income     = 1;
                                    model2.Remark     = "客户信息奖励";
                                    model2.OrderId    = "";
                                    model2.CreateTime = DateTime.Now;
                                    dal1.AddBeansRecords(model2);
                                }
                            }
                        }
                    }
                    return(flag);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Log(string.Format("UpdateStatus:message:{0},StackTrace:{1}", ex.Message, ex.StackTrace));
                return(false);
            }
        }