예제 #1
0
        public JsonResult AddMessage(SystemMessageModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                //模型赋值
                T_SystemMessage msg = new T_SystemMessage()
                {
                    Title      = model.Title,
                    Content    = model.Content,
                    CreateTime = DateTime.Now
                };
                //调用BLL层进行添加处理
                ISystemMessageBLL messageBll = BLLFactory <ISystemMessageBLL> .GetBLL("SystemMessageBLL");

                messageBll.Save(msg);
                //记录日志
                jm.Content = PropertyUtils.ModelToJsonString(model);

                //推送给所有业主客户端
                IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                var  registrationIds = userPushBLL.GetList(p => p.User.DelFlag == ConstantParam.DEL_FLAG_DEFAULT).Select(p => p.RegistrationId).ToArray();
                bool flag            = PropertyUtils.SendPush("系统消息", model.Title, ConstantParam.MOBILE_TYPE_OWNER, registrationIds);
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public JsonResult AddShopSales(ShopSaleModel model)
        {
            JsonModel Jm = new JsonModel();

            if (ModelState.IsValid)
            {
                var currentShopId = GetCurrentShopId();
                //如果门店已创建
                if (currentShopId != null)
                {
                    T_ShopSale ShopSale = new T_ShopSale();
                    ShopSale.Title           = model.Title;
                    ShopSale.Phone           = model.Phone;
                    ShopSale.Content         = model.Content;
                    ShopSale.GoodsCategoryId = model.GoodsCategoryId.Value;
                    ShopSale.RemainingAmout  = model.RemainingAmout;
                    ShopSale.Price           = model.Price;
                    ShopSale.CreateTime      = DateTime.Now;
                    ShopSale.InSales         = 1;
                    //促销BLL
                    IShopSaleBLL SaleBLL = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL");

                    //保存
                    SaleBLL.Save(ShopSale);

                    //绿色直供推送
                    if (model.IsPush)
                    {
                        IShopBLL shopBLL = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                        string shopName = shopBLL.GetEntity(s => s.Id == currentShopId).ShopName;

                        //推送给业主客户端
                        IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                        var registrationIds = userPushBLL.GetList(p => !string.IsNullOrEmpty(p.RegistrationId)).Select(p => p.RegistrationId).ToArray();

                        string alert = shopName + "的商品" + model.Title + "上架了";
                        bool   flag  = PropertyUtils.SendPush("商品上架", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationIds);
                        if (!flag)
                        {
                            Jm.Msg = "推送发生异常";
                        }
                    }
                    //记录 Log
                    Jm.Content = Property.Common.PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    Jm.Msg = "门店还未创建";
                }
            }
            else
            {
                Jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(Jm, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public JsonResult DisposeQuestion(DisposeQuestionModel model)
        {
            JsonModel jm = new JsonModel();

            if (ModelState.IsValid)
            {
                //获取要处理的上报问题
                IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL");

                T_Question question = questionBll.GetEntity(m => m.Id == model.Id);
                if (question != null)
                {
                    //修改处理状态并添加处理记录
                    question.Status    = ConstantParam.DISPOSED;
                    question.IsPublish = model.IsPublish ? 1 : 0;
                    T_QuestionDispose questionDispose = new T_QuestionDispose()
                    {
                        DisposeDesc   = model.DisposeDesc,
                        DisposeUserId = GetSessionModel().UserID,
                        QuestionId    = model.Id,
                        DisposeTime   = DateTime.Now
                    };
                    //保存到数据库
                    questionBll.DisposeQuestion(question, questionDispose);

                    IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                    var userPush = userPushBLL.GetEntity(p => p.UserId == question.UploadUserId);
                    if (userPush != null)
                    {
                        string registrationId = userPush.RegistrationId;
                        string alert          = "您" + question.UploadTime.ToString("yyyy-MM-dd HH:mm") + "上报的问题已处理";
                        //通知信息
                        bool flag = PropertyUtils.SendPush("上报问题处理", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId);
                        if (!flag)
                        {
                            jm.Msg = "推送发生异常";
                        }
                    }

                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    jm.Msg = "该问题不存在";
                }
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        public ActionResult UpdateOrderStatus(OrderStatusUpdateModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                //获取指定订单
                IOrderBLL orderBll = BLLFactory <IOrderBLL> .GetBLL("OrderBLL");

                var order = orderBll.GetEntity(o => o.Id == model.OrderId && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && o.IsStoreHided == ConstantParam.DEL_FLAG_DEFAULT);
                if (order != null)
                {
                    string alert = "";

                    if (model.OrderStatus == ConstantParam.OrderStatus_RECEIPT)
                    {
                        alert             = "您在" + order.Shop.ShopName + "提交的订单商家已接单,请您耐心等待收货";
                        order.OrderStatus = model.OrderStatus;
                    }
                    else if (model.OrderStatus == ConstantParam.OrderStatus_FINISH)
                    {
                        alert              = "您在" + order.Shop.ShopName + "提交的订单交易已完成";
                        order.OrderStatus  = ConstantParam.OrderStatus_FINISH;
                        order.CompleteTime = DateTime.Now;
                    }
                    //如果订单修改成功
                    if (orderBll.Update(order))
                    {
                        //推送给订单所属用户
                        IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                        var userPush = userPushBLL.GetEntity(p => p.UserId == order.AppUserId);
                        if (userPush != null)
                        {
                            string registrationId = userPush.RegistrationId;

                            //通知信息
                            PropertyUtils.SendPush("订单最新状态", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId);
                        }
                    }
                }
                else
                {
                    jm.Msg = "该订单已不存在";
                }
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        public JsonResult PassOwnerMgr(int id)
        {
            JsonModel jm = new JsonModel();

            if (ModelState.IsValid)
            {
                IPropertyIdentityVerificationBLL propertyIdentityVerificationBll = BLLFactory <IPropertyIdentityVerificationBLL> .GetBLL("PropertyIdentityVerificationBLL");

                //获取要审批的业主信息
                var propertyIdentityVerification = propertyIdentityVerificationBll.GetEntity(m => m.Id == id);

                if (propertyIdentityVerification != null)
                {
                    //修改状态
                    propertyIdentityVerification.IsVerified = ConstantParam.IsVerified_YES;

                    //保存到数据库
                    propertyIdentityVerificationBll.Update(propertyIdentityVerification);

                    IUserPushBLL userPushBll = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                    var userPush = userPushBll.GetEntity(u => u.UserId == propertyIdentityVerification.AppUserId);

                    if (userPush != null)
                    {
                        //设备Id
                        var registrationId = userPush.RegistrationId;

                        //通知消息
                        string alert = "尊敬的住户,您的身份已通过验证,开始体验新功能吧";
                        bool   flag  = PropertyUtils.SendPush("审批业主信息", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId);

                        if (!flag)
                        {
                            jm.Msg = "推送发生异常";
                        }
                    }

                    //记录日志
                    jm.Content = PropertyUtils.ModelToJsonString(userPush);
                }
                else
                {
                    jm.Msg = "该业主信息不存在";
                }
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }

            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        public JsonResult PayRemind(int id)
        {
            JsonModel jm = new JsonModel();

            IHouseUserExpenseDetailsBLL expenseDetailsBLL = BLLFactory <IHouseUserExpenseDetailsBLL> .GetBLL("HouseUserExpenseDetailsBLL");

            var expenseDetails = expenseDetailsBLL.GetEntity(u => u.Id == id);

            if (expenseDetails == null)
            {
                jm.Msg = "该缴费记录不存在";
            }
            else if (expenseDetails.IsPayed == ConstantParam.PAYED_TRUE)
            {
                jm.Msg = "该缴费记录已缴费";
            }
            else
            {
                List <int> userIds = null;
                IUserBLL   userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                if (expenseDetails.BuildDoorId != null)
                {
                    userIds = expenseDetails.BuildDoor.PropertyIdentityVerifications.Where(v => v.IsVerified == 1 && v.User.DelFlag == ConstantParam.DEL_FLAG_DEFAULT)
                              .Select(v => v.AppUserId).Distinct().ToList();
                }
                else if (expenseDetails.BuildCompanyId != null)
                {
                    userIds = expenseDetails.BuildCompany.PropertyIdentityVerification.Where(v => v.IsVerified == 1 && v.User.DelFlag == ConstantParam.DEL_FLAG_DEFAULT)
                              .Select(v => v.AppUserId).Distinct().ToList();
                }

                //推送缴费提醒
                //推送给业主客户端
                IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                string alert           = expenseDetails.ExpenseDateDes + expenseDetails.PropertyExpenseType.Name + "缴费提醒";
                var    registrationIds = userPushBLL.GetList(p => userIds.Contains(p.UserId)).Select(p => p.RegistrationId).ToArray();
                bool   flag            = PropertyUtils.SendPush("缴费提醒", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationIds);
                if (!flag)
                {
                    jm.Msg = "推送发生异常";
                }
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #7
0
        public ApiResultModel AddGoods(GoodsInfoModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //获取当前商家用户
                IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL");

                T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果商家用户存在
                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //商品分类实例化
                    T_ShopSale goods = new T_ShopSale()
                    {
                        Title           = model.Name,
                        Content         = model.Content,
                        CreateTime      = DateTime.Now,
                        GoodsCategoryId = model.GoodCategoryId,
                        Price           = model.Price,
                        RemainingAmout  = model.RemainingAmount,
                        InSales         = 1
                    };

                    //话题文件资源保存目录
                    string dir = HttpContext.Current.Server.MapPath(ConstantParam.SHOP_Sales);

                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    //图片上传
                    if (!string.IsNullOrEmpty(model.PicList))
                    {
                        var    fileName = DateTime.Now.ToFileTime().ToString() + ".zip";
                        string filepath = Path.Combine(dir, fileName);

                        using (FileStream fs = new FileStream(filepath, FileMode.Create))
                        {
                            using (BinaryWriter bw = new BinaryWriter(fs))
                            {
                                byte[] datas = Convert.FromBase64String(model.PicList);
                                bw.Write(datas);
                                bw.Close();
                            }
                        }
                        //图片集路径保存
                        goods.ImgPath = PropertyUtils.UnZip(filepath, dir, ConstantParam.SHOP_Sales);

                        StringBuilder imgsSB = new StringBuilder();
                        //生成缩略图保存
                        foreach (var path in goods.ImgPath.Split(';'))
                        {
                            string thumpFile = DateTime.Now.ToFileTime() + ".jpg";
                            string thumpPath = Path.Combine(HttpContext.Current.Server.MapPath(ConstantParam.SHOP_Sales_ThumIMG), thumpFile);
                            PropertyUtils.getThumImage(Path.Combine(HttpContext.Current.Server.MapPath(path)), 18, 3, thumpPath);
                            imgsSB.Append(ConstantParam.SHOP_Sales_ThumIMG + "/" + thumpFile + ";");
                        }

                        goods.ImgThumbnail = imgsSB.ToString();
                        goods.ImgThumbnail = goods.ImgThumbnail.Substring(0, goods.ImgThumbnail.Length - 1);
                    }

                    //保存商品
                    IShopSaleBLL goodsBLL = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL");

                    goodsBLL.Save(goods);

                    //绿色直供推送
                    if (model.IsPush == 1)
                    {
                        IShopBLL shopBLL = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                        string shopName = shopBLL.GetEntity(s => s.Id == model.ShopId).ShopName;

                        //推送给业主客户端
                        IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                        var registrationIds = userPushBLL.GetList(p => !string.IsNullOrEmpty(p.RegistrationId)).Select(p => p.RegistrationId).ToArray();

                        string alert = shopName + "的商品" + goods.Title + "上架了";
                        bool   flag  = PropertyUtils.SendPush("商品上架", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationIds);
                        if (!flag)
                        {
                            resultModel.Msg = "推送发生异常";
                        }
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch (Exception ex)
            {
                PropertyUtils.WriteLogInfo("test");
                PropertyUtils.WriteLogError(ex);
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
예제 #8
0
        public ApiResultModel UpdateOrderStatus(OrderUpdateStatusModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //获取当前商家用户
                IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL");

                var user = shopUserBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (user == null)
                {
                    resultModel.Msg = APIMessage.NO_USER;
                    return(resultModel);
                }
                //如果验证Token不通过或已过期
                if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                {
                    resultModel.Msg = APIMessage.TOKEN_INVALID;
                    return(resultModel);
                }
                //更新最近登录时间和Token失效时间
                user.LatelyLoginTime  = DateTime.Now;
                user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                shopUserBll.Update(user);

                //获取指定订单
                IOrderBLL orderBll = BLLFactory <IOrderBLL> .GetBLL("OrderBLL");

                var order = orderBll.GetEntity(o => o.Id == model.OrderId && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && o.IsStoreHided == ConstantParam.DEL_FLAG_DEFAULT);
                if (order != null)
                {
                    string alert = "";
                    //如果已退单
                    if (model.OrderStatus == ConstantParam.OrderStatus_EXIT)
                    {
                        order.Reason = model.Reason;
                        //如果订单状态为待收货
                        if (order.OrderStatus == ConstantParam.OrderStatus_RECEIPT)
                        {
                            //如果订单支付方式为微信在线支付
                            if (order.PayWay == 1)
                            {
                                //微信退款
                                //获取商家账户信息
                                var wxAccount = order.Shop.ShopAccounts.Where(a => a.AccountType == ConstantParam.PROPERTY_ACCOUNT_WeChat).FirstOrDefault();
                                if (wxAccount == null)
                                {
                                    resultModel.Msg = "该订单所属商家未设置账户信息";
                                    return(resultModel);
                                }
                                //获取商家账户信息
                                string WeixinAppId  = wxAccount.Number;
                                string WeixinMchId  = wxAccount.MerchantNo;
                                string WeixinPayKey = wxAccount.AccountKey;
                                //申请退款
                                string result = ApplyRefund(order, WeixinAppId, WeixinMchId, WeixinPayKey);
                                //如果请求失败
                                if (result == null)
                                {
                                    resultModel.Msg = APIMessage.WEIXIN_REFUND_FAIL;
                                    return(resultModel);
                                }
                                //解析返回数据
                                XmlDocument doc = new XmlDocument();
                                doc.LoadXml(result);
                                //如果返回成功
                                string return_code = doc.GetElementsByTagName("return_code")[0].InnerText;
                                if (return_code == "SUCCESS")
                                {
                                    string result_code = doc.GetElementsByTagName("result_code")[0].InnerText;
                                    if (result_code == "SUCCESS")
                                    {
                                        order.OrderStatus  = model.OrderStatus;
                                        order.RecedeType   = 2;
                                        resultModel.result = "订单退款申请成功";
                                    }
                                    else
                                    {
                                        resultModel.Msg = APIMessage.WEIXIN_REFUND_FAIL;
                                        return(resultModel);
                                    }
                                }
                                else
                                {
                                    resultModel.Msg = APIMessage.WEIXIN_REFUND_FAIL;
                                    return(resultModel);
                                }
                            }
                            //支付宝支付退款
                            else if (order.PayWay == 2)
                            {
                            }
                            else
                            {
                                order.OrderStatus = model.OrderStatus;
                                order.RecedeType  = 0;
                            }
                        }
                        else if (order.OrderStatus == ConstantParam.OrderStatus_CONFIRM)
                        {
                            order.OrderStatus = model.OrderStatus;
                            order.RecedeType  = 0;
                        }
                        order.RecedeTime = DateTime.Now;
                        alert            = "您在" + order.Shop.ShopName + "提交的订单已被商家退单";

                        //如果订单修改成功
                        if (orderBll.CancelOrder(order))
                        {
                            //推送给订单所属用户
                            IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                            var userPush = userPushBLL.GetEntity(p => p.UserId == order.AppUserId);
                            if (userPush != null)
                            {
                                string registrationId = userPush.RegistrationId;

                                //通知信息
                                PropertyUtils.SendPush("订单最新状态", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId);
                            }
                        }
                    }
                    else
                    {
                        if (model.OrderStatus == ConstantParam.OrderStatus_RECEIPT)
                        {
                            alert             = "您在" + order.Shop.ShopName + "提交的订单商家已接单,请您耐心等待收货";
                            order.OrderStatus = model.OrderStatus;
                        }
                        else if (model.OrderStatus == ConstantParam.OrderStatus_FINISH)
                        {
                            alert              = "您在" + order.Shop.ShopName + "提交的订单交易已完成";
                            order.OrderStatus  = ConstantParam.OrderStatus_FINISH;
                            order.CompleteTime = DateTime.Now;
                        }
                        //如果订单修改成功
                        if (orderBll.Update(order))
                        {
                            //推送给订单所属用户
                            IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                            var userPush = userPushBLL.GetEntity(p => p.UserId == order.AppUserId);
                            if (userPush != null)
                            {
                                string registrationId = userPush.RegistrationId;

                                //通知信息
                                PropertyUtils.SendPush("订单最新状态", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId);
                            }
                        }
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.ORDER_NOEXIST;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
예제 #9
0
        public ActionResult AddNews(NewsNoticeModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                var      sessionModel = GetSessionModel();
                IPostBLL postBll      = BLLFactory <IPostBLL> .GetBLL("PostBLL");

                T_Post newPost = new T_Post()
                {
                    Title           = model.Title,
                    Content         = model.Content,
                    PropertyPlaceId = sessionModel.PropertyPlaceId.Value,
                    SubmitUserId    = sessionModel.UserID,
                    SubmitTime      = DateTime.Now.ToLocalTime(),
                    PublishedFlag   = model.PublishedFlag ? 1 : 0,
                    PublishedTime   = DateTime.Now.ToLocalTime()
                };
                // 保存到数据库
                postBll.Save(newPost);

                // 若选中“发布选项”则即时推送
                if (model.PublishedFlag)
                {
                    // 公告推送
                    //推送给业主客户端
                    IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

                    var userIds = placeBll.GetEntity(p => p.Id == newPost.PropertyPlaceId).UserPlaces.Select(m => m.UserId);
                    if (userIds != null)
                    {
                        userIds = userIds.ToList();
                    }
                    IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                    var  registrationIds = userPushBLL.GetList(p => userIds.Contains(p.UserId)).Select(p => p.RegistrationId).ToArray();
                    bool flag            = PropertyUtils.SendPush("新闻公告", model.Title, ConstantParam.MOBILE_TYPE_OWNER, registrationIds);

                    //推送给物业客户端
                    IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                    var PropertyUserIds = userBll.GetList(u => u.PropertyPlaceId == newPost.PropertyPlaceId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT).Select(u => u.Id);
                    if (PropertyUserIds != null)
                    {
                        PropertyUserIds = PropertyUserIds.ToList();
                    }
                    IPropertyUserPushBLL propertyUserPushBLL = BLLFactory <IPropertyUserPushBLL> .GetBLL("PropertyUserPushBLL");

                    var  propertyRegistrationIds = propertyUserPushBLL.GetList(p => PropertyUserIds.Contains(p.UserId)).Select(p => p.RegistrationId).ToArray();
                    bool flag1 = PropertyUtils.SendPush("新闻公告", model.Title, ConstantParam.MOBILE_TYPE_PROPERTY, propertyRegistrationIds);
                    if (!flag || !flag1)
                    {
                        jm.Msg = "推送发生异常";
                    }
                }
                //日志记录
                jm.Content = PropertyUtils.ModelToJsonString(model);
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #10
0
        public ActionResult RecedeOrder(RecedeReasonModel model)
        {
            if (ModelState.IsValid)
            {
                IOrderBLL orderBll = BLLFactory <IOrderBLL> .GetBLL("OrderBLL");

                T_Order order = orderBll.GetEntity(o => o.Id == model.OrderId && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && o.IsStoreHided == ConstantParam.DEL_FLAG_DEFAULT);

                if (order != null)
                {
                    string alert = "";
                    //如果订单状态为待收货
                    if (order.OrderStatus == ConstantParam.OrderStatus_RECEIPT)
                    {
                        //如果订单支付方式为微信在线支付
                        if (order.PayWay == 1)
                        {
                            //微信退款
                            //获取商家信息
                            var wxAccount = order.Shop.ShopAccounts.Where(a => a.AccountType == ConstantParam.PROPERTY_ACCOUNT_WeChat).FirstOrDefault();
                            if (wxAccount != null)
                            {
                                //获取商家账户信息
                                string WeixinAppId  = wxAccount.Number;
                                string WeixinMchId  = wxAccount.MerchantNo;
                                string WeixinPayKey = wxAccount.AccountKey;

                                //申请退款
                                string result = ApplyRefund(order, WeixinAppId, WeixinMchId, WeixinPayKey);
                                //如果请求失败
                                if (result == null)
                                {
                                    ModelState.AddModelError("OrderId", "订单退款申请失败");
                                    return(View(model));
                                }
                                //解析返回数据
                                XmlDocument doc = new XmlDocument();
                                doc.LoadXml(result);
                                string return_code = doc.GetElementsByTagName("return_code")[0].InnerText;

                                //如果返回成功
                                if (return_code == "SUCCESS")
                                {
                                    string result_code = doc.GetElementsByTagName("result_code")[0].InnerText;
                                    if (result_code == "SUCCESS")
                                    {
                                        order.RecedeType = 2;
                                    }
                                    else
                                    {
                                        ModelState.AddModelError("OrderId", "订单退款申请失败");
                                        return(View(model));
                                    }
                                }
                                else
                                {
                                    ModelState.AddModelError("OrderId", "订单退款申请失败");
                                    return(View(model));
                                }
                            }
                            else
                            {
                                ModelState.AddModelError("OrderId", "该订单所属商家未设置账户信息");
                                return(View(model));
                            }
                        }
                        //支付宝支付退款
                        else if (order.PayWay == 2)
                        {
                            order.Reason = model.Reason;
                            orderBll.Update(order);

                            var    r           = new Random();
                            string batch_no    = DateTime.Now.ToString("yyyyMMddHHmmssfff") + r.Next(1000);
                            string detail_data = order.PayTradeNo + "^" + order.OrderPrice + "^" + model.Reason;

                            //把请求参数打包成数组
                            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                            sParaTemp.Add("service", Alipay.Config.service);
                            sParaTemp.Add("partner", Alipay.Config.partner);
                            sParaTemp.Add("_input_charset", Alipay.Config.input_charset.ToLower());
                            sParaTemp.Add("notify_url", PropertyUtils.GetConfigParamValue("HostUrl") + "/Common/AlipayRefundNotifyUrl");
                            sParaTemp.Add("seller_user_id", Alipay.Config.seller_user_id);
                            sParaTemp.Add("refund_date", Alipay.Config.refund_date);
                            sParaTemp.Add("batch_no", batch_no);
                            sParaTemp.Add("batch_num", "1");
                            sParaTemp.Add("detail_data", detail_data);

                            //建立请求
                            string html = Alipay.Submit.BuildRequest(sParaTemp, "get", "确定");
                            return(Content(html));
                        }
                        else
                        {
                            order.RecedeType = 0;
                        }
                    }
                    //订单状态为待确认
                    else if (order.OrderStatus == ConstantParam.OrderStatus_CONFIRM)
                    {
                        order.RecedeType = 0;
                    }

                    order.OrderStatus = ConstantParam.OrderStatus_EXIT;
                    order.Reason      = model.Reason;
                    order.RecedeTime  = DateTime.Now;
                    alert             = "您在" + order.Shop.ShopName + "提交的订单已被商家退单";

                    //如果退单成功
                    if (orderBll.CancelOrder(order))
                    {
                        //推送给订单所属用户
                        IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                        var userPush = userPushBLL.GetEntity(p => p.UserId == order.AppUserId);
                        if (userPush != null)
                        {
                            string registrationId = userPush.RegistrationId;

                            //通知信息
                            PropertyUtils.SendPush("订单最新状态", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId);
                        }
                    }
                    return(RedirectToAction("OrderList"));
                }
                else
                {
                    return(RedirectToAction("OrderList"));
                }
            }
            else
            {
                ModelState.AddModelError("OrderId", ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR);
                return(View(model));
            }
        }
예제 #11
0
        public static bool RejectOrders()
        {
            try
            {
                //CommonUtils.WriteLog("进入到RejectOrders方法内部");
                //调用定单接口
                IOrderBLL templateBLL = BLLFactory <IOrderBLL> .GetBLL("OrderBLL");

                var twoHourAgoTime = DateTime.Now.AddHours(-2);

                //找出所有超过2小时商家没有接单的
                var orders = templateBLL.GetList(o => o.OrderStatus == ConstantParam.OrderStatus_CONFIRM && o.PayDate < twoHourAgoTime).ToList();
                //CommonUtils.WriteLog("成功连接数据库成功");
                //修改订单状态为退单状态

                foreach (var order in orders)
                {
                    order.OrderStatus = ConstantParam.OrderStatus_EXIT;
                    order.RecedeType  = 1;
                    order.RecedeTime  = DateTime.Now;
                    order.Reason      = "商家2小时未接单,系统自动退单";
                    var alert = "您在" + order.Shop.ShopName + "提交的订单因商家2小时未接单已自动退单";

                    if (templateBLL.CancelOrder(order))
                    {
                        IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                        var userPush = userPushBLL.GetEntity(p => p.UserId == order.AppUserId);

                        if (userPush != null)
                        {
                            string registrationId = userPush.RegistrationId;
                            //通知信息
                            PropertyUtils.SendPush("订单最新状态", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId);
                        }
                    }
                }

                var twoDayAgoTime = DateTime.Now.AddDays(-2);

                var end   = twoDayAgoTime.AddHours(2);
                var start = end.AddMinutes(-2);
                //获取所有提交订单超过46小时,且没有付款没有提醒的订单
                var noPayAndRemindOrders = templateBLL.GetList(o => o.OrderStatus == ConstantParam.OrderStatus_NOPAY && o.OrderDate < end && o.OrderDate >= start).ToList();
                foreach (var order in noPayAndRemindOrders)
                {
                    var          alert       = "您在" + order.Shop.ShopName + "提交的订单还未付款,2小时后订单会自动关闭";
                    IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                    var userPush = userPushBLL.GetEntity(p => p.UserId == order.AppUserId);

                    if (userPush != null)
                    {
                        string registrationId = userPush.RegistrationId;
                        //通知信息
                        PropertyUtils.SendPush("订单最新状态", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId);
                    }
                }


                //获取所有提交订单超过2天,且没有付款的订单
                var noPayOrders = templateBLL.GetList(o => o.OrderStatus == ConstantParam.OrderStatus_NOPAY && o.OrderDate < twoDayAgoTime).ToList();
                foreach (var order in noPayOrders)
                {
                    order.OrderStatus = ConstantParam.OrderStatus_CLOSE;
                    var alert = "您在" + order.Shop.ShopName + "提交的订单因长时间不付款已自动关闭";

                    if (templateBLL.CancelOrder(order))
                    {
                        IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                        var userPush = userPushBLL.GetEntity(p => p.UserId == order.AppUserId);

                        if (userPush != null)
                        {
                            string registrationId = userPush.RegistrationId;
                            //通知信息
                            PropertyUtils.SendPush("订单最新状态", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId);
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                CommonUtils.WriteLogError(ex);
                return(false);
            }
        }
예제 #12
0
        public static void ExpenseNotification()
        {
            try
            {
                var allList = new List <T_HouseUserExpenseTemplate>();

                //当前日期
                DateTime CurrentDate = DateTime.Now.Date;
                //明天日期
                DateTime TommorrowDate = CurrentDate.AddDays(1).Date;

                //所有符合发推送的缴费信息列表
                IHouseUserExpenseTemplateBLL templateBLL = BLLFactory <IHouseUserExpenseTemplateBLL> .GetBLL("HouseUserExpenseTemplateBLL");

                var expenseTemplateList = templateBLL.GetList().ToList();

                foreach (var expenseTemplate in expenseTemplateList)
                {
                    //看看要处理是不是今天,如果不是今天按照推送的周期加周期的天数(每月加30,每两月加60,每季度90...)
                    var isCheck = CurrentDate <= expenseTemplate.NotificationDate && expenseTemplate.NotificationDate < TommorrowDate;

                    if (isCheck)
                    {
                        allList.Add(expenseTemplate);
                    }
                    else
                    {
                        expenseTemplate.NotificationDate = expenseTemplate.NotificationDate.AddDays(expenseTemplate.ExpenseCycleId * 30);
                        isCheck = CurrentDate <= expenseTemplate.NotificationDate && expenseTemplate.NotificationDate < TommorrowDate;

                        if (isCheck)
                        {
                            allList.Add(expenseTemplate);
                        }
                    }
                }

                //保存到ExpenseDetail表
                IHouseUserExpenseDetailsBLL expenseDetailsBLL = BLLFactory <IHouseUserExpenseDetailsBLL> .GetBLL("HouseUserExpenseDetailsBLL");

                //缴费周期 应缴费开始时间加上缴费周期天数就是应缴费结束时间
                int expensePeriod = int.Parse(ConfigurationManager.AppSettings["ExpensePeriod"].ToString());
                var detailsList   = expenseDetailsBLL.SaveExpenseDetails(allList, expensePeriod);

                var registrationIdList = new List <string>();
                var title   = "缴费提醒";
                var content = "您有一条缴费提醒, 请注意查收。";

                //将保存成功的ExpenseDetail队列发推送
                if (detailsList.Count > 0)
                {
                    CommonUtils.WriteLogInfo("已经进入到发推送里面");
                    IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                    //全部保存成功后,取得所有要推送的用户
                    foreach (var item in detailsList)
                    {
                        var appUserIds      = item.BuildDoor.PropertyIdentityVerifications.Select(p => p.AppUserId);
                        var registrationIds = userPushBLL.GetList(u => appUserIds.Contains(u.UserId)).Select(u => u.RegistrationId);
                        registrationIdList.AddRange(registrationIds);
                    }

                    foreach (var item in registrationIdList)
                    {
                        CommonUtils.WriteLogInfo(string.Format("发推送人的设备是:{0}", item));
                    }

                    //批量推送出去
                    bool check = Property.Common.PropertyUtils.SendPush(title, content, ConstantParam.MOBILE_TYPE_OWNER, registrationIdList.ToArray());
                    CommonUtils.WriteLogInfo(string.Format("调用完推送返回的结果:{0}", check));
                    CommonUtils.WriteLogInfo("已经完成发推送。");
                }
            }
            catch (Exception ex)
            {
                CommonUtils.WriteLogError(ex);
            }
        }
예제 #13
0
        public ActionResult AlipayRefundNotifyUrl()
        {
            SortedDictionary <string, string> sArray = new SortedDictionary <string, string>();
            NameValueCollection coll;

            coll = Request.Form;
            String[] requestItem = coll.AllKeys;

            for (int i = 0; i < requestItem.Length; i++)
            {
                sArray.Add(requestItem[i], Request.Form[requestItem[i]]);
            }

            //判断是否有带返回参数
            if (sArray.Count > 0)
            {
                Notify aliNotify    = new Notify();
                bool   verifyResult = aliNotify.Verify(sArray, Request.Form["notify_id"], Request.Form["sign"]);
                verifyResult = true;
                if (verifyResult)//验证成功
                {
                    string    TradeNo  = Request.Form["result_details"].Split('^')[0];
                    IOrderBLL orderBll = BLLFactory <IOrderBLL> .GetBLL("OrderBLL");

                    var order = orderBll.GetEntity(o => o.PayTradeNo == TradeNo);
                    if (order != null)
                    {
                        order.OrderStatus = ConstantParam.OrderStatus_EXIT;
                        order.RecedeType  = 2;
                        order.RecedeTime  = DateTime.Now;

                        if (Request.Form["result_details"].Split('^')[2] == "SUCCESS")
                        {
                            order.RefundResult = "退款成功";
                        }
                        else
                        {
                            order.RefundResult = "退款失败";
                        }
                        string alert = "您在" + order.Shop.ShopName + "提交的订单已被商家退单";

                        //如果修改成功
                        if (orderBll.Update(order))
                        {
                            //推送给订单所属用户
                            IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                            var userPush = userPushBLL.GetEntity(p => p.UserId == order.AppUserId);
                            if (userPush != null)
                            {
                                string registrationId = userPush.RegistrationId;

                                //通知信息
                                PropertyUtils.SendPush("订单最新状态", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId);
                            }
                        }
                    }
                    return(Content("success"));
                }
                else//验证失败
                {
                    return(Content("fail"));
                }
            }
            else
            {
                return(Content("无通知参数"));
            }
        }
예제 #14
0
        public ApiResultModel ReplyTopic(ReplyTopicModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }

                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    var replyTopic = new T_PostBarTopicDiscuss()
                    {
                        Content    = model.Content,
                        ParentId   = model.ParentId,
                        ReplyId    = model.ReplyId,
                        PostUserId = model.UserId,
                        PostTime   = DateTime.Now,
                        TopicId    = model.Topicid
                    };

                    //图片上传
                    if (!string.IsNullOrEmpty(model.PicList))
                    {
                        //话题文件资源保存目录
                        string dir = HttpContext.Current.Server.MapPath(ConstantParam.Topic_Pictures_DIR + model.PropertyPlaceId);

                        if (!Directory.Exists(dir))
                        {
                            Directory.CreateDirectory(dir);
                        }

                        var    fileName = DateTime.Now.ToFileTime().ToString() + ".zip";
                        string filepath = Path.Combine(dir, fileName);

                        using (FileStream fs = new FileStream(filepath, FileMode.Create))
                        {
                            using (BinaryWriter bw = new BinaryWriter(fs))
                            {
                                byte[] datas = Convert.FromBase64String(model.PicList);
                                bw.Write(datas);
                                bw.Close();
                            }
                        }
                        //图片集路径保存
                        replyTopic.ImgPath = PropertyUtils.UnZip(filepath, dir, ConstantParam.Topic_Pictures_DIR + model.PropertyPlaceId);

                        StringBuilder imgsSB = new StringBuilder();
                        //生成缩略图保存
                        foreach (var path in replyTopic.ImgPath.Split(';'))
                        {
                            string thumpFile = DateTime.Now.ToFileTime() + ".jpg";
                            string thumpPath = Path.Combine(HttpContext.Current.Server.MapPath(ConstantParam.Topic_ThumPictures_DIR + model.PropertyPlaceId), thumpFile);
                            PropertyUtils.getThumImage(Path.Combine(HttpContext.Current.Server.MapPath(path)), 18, 3, thumpPath);
                            imgsSB.Append(ConstantParam.Topic_ThumPictures_DIR + model.PropertyPlaceId + "/" + thumpFile + ";");
                        }

                        replyTopic.ImgThumbnail = imgsSB.ToString();
                        replyTopic.ImgThumbnail = replyTopic.ImgThumbnail.Substring(0, replyTopic.ImgThumbnail.Length - 1);
                    }

                    //保存话题回复
                    IPostBarTopicDiscussBLL replyTopicBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL");

                    replyTopicBLL.Save(replyTopic);

                    if (model.ReplyId != model.UserId)
                    {
                        //发推送给回复人
                        IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                        var userPush = userPushBLL.GetEntity(u => u.UserId == model.ReplyId);

                        if (userPush != null)
                        {
                            var title   = "你有一条话题圈的回复";
                            var content = replyTopic.Content;

                            Property.Common.PropertyUtils.SendPush(title, content, ConstantParam.MOBILE_TYPE_OWNER, userPush.RegistrationId);
                        }
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
예제 #15
0
        public ApiResultModel DisposeQuestion(DisposerModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //获取要处理的问题
                    IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL");

                    T_Question question = questionBll.GetEntity(m => m.Id == model.Id);
                    if (question != null)
                    {
                        //修改处理状态并添加处理记录
                        question.Status    = ConstantParam.DISPOSED;
                        question.IsPublish = model.IsPublish;
                        T_QuestionDispose questionDispose = new T_QuestionDispose()
                        {
                            DisposeDesc   = model.DisposeDesc,
                            DisposeUserId = user.Id,
                            QuestionId    = model.Id,
                            DisposeTime   = DateTime.Now
                        };
                        //保存到数据库
                        questionBll.DisposeQuestion(question, questionDispose);

                        //推送通知
                        IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                        var userPush = userPushBLL.GetEntity(p => p.UserId == question.UploadUserId);
                        if (userPush != null)
                        {
                            string registrationId = userPush.RegistrationId;
                            string alert          = "您" + question.UploadTime.ToString("yyyy-MM-dd HH:mm") + "上报的问题已处理";
                            //通知信息
                            bool flag = PropertyUtils.SendPush("上报问题处理", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId);
                            if (!flag)
                            {
                                resultModel.Msg = "问题处理完成,推送失败";
                            }
                        }
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.QUESTION_NOEXIST;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }