/// <summary> /// 商品管理 /// </summary> /// <param name="user"></param> /// <returns></returns> public IActionResult ProductManage(SysUser user) { //所属分类 List <ProductCatg> productCatgs = ServiceIoc.Get <ProductCatgService>().GetTrees("", HttpUtility.HtmlDecode(" ")); productCatgs.Insert(0, new ProductCatg() { name = "——商品分类——", id = 0 }); ViewBag.productCatgs = productCatgs; //导购分类 List <GuideProductCatg> guideProductCatgs = ServiceIoc.Get <GuideProductCatgService>().GetTrees("", HttpUtility.HtmlDecode(" ")); guideProductCatgs.Insert(0, new GuideProductCatg() { name = "——导购分类——", id = 0 }); ViewBag.guideProductCatgs = guideProductCatgs; //品牌 List <ProductBrand> brands = ServiceIoc.Get <ProductBrandService>().GetAll(); brands.Insert(0, new ProductBrand() { name = "——所属品牌——", id = 0 }); ViewBag.Brands = brands; return(View()); }
/// <summary> /// 同步公众号所用粉丝 /// </summary> /// <param name="wxAccount"></param> public void SyncAllWXUser(WeChatAccount wxAccount, string next_openid) { if (wxAccount.type == WeChatAccountType.AuthSubscriber || wxAccount.type == WeChatAccountType.AuthService) { //获取ToKen WXAccessTokenCache token = ServiceIoc.Get <WeChatTokenService>().AccessToken(wxAccount.appid, wxAccount.app_secret); string user_list = WeChatUserHelper.GetWXUserList(token.token, next_openid); WeChatUserBase wxUsers = JsonConvert.DeserializeObject <WeChatUserBase>(user_list); if (wxUsers.data != null) { //open_id 集合 string[] open_ids = wxUsers.data.openid; //遍历 foreach (string open_id in open_ids) { //通过微信接口获取 string WeChatUser_json = WeChatUserHelper.GetWXUserInfo(token.token, open_id); //序列化用户 WeChatUser WeChatUser = JsonConvert.DeserializeObject <WeChatUser>(WeChatUser_json); SyncWXUser(WeChatUser); } //存在下一openid if (!string.IsNullOrEmpty(wxUsers.next_openid)) { SyncAllWXUser(wxAccount, wxUsers.next_openid); } } } }
/// <summary> /// 品牌 翻页/查询 /// </summary> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="keyword"></param> /// <returns></returns> public ContentResult GetBrands(int pageSize, int pageIndex, string keyword) { //查询对象 Criteria ct = new Criteria(); //查询表达式 MutilExpression me = new MutilExpression(); ct.SetFromTables("v_pdt_brand") .SetPageSize(pageSize) .SetStartPage(pageIndex) .SetFields(new string[] { "*" }) .AddOrderBy(new OrderBy("id", "desc")); //关键词名称 if (!string.IsNullOrEmpty(keyword)) { me.Add(new SingleExpression("name", LogicOper.LIKE, keyword)); } //设置查询条件 if (me.Expressions.Count > 0) { ct.SetWhereExpression(me); } DataTable dt = ServiceIoc.Get <ProductBrandService>().Fill(ct); return(PageResult(StateCode.State_200, ct.TotalRow, dt)); }
/// <summary> /// 显示、隐藏 导购分类 /// </summary> /// <param name="id"></param> /// <param name="isshow"></param> /// <returns></returns> public JsonResult SetEnableGuideProductCgty(int id, bool isshow) { //获取状态 StateCode state = ServiceIoc.Get <GuideProductCatgService>().SetEnable(id, isshow); return(Json(GetResult(state))); }
/// <summary> /// 删除导购分类 /// </summary> /// <param name="id"></param> /// <returns></returns> public JsonResult DeletePdtGuideCatg() { //获取状态 StateCode state = ServiceIoc.Get <GuideProductCatgService>().Delete(bid); return(Json(GetResult(state))); }
/// <summary> /// 前端导购分类 /// </summary> /// <returns></returns> public IActionResult GuidePdtCatgForm(SysUser user, GuideProductCatg entity = null, string imgmsg = null) { if (NHttpContext.Current.Request.IsAjaxRequest()) { //获取状态 StateCode state = ServiceIoc.Get <GuideProductCatgService>().Save(user.id, entity, imgmsg); return(Json(GetResult(state))); } else { //所属分类 List <GuideProductCatg> Parents = ServiceIoc.Get <GuideProductCatgService>().GetTrees("", HttpUtility.HtmlDecode(" ")); Parents.Insert(0, new GuideProductCatg() { name = "根", id = 0 }); ViewBag.Parents = Parents; //当前商品分类 entity = ServiceIoc.Get <GuideProductCatgService>().GetById(bid); if (entity != null) { ViewBag.entity = JsonConvert.SerializeObject(entity); } } return(View()); }
/// <summary> /// 保存商品类别 /// </summary> /// <returns></returns> public JsonResult SaveProductCgty(SysUser user, ProductCatg productCgty, string imgMsg) { //获取状态 StateCode state = ServiceIoc.Get <ProductCatgService>().Save(user, productCgty, imgMsg); return(Json(GetResult(state))); }
/// <summary> /// 加载类别数据 /// </summary> /// <returns></returns> public ContentResult GetCgtyChildrens() { //获取当前子类别 DataTable dt = ServiceIoc.Get <ProductCatgService>().Fill("select * from v_pdt_productcatg where parent_id = @0", bid); return(ContentResult(StateCode.State_200, dt)); }
/// <summary> /// 获取LBS地理位置 /// </summary> /// <param name="pageSize"></param> /// <param name="currentPage"></param> /// <param name="keyword"></param> /// <returns></returns> public ContentResult GetLBSReplys(int pageSize, int currentPage, int type, string keyword) { //查询对象 Criteria ct = new Criteria(); //查询表达式 MutilExpression me = new MutilExpression(); ct.SetFromTables("tb_rpy_lbs") .SetPageSize(pageSize) .SetStartPage(currentPage) .SetFields(new string[] { "*" }) .AddOrderBy(new OrderBy("id", "desc")); //商品类型 if (type == 0) { me.Add(new SingleExpression("name", LogicOper.LIKE, keyword)); } else { me.Add(new SingleExpression("lbsaddress", LogicOper.LIKE, keyword)); } if (me.Expressions.Count > 0) { ct.SetWhereExpression(me); } DataTable dt = ServiceIoc.Get <ImgTextReplyService>().Fill(ct); return(PageResult(StateCode.State_200, ct.TotalRow, dt)); }
/// <summary> /// 品牌信息页面 /// </summary> /// <param name="user"></param> /// <param name="entity"></param> /// <param name="imgmsg"></param> /// <returns></returns> public IActionResult BrandForm(SysUser user, ProductBrand entity, string imgmsg) { if (NHttpContext.Current.Request.IsAjaxRequest()) { //获取状态 StateCode state = ServiceIoc.Get <ProductBrandService>().Save(user.id, entity, imgmsg); return(Json(GetResult(state))); } else { ViewBag.Ticket = StringHelper.GetEncryption(ImgType.Product_Brand + "#" + bid); ViewBag.defurl = ResXmlConfig.Instance.DefaultImgSrc(AppGlobal.Res, ImgType.Product_Brand); ViewBag.imgurl = ViewBag.imgurl; entity = ServiceIoc.Get <ProductBrandService>().GetById(bid); if (entity != null) { Img img = ServiceIoc.Get <ImgService>().GetImg(ImgType.Product_Brand, entity.id); if (img != null) { ViewBag.imgurl = string.IsNullOrEmpty(img.getImgUrl()) ? ViewBag.defimgurl : img.getImgUrl(); } ViewBag.entity = JsonConvert.SerializeObject(entity); } } return(View()); }
/// <summary> /// 删除微信菜单 /// </summary> /// <returns></returns> public JsonResult DelWeChatMenu() { try { string data; WeChatAccount wxAccount = ServiceIoc.Get <WeChatAccountService>().Get(); AccessToken token = WeChatBaseHelper.GetAccessToken(wxAccount.appid, wxAccount.app_secret); if (token.access_token == null) { return(Json(GetResult(StateCode.State_152))); } data = WeChatBaseHelper.DeleteWXMenu(token.access_token); var errcode = JsonConvert.DeserializeObject <WXErrCode>(data); if (errcode.errcode > 0) { return(Json(GetResult(StateCode.State_152, token.errcode))); } //errcode 等于0时候成功 return(Json(GetResult(StateCode.State_200))); } catch { return(Json(GetResult(StateCode.State_500))); } }
/// <summary> /// 用户登录 /// </summary> /// <param name="posx"></param> /// <param name="loginpk"></param> /// <param name="verifyvode"></param> /// <returns></returns> public JsonResult LoginIn([FromBody] dynamic data) { //图形验证码 //if (!LoginUser.VerificationCode.ToString().Equals(vcode)) return Json(GetResult(StateCode.State_104), JsonRequestBehavior.AllowGet); //当前私钥 string private_key = HttpContext.Session.GetString("privateKey").Replace("\r\n", ""); //解密登录信息 string posx = AlgorithmHelper.Decrypt(private_key, data.posx.ToString()); //用户密码 string username = posx.Split("\\")[0]; string password = posx.Split("\\")[1]; //登录 SysUser user = ServiceIoc.Get <SysUserService>().Login(username, password, HttpContext.GetClientIp()); if (user.login_code == StateCode.State_200) { //登录操作 LoginUser.Instance.LoginIn(user, this.HttpContext); return(Json(GetResult(user.login_code))); } return(Json(GetResult(user.login_code))); }
/// <summary> /// 订单明细 /// </summary> /// <param name="user"></param> /// <returns></returns> public ActionResult ProductOrderForm(SysUser user) { //订单 ProductOrder order = ServiceIoc.Get <ProductOrderService>().GetById(bid); //订单发货地址 OrderDelivery delivery = ServiceIoc.Get <OrderDeliveryService>().GetByOrderId(bid); ViewBag.delivery = delivery; //订单详情 List <ProductOrderDetail> order_details = ServiceIoc.Get <ProductOrderDetailService>().GetListByOrderId(bid); if (order == null || order_details == null) { throw new Exception("订单数据异常"); } //物流公司 ViewBag.companys = ServiceIoc.Get <LogisticsCompanyService>().GetAll(); //判断是否为跳转过来的链接 ViewBag.isUrlReferrer = Request.Headers["Referer"].FirstOrDefault() == null ? false : true; ViewBag.order = order; ViewBag.order_details = order_details; return(View()); }
/// <summary> /// 微信菜单设置 /// </summary> /// <returns></returns> public IActionResult WeChatMenuForm() { List <DefineMenuGroup> Menus = ServiceIoc.Get <DefineMenuGroupService>().GetAll(); ViewBag.Menus = JsonConvert.SerializeObject(Menus); return(View()); }
/// <summary> /// 保存权限 /// </summary> /// <param name="id"></param> /// <param name="entity"></param> /// <returns></returns> public StateCode Save(long user_id, SysPermission entity) { using (ISession s = SessionFactory.Instance.CreateSession()) { try { if (entity.id == 0) { //创建用户ID entity.created_user_id = user_id; //创建时间 entity.created_date = DateTime.Now; s.Insert(entity); } else { //修改用户ID entity.updated_user_id = user_id; //修改时间 entity.updated_date = DateTime.Now; ServiceIoc.Get <SysPermissionService>().Update(entity); } return(StateCode.State_200); } catch (Exception ex) { return(StateCode.State_500); } } }
/// <summary> /// 关闭订单 /// </summary> /// <param name="id"></param> /// <param name="status"></param> /// <returns></returns> public JsonResult CloseOrder(long id) { StateCode state = StateCode.State_200; try { ProductOrder order = ServiceIoc.Get <ProductOrderService>().GetById(id); if (order == null) { state = StateCode.State_1; } else { order.status = OrderStatus.Close; order.updated_date = DateTime.Now; ServiceIoc.Get <ProductOrderService>().Update(order); } } catch { state = StateCode.State_500; } return(Json(GetResult(state))); }
/// <summary> /// 粉丝列表页 /// </summary> /// <returns></returns> public IActionResult FansTagManage() { //获取所有粉丝标签 List <WeChatUserTag> tags = ServiceIoc.Get <WeChatUserTagService>().GetList("", ""); ViewBag.userTags = tags; return(View()); }
/// <summary> /// 运费模板管理 /// </summary> /// <param name="user"></param> /// <param name="entity"></param> /// <param name="FRegions"></param> /// <returns></returns> public JsonResult DoFreightTemplateForm(SysUser user, [FromBody] dynamic entity) { FreightTemplate fTemplate = JsonConvert.DeserializeObject <FreightTemplate>(entity.entity.ToString()); List <FreightRegion> FRegions = JsonConvert.DeserializeObject <List <FreightRegion> >(entity.FRegions.ToString()); StateCode code = ServiceIoc.Get <FreightTemplateService>().Save(user.id, fTemplate, FRegions); return(Json(GetResult(code))); }
/// <summary> /// 获取订单信息 /// </summary> /// <param name="order_no"></param> /// <returns></returns> public ContentResult GetSearchEmployee(SysUser user, string k) { //订单详情 Employee entity = ServiceIoc.Get <EmployeeService>().TopSearchNo(k, 1).FirstOrDefault(); //返回数据 return(Content(JsonConvert.SerializeObject(GetResult(StateCode.State_200, new { entity })))); }
/// <summary> /// 保存广告图 /// </summary> /// <param name="user"></param> /// <param name="adimg"></param> /// <param name="imgmsg"></param> /// <returns></returns> public IActionResult BannerForm(SysUser user, Banner entity, string imgmsg) { if (NHttpContext.Current.Request.IsAjaxRequest()) { StateCode code = ServiceIoc.Get <BannerService>().Save(user.id, entity, imgmsg); return(Json(GetResult(code))); } else { //所属分类 List <ProductCatg> productCgtys = ServiceIoc.Get <ProductCatgService>().GetTrees("", HttpUtility.HtmlDecode(" ")); productCgtys.Insert(0, new ProductCatg() { name = "——商品分类——", id = 0 }); ViewBag.productCgtys = productCgtys; //上传票据 ViewBag.Ticket = StringHelper.GetEncryption(ImgType.Banner + "#" + bid); //缺省图片路 ViewBag.defurl = ResXmlConfig.Instance.DefaultImgSrc(AppGlobal.Res, ImgType.Banner); ViewBag.imgurl = ViewBag.defurl; entity = ServiceIoc.Get <BannerService>().GetById(bid); if (entity != null) { ViewBag.entity = JsonConvert.SerializeObject(entity); Img img = ServiceIoc.Get <ImgService>().GetImg(ImgType.Banner, entity.id); if (img != null) { ViewBag.imgurl = string.IsNullOrEmpty(img.getImgUrl()) ? ViewBag.defimgurl : img.getImgUrl(); } //商品详情 if (entity.content_type == (int)BannerLink.ProductDetails && !string.IsNullOrEmpty(entity.content_value)) { long pid = 0; long.TryParse(entity.content_value, out pid); Product product = ServiceIoc.Get <ProductService>().GetById(pid); if (product != null) { ViewBag.bizEntity = JsonConvert.SerializeObject(product); } }//商品列表 else if (entity.content_type == (int)BannerLink.ProductList && !string.IsNullOrEmpty(entity.content_value)) { GuideProductCatg guideProductCgty = ServiceIoc.Get <GuideProductCatgService>().GetById(long.Parse(entity.content_value)); if (guideProductCgty != null) { ViewBag.bizEntity = JsonConvert.SerializeObject(guideProductCgty); } } } } return(View()); }
/// <summary> /// 初始化数据 /// </summary> public void Initial() { //读取 enableRedis = ConfigManage.AppSettings <bool>("RedisConfig:EnableRedis"); if (enableRedis) { cacheRedis = CacheSessionFactory.Instance.CreateCache(); } //版本号 VNo = ConfigManage.AppSettings <string>("AppSettings:VNo"); //系统名称 SysName = ConfigManage.AppSettings <string>("AppSettings:SysName"); //资源域名 Res = ConfigManage.AppSettings <string>("AppSettings:DomainRes"); //后台域名 Admin = ConfigManage.AppSettings <string>("AppSettings:DomainAdmin"); //获取所有菜单 List <SysModelMenu> db_menus = ServiceIoc.Get <SysModelMenuService>().Where(m => m.is_enable == true).OrderByDescending(a => a.order_index).ToList(); //获取所有权限 List <SysPermission> db_permissions = ServiceIoc.Get <SysPermissionService>().GetAll().OrderByDescending(a => a.order_index).ToList(); //角色集合 List <SysRole> db_reles = ServiceIoc.Get <SysRoleService>().Where(r => r.is_enable == true).ToList(); //用户角色权限 List <UserRole> db_user_reles = ServiceIoc.Get <UserRoleService>().GetAll(); //所有用户权限 //List<SysUserPermission> db_user_permissions = ServiceIoc.Get<SysUserPermissionService>().GetAll(); //用户角色权限 List <SysRolePermission> db_role_permissions = ServiceIoc.Get <SysRolePermissionService>().GetAll(); //是否开启Redis缓存 if (EnableRedis) { //系统菜单 cacheRedis.Write(sys_menu_key, db_menus, CacheId.module); //系统权限 cacheRedis.Write(sys_func_key, db_permissions, CacheId.module); //系统角色 cacheRedis.Write(sys_role_key, db_reles, CacheId.module); //系统角色权限 cacheRedis.Write(sys_role_func_key, db_role_permissions, CacheId.module); } else { //系统菜单 menus = db_menus; //系统权限 permissions = db_permissions; //系统角色 roles = db_reles; //系统角色权限 rolePermissions = db_role_permissions; } }
/// <summary> /// 设置系统菜单是否可用 /// </summary> /// <param name="user"></param> /// <param name="menu"></param> /// <returns></returns> public JsonResult SetSysMenuEnable(bool isenable) { StateCode state = ServiceIoc.Get <SysModelMenuService>().SetEnable(bid, isenable); if (StateCode.State_200 == state) { AppGlobal.Instance.Initial(); } return(Json(GetResult(state))); }
/// <summary> /// 获取商品SKU信息,生成采购 /// </summary> /// <param name="user"></param> /// <param name="tid"></param> /// <returns></returns> public JsonResult GetPurProduct(SysUser user, long tid) { try { return(Json(GetResult(StateCode.State_200, ServiceIoc.Get <ProductService>().GetPurProduct(bid, tid)))); } catch { return(Json(GetResult(StateCode.State_500))); } }
/// <summary> /// 保存导购分类 /// </summary> /// <param name="sys_user_id"></param> /// <param name="entity"></param> /// <param name="imgmsg"></param> /// <returns></returns> public StateCode Save(long sys_user_id, GuideProductCatg entity, string imgmsg) { string p_path = ServiceIoc.Get <GuideProductCatgService>().GetParentPath(entity.parent_id); entity.parent_path = p_path; using (ISession s = SessionFactory.Instance.CreateSession()) { s.StartTransaction(); try { if (entity.id == 0) { //创建用户ID entity.created_user_id = sys_user_id; //创建时间 entity.created_date = DateTime.Now; s.Insert(entity); } else { //修改用户ID entity.updated_user_id = sys_user_id; //修改时间 entity.updated_date = DateTime.Now; s.Update(entity); } //判断是否存在图片信息 if (!string.IsNullOrEmpty(imgmsg) && imgmsg.IndexOf("#") != -1) { //图片名称 string filename = imgmsg.Split('#')[0]; //图片类型 string biztype = imgmsg.Split('#')[1]; //去除重复图片 s.ExcuteUpdate("update tb_img set biz_id = 0 where biz_type = @0 and biz_id = @1 ", biztype, entity.id); Img img = s.Get <Img>(" where file_name = @0 and biz_type = @1 ", filename, biztype); if (img != null) { img.biz_id = entity.id; s.Update <Img>(img); } } s.Commit(); return(StateCode.State_200); } catch { s.RollBack(); return(StateCode.State_500); } } }
/// <summary> /// 物流公司信息页面 /// </summary> /// <param name="user"></param> /// <param name="entity"></param> /// <returns></returns> public IActionResult LogisticsCompanyForm(SysUser user) { LogisticsCompany entity = ServiceIoc.Get <LogisticsCompanyService>().GetById(bid); if (entity != null) { ViewBag.entity = JsonConvert.SerializeObject(entity); } return(View()); }
/// <summary> /// 获取退货单列表 /// </summary> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="status"></param> /// <param name="keyword"></param> /// <param name="date"></param> /// <returns></returns> public ContentResult GetOrderRefunds(int pageSize, int pageIndex, int status, string keyword, string date) { //创建查询对象 Criteria ct = new Criteria(); ct.SetFromTables("v_odr_refund") .SetPageSize(pageSize) .SetStartPage(pageIndex) .SetFields(new string[] { "*" }).AddOrderBy(new OrderBy("id", "desc")); //查询表达式 MutilExpression me = new MutilExpression(); //状态 if (status != -1) { me.Add(new SingleExpression("status", LogicOper.EQ, status)); } //查询关键词 if (!string.IsNullOrEmpty(keyword)) { me.Add(new SingleExpression("", LogicOper.CUSTOM, "(")); me.Add(new SingleExpression("order_serial_no", LogicOper.LIKE, "", keyword)); me.Add(new SingleExpression("contact", LogicOper.LIKE, " or ", keyword)); me.Add(new SingleExpression("mobile", LogicOper.LIKE, " or ", keyword)); me.Add(new SingleExpression("", LogicOper.CUSTOM, "", ")")); } //日期 if (!string.IsNullOrEmpty(date)) { DateTime startDate = Convert.ToDateTime(date.Split('-')[0]); DateTime endDate = Convert.ToDateTime(date.Split('-')[1]); if (startDate.CompareTo(endDate) == 0) { me.Add(new SingleExpression("created_date", LogicOper.BETWEEN, new[] { startDate.ToString(), endDate.AddDays(1).ToString() })); } else { me.Add(new SingleExpression("created_date", LogicOper.BETWEEN, new[] { startDate.ToString(), endDate.AddDays(1).ToString() })); } } //设置查询条件 if (me.Expressions.Count > 0) { ct.SetWhereExpression(me); } DataTable dt = ServiceIoc.Get <OrderRefundService>().Fill(ct); return(PageResult(StateCode.State_200, ct.TotalRow, dt)); }
/// <summary> /// 删除配送方式 /// </summary> /// <returns></returns> public JsonResult DeleteDeliveryMode() { try { ServiceIoc.Get <DeliveryModeService>().Delete(bid); return(Json(GetResult(StateCode.State_200))); } catch { return(Json(GetResult(StateCode.State_500))); } }
/// <summary> /// 运费模板管理 /// </summary> /// <param name="user"></param> /// <returns></returns> public IActionResult FreightTemplateForm(SysUser user) { FreightTemplate entity = ServiceIoc.Get <FreightTemplateService>().GetById(bid); if (entity != null) { //运费模板对象 ViewBag.entity = JsonConvert.SerializeObject(entity); ViewBag.FRegions = ServiceIoc.Get <FreightRegionService>().GetList("where freight_template_id = @0", bid); } return(View()); }
/// <summary> /// 删除广告图 /// </summary> /// <param name="user"></param> /// <param name="ids"></param> /// <returns></returns> public JsonResult DeleteBanner(SysUser user, long[] ids) { try { ServiceIoc.Get <BannerService>().Deletes(ids); return(Json(GetResult(StateCode.State_200))); } catch { return(Json(GetResult(StateCode.State_500))); } }
/// <summary> /// 删除物流公司 /// </summary> /// <param name="bid"></param> /// <returns></returns> public JsonResult DeleteLogisticsCompany() { try { ServiceIoc.Get <LogisticsCompanyService>().Delete(bid); return(Json(GetResult(StateCode.State_200))); } catch { return(Json(GetResult(StateCode.State_500))); } }