public ResultModel ConvertFile(ConversionDto conversionDto)
        {
            var fileNames = _storageRepository.ParseNames(conversionDto.sessionId);

            if (fileNames == null)
            {
                return(ResultModel.Error(fileNames.Id, "Invalid session id", 400));
            }
            return(OpConvert.Measure(fileNames.Id, () =>
            {
                FileFormat fmt;
                if (conversionDto.outputType != null && formats.TryGetValue(conversionDto.outputType, out fmt))
                {
                    SceneImportContext importContext = CreateLoadContext(fileNames);
                    //User uploaded an unsupported file format.
                    if (importContext.SourceFormat == null)
                    {
                        _logger.LogError("Failed to detect file type from file {0}", fileNames.Id);
                        return ResultModel.Error(fileNames.Id, "Unsupported input file", 400);
                    }

                    Scene scene;
                    try
                    {
                        scene = importContext.LoadScene();
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e, "Failed to open input file {0}", fileNames.Id);
                        OperationFailed(e);
                        return ResultModel.Error(fileNames.Id, "Internal server error", 500);
                    }
                    var originalFile = importContext.MainFile;
                    try
                    {
                        var fileName = fileNames[OutputFile];
                        using (var stream = LimitedStream.CreateFile(fileName, MaximumOutputSize))
                        {
                            scene.Save(stream, fmt);
                        }
                    }
                    catch (Exception e)
                    {
                        var msg = "Internal server error";
                        if (e is ExportException)
                        {
                            msg = e.Message;
                        }
                        _logger.LogError(e, "Failed to save converted file to {0}", fileNames[SourceFile]);
                        OperationFailed(e);
                        return ResultModel.Error(fileNames.Id, msg, 500);
                    }
                    var newFileName = Path.ChangeExtension(originalFile, fmt.Extension);
                    importContext.MetaData.OutputFile = newFileName;
                    SetMetaData(fileNames, importContext.MetaData);
                    return ResultModel.Ok(true);
                }
                return ResultModel.Error(fileNames.Id, "Output type not found", 400);
            }));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <ResultModel> > Error2Forum([FromBody] Error2ForumRequest req)
        {
            var repo = storageService.GetRepository(req.Application);

            if (repo == null)
            {
                return(new ActionResult <ResultModel>(ResultModel.Error("Invalid application", 400)));
            }
            var fileNames = repo.ParseNames(req.Session);

            if (fileNames == null || !Directory.Exists(fileNames.Directory))
            {
                return(new ActionResult <ResultModel>(ResultModel.Error("Invalid session id", 400)));
            }
            var          now      = DateTime.Now.ToString();
            var          appName  = FormatAppName(req.Application);
            const string username = "******";
            var          title    = $"{appName} issue - {now}";
            var          content  = $"<p><b>Session :</b> {req.Session}</p><p><b>Date :</b> {now}</p>";

            try
            {
                var url = await conholdateService.PostToForum(title, req.Email, username, content);

                return(new ActionResult <ResultModel>(ResultModel.Ok(url)));
            }
            catch (Exception e)
            {
                logger.LogError("Failed to post error to forum", e);
            }
            return(new ActionResult <ResultModel>(ResultModel.Error("Something bad happened", 500)));
        }
Exemplo n.º 3
0
 /// <summary>
 /// 编辑商家信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public ResultModel EditSYSInfo(ShowSYSModel model)
 {
     using (brnshopEntities context = new brnshopEntities())
     {
         try
         {
             var sys = context.bsp_businesses.FirstOrDefault();
             sys.address         = model.address;
             sys.name            = model.name;
             sys.businessEnd     = sys.businessEnd;
             sys.businessStart   = sys.businessStart;
             sys.businessTimeStr = sys.businessTimeStr;
             sys.canSendRadius   = sys.canSendRadius;
             sys.description     = sys.description;
             sys.latitude        = sys.latitude;
             sys.longitude       = sys.longitude;
             sys.showimg         = sys.showimg;
             context.SaveChanges();
             return(ResultModel.Success("修改成功"));
         }
         catch (Exception ex)
         {
             Logger._.Error(ex);
             return(ResultModel.Error());
         }
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 新增拼团活动
 /// </summary>
 public ResultModel CreateGroupInfo(GroupInfoModel model)
 {
     using (brnshopEntities context = new brnshopEntities())
     {
         try
         {
             bsp_groupinfos newGroupInfo = new bsp_groupinfos();
             newGroupInfo.endtime    = model.endtime;
             newGroupInfo.groupoid   = model.groupoid;
             newGroupInfo.groupprice = model.groupprice;
             newGroupInfo.grouptype  = model.grouptype;
             newGroupInfo.maxtime    = model.maxtime;
             newGroupInfo.needcount  = model.needcount;
             newGroupInfo.shopprice  = model.shopprice;
             newGroupInfo.starttime  = model.starttime;
             context.bsp_groupinfos.Add(newGroupInfo);
             context.SaveChanges();
             return(ResultModel.Success("新增成功"));
         }
         catch (Exception ex)
         {
             Logger._.Error("CreateGroupInfo方法,", ex);
             return(ResultModel.Error(ex.ToString()));
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 获取当前拼团活动正在进行的团
        /// </summary>
        /// <returns></returns>
        public ResultModel GetRunningGroupListByInfo(int groupInfoId)
        {
            using (brnshopEntities context = new brnshopEntities())
            {
                try
                {
                    string sql    = $@"select bsp_groups.*,
	                                       bsp_groupdetails.groupdetailid gd_groupdetailid,
	                                       bsp_groupdetails.groupid gd_groupid,
	                                       bsp_groupdetails.paytime gd_paytime,
	                                       bsp_groupdetails.sno gd_sno,
	                                       bsp_groupdetails.uid gd_uid
                                    from bsp_groups 
                                    left join bsp_groupdetails on bsp_groupdetails.groupid = bsp_groups.groupid
                                    where groupinfoid = {groupInfoId} and isfinish = 0 and isfail = 0";
                    var    dt     = SqlManager.FillDataTable(AppConfig.ConnectionString, new SqlCommand(sql));
                    var    groups = dt.GetList <GroupModel>("").Distinct(new DistinctModel <GroupModel>()).ToList();

                    foreach (var group in groups)
                    {
                        //拼团信息
                        DataTable gddt = dt.Select($"groupid = {group.groupid}").CopyToDataTable();
                        group.details = gddt.GetList <GroupDetailModel>("");
                    }

                    return(ResultModel.Success("", groups));
                }
                catch (Exception ex)
                {
                    Logger._.Error("GroupInfoList方法,", ex);
                    return(ResultModel.Error(ex.ToString()));
                }
            }
        }
Exemplo n.º 6
0
 public ResultModel AddSKU(int pid, int valueid, int isdefaultprice, decimal price)
 {
     using (brnshopEntities context = new brnshopEntities())
     {
         try
         {
             var sku = context.bsp_productskus.SingleOrDefault(t => t.pid == pid && t.attrvalueid == valueid);
             if (sku != null)
             {
                 return(ResultModel.Fail("该规格SKU已经存在"));
             }
             var             attrvalue = context.bsp_attributevalues.SingleOrDefault(t => t.attrvalueid == valueid);
             bsp_productskus newsku    = new bsp_productskus();
             newsku.pid            = pid;
             newsku.attrid         = attrvalue.attrid;
             newsku.attrvalueid    = valueid;
             newsku.inputattr      = attrvalue.attrname;
             newsku.inputvalue     = attrvalue.attrvalue;
             newsku.isdefaultprice = isdefaultprice;
             newsku.price          = price;
             context.bsp_productskus.Add(newsku);
             context.SaveChanges();
             ProductCache.InitProductList();
             return(ResultModel.Success("", newsku.recordid));
         }
         catch (Exception ex)
         {
             Logger._.Error(ex);
             return(ResultModel.Error(ex.ToString()));
         }
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// 客户端调用Login之后传回Code,根据code获取openid,如果已存在用户信息,则返回用户信息,否则返回错误状态值,前端再请求用户授权
        /// </summary>
        public ResultModel Login(string code)
        {
            string session2Url = string.Format("https://api.weixin.qq.com/sns/jscode2session?appid={0}&secret={1}&js_code={2}&grant_type=authorization_code",
                                               WXPayHelper.appid, WXPayHelper.appsecret, code);

            var jsonstr = HttpHelper.HttpGet(session2Url, "");
            Code2SessionModel result = JsonConvert.DeserializeObject <Code2SessionModel>(jsonstr);

            if (result.errcode != 0)
            {
                Logger._.Error($"code2session接口请求失败,errcode:{result.errcode},errmsg:{result.errmsg}");
                return(ResultModel.Error($"code2session接口请求失败,errcode:{result.errcode},errmsg:{result.errmsg}"));
            }
            using (brnshopEntities context = new brnshopEntities())
            {
                try
                {
                    var user = context.bsp_users.SingleOrDefault(t => t.openid == result.openid);
                    if (user == null)
                    {
                        return(ResultModel.Fail(result.openid));
                    }
                    return(ResultModel.Success("", user2ShowUser(user)));
                }catch (Exception ex)
                {
                    Logger._.Error(ex);
                    return(ResultModel.Error("数据库操作异常"));
                }
            }
        }
Exemplo n.º 8
0
 public ResultModel AddAttributeValue(short attrid, string value)
 {
     using (brnshopEntities context = new brnshopEntities())
     {
         try
         {
             var attrvalue = context.bsp_attributevalues.SingleOrDefault(t => t.attrid == attrid && t.attrvalue == value);
             if (attrvalue != null)
             {
                 return(ResultModel.Fail("该属性值已经存在"));
             }
             var attr = context.bsp_attributes.SingleOrDefault(t => t.attrid == attrid);
             bsp_attributevalues newattrvalue = new bsp_attributevalues();
             newattrvalue.attrid    = attrid;
             newattrvalue.attrname  = attr.name;
             newattrvalue.attrvalue = value;
             context.bsp_attributevalues.Add(newattrvalue);
             context.SaveChanges();
             return(ResultModel.Success("", newattrvalue.attrvalueid));
         }
         catch (Exception ex)
         {
             Logger._.Error(ex);
             return(ResultModel.Error(ex.ToString()));
         }
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// 删除分类
        /// </summary>
        /// <param name="cateid"></param>
        /// <returns></returns>
        public ResultModel DeleteCateGory(int cateid)
        {
            using (brnshopEntities context = new brnshopEntities())
            {
                try
                {
                    var sql = $@"select COUNT(bsp_cateproducts.catepid)
						    from bsp_cateproducts
						    left join bsp_products on bsp_products.pid = bsp_cateproducts.pid
						    where bsp_products.isdelete = 0 and bsp_cateproducts.cateid = {cateid}"                        ;
                    var dt  = SqlManager.FillDataTable(AppConfig.ConnectionString, new SqlCommand(sql));
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        if (int.Parse(dt.Rows[0][0].ToString()) > 0)
                        {
                            return(ResultModel.Fail("该分类下存在商品,不允许删除"));
                        }
                    }
                    var cate = context.bsp_categories.SingleOrDefault(t => t.cateid == cateid);
                    if (cate == null)
                    {
                        return(ResultModel.Fail("该分类已经删除,请刷新"));
                    }
                    context.bsp_categories.Remove(cate);
                    context.SaveChanges();
                    return(ResultModel.Success("删除成功"));
                }
                catch (Exception ex)
                {
                    Logger._.Error(ex);
                    return(ResultModel.Error(ex.ToString()));
                }
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// 添加分类
 /// </summary>
 /// <returns></returns>
 public ResultModel AddCateGory(string name, int displayorder = 0)
 {
     using (brnshopEntities context = new brnshopEntities())
     {
         try
         {
             var catrgory = context.bsp_categories.SingleOrDefault(t => t.name == name);
             if (catrgory != null)
             {
                 return(ResultModel.Fail("已存在该分类"));
             }
             bsp_categories newcate = new bsp_categories();
             newcate.name         = name;
             newcate.displayorder = displayorder;
             newcate.pricerange   = "";
             newcate.path         = "";
             context.bsp_categories.Add(newcate);
             context.SaveChanges();
             return(ResultModel.Success("添加成功", newcate.cateid));
         }
         catch (Exception ex)
         {
             Logger._.Error(ex);
             return(ResultModel.Error(ex.ToString()));
         }
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// 删除包厢
        /// </summary>
        /// <param name="boxid"></param>
        /// <returns></returns>
        public ResultModel DeleteBox(int boxid)
        {
            using (brnshopEntities context = new brnshopEntities())
            {
                var tran = context.Database.BeginTransaction();
                try
                {
                    var box = context.bsp_boxes.SingleOrDefault(t => t.boxid == boxid);
                    if (box == null)
                    {
                        return(ResultModel.Fail("该包厢已删除,请刷新"));
                    }
                    context.bsp_boxes.Remove(box);
                    context.SaveChanges();

                    tran.Commit();
                    new BoxCache().Init();
                    return(ResultModel.Success("删除成功"));
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    Logger._.Error(ex);
                    return(ResultModel.Error(ex.ToString()));
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 更新包厢
        /// </summary>
        /// <param name="boxid"></param>
        /// <param name="state"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public ResultModel UpdateBox(int boxid, BoxState state, string name, decimal price, decimal bookprice)
        {
            using (brnshopEntities context = new brnshopEntities())
            {
                var tran = context.Database.BeginTransaction();
                try
                {
                    var box = context.bsp_boxes.SingleOrDefault(t => t.boxid == boxid);
                    if (box == null)
                    {
                        return(ResultModel.Fail("该包厢已删除,请刷新"));
                    }
                    box.state     = (int)state;
                    box.name      = name;
                    box.price     = price;
                    box.bookprice = bookprice;
                    if (state == BoxState.Empty)
                    {
                        box.username = "";
                        box.phone    = "";
                    }
                    context.SaveChanges();

                    tran.Commit();
                    new BoxCache().Init();
                    return(ResultModel.Success("修改成功"));
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    Logger._.Error(ex);
                    return(ResultModel.Error(ex.ToString()));
                }
            }
        }
        public ResultModel UploadIForm([FromForm] IFormCollection formData)
        {
            IFormFileCollection files = formData.Files;
            int fileCount             = files.Count;

            if (files == null || fileCount == 0)
            {
                return(ResultModel.Error("file can't be null!", 400));
            }
            var fileNames = _storageRepository.NewNames();

            return(OpUpload.Measure(fileNames.Id, () =>
            {
                try
                {
                    SaveUploadedFiles(fileNames, files);
                }
                catch (Exception e)
                {
                    OperationFailed(e);
                    return ResultModel.Error(fileNames.Id, e.Message, 400);
                }
                return ResultModel.Ok(fileNames.Id);
            }));
        }
Exemplo n.º 14
0
        public ResultModel <bool> TestValiTokenState(string tokenStr)
        {
            var       result    = new ResultModel <bool>();
            string    loginID   = "";
            var       secretKey = ConfigurationManager.GetJwtSettings("SecretKey");
            TokenType tokenType = _tokenHelper.ValiTokenState(tokenStr, secretKey, a => a["iss"] == "webapi.cn" && a["aud"] == "webapi", action => { loginID = action["id"]; });

            if (tokenType == TokenType.Fail)
            {
                return(result.Error("token验证失败", false));
            }
            if (tokenType == TokenType.Expired)
            {
                return(result.Error("token已经过期", false));
            }
            return(result.Success("访问成功", true));;
        }
Exemplo n.º 15
0
 /// <summary>
 /// 参数校验
 /// </summary>
 /// <returns></returns>
 public ResultModel ArgsCheck()
 {
     if (string.IsNullOrEmpty(ViewName))
     {
         return(ResultModel.Error("ViewName can not be null!"));
     }
     return(ResultModel.Success());
 }
 public ResultModel QueryArgsCheck()
 {
     if (string.IsNullOrEmpty(interfaceCode))
     {
         return(ResultModel.Error("interfaceCode can not be null!"));
     }
     return(ResultModel.Success());
 }
Exemplo n.º 17
0
        /// <summary>
        /// 新增优惠券(后台)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResultModel AddCouponType(ShowCouponTypeInfo model)
        {
            using (brnshopEntities context = new brnshopEntities())
            {
                var tran = context.Database.BeginTransaction();
                try
                {
                    //新增
                    if (model.ct_coupontypeid == 0)
                    {
                        bsp_coupontypes newcoupontype = new bsp_coupontypes();
                        newcoupontype.cutmoney         = model.ct_cutmoney;
                        newcoupontype.discount         = model.ct_discount;
                        newcoupontype.fullmoney        = model.ct_fullmoney;
                        newcoupontype.count            = 0;
                        newcoupontype.getmode          = 0;
                        newcoupontype.isstack          = model.ct_isstack;
                        newcoupontype.limitbrandid     = 0;
                        newcoupontype.limitcateid      = 0;
                        newcoupontype.limitproduct     = 0;
                        newcoupontype.money            = 0;
                        newcoupontype.name             = model.ct_name;
                        newcoupontype.orderamountlower = 0;
                        newcoupontype.sendendtime      = model.ct_sendendtime;
                        newcoupontype.sendmode         = 0;
                        newcoupontype.sendstarttime    = model.ct_sendstarttime;
                        newcoupontype.state            = 0;
                        newcoupontype.type             = model.ct_type;
                        newcoupontype.useendtime       = model.ct_useexpiretime == 1?model.ct_useendtime:DateTime.Now;
                        newcoupontype.useexpiretime    = model.ct_useexpiretime;
                        newcoupontype.usemode          = 0;
                        newcoupontype.userranklower    = 0;
                        newcoupontype.usestarttime     = model.ct_useexpiretime == 1 ? model.ct_usestarttime : DateTime.Now;
                        newcoupontype.isforgroup       = model.ct_isforgroup;
                        context.bsp_coupontypes.Add(newcoupontype);
                        context.SaveChanges();

                        if (model.ct_pid > 0)
                        {
                            bsp_couponproducts bsp_Couponproduct = new bsp_couponproducts();
                            bsp_Couponproduct.coupontypeid = newcoupontype.coupontypeid;
                            bsp_Couponproduct.pid          = model.ct_pid;
                            context.bsp_couponproducts.Add(bsp_Couponproduct);
                            context.SaveChanges();
                        }
                    }
                    tran.Commit();
                    return(ResultModel.Success("添加成功"));
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    Logger._.Error(ex);
                    return(ResultModel.Error());
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// 用户参团(支付回调时调用)
        /// </summary>
        /// <returns></returns>
        public ResultModel JoinGroup(int GroupId, int uid, string outtradeno, string transaction_id)
        {
            using (brnshopEntities context = new brnshopEntities())
            {
                var tran = context.Database.BeginTransaction();
                try
                {
                    bsp_groups Group = context.bsp_groups.SingleOrDefault(t => t.groupid == GroupId);
                    Group.nowcount += 1;
                    //拼团成功,发放优惠券
                    if (Group.needcount <= Group.nowcount)
                    {
                        Group.isfinish = true;
                        Group.endtime  = DateTime.Now;
                        var groupdetails = context.bsp_groupdetails.Where(t => t.groupid == GroupId).ToList();
                        foreach (var groupdetail in groupdetails)
                        {
                            if (!groupdetail.isgetcoupon.Value)
                            {
                                coupon.RecpientCoupon(groupdetail.uid, Group.groupoid);
                                groupdetail.isgetcoupon = true;
                            }
                        }
                    }

                    bsp_groupdetails newGroupetail = new bsp_groupdetails();
                    newGroupetail.groupid        = Group.groupid;
                    newGroupetail.paytime        = DateTime.Now;
                    newGroupetail.sno            = Group.nowcount;
                    newGroupetail.uid            = uid;
                    newGroupetail.isgetcoupon    = false;
                    newGroupetail.paytime        = DateTime.Parse("1997-01-27");
                    newGroupetail.transaction_id = transaction_id;
                    newGroupetail.outtradeno     = outtradeno;
                    if (Group.needcount <= Group.nowcount)
                    {
                        coupon.RecpientCoupon(newGroupetail.uid, Group.groupoid);
                        newGroupetail.isgetcoupon = true;
                    }
                    context.bsp_groupdetails.Add(newGroupetail);
                    context.SaveChanges();

                    ORDER.AddStatistics(true, Group, newGroupetail, context);
                    tran.Commit();
                    return(ResultModel.Success("参团成功"));
                }
                catch (Exception ex)
                {
                    Logger._.Error("JoinGroup方法,", ex);
                    tran.Rollback();
                    return(ResultModel.Error(ex.ToString()));
                }
            }
        }
        public ResultModel Delete(int metaObjectId, FilterDefinition <BsonDocument> condition)
        {
            var metaObject = metaObjectService.GetById(metaObjectId);

            if (metaObject == null)
            {
                return(ResultModel.Error("没有找到该实体编码对应的实体信息"));
            }

            return(Delete(metaObject, condition));
        }
Exemplo n.º 20
0
 public IActionResult Check(IEnumerable <TypeModel> typeModels)
 {
     try
     {
         bll.Check(typeModels);
         return(Json(ResultModel.Success("更新收支类型成功!")));
     }
     catch (Exception e)
     {
         return(Json(ResultModel.Error(e.Message)));
     }
 }
Exemplo n.º 21
0
 public IActionResult SaveData(IEnumerable <DayModel> data)
 {
     try
     {
         bll.CheckData(data);
         return(Json(ResultModel.Success("更新数据成功")));
     }
     catch (Exception e)
     {
         return(Json(ResultModel.Error(e.Message)));
     }
 }
Exemplo n.º 22
0
        public async Task <JsonResult> Register([FromBody] RegisterApiRequest model)
        {
            using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                try
                {
                    if (model.RePassword != model.Password)
                    {
                        return(BadResponse(ResultModel.Error("Repassword must match password")));
                    }

                    AppUserDetail appUserDetail = new AppUserDetail
                    {
                        FirstName        = model.FirstName,
                        LastName         = model.LastName,
                        ProfilePhotoPath = "http://placehold.it/300x300",
                        CoverPhotoPath   = "http://placehold.it/1030x360"
                    };
                    ResultModel resultModel = _userDetailService.Create(appUserDetail);
                    if (!resultModel.Status)
                    {
                        return(BadResponse(resultModel));
                    }

                    AppUser userEntity = new AppUser
                    {
                        UserName    = model.UserName,
                        Email       = model.Email,
                        CreatedDate = DateTime.Now,
                        DetailId    = appUserDetail.Id
                    };

                    IdentityResult result = await _userManager.CreateAsync(userEntity, model.Password);

                    if (!result.Succeeded)
                    {
                        Result.Status  = false;
                        Result.Message = string.Join(",", result.Errors.Select(x => x.Description));
                        scope.Dispose();
                        return(BadResponse(Result));
                    }
                    scope.Complete();
                    return(OkResponse(Result));
                }
                catch (Exception ex)
                {
                    scope.Dispose();
                    Result.Status  = false;
                    Result.Message = ex.ToString();
                    return(BadResponse(Result));
                }
            }
        }
Exemplo n.º 23
0
        public async Task <JsonResult> Login([FromBody] LoginApiRequest model)
        {
            Log.Logger.Information("LoginController - Login Logged");
            if (model.Username == configuration.GetValue <string>("MySettings:UserName") && model.Password == configuration.GetValue <string>("MySettings:Password"))
            {
                var token = _tokenService.GenerateToken(model.Username);

                return(OkResponse(token));
            }


            return(BadResponse(ResultModel.Error("Kullanıcı adı veya şifre yanlış")));
        }
 /// <summary>
 /// 根据id删除配置字段,校验是否被引用
 /// </summary>
 /// <param name="id"></param>
 public new ResultModel Delete(int id)
 {
     if (dbContext.QueryExist <InterfaceAggregation>(t => t.SearchConditionId == id))
     {
         //存在引用关系,先删除引用该数据的数据
         return(ResultModel.Error("存在引用关系,先删除引用该数据的数据"));
     }
     else
     {
         base.Delete(id);
         return(ResultModel.Success());
     }
 }
Exemplo n.º 25
0
        /// <summary>
        /// 用户发起拼团支付
        /// </summary>
        /// <param name="isstart">1开团 2参团</param>
        /// <param name="gid"></param>
        /// <param name="uid"></param>
        /// <returns></returns>
        public ResultModel PayGroup(int isstart, int gid, int uid, decimal totalfee)
        {
            try
            {
                using (brnshopEntities context = new brnshopEntities())
                {
                    if (isstart == 1)
                    {
                        var groupCount = context.bsp_groups.Where(t => t.startuid == uid & t.groupinfoid == gid).Count();
                        if (groupCount > 0)
                        {
                            return(ResultModel.Fail("您已参与过该团"));
                        }
                    }
                    else
                    {
                        var groupCount = context.bsp_groupdetails.Where(t => t.uid == uid & t.groupid == gid).Count();
                        if (groupCount > 0)
                        {
                            return(ResultModel.Fail("您已参与过该团"));
                        }
                    }

                    var         user               = context.bsp_users.SingleOrDefault(t => t.uid == uid);
                    WXPayHelper wXPayHelper        = new WXPayHelper();
                    var         unifiedorderResult = wXPayHelper.unifiedorderForGroup(isstart, gid, uid, "拼团", user.openid, totalfee);
                    if (!unifiedorderResult.Item1)
                    {
                        return(ResultModel.Fail("拼团支付调用微信下单接口失败,详情见日志"));
                    }
                    SortedDictionary <string, object> payDic = unifiedorderResult.Item2 as SortedDictionary <string, object>;

                    var             timestamp = WXPayHelper.GetTimeStamp();
                    string          aSign     = $@"appId={payDic["appid"]}&nonceStr={payDic["nonce_str"].ToString()}&package=prepay_id={payDic["prepay_id"].ToString()}&signType=MD5&timeStamp={timestamp}&key={WXPayHelper.apisecret}";
                    WxpayDataForApi model     = new WxpayDataForApi();
                    model.appId     = payDic["appid"].ToString();
                    model.nonceStr  = payDic["nonce_str"].ToString();
                    model.package   = $@"prepay_id={payDic["prepay_id"].ToString()}";
                    model.paySign   = EncryptHelp.EncryptMD5(aSign);
                    model.signType  = WxPayAPI.WxPayData.SIGN_TYPE_MD5;
                    model.timeStamp = timestamp;

                    return(ResultModel.Success("", model));
                }
            }
            catch (Exception ex)
            {
                Logger._.Error("PayGroup方法,", ex);
                return(ResultModel.Error(ex.ToString()));
            }
        }
Exemplo n.º 26
0
        public ResultModel <string> GetDownLoadFile(string url)
        {
            var userId = Convert.ToInt32(HttpContext.User.FindFirst("id").Value);
            //根据orderNo 与 会员Id查询 订单信息

            /*
             * 此时为了跟大家演示 下载效果 只需要传参 url即可
             * 真实的业务场景,会根据登录用户,以及业务编号  我们可以根据需求去重写 对应的业务即可即可
             */

            var result = new ResultModel <string>();

            if (string.IsNullOrEmpty(url))
            {
                return(result.Error("请输入文件地址", null));
            }
            string cdipath = Directory.GetCurrentDirectory() + url;

            if (!System.IO.File.Exists(cdipath))
            {
                return(result.Error("文件不存在", null));
            }
            //根据当前登录用户验证 文件相对路径 是否包含userId值
            if (!url.Contains(userId.ToString() + "_"))
            {
                return(result.Error("您当前下载的文件不正确", null));
            }

            /*
             * 真实场景  下载客户文件时,需要根据业务信息动态获取客户源文件名,生成文件名的规则 你们也可以自定义
             * 此处 我会根据切割  地址获取文件名 /MyUpfiles/2020/09/24/55020_04-03-{文件名}_c825733e-3f87-44b5-b002-0fd4d94a94d1.zip
             */
            var getfileName = url.Split('_')[1].ToString();
            var fileKey     = _protector.Protect(getfileName, TimeSpan.FromSeconds(120));

            //fileKey 是根据文件进行加密后的秘钥,有效时间为:120s
            return(result.Success("文件秘钥生成成功", fileKey));
        }
Exemplo n.º 27
0
        public ActionResult Get(int id)
        {
            Log.Logger.Information("ArticleController - Get Logged");
            var data = _articleService.GetById(id);

            if (data != null)
            {
                return(OkResponse(data));
            }
            else
            {
                return(BadResponse(ResultModel.Error("Makale bulunamadı.")));
            }
        }
Exemplo n.º 28
0
        public JsonResult CreatePost([FromBody] PostCreateApi model)
        {
            using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                try
                {
                    if (model.Text == null)
                    {
                        Result.Status  = false;
                        Result.Message = "You can not add a post without writing text ! ";
                        return(BadResponse(Result));
                    }

                    #region CRUD

                    var newPost = new Post
                    {
                        Text = model.Text,
                    };
                    ResultModel postModel = _postService.Create(newPost);

                    if (!postModel.Status)
                    {
                        scope.Dispose();
                        return(BadResponse(ResultModel.Error("The upload process can not be done !")));
                    }

                    #endregion

                    scope.Complete();
                    //TODO
                    //There must be an integration that returns the last post that has just been createad.

                    return(OkResponse(new PostListDto
                    {
                        Id = newPost.Id,
                        Text = newPost.Text,
                        CreatedDate = newPost.CreatedDate,
                        Comments = null
                    }));
                }
                catch (Exception ex)
                {
                    scope.Dispose();
                    Result.Status  = false;
                    Result.Message = ex.ToString();
                    return(BadResponse(Result));
                }
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// 获取首页拼团列表
 /// </summary>
 /// <returns></returns>
 public ResultModel GroupInfoList()
 {
     using (brnshopEntities context = new brnshopEntities())
     {
         try
         {
             string sql = $@"select * from bsp_groupinfos";
             List <GroupInfoModel> groupInfos = context.Database.SqlQuery <GroupInfoModel>(sql).ToList();
             var couponTypes = coupon.GetCouponTypeForGroup();
             foreach (var groupInfo in groupInfos)
             {
                 groupInfo.couponTypeInfo = couponTypes.SingleOrDefault(t => t.ct_coupontypeid == groupInfo.groupoid);
                 bool isfind = false;
                 foreach (var products in ProductCache.ProductList)
                 {
                     foreach (var product in products.productInfos)
                     {
                         if (product.pid == groupInfo.couponTypeInfo.ct_pid)
                         {
                             groupInfo.productInfo = product;
                             isfind = true;
                             break;
                         }
                     }
                     if (isfind)
                     {
                         break;
                     }
                 }
                 var couponTypeInfodes = "";
                 if (groupInfo.couponTypeInfo.ct_type == 1)
                 {
                     couponTypeInfodes = $@" 满{Math.Round(groupInfo.couponTypeInfo.ct_fullmoney,2)}减{Math.Round(groupInfo.couponTypeInfo.ct_cutmoney,2)}";
                 }
                 else
                 {
                     couponTypeInfodes = $@" {(int)groupInfo.couponTypeInfo.ct_discount}折";
                 }
                 groupInfo.title = groupInfo.couponTypeInfo.ct_name + couponTypeInfodes;
             }
             return(ResultModel.Success("", groupInfos));
         }
         catch (Exception ex)
         {
             Logger._.Error("GroupInfoList方法,", ex);
             return(ResultModel.Error(ex.ToString()));
         }
     }
 }
Exemplo n.º 30
0
        /// <summary>
        /// 用户开团(支付回调时调用)
        /// </summary>
        /// <returns></returns>
        public ResultModel StartGroup(int groupInfoId, int uid, string outtradeno, string transaction_id)
        {
            using (brnshopEntities context = new brnshopEntities())
            {
                var tran = context.Database.BeginTransaction();
                try
                {
                    bsp_groupinfos GroupInfo = context.bsp_groupinfos.SingleOrDefault(t => t.groupinfoid == groupInfoId);
                    bsp_groups     newGroup  = new bsp_groups();
                    newGroup.endtime     = DateTime.Now.AddSeconds(GroupInfo.maxtime);
                    newGroup.failtype    = 0;
                    newGroup.groupoid    = GroupInfo.groupoid;
                    newGroup.groupprice  = GroupInfo.groupprice;
                    newGroup.grouptype   = GroupInfo.grouptype;
                    newGroup.isfail      = false;
                    newGroup.isfinish    = false;
                    newGroup.maxtime     = GroupInfo.maxtime;
                    newGroup.needcount   = GroupInfo.needcount;
                    newGroup.nowcount    = 1;
                    newGroup.shopprice   = GroupInfo.shopprice;
                    newGroup.starttime   = DateTime.Now;
                    newGroup.startuid    = uid;
                    newGroup.groupinfoid = groupInfoId;
                    context.bsp_groups.Add(newGroup);
                    context.SaveChanges();

                    bsp_groupdetails newGroupetail = new bsp_groupdetails();
                    newGroupetail.groupid        = newGroup.groupid;
                    newGroupetail.paytime        = DateTime.Now;
                    newGroupetail.sno            = 1;
                    newGroupetail.uid            = uid;
                    newGroupetail.isgetcoupon    = false;
                    newGroupetail.paytime        = DateTime.Parse("1997-01-27");
                    newGroupetail.transaction_id = transaction_id;
                    newGroupetail.outtradeno     = outtradeno;
                    context.bsp_groupdetails.Add(newGroupetail);
                    context.SaveChanges();
                    ORDER.AddStatistics(true, newGroup, newGroupetail, context);
                    tran.Commit();
                    return(ResultModel.Success("开团成功"));
                }
                catch (Exception ex)
                {
                    Logger._.Error("StartGroup方法,", ex);
                    tran.Rollback();
                    return(ResultModel.Error(ex.ToString()));
                }
            }
        }