/// <summary>
        /// 新增文章
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string AddNews(Mnews model, HttpPostedFileBase productimgurl = null, string path = "", int type = 1)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            string savePath = string.Empty;

            //// 存图片
            if (productimgurl != null)
            {
                string fileSave = FileOpert.UploadImg(productimgurl, path + "uploadFile\\" + System.DateTime.Now.ToString("yyyy") + "\\", out savePath);
                if (string.IsNullOrEmpty(fileSave))
                {
                    model.img = savePath.Replace(path, "");
                }
            }

            try
            {
                if (string.IsNullOrEmpty(model.id))
                {
                    DateTime dateTimeNow = System.DateTime.Now;
                    model.isDelete    = "0";
                    model.isEffective = "1";
                    model.great_time  = dateTimeNow;
                    model.modify_time = dateTimeNow;
                    model.type        = type;
                    model.id          = PublicTools.GetRandomNumberByTime();
                    if (new NewsService().AddNews(model))
                    {
                        mwxResult.errcode = 0;
                        mwxResult.errmsg  = "操作成功!";
                    }
                    else
                    {
                        mwxResult.errmsg = "操作失败!";
                    }
                }
                else
                {
                    if (new NewsService().UpdateNews(model))
                    {
                        mwxResult.errcode = 0;
                        mwxResult.errmsg  = "操作成功!";
                    }
                    else
                    {
                        mwxResult.errmsg = "操作失败!";
                    }
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #2
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        public string Delete(string id)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    mwxResult.errmsg = "操作失败:ID不能为空!";
                }
                else
                {
                    if (!new CouponService().Delete(id))
                    {
                        mwxResult.errmsg = "操作失败";
                    }
                    else
                    {
                        mwxResult.errcode = 0;
                        mwxResult.errmsg  = "操作成功";
                    }
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #3
0
        /// <summary>
        /// 根据id删除管理员数据
        /// </summary>
        /// <param name="adminuserid"></param>
        /// <returns></returns>
        public string DeletUserByIdMeth(string adminuserid)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                if (string.IsNullOrEmpty(adminuserid))
                {
                    mwxResult.errmsg = "操作失败:ID不能为空!";
                }
                else
                {
                    if (!new AdminuserService().DeleteAdminUser(adminuserid))
                    {
                        mwxResult.errmsg = "操作失败";
                    }
                    else
                    {
                        mwxResult.errcode = 0;
                        mwxResult.errmsg  = "操作成功";
                    }
                }
            }
            catch (Exception)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #4
0
        /// <summary>
        /// 新增产品
        /// </summary>
        /// <param name="mproduct"></param>
        /// <param name="productimgurl"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public string AddProduct(Mproduct mproduct, HttpPostedFileBase productimgurl, string path)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            //// 实现步骤
            //// 1.数据合法性验证
            //// 2.图片入库
            //// 3.数据落地
            string savePath = string.Empty;

            mwxResult.errmsg = this.CheckedProduct(mproduct);

            if (productimgurl == null)
            {
                mwxResult.errmsg = "产品图片不能为空!";
                return(JsonHelper.GetJson <MwxResult>(mwxResult));
            }

            if (!string.IsNullOrEmpty(mwxResult.errmsg))
            {
                return(JsonHelper.GetJson <MwxResult>(mwxResult));
            }

            //// 存图片
            string fileSave = FileOpert.UploadImg(productimgurl, path + "uploadFile\\" + System.DateTime.Now.ToString("yyyy") + "\\", out savePath);

            if (string.IsNullOrEmpty(fileSave))
            {
                mproduct.productimgurl = savePath.Replace(path, "");
            }
            else
            {
                //// 构建错误信息并返回
                mwxResult.errmsg = fileSave;
                return(JsonHelper.GetJson <MwxResult>(mwxResult));
            }

            mproduct.productid = PublicTools.GetRandomNumberByTime();
            ///// 入库
            bool addResult = new ProductService().AddProduct(mproduct);

            if (addResult)
            {
                mwxResult.errmsg              = "新增成功!";
                mwxResult.errcode             = 0;
                CacheData.allRecommendPro     = null;
                CacheData.allRecommendProList = null;
            }
            else
            {
                mwxResult.errmsg = "新增失败!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #5
0
        /// <summary>
        /// 登录操作
        /// </summary>
        /// <param name="acount"></param>
        /// <param name="pass"></param>
        /// <param name="verifiCode"></param>
        /// <returns></returns>
        public string SubLogin(string acount, string pass, string verifiCode)
        {
            //// 实现步骤
            //// 1.首先简单验证数据的合法性
            //// 2.根据账号到数据库用户表取数据,看是否能够取到数据
            //// 3.根据第二步取到的数据,验证密码是否匹配
            //// 4.如果用户信息账号密码相匹配,那么session中存储用户登录信息,并返回登录成功
            //// 5.如果用户账号信息秘密不匹配,登录失败,并返回相应的错误信息

            //// 1.首先简单验证数据的合法性
            MwxResult mwxResult = this.CheckLogin(acount, pass, verifiCode);

            try
            {
                if (mwxResult != null && mwxResult.errcode == 0)
                {
                    //// 2.根据账号到数据库用户表取数据,看是否能够取到数据
                    Madminuser madminuser = new AdminuserService().GetMadminuserModelByAcount(acount);

                    //// 5.如果用户账号信息秘密不匹配,登录失败,并返回相应的错误信息
                    if (madminuser == null)
                    {
                        mwxResult.errcode = -1;
                        mwxResult.errmsg  = "账号错误";
                    }
                    else if (PublicTools.MD5CryptoService(pass) != madminuser.password)
                    {
                        mwxResult.errcode = -1;
                        mwxResult.errmsg  = "密码错误";
                    }
                    else
                    {
                        //// 4.如果用户信息账号密码相匹配,那么session中存储用户登录信息,并返回登录成功
                        httpContext.Session["madminuser"]    = madminuser;
                        httpContext.Session["adminuserid"]   = madminuser.adminuserid;
                        httpContext.Session["adminusername"] = madminuser.name;
                    }
                }
            }
            catch (Exception ex)
            {
                mwxResult = new MwxResult()
                {
                    errcode = -1, errmsg = "系统错误!"
                };
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #6
0
        /// <summary>
        /// 新增平台用户
        /// </summary>
        /// <param name="madminuser"></param>
        /// <returns></returns>
        public string AddUserMeth(MsendGoodsUser model)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                //// 数据合法性检查
                string checkAdminUser = this.CheckSendUser(model);
                if (!string.IsNullOrEmpty(checkAdminUser))
                {
                    mwxResult.errmsg = checkAdminUser;
                }

                bool doResult = false;
                if (string.IsNullOrEmpty(model.id))
                {
                    //// 时间相关参数赋值
                    model.great_time  = System.DateTime.Now;
                    model.modify_time = model.great_time;
                    model.id          = PublicTools.GetRandomNumberByTime();
                    doResult          = new SndGoodsUserService().AddSndGoodsUser(model);
                }
                else
                {
                    doResult = new SndGoodsUserService().ChangSndGoodsUserInfor(model);
                }

                //// 数据落地入库
                if (!doResult)
                {
                    mwxResult.errmsg = "操作失败";
                }
                else
                {
                    mwxResult.errcode = 0;
                    mwxResult.errmsg  = "操作成功";
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #7
0
        /// <summary>
        /// 向微信服务器请求创建自定义菜单
        /// </summary>
        /// <param name="jsonStr"></param>
        /// <returns></returns>
        public MwxResult AddMenu(string jsonStr)
        {
            //// 处理结果对象
            MwxResult model = null;

            //// 微信API地址
            string interfaceUrl = WebConfigeOpert.GetWXAPIURL();

            interfaceUrl = string.IsNullOrEmpty(interfaceUrl) ? "https://api.weixin.qq.com/" : interfaceUrl;

            //声明一个HttpWebRequest请求
            interfaceUrl = string.Format("{0}cgi-bin/menu/create?access_token={1}", interfaceUrl, WXTokenOpert.GetAccessToken());

            model = PublicTools.HttpPostRequest <MwxResult>(interfaceUrl, jsonStr);

            return(model);
        }
Exemple #8
0
        /// <summary>
        /// 修改用户备注信息
        /// </summary>
        /// <param name="openid">被修改这者的openid</param>
        /// <param name="remark">修改后的备注信息</param>
        /// <returns></returns>
        public MwxResult CheckUserRemark(string openid, string remark)
        {
            //// 处理结果对象
            MwxResult model = null;

            //// 微信API地址
            string wxAPIURL = WebConfigeOpert.GetWXAPIURL();

            //声明一个HttpWebRequest请求
            string interfaceUrl = string.Format("{0}cgi-bin/user/info/updateremark?access_token={1}", wxAPIURL, WXTokenOpert.GetAccessToken());

            string jsonStr = "{" + "\"openid\";" + openid + ",\"remark\":" + remark + "}";

            model = PublicTools.HttpPostRequest <MwxResult>(interfaceUrl, jsonStr);

            return(model);
        }
Exemple #9
0
        /// <summary>
        /// 跟新送货信息(批量)
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="deliveryName"></param>
        /// <param name="deliveryTell"></param>
        /// <returns></returns>
        public string UpdateOrderStateToDelivery(string orderids, string sendGoodUserId)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                if (string.IsNullOrEmpty(orderids))
                {
                    mwxResult.errmsg = "操作失败:请选中被操作的订单!";
                }
                else
                {
                    orderids = orderids.Trim(',');
                    //// 根据送货人ID获取送货人信息

                    MsendGoodsUser model = new SndGoodsUserBus().GetSendGoodsUserModelById(sendGoodUserId);
                    if (model == null)
                    {
                        mwxResult.errmsg = "操作失败:请选择正确的送货员信息!";
                    }
                    else
                    {
                        //// 重置
                        if (!new OrderService().UpdateOrderStateToDelivery(orderids, model.userName, model.phone))
                        {
                            mwxResult.errmsg = "操作失败";
                        }
                        else
                        {
                            mwxResult.errcode = 0;
                            mwxResult.errmsg  = "操作成功";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #10
0
        /// <summary>
        /// 编辑产品类别
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string EditProductclass(Mproductclass model, HttpPostedFileBase productimgurl, string path)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                //// 数据合法性检查
                if (model == null || model.classid < 1 || string.IsNullOrEmpty(model.classname))
                {
                    mwxResult.errmsg = "操作失败,新增数据不能为空!";
                }

                if (productimgurl != null)
                {
                    string savePath = string.Empty;
                    string fileSave = FileOpert.UploadImg(productimgurl, path + "uploadFile\\" + System.DateTime.Now.ToString("yyyy") + "\\", out savePath);
                    if (string.IsNullOrEmpty(fileSave))
                    {
                        model.imgpath = savePath.Replace(path, "");
                    }
                }

                //// 数据落地入库
                if (!new ProductclassService().EditProductclass(model))
                {
                    mwxResult.errmsg = "操作失败";
                }
                else
                {
                    mwxResult.errcode         = 0;
                    mwxResult.errmsg          = "操作成功";
                    CacheData.allProductClass = null;
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #11
0
        /// <summary>
        /// 更新订单状态
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="orderState"></param>
        /// <returns></returns>
        public string UpdateOrderHasRecepitByIds(string orderidS)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                if (string.IsNullOrEmpty(orderidS))
                {
                    mwxResult.errmsg = "操作失败:请选中被操作的订单!";
                }
                else
                {
                    orderidS = orderidS.Trim(',');

                    string[] idList = orderidS.Split(',');
                    foreach (var item in idList)
                    {
                        //// 重置
                        if (!new OrderService().UpdateOrderStateByIds(item, 8))
                        {
                            mwxResult.errmsg = "操作失败";
                            break;
                        }
                        else
                        {
                            mwxResult.errcode = 0;
                            mwxResult.errmsg  = "操作成功";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #12
0
        /// <summary>
        /// 新增平台用户
        /// </summary>
        /// <param name="madminuser"></param>
        /// <returns></returns>
        public string AddUserMeth(Madminuser madminuser)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                //// 数据合法性检查
                string checkAdminUser = this.CheckAdminUser(madminuser);
                if (!string.IsNullOrEmpty(checkAdminUser))
                {
                    mwxResult.errmsg = checkAdminUser;
                }

                //// 时间相关参数赋值
                madminuser.great_time  = System.DateTime.Now;
                madminuser.modify_time = madminuser.great_time;
                madminuser.adminuserid = PublicTools.GetRandomNumberByTime();
                madminuser.isEffective = 1;
                madminuser.password    = PublicTools.MD5CryptoService(madminuser.password);
                //// 数据落地入库
                if (!new AdminuserService().AddAdminUser(madminuser))
                {
                    mwxResult.errmsg = "操作失败";
                }
                else
                {
                    mwxResult.errcode = 0;
                    mwxResult.errmsg  = "操作成功";
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
        /// <summary>
        /// 新增平台用户
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string Add(MTFCEvidenceInfor model)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                //// 数据合法性检查
                string checkResult = this.CheckAddInfor(model);
                if (!string.IsNullOrEmpty(checkResult))
                {
                    mwxResult.errmsg = checkResult;
                }
                else
                {
                    //// 时间相关参数赋值
                    model.great_time = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    model.Id         = PublicTools.GetRandomNumberByTime();

                    //// 数据落地入库
                    if (!new TFCEvidenceInforService().Add(model))
                    {
                        mwxResult.errmsg = "提交失败";
                    }
                    else
                    {
                        mwxResult.errcode = 0;
                        mwxResult.errmsg  = "提交成功";
                    }
                }
            }
            catch (Exception)
            {
                mwxResult.errmsg = "提交失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
        /// <summary>
        /// 登录操作
        /// </summary>
        /// <param name="acount"></param>
        /// <param name="pass"></param>
        /// <param name="verifiCode"></param>
        /// <returns></returns>
        public string SubLogin(string acount, string pass, string verifiCode)
        {
            //// 实现步骤
            //// 1.首先简单验证数据的合法性
            //// 2.根据账号到数据库用户表取数据,看是否能够取到数据
            //// 3.根据第二步取到的数据,验证密码是否匹配
            //// 4.如果用户信息账号密码相匹配,那么session中存储用户登录信息,并返回登录成功
            //// 5.如果用户账号信息秘密不匹配,登录失败,并返回相应的错误信息

            //// 1.首先简单验证数据的合法性
            MwxResult mwxResult = this.CheckLogin(acount, pass, verifiCode);

            try
            {
                if (mwxResult != null && mwxResult.errcode == 0)
                {
                    if (acount != "admin" && pass != "tfc2018")
                    {
                        mwxResult.errcode = -1;
                        mwxResult.errmsg  = "账号密码错误";
                    }
                    else
                    {
                        //// 4.如果用户信息账号密码相匹配,那么session中存储用户登录信息,并返回登录成功
                        httpContext.Session["acount"]        = acount;
                        httpContext.Session["adminusername"] = "******";
                    }
                }
            }
            catch (Exception)
            {
                mwxResult = new MwxResult()
                {
                    errcode = -1, errmsg = "系统错误!"
                };
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #15
0
        /// <summary>
        /// 新增微信菜单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string AddWxmenu(Mwxmenu model)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                //// 时间相关参数赋值
                model.url         = string.IsNullOrEmpty(model.url) ? "" : model.url;
                model.id          = PublicTools.GetRandomNumberByTime();
                model.type        = "view";
                model.great_time  = System.DateTime.Now;
                model.modify_time = model.great_time;
                model.isDelete    = 0;
                model.isEffective = 1;
                if (model.superId == "0")
                {
                    model.superId = "";
                }
                //// 数据落地入库
                if (!new WxmenuService().AddWxmenu(model))
                {
                    mwxResult.errmsg = "操作失败";
                }
                else
                {
                    mwxResult.errcode = 0;
                    mwxResult.errmsg  = "操作成功";
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #16
0
        /// <summary>
        /// 更新订单已完成
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public string UpdateOrderHasRecepit(string orderid)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                if (string.IsNullOrEmpty(orderid))
                {
                    mwxResult.errmsg = "操作失败:请选中被操作的订单!";
                }
                else
                {
                    //// 获取一个新密码
                    string newPass = PublicTools.RandomCode(10);

                    //// 重置
                    if (!new OrderService().UpdateOrderState(orderid, 8))
                    {
                        mwxResult.errmsg = "操作失败";
                    }
                    else
                    {
                        mwxResult.errcode = 0;
                        mwxResult.errmsg  = "操作成功";
                    }
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #17
0
        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="adminuserid"></param>
        /// <returns></returns>
        public string ChangAdminUserPass(string adminuserid)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                if (string.IsNullOrEmpty(adminuserid))
                {
                    mwxResult.errmsg = "操作失败:请选中被操作用户!";
                }
                else
                {
                    //// 获取一个新密码
                    string newPass = PublicTools.RandomCode(10);

                    //// 重置
                    if (!new AdminuserService().ChangAdminUserPass(adminuserid, PublicTools.MD5CryptoService(newPass)))
                    {
                        mwxResult.errmsg = "操作失败";
                    }
                    else
                    {
                        mwxResult.errcode = 0;
                        mwxResult.errmsg  = "操作成功,新的密码为:" + newPass;
                    }
                }
            }
            catch (Exception)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #18
0
        /// <summary>
        /// 更新订单状态(已取消)
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="orderState"></param>
        /// <returns></returns>
        public string UpdateOrderHasCancleByIds(string orderidS)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                if (string.IsNullOrEmpty(orderidS))
                {
                    mwxResult.errmsg = "操作失败:请选中被操作的订单!";
                }
                else
                {
                    orderidS = orderidS.Trim(',');

                    //// 重置
                    if (!new OrderService().UpdateOrderStateByIds(orderidS, 2))
                    {
                        mwxResult.errmsg = "操作失败";
                    }
                    else
                    {
                        mwxResult.errcode = 0;
                        mwxResult.errmsg  = "操作成功";
                    }
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #19
0
        /// <summary>
        /// 发布微信菜单
        /// </summary>
        /// <returns></returns>
        public string FabuMenuToWX()
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                List <Mwxmenu> menuList = this.GetAllMenu();
                if (menuList != null && menuList.Count > 0)
                {
                    ///// 构建微信菜单对象
                    MwxMenu <MwxMenuBase> wxMenu = new MwxMenu <MwxMenuBase>();
                    wxMenu.button = new List <MwxMenuBase>();
                    //// 获取所有主菜单
                    List <Mwxmenu> mianMenuList = menuList.FindAll(p => string.IsNullOrEmpty(p.superId));
                    if (mianMenuList != null && mianMenuList.Count > 0)
                    {
                        mianMenuList = mianMenuList.OrderBy(p => p.sortNum).ToList <Mwxmenu>();
                        foreach (var item in mianMenuList)
                        {
                            if (menuList.Exists(p => p.superId == item.id))
                            {
                                List <MwxMenuView> listSubMent = new List <MwxMenuView>();
                                List <Mwxmenu>     subMenu     = menuList.FindAll(p => p.superId == item.id);
                                subMenu = subMenu.OrderBy(p => p.sortNum).ToList <Mwxmenu>();;
                                foreach (var item2 in subMenu)
                                {
                                    MwxMenuView model2 = new MwxMenuView();
                                    model2.type = item2.type;
                                    model2.name = item2.menuName;
                                    model2.url  = item2.url;
                                    listSubMent.Add(model2);
                                }
                                ///// 存在子菜单
                                MminWxMenuView <MwxMenuView> model = new MminWxMenuView <MwxMenuView>();
                                model.name       = item.menuName;
                                model.sub_button = listSubMent;
                                wxMenu.button.Add(model);
                            }
                            else
                            {
                                MwxMenuView model = new MwxMenuView();
                                model.type = item.type;
                                model.name = item.menuName;
                                model.url  = item.url;
                                wxMenu.button.Add(model);
                            }
                        }
                    }

                    if (wxMenu != null)
                    {
                        string menuHtml = JsonConvert.SerializeObject(wxMenu);

                        //// 开始调用接口生成菜单
                        mwxResult = new WXApiOpert().AddMenu(menuHtml);
                    }
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #20
0
        public string AddOrderByShoppingCart(string userId, string deliveryTime,
                                             string mailAddress,
                                             string deliveryName,
                                             string deliveryTell,
                                             string hasSelProId)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                if (string.IsNullOrEmpty(userId))
                {
                    mwxResult.errmsg = "请先登录!";
                    return(JsonHelper.GetJson <MwxResult>(mwxResult));
                }

                if (string.IsNullOrEmpty(hasSelProId))
                {
                    mwxResult.errmsg = "请选择需要购买的产品!";
                    return(JsonHelper.GetJson <MwxResult>(mwxResult));
                }

                ///// 获取该用户的购物车全部商品
                List <MshoppingCart> mshoppingCartsList = new ShoppingCartBus().GetAllShoppingCartListBySserId(userId);
                string[]             hasSel             = hasSelProId.Split(',');

                if (hasSel == null || hasSel.Length < 1 || mshoppingCartsList == null || mshoppingCartsList.Count <= 0)
                {
                    mwxResult.errmsg = "请选择需要购买的产品!";
                    return(JsonHelper.GetJson <MwxResult>(mwxResult));
                }
                else
                {
                    ///// 构建订单列表
                    List <Morder> modelList = new List <Morder>();
                    decimal       freight   = 0;
                    decimal       totalF    = 0;
                    foreach (var item in mshoppingCartsList)
                    {
                        if (!hasSel.Contains(item.productId))
                        {
                            continue;
                        }
                        totalF = totalF + item.sellPrice * item.buyNum;
                        modelList.Add(new Morder()
                        {
                            buyNum              = item.buyNum,
                            mailAddress         = mailAddress + "-" + deliveryName + "-" + deliveryTell,
                            requireDeliveryTime = deliveryTime,
                            deliveryTime        = System.DateTime.MinValue,
                            receiptTime         = System.DateTime.MinValue,

                            userId        = item.userId,
                            userName      = item.userName,
                            productId     = item.productId,
                            productname   = item.productname,
                            productformat = item.productformat,
                            origPrice     = item.origPrice,
                            sellPrice     = item.sellPrice,
                            totalPrice    = item.sellPrice * item.buyNum,
                            // freight = item.sellPrice,

                            shoppingCartId = item.shoppingCartId
                        });
                    }

                    // 小于20需要1元钱运费
                    if (totalF < 20)
                    {
                        foreach (var item in modelList)
                        {
                            item.freight = 0M;
                        }
                    }

                    mwxResult = this.AddOrder(modelList);
                    if (mwxResult.errcode == 0)
                    {
                        try
                        {
                            NewOrderNum.TotalNum = NewOrderNum.TotalNum + 1;
                        }
                        catch (Exception)
                        {
                        }
                    }
                    return(JsonHelper.GetJson <MwxResult>(mwxResult));
                }
            }
            catch (Exception)
            {
                mwxResult.errmsg = "下单失败!";
                return(JsonHelper.GetJson <MwxResult>(mwxResult));
            }
        }
Exemple #21
0
        /// <summary>
        /// 加入到购物车
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string AddShopCart(MshoppingCart model)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                bool addResult = true;

                ShoppingCartService opert = new ShoppingCartService();
                //// 补全产品信息
                Mproduct product = new ProductBus().GetProductById(model.productId);
                if (product == null || string.IsNullOrEmpty(product.productid))
                {
                    addResult = false;
                }
                else
                {
                    string productformatunit = product.productformatunit == "0" ? "个" :
                                               product.productformatunit == "1" ? "袋" :
                                               product.productformatunit == "2" ? "斤" :
                                               product.productformatunit == "3" ? "瓶" :
                                               product.productformatunit == "4" ? "升" :
                                               product.productformatunit == "5" ? "听" :
                                               product.productformatunit == "4" ? "升" :
                                               product.productformatunit == "6" ? "件" :
                                               product.productformatunit == "7" ? "盒" :
                                               product.productformatunit == "8" ? "包" :
                                               product.productformatunit == "9" ? "提" : "双";
                    model.origPrice     = product.origprice;
                    model.productformat = $"{product.productformat}/{productformatunit}";
                    model.productname   = product.productname;
                    model.sellPrice     = product.sellprice;

                    //// 首先根据产id和用户 ID获取一次购物车信息
                    MshoppingCart shopCartModel = opert.GetShoppingCartListByUserIdAndProductId(model.userId, model.productId);

                    if (model.buyNum > 0)
                    {
                        ///// 加购物车
                        if (shopCartModel != null && !string.IsNullOrEmpty(shopCartModel.shoppingCartId))
                        {
                            /////  数量加1
                            addResult = opert.UpdatePriceAndNum(shopCartModel.shoppingCartId, model.userId,
                                                                model.origPrice, model.sellPrice, model.totalPrice + (model.sellPrice * model.buyNum), model.buyNum);
                        }
                        else
                        {
                            //// 新增
                            model.shoppingCartId = PublicTools.GetRandomNumberByTime();
                            addResult            = opert.Add(model);
                        }
                    }
                    else
                    {
                        //// 减购物车
                        if (shopCartModel != null && !string.IsNullOrEmpty(shopCartModel.shoppingCartId))
                        {
                            if (shopCartModel.buyNum <= (-model.buyNum))
                            {
                                //// 直接删除
                                addResult = opert.DeleteShoppingCartById(shopCartModel.shoppingCartId, shopCartModel.userId);
                            }
                            else
                            {
                                /////  数量减1
                                addResult = opert.UpdatePriceAndNum(shopCartModel.shoppingCartId, model.userId,
                                                                    model.origPrice, model.sellPrice, model.totalPrice + shopCartModel.totalPrice, model.buyNum);
                            }
                        }
                    }
                }


                if (addResult)
                {
                    mwxResult.errmsg  = "操作成功!";
                    mwxResult.errcode = 0;
                }
                else
                {
                    mwxResult.errmsg = "操作失败!";
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败!";
                LogOpert.AddWeiXinMessage("系统异常:" + ex.Message);
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
Exemple #22
0
        /// <summary>
        /// 新增产品类别
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string AddProductclasses(Mproductclass model, HttpPostedFileBase productimgurl, string path)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                //// 数据合法性检查
                if (model == null || string.IsNullOrEmpty(model.classname))
                {
                    mwxResult.errmsg = "操作失败,新增数据不能为空!";
                }

                if (productimgurl == null)
                {
                    mwxResult.errmsg = "图片不能为空!";
                    return(JsonHelper.GetJson <MwxResult>(mwxResult));
                }

                string savePath = string.Empty;

                //// 存图片
                string fileSave = FileOpert.UploadImg(productimgurl, path + "uploadFile\\" + System.DateTime.Now.ToString("yyyy") + "\\", out savePath);
                if (string.IsNullOrEmpty(fileSave))
                {
                    model.imgpath = savePath.Replace(path, "");
                }
                else
                {
                    //// 构建错误信息并返回
                    mwxResult.errmsg = fileSave;
                    return(JsonHelper.GetJson <MwxResult>(mwxResult));
                }

                //// 时间相关参数赋值
                model.great_time  = System.DateTime.Now;
                model.modify_time = model.great_time;
                model.isDelete    = 0;
                model.isEffective = 1;

                //// 数据落地入库
                if (!new ProductclassService().AddProductclass(model))
                {
                    mwxResult.errmsg = "操作失败";
                }
                else
                {
                    mwxResult.errcode         = 0;
                    mwxResult.errmsg          = "操作成功";
                    CacheData.allProductClass = null;
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }