예제 #1
0
 /// <summary>
 /// 微信推荐服务公司
 /// </summary>
 /// <returns></returns>
 public ActionResult WxAddIntroductCompany(IntroducCompany info)
 {
     //本地测试,没有Session["WxUser"]
     if (Session["WxUser"] != null)
     {
         var wxUser = Session["WxUser"] as WeiXinUser;
         var user   = new AuthAccountServer().Get(wxUser.openid);
         info.UserId = user.UserId;
     }
     if (CompanyService.Instance.WxAddIntroductCompany(info) > 0)
     {
         //发送短信
         return(Json(new { success = "推荐成功" }));
     }
     else
     {
         return(Json(new { error = "推荐失败" }));
     }
 }
예제 #2
0
        /// <summary>
        /// 微信手工单
        /// 2017-05-26
        /// </summary>
        public ActionResult WxHandWorkOrder(MainOrder mainOrder)
        {
            long deviceId = DeviceService.Instance.WxDeviceWrite(mainOrder);

            if (deviceId > 0)
            {
                //创建新工单
                var wxUser = Session["WxUser"] as WeiXinUser;
                var user   = new AuthAccountServer().Get(wxUser.openid);
                mainOrder.MainOrderId = SequNo.NewId;
                mainOrder.DeviceId    = deviceId;
                mainOrder.UserId      = user.User.UserId;
                ServiceCompany serviceCompany = CompanyService.Instance.GetServiceCompany(mainOrder.ServiceCompanyId);
                var            serviceUsers   = UserService.Instance.ServiceCompanyUserList(mainOrder.ServiceCompanyId);
                //判断RepairImages 是否为空 不为空要更新图片
                if (!string.IsNullOrEmpty(mainOrder.RepairImages))
                {
                    new PictureService().UpdatePicOuterId(mainOrder.RepairImages, mainOrder.MainOrderId);
                }

                var flag = OrderService.Instance.Create(mainOrder, serviceCompany);
                if (flag)
                {
                    //判断包修人员信息有没有更改
                    if (mainOrder.ContactsPhone != user.User.Phone || mainOrder.Contacts != user.User.RealName || mainOrder.UseCompanyName != user.User.CompanyName)
                    {
                        new Task(new Action(() =>
                        {
                            user.User.Phone       = mainOrder.ContactsPhone;
                            user.User.RealName    = mainOrder.Contacts;
                            user.User.CompanyName = mainOrder.UseCompanyName;
                            UserService.Instance.Edit(user.User);
                        })).Start();
                    }

                    new Task(new Action(() =>
                    {
                        if (serviceUsers != null)
                        {
                            foreach (var item in serviceUsers)
                            {
                                if (item.RoleKey == UserType.SvcCompanyUserAdmin || item.RoleKey == (UserType.UseCompanyUserAdmin | UserType.SvcCompanyUserAdmin))
                                {
                                    SMSManager.Instance.SendNotify(item.Phone, mainOrder.MainOrderId.ToString());
                                }
                            }
                        }

                        //消息推送
                        var obj = new { title = "新订单提醒", content = string.Format("您有一个新的服务工单:{0}", mainOrder.MainOrderId), orderId = mainOrder.MainOrderId, page = string.Format("/orderDetail/{0}", mainOrder.MainOrderId) };

                        var tagList = new List <string> {
                            serviceCompany.ServiceCompanyId.ToString(), "1"
                        };
                        var resultMsg = PushMassageHelper.Push(Newtonsoft.Json.JsonConvert.SerializeObject(obj), tagList, PushMassageHelper.AppType.WX);

                        Logger.InfoFormat("个推推送结果{0}===={1}", serviceCompany.ServiceCompanyId, resultMsg);
                    })).Start();
                    //发送短信
                    //判断报修终端
                    if (mainOrder.RepairType == RepairType.Wx)
                    {
                        //发送公共号消息
                        new Task(new Action(() =>
                        {
                            var resultMsg = os.SendWxTmpMsg(mainOrder.UserId, mainOrder.MainOrderId, OrderState.Created);
                            Logger.InfoFormat("微信消息推送{0}===={1}", mainOrder.UserId, resultMsg);
                        })).Start();
                    }
                    return(Json(new { success = "创建成功", id = mainOrder.MainOrderId.ToString() }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { error = "服务器繁忙,请稍后再试试" }
                                , JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { error = "服务器繁忙,请稍后再试试" }
                            , JsonRequestBehavior.AllowGet));
            }
        }