/// <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); } }
public static bool Update(int userId, string orderId, int status, ref ApiStatusCode code) { using (var dal = FactoryDispatcher.OrderFactory()) { OrderModel orderModel = dal.GetModel(orderId); if (orderModel == null) { code = ApiStatusCode.订单存在问题; return(false); } if (orderModel.OrderStatus != 0) { code = ApiStatusCode.订单目前状态存在异常; return(false); } if (status == 1 && string.IsNullOrEmpty(orderModel.SuccessImg)) { code = ApiStatusCode.请先上传成交凭证; return(false); } //改订单为已处理 if (status == 1 && orderModel.UserId != orderModel.Ct_BelongId) { //更新盟友用户等级 UserLogic.userUpdate(orderModel.Ct_BelongId); //更新盟主用户等级 UserLogic.masterUpdate(orderModel.UserId); if (orderModel.MengBeans > 0) { //给盟友加盟豆 UserLogic.addUserMoney(orderModel.Ct_BelongId, orderModel.MengBeans); using (var dal1 = FactoryDispatcher.UserFactory()) { TempBeansRecordsModel model1 = new TempBeansRecordsModel(); model1.Amount = -orderModel.MengBeans; model1.UserId = orderModel.Ct_BelongId; model1.LogType = 0; model1.Income = 0; model1.CreateTime = DateTime.Now; model1.Status = 0; model1.OrderId = orderModel.orderId; model1.Remark = "转正"; dal1.AddTempBeansRecords(model1); BeansRecordsModel model2 = new BeansRecordsModel(); model2.Amount = orderModel.MengBeans; model2.UserId = orderModel.Ct_BelongId; model2.LogType = 0; model2.Income = 1; model2.Remark = "订单奖励"; model2.OrderId = orderModel.orderId; model2.CreateTime = DateTime.Now; dal1.AddBeansRecords(model2); } } } if (status == 2 && orderModel.UserId != orderModel.Ct_BelongId && orderModel.MengBeans > 0) { using (var dal1 = FactoryDispatcher.UserFactory()) { TempBeansRecordsModel model1 = new TempBeansRecordsModel(); model1.Amount = -orderModel.MengBeans; model1.UserId = orderModel.Ct_BelongId; model1.LogType = 0; model1.Income = 0; model1.CreateTime = DateTime.Now; model1.Status = 0; model1.OrderId = orderModel.orderId; model1.Remark = "退单"; dal1.AddTempBeansRecords(model1); } } bool flag = dal.Update(orderId, status) == 1; if (status == 1) { if (orderModel.UserId != orderModel.Ct_BelongId && orderModel.UserId > 0 && orderModel.Ct_BelongId > 0) { //添加用户订单量 UserLogic.AddUserOrderSuccessAmount(orderModel.UserId); UserLogic.AddUserOrderSuccessAmount(orderModel.Ct_BelongId); } else { //添加用户订单量 UserLogic.AddUserOrderSuccessAmount(orderModel.UserId); } } return(flag); } }