/// <summary>
 /// 添加预约
 /// </summary>
 /// <param name="model">预约实体</param>
 /// <returns></returns>
 public bool AddAppointmentOrderInfo(AppointmentOrderInfoEntity model)
 {
     AdjDBObject adjDbObject = new AdjDBObject();
     bool isok = true;
     try
     {
         adjDbObject.GetStoredProcCommand("sp3_D_AppointmentOrderInfo_i");
         adjDbObject.AddOutParameter("@Id", DbType.Int32, 4);
         adjDbObject.AddInParameter("@AppointOrderId", DbType.String, model.AppointOrderId);
         adjDbObject.AddInParameter("@OrderId", DbType.String, model.OrderId);
         adjDbObject.AddInParameter("@AppointOrderType", DbType.Int32, model.AppointOrderType);
         adjDbObject.AddInParameter("@AppointOrderState", DbType.Int32, model.AppointOrderState);
         adjDbObject.AddInParameter("@BusinessType", DbType.Int32, model.BusinessType);
         adjDbObject.AddInParameter("@AppointOrderFrom", DbType.Int32, model.AppointOrderFrom);
         adjDbObject.AddInParameter("@CustomerId", DbType.String, model.CustomerId);
         adjDbObject.AddInParameter("@CustomerName", DbType.String, model.CustomerName);
         adjDbObject.AddInParameter("@CustomerType", DbType.Int32, model.CustomerType);
         adjDbObject.AddInParameter("@AccountType", DbType.Int32, model.AccountType);
         adjDbObject.AddInParameter("@Cellphone", DbType.String, model.Cellphone);
         adjDbObject.AddInParameter("@FromCellphone", DbType.String, model.FromCellphone);
         adjDbObject.AddInParameter("@AppointAddress", DbType.String, model.AppointAddress);
         adjDbObject.AddInParameter("@AppointTimeStr", DbType.String, model.AppointTimeStr);
         adjDbObject.AddInParameter("@AppointTime", DbType.DateTime, model.AppointTime);
         //adjDbObject.AddInParameter("@EstimateEndTime", DbType.DateTime, model.EstimateEndTime);
         adjDbObject.AddInParameter("@IsLock", DbType.Boolean, false);
         adjDbObject.AddInParameter("@LockUser", DbType.String, model.LockUser);
         adjDbObject.AddInParameter("@partyId", DbType.Int32, model.PartyId);
         adjDbObject.AddInParameter("@SendOrderUser", DbType.String, model.SendOrderUser);
         adjDbObject.AddInParameter("@AppointOrderSign", DbType.String, model.AppointOrderSign);
         adjDbObject.AddInParameter("@PhoneCallTime", DbType.Int32, model.PhoneCallTime);
         adjDbObject.AddInParameter("@lng", DbType.Double, model.Lng);
         adjDbObject.AddInParameter("@lat", DbType.Double, model.Lat);
         adjDbObject.AddInParameter("@create_time", DbType.DateTime, model.Create_time);
         adjDbObject.AddInParameter("@create_user", DbType.String, model.Create_user);
         //adjDbObject.AddInParameter("@update_time", DbType.DateTime, model.Update_time);
         // adjDbObject.AddInParameter("@update_user", DbType.String, model.Update_user);
         //adjDbObject.AddInParameter("@delete_time", DbType.DateTime, model.Delete_time);
         // adjDbObject.AddInParameter("@delete_user", DbType.String, model.Delete_user);
         // adjDbObject.AddInParameter("@delete_flag", DbType.Boolean, model.Delete_flag);
         adjDbObject.Execute();
     }
     catch (Exception ex)
     {
         isok = false;
     }
     return isok;
 }
