public ActionResult UpRenew(ShopRenewRecordInfo model) { if (model == null) { return(Json(new Result() { success = false, msg = "更新对象为空" })); } model.OperateType = ShopRenewRecordInfo.EnumOperateType.Upgrade; model.Operator = CurrentSellerManager.UserName; model.OperateDate = DateTime.Now; if (model.Type == ShopRenewRecordInfo.EnumOperateType.ReNew) { model.OperateType = ShopRenewRecordInfo.EnumOperateType.ReNew; var shopInfo = _iShopService.GetShop(model.ShopId); if (shopInfo != null) { DateTime beginTime = shopInfo.EndDate; if (beginTime < DateTime.Now) { beginTime = DateTime.Now; } string strNewEndTime = beginTime.AddYears(model.Year).ToString("yyyy-MM-dd"); model.OperateContent = "续费 " + model.Year + " 年至 " + strNewEndTime; _iShopService.AddShopRenewRecord(model); _iShopService.ShopReNew(model.ShopId, model.Year); //店铺续费 ShopApplication.ClearCacheShop(CurrentSellerManager.ShopId); return(Json(new Result() { success = true })); } } else { var shopInfo = _iShopService.GetShop(model.ShopId); if (shopInfo != null) { var shopGrade = _iShopService.GetShopGrades().Where(c => c.Id == shopInfo.GradeId).FirstOrDefault(); var newshopGrade = _iShopService.GetShopGrades().Where(c => c.Id == model.GradeId).FirstOrDefault(); model.OperateContent = "将套餐‘" + shopGrade.Name + "'升级为套餐‘" + newshopGrade.Name + "'"; _iShopService.AddShopRenewRecord(model); _iShopService.ShopUpGrade(model.ShopId, model.GradeId); //店铺升级 ShopApplication.ClearCacheShop(CurrentSellerManager.ShopId); return(Json(new Result() { success = true })); } } return(Json(new Result() { success = false, msg = "操作失败" })); }
public ContentResult ReNewPayNotify_Post(string id, string str) { decimal balance = decimal.Parse(str.Split('-')[0]); string userName = str.Split('-')[1]; long shopId = long.Parse(str.Split('-')[2]); int type = int.Parse(str.Split('-')[3]); int value = int.Parse(str.Split('-')[4]); id = DecodePaymentId(id); string errorMsg = string.Empty; string response = string.Empty; try { var payment = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id); var payInfo = payment.Biz.ProcessNotify(HttpContext.Request); ShopRenewRecord model = new ShopRenewRecord(); model.TradeNo = payInfo.TradNo; bool result = Cache.Get(CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds))) == null ? false : true; if (!result) { //添加店铺续费记录 model.ShopId = shopId; model.OperateDate = DateTime.Now; model.Operator = userName; model.Amount = balance; //续费操作 if (type == 1) { model.OperateType = ShopRenewRecord.EnumOperateType.ReNew; var shopInfo = _iShopService.GetShop(shopId); DateTime beginTime = shopInfo.EndDate.Value; if (beginTime < DateTime.Now) { beginTime = DateTime.Now; } string strNewEndTime = beginTime.AddYears(value).ToString("yyyy-MM-dd"); model.OperateContent = "续费 " + value + " 年至 " + strNewEndTime; _iShopService.AddShopRenewRecord(model); //店铺续费 _iShopService.ShopReNew(shopId, value); } //升级操作 else { model.ShopId = shopId; model.OperateType = ShopRenewRecord.EnumOperateType.Upgrade; var shopInfo = _iShopService.GetShop(shopId); var shopGrade = _iShopService.GetShopGrades().Where(c => c.Id == shopInfo.GradeId).FirstOrDefault(); var newshopGrade = _iShopService.GetShopGrades().Where(c => c.Id == (long)value).FirstOrDefault(); model.OperateContent = "将套餐‘" + shopGrade.Name + "'升级为套餐‘" + newshopGrade.Name + "'"; _iShopService.AddShopRenewRecord(model); //店铺升级 _iShopService.ShopUpGrade(shopId, (long)value); } response = payment.Biz.ConfirmPayResult(); string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds)); //获取支付状态缓存键 Cache.Insert(payStateKey, true); //标记为已支付 if (Cache.Exists(CacheKeyCollection.CACHE_SHOP(shopId, false))) { Cache.Remove(CacheKeyCollection.CACHE_SHOP(shopId, false)); } } } catch (Exception ex) { errorMsg = ex.Message; Log.Error("ReNewPayNotify_Post", ex); } return(Content(response)); }