/// <summary> /// 报价 图片上传 /// </summary> /// <returns></returns> public Task <ApiReturnModel> QuotationProductImgUpload() { // 检查是否是 multipart/form-data if (!Request.Content.IsMimeMultipartContent("form-data")) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } //文件保存目录路径 string SaveTempPath = ConfigHelp.GetValueByNameInAppSettings("QuotationProductImg"); SaveTempPath += DateTime.Now.ToString("yyyy") + '/'; SaveTempPath += DateTime.Now.ToString("MM") + '/'; String dirTempPath = HttpContext.Current.Server.MapPath(SaveTempPath); if (!System.IO.Directory.Exists(dirTempPath)) { System.IO.Directory.CreateDirectory(dirTempPath); } // 设置上传目录 var provider = new MultipartFormDataStreamProvider(dirTempPath); //var queryp = Request.GetQueryNameValuePairs();//获得查询字符串的键值集合 var task = Request.Content.ReadAsMultipartAsync(provider). ContinueWith <ApiReturnModel>(o => { var file = provider.FileData[0];//provider.FormData string orfilename = file.Headers.ContentDisposition.FileName.TrimStart('"').TrimEnd('"'); FileInfo fileinfo = new FileInfo(file.LocalFileName); //最大文件大小 int maxSize = 10000000; if (fileinfo.Length <= 0) { return(ApiReturnModel.ReturnError("请上传文件")); } else if (fileinfo.Length > maxSize) { return(ApiReturnModel.ReturnError("文件大小超过限制")); } else { string fileExt = orfilename.Substring(orfilename.LastIndexOf('.')); //定义允许上传的文件扩展名 String fileTypes = "gif,jpg,jpeg,png,bmp"; if (String.IsNullOrEmpty(fileExt) || Array.IndexOf(fileTypes.Split(','), fileExt.Substring(1).ToLower()) == -1) { return(ApiReturnModel.ReturnError("只能上传 图片")); } else { String ymd = DateTime.Now.ToString("yyyyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo); String newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", System.Globalization.DateTimeFormatInfo.InvariantInfo); fileinfo.CopyTo(Path.Combine(dirTempPath, newFileName + fileExt), true); fileinfo.Delete(); return(ApiReturnModel.ReturnOk("上传 成功", SaveTempPath + newFileName + fileExt)); } } }); return(task); }
/// <summary> /// 用户提交意见 /// </summary> /// <param name="apiSuggestionModel"></param> /// <returns></returns> public object AddSuggestion([FromBody] ApiSuggestionModel apiSuggestionModel) { var userInfo = GetCurrentUserInfo(); UserSuggestion userSuggestion = new UserSuggestion() { Id = Guid.NewGuid(), Msg = apiSuggestionModel.Msg, UserId = userInfo.Id, CreateTime = DateTime.Now }; try { SuggestionBusiness.AddItem(userSuggestion); return(ApiReturnModel.ReturnOk("提交成功")); } catch (Exception e) { //记录日志 LogHelp.WriteLog(e.Message, ApiFileDirectoryPara.ApiErrorDir); return(ApiReturnModel.ReturnError("提交错误")); } }
public object UserRegister(ApiUserRegisterModel register) { if (register.Type == ApiRegisterFlag.ByPwd) //通过密码 { var isHave = UserBusiness.GetItemByUserAccount(register.UserAccount); if (isHave != null) { return(ApiReturnModel.ReturnError("当前账号已经注册")); } var userInfo = ApiToDalModelMapping.UserRegisterModelToUserInfo(register, (int)UserLvModel.User); userInfo = UserBusiness.AddItem(userInfo); #region 开始写入缓存 var token = Guid.NewGuid(); CacheHelper.TryAddCache($"{token}-{AuthenticationPara.UserAuthentication}", userInfo, DateTime.Now.AddDays(30)); //缓存 ApiUserInfoModel apiUserInfo = new ApiUserInfoModel() { Token = token.ToString(), UserAccount = userInfo.UserAccount, UserLv = userInfo.UserLv.ToString() }; #endregion ApiReturnModel.ReturnOk("注册成功", apiUserInfo); } else if (register.Type == ApiRegisterFlag.ByValidate) //通过验证码注册 { } return(ApiReturnModel.ReturnOk()); }
public object DeleteCounterman([FromBody] ApiCountermanManagerModel apiCountermanManagerModel) { if (userBusiness.UpdateUserStateByIdAndLv(apiCountermanManagerModel.Id, (int)UserLvModel.Counterman, (int)UserFlag.Delete)) { return(ApiReturnModel.ReturnOk()); } return(ApiReturnModel.ReturnError()); }
public object UpdateCounterman([FromBody] ApiCountermanManagerModel apiCountermanManagerModel) { if (userBusiness.UpdateUserByIdAndLv(apiCountermanManagerModel.Id, apiCountermanManagerModel.UserPassWord, apiCountermanManagerModel.UserAccount, (int)UserLvModel.Counterman)) { return(ApiReturnModel.ReturnOk()); } return(ApiReturnModel.ReturnError()); }
public ApiReturnModel UploadInquiryOrder([FromBody] ApiUserProductModel apiUserProductModel) { var userInfo = GetCurrentUserInfo(); if (inquiryOrderBusiness.AddUserInquiryOrder(userInfo.Id, apiUserProductModel.Remarks, apiUserProductModel.Price, apiUserProductModel.ImgUrl)) { return(ApiReturnModel.ReturnOk()); } return(ApiReturnModel.ReturnError()); }
/// <summary> /// 修改 某个物流信息 /// </summary> /// <param name="apiCountermanLogisticsModel"></param> /// <returns></returns> public ApiReturnModel UpdateLogisticsItem([FromBody] ApiCountermanLogisticsModel apiCountermanLogisticsModel) { var userInfo = GetCurrentUserInfo(); if (userLogisticsBusiness.UpdateLogisticsById(apiCountermanLogisticsModel.Id, userInfo.Id, apiCountermanLogisticsModel.DetailedInformation, apiCountermanLogisticsModel.LogisticsTime)) { return(ApiReturnModel.ReturnOk()); } return(ApiReturnModel.ReturnError()); }
public ApiReturnModel DeleteUserAddress([FromBody] ApiUserAddressModel apiUserAddressModel) { var userInfo = GetCurrentUserInfo(); if (UserAddressBusiness.DeleteUserAddress(apiUserAddressModel.Id, userInfo.Id)) { return(ApiReturnModel.ReturnOk()); } return(ApiReturnModel.ReturnError()); }
/// <summary> /// 业务员 取消询价单 /// </summary> /// <param name="apiIntentionOrderModel"></param> /// <returns></returns> public ApiReturnModel CancelIntentionOrder([FromBody] ApiInquiryOrderModel apiIntentionOrderModel) { var userInfo = GetCurrentUserInfo(); var msg = inquiryOrderBusiness.UpdateInquiryOrderFlag(apiIntentionOrderModel.Id, userInfo.Id, apiIntentionOrderModel.Remarks, BusinessOrderFlag.Invalid); if (msg == BReturnModel.IsOk) { return(ApiReturnModel.ReturnOk()); } return(ApiReturnModel.ReturnError(msg)); }
/// <summary> /// 业务员 确认询价订单 /// </summary> /// <param name="apiInquiryOrderModel"></param> /// <returns></returns> public ApiReturnModel ConfirmInquiryOrder([FromBody] ApiInquiryOrderModel apiInquiryOrderModel) { var userInfo = GetCurrentUserInfo(); var msg = inquiryOrderBusiness.UpdateInquiryOrderFlag(apiInquiryOrderModel.Id, userInfo.Id, apiInquiryOrderModel.Remarks, BusinessOrderFlag.Effective, DateTime.Now); if (msg == BReturnModel.IsOk) { return(ApiReturnModel.ReturnOk()); } return(ApiReturnModel.ReturnError(msg)); }
public ApiReturnModel UpdateUserBasicsData(ApiUserInfoModel apiUserInfoModel) { var userInfo = GetCurrentUserInfo(); userInfo.CompanyName = apiUserInfoModel.CompanyName; userInfo.UserImg = apiUserInfoModel.UserImg; userInfo.UserPassWord = apiUserInfoModel.UserPwd; UserBusiness.UpdateItem(userInfo); return(ApiReturnModel.ReturnOk("修改成功")); }
/// <summary> /// 业务员 取消合同单 /// </summary> /// <param name="apiContractOrderModel"></param> /// <returns></returns> public ApiReturnModel CancelContractOrder([FromBody] ApiContractOrderModel apiContractOrderModel) { var userInfo = GetCurrentUserInfo(); var BReturnModel = contractOrderBusiness.UpdateContractOrderFlag(apiContractOrderModel.Id, userInfo.Id, apiContractOrderModel.Remarks, BusinessOrderFlag.Invalid); if (BReturnModel.IsOk == BReturnModel.Code) { return(ApiReturnModel.ReturnOk()); } return(ApiReturnModel.ReturnError(BReturnModel.Msg)); }
/// <summary> /// 业务员 确认意向订单 /// </summary> /// <param name="apiIntentionOrderModel"></param> /// <returns></returns> public ApiReturnModel ConfirmIntentionOrder([FromBody] ApiIntentionOrderModel apiIntentionOrderModel) { var userInfo = GetCurrentUserInfo(); var msg = intentionOrderBusiness.UpdateIntentionOrderFlag(apiIntentionOrderModel.Id, userInfo.Id, apiIntentionOrderModel.ReceiveRemarks, BusinessOrderFlag.Effective); if (msg == BReturnModel.IsOk) { return(ApiReturnModel.ReturnOk()); } else { return(ApiReturnModel.ReturnError(msg)); } }
public object AddCounterman([FromBody] ApiCountermanManagerModel apiCountermanManagerModel) { UserInfo userInfo = new UserInfo() { Id = Guid.NewGuid(), CreateTime = DateTime.Now, UserLv = (int)UserLvModel.Counterman, UserAccount = apiCountermanManagerModel.UserAccount, UserPassWord = apiCountermanManagerModel.UserPassWord, UserName = apiCountermanManagerModel.UserName }; userBusiness.AddItem(userInfo); return(ApiReturnModel.ReturnOk()); }
/// <summary> /// 业务员新增 物流数据 /// </summary> /// <param name="apiCountermanLogisticsModel"></param> /// <returns></returns> public object AddLogistics([FromBody] ApiCountermanLogisticsModel apiCountermanLogisticsModel) { var userInfo = GetCurrentUserInfo(); var orderInfo = userOrderBusiness.GetItemById(apiCountermanLogisticsModel.OrderId); UserLogistics userLogistics = new UserLogistics() { Id = Guid.NewGuid(), OrderId = orderInfo.Id, UserId = orderInfo.UserId, CreateTime = DateTime.Now, LogisticsTime = apiCountermanLogisticsModel.LogisticsTime, DetailedInformation = apiCountermanLogisticsModel.DetailedInformation, AdminId = userInfo.Id }; userLogisticsBusiness.AddItem(userLogistics); return(ApiReturnModel.ReturnOk()); }
public ApiReturnModel AddUserAddress([FromBody] ApiUserAddressModel apiUserAddressModel) { var userInfo = GetCurrentUserInfo(); UserAddress userAddress = new UserAddress() { Id = Guid.NewGuid(), UserId = userInfo.Id, City = apiUserAddressModel.City, Province = apiUserAddressModel.Province, DetailedAddress = apiUserAddressModel.DetailedAddress, ConsigneeName = apiUserAddressModel.ConsigneeName, Flag = 0, Phone = apiUserAddressModel.Phone }; userAddress = UserAddressBusiness.AddItem(userAddress); return(ApiReturnModel.ReturnOk("增加成功", userAddress)); }
/// <summary> /// 业务员登陆 /// </summary> /// <param name="apiLoginUserModel"></param> /// <returns></returns> public object CountermanLogin([FromBody] ApiLoginUserModel apiLoginUserModel) { var userInfo = employeeBusiness.GetItemByEmployeePwd(apiLoginUserModel.UserId, apiLoginUserModel.Pwd, (int)UserLvModel.Counterman); if (userInfo != null) //密码登陆成功 { var token = Guid.NewGuid(); CacheHelper.TryAddCache($"{token}-{AuthenticationPara.CountermanAuthentication}", userInfo, DateTime.Now.AddDays(30)); //缓存 ApiUserInfoModel apiUserInfo = new ApiUserInfoModel() { Token = token.ToString(), UserName = userInfo.EmployeeName, UserLv = EnumHelper.GetDescriptionByValue <UserLvModel>(userInfo.RoleLv) }; return(ApiReturnModel.ReturnOk("登陆成功", apiUserInfo)); } return(ApiReturnModel.ReturnError("用户名或者密码错误")); }
public ApiReturnModel GetUserBasicsData() { var userInfo = GetCurrentUserInfo(); userInfo = UserBusiness.GetItemById(userInfo.Id); var token = Request.Headers.Authorization.Parameter; CacheHelper.TryAddCache($"{token}-{AuthenticationPara.UserAuthentication}", userInfo, DateTime.Now.AddDays(30)); //更新缓存 ApiUserInfoModel apiUserInfoModel = new ApiUserInfoModel() { CompanyName = userInfo.CompanyName, UserName = userInfo.UserName, UserLv = UserRoleBusiness.GetItemById(userInfo.UserLv).RoleName }; return(ApiReturnModel.ReturnOk("查询成功", apiUserInfoModel)); }
public ApiReturnModel GetUserAddressList(int pageIndex, int pageSize = 5) { var userInfo = GetCurrentUserInfo(); if (pageIndex < 0 || pageSize < 0) { return(ApiReturnModel.ReturnError("参数值不能小于0")); } if (pageSize == 0) { var allAddress = UserAddressBusiness.GetAllUserAddress(userInfo.Id); return(ApiReturnModel.ReturnOk("获取成功", allAddress)); } else { var allAddress = UserAddressBusiness.GetUserAddressPaging(pageIndex, pageSize, userInfo.Id); return(ApiReturnModel.ReturnOk("分页获取成功", allAddress)); } }
public ApiReturnModel UploadIntentionOrder([FromBody] ApiIntentionOrderModel apiIntentionOrderModel) { var userInfo = GetCurrentUserInfo(); IList <BProductDetailModel> bProductDetailModelList = new List <BProductDetailModel>(); foreach (var item in apiIntentionOrderModel.apiOrderProductModel) { var productModel = ApiToBusinessModelMapping.GetBProductDetailModelByApiUserProductModel(item); bProductDetailModelList.Add(productModel); } var msg = intentionOrderBusiness.AddIntentionOrder(apiIntentionOrderModel.OrderId, userInfo.Id, apiIntentionOrderModel.Remarks, bProductDetailModelList); if (msg == BReturnModel.IsOk) { return(ApiReturnModel.ReturnOk()); } else { return(ApiReturnModel.ReturnError(msg)); } }
public ApiReturnModel UpdateUserAddress([FromBody] ApiUserAddressModel apiUserAddressModel) { var userInfo = GetCurrentUserInfo(); UserAddress userAddress = new UserAddress() { Id = apiUserAddressModel.Id, UserId = userInfo.Id, City = apiUserAddressModel.City, Province = apiUserAddressModel.Province, DetailedAddress = apiUserAddressModel.DetailedAddress, ConsigneeName = apiUserAddressModel.ConsigneeName, Flag = 0, Phone = apiUserAddressModel.Phone }; if (UserAddressBusiness.UpdateUserAddress(userAddress)) { return(ApiReturnModel.ReturnOk()); } return(ApiReturnModel.ReturnError()); }
/// <summary> /// 业务员 提交合同订单 /// </summary> /// <param name="apiContractOrderModel"></param> /// <returns></returns> public ApiReturnModel UploadContractOrder([FromBody] ApiContractOrderModel apiContractOrderModel) { var userInfo = GetCurrentUserInfo(); IList <BProductDetailModel> bProductDetailModelList = new List <BProductDetailModel>(); foreach (var item in apiContractOrderModel.apiOrderProductModel) { var productModel = ApiToBusinessModelMapping.GetBProductDetailModelByApiUserProductModel(item); bProductDetailModelList.Add(productModel); } var BReturnModel = contractOrderBusiness.AddContractOrder(apiContractOrderModel.OrderId, userInfo.Id, apiContractOrderModel.ExpireTime, bProductDetailModelList); if (BReturnModel.Code == BReturnModel.IsOk) { return(ApiReturnModel.ReturnOk()); } else { return(ApiReturnModel.ReturnError(BReturnModel.Msg)); } }