示例#2
0
        public string execute(string request)
        {
            //1202|1张三|21381234567|3莘凌路211号(小锦江酒店)|421:00|5asdfas1231asd|6IMEI|7MD5串|8lat|9lng
            string result = "0";
            string[] req = request.Split('|');
            var sign = EncodingUtil.GetMd5(req[2] + "aidaijia", "utf-8");
            if (sign.ToLower() == req[7].ToLower())
            {

                //判断T_ClentInfo是否有此手机号相关信息
                //如果用户不存在,创建一个新用户
                CustomerInfoEntity cinfo = new D_CustomerInfoDal().GetClientInfoByPhone(req[2].Trim());
                string cusid = string.Empty;
                int CustomerType = 1;
                int AccountType = 2;

                T_ParterEntity parter = new T_PartyDal().GetParterModelBySign(req[5].ToLower());
                if (parter != null)
                {

                    #region 用户不存在则创建

                    if (cinfo == null)
                    {
                        int clentnum = new D_CustomerInfoDal().SelectSeqClent();
                        if (clentnum != 0)
                        {
                            string num = string.Empty;
                            for (int i = 0; i < 8 - clentnum.ToString().Length; i++)
                            {
                                num += @"0";
                            }
                            num = "U" + num + clentnum;
                            cusid = num;
                            CustomerInfoEntity customerEn = new CustomerInfoEntity()
                            {
                                AccountType = 2,
                                Amount = 0,
                                BusinessmanId = 0,
                                Cellphone = req[2].Trim(),
                                ParentPhone = req[2].Trim(),
                                CustomerId = num,
                                CustomerName = req[1].Trim(),
                                CustomerType = 1,
                                Email = string.Empty,
                                HomeAddress = string.Empty,
                                IsNewCustomer = true,
                                LastAppointmentTime = null,
                                LastCalledAddress = string.Empty,
                                RecommendCode =
                                    new D_CustomerInfoDal().GenerateCustomerRecommendCode(
                                        new D_CustomerInfoDal().SelectSeqClent()),
                                RegisterFrom = 8,       //第三方API
                                RegisterVersion = ""
                            };
                            bool isture = new D_CustomerInfoDal().AddCustomerInfo(customerEn);
                            if (!isture)
                            {
                                return "0";
                            }

                        }
                        else
                        {
                            return "0";
                        }

                    }
                    else
                    {
                        cusid = cinfo.CustomerId;
                        CustomerType = cinfo.CustomerType;
                        AccountType = cinfo.AccountType;
                    }
                    #endregion

                    #region 优惠码操作
                    string couponCode = "";
                    if (req.Length == 12 && parter.url != null)
                    {
                        ThirdPartyCoupon cc = new ThirdPartyCoupon();
                        if (!cc.check(req[10], req[11], parter.url))
                        {
                            throw new Exception("优惠码无效");
                        }
                        couponCode = cc.addCoupon(parter.Id.ToString(), req[10], req[11], cinfo);
                    }
                    #endregion

                    #region 创建预约订单

                    int zz = new D_AppointmentOrderInfoDA().SelectSeqOrder();
                    if (zz != 0)
                    {
                        string ordernum = string.Empty;
                        for (int i = 0; i < 8 - zz.ToString().Length; i++)
                        {
                            ordernum += @"0";
                        }
                        ordernum = "Party" + ordernum + zz;
                        string lat = req[8].Trim();
                        string lng = req[9].Trim();
                        if (parter.Id == 11)//判断是博泰,对坐标进行转换
                        {
                            ChangeCoords.ChangeCoordinate(ref lat, ref lng, 3, 5);
                        }
                        AppointmentOrderInfoEntity orderEn = new AppointmentOrderInfoEntity()
                        {
                            AppointAddress = req[3].ToLower(),
                            AppointOrderId = ordernum,
                            AppointOrderFrom = 5, //  第三方合作用户,由8改为5
                            AppointOrderSign = "1",
                            AppointOrderState = 10,
                            AppointOrderType = 1, // 1自己叫
                            AppointTime = Convert.ToDateTime(req[4].Trim()),
                            AppointTimeStr = DateTime.Now.ToString("yyyy-MM-dd-HH-mm"),
                            Cellphone = req[2].Trim(),
                            FromCellphone = req[2].Trim(),
                            CustomerId = cusid,
                            CustomerName = req[1].Trim(),
                            Create_time = DateTime.Now,
                            Create_user = "******",
                            BusinessType = 1,
                            CustomerType = CustomerType,
                            AccountType = AccountType,
                            PartyId = parter.Id
                        };
                        if (req.Length > 8)
                        {
                            orderEn.Lat = Convert.ToDecimal(lat);
                            orderEn.Lng = Convert.ToDecimal(lng);
                        }
                        bool istrue = new D_AppointmentOrderInfoDA().AddAppointmentOrderInfo(orderEn);
                        if (!istrue)
                        {
                            result = "0";
                        }
                        else
                        {
                            //添加数据
                            T_ParterDyLog tpl = new T_ParterDyLog();
                            tpl.sign = req[5];
                            tpl.lat = "0";
                            tpl.lng = "0";
                            tpl.imei = req[6];
                            tpl.addtime = DateTime.Now;
                            //1:获取司机2:上传通话3:上传预约
                            tpl.typeid = 3;
                            new T_ParterDyLogDal().AddParterDyLog(tpl);
                            result = "1";
                        }

                    }
                    else
                    {
                        throw new Exception("预约订单失败!");
                    }

                    #endregion
                }
                else
                {
                    throw new Exception("商户标识错误。");
                }
            }
            else
            {
                throw new Exception("签名错误。");
            }
            return result;
        }