public bool addCoupon(string couponsCode, double couponsValue, string partyid, CustomerInfoEntity ci) { AdjDBObject adjDbObject = new AdjDBObject(); StringBuilder sb = new StringBuilder(); sb.AppendLine("insert into d_youhui"); sb.AppendLine("(BatchId,cardcode,Money,Youhuima,Type,UseState,property,usecount,Remark ,Addtime,CREATE_USER,ExpiredDate,UsePeople,UserPeopleId,UserType)"); sb.AppendLine("values"); sb.AppendLine("(@BatchId,@cardcode,@Money,@Youhuima,@Type,@UseState,@property,@usecount,@Remark ,@Addtime,@CREATE_USER,@ExpiredDate,@UsePeople,@UserPeopleId,@UserType)"); adjDbObject.GetSqlStringCommand(sb.ToString()); adjDbObject.AddInParameter("@BatchId",System.Data.DbType.Int32,0); adjDbObject.AddInParameter("@cardcode", System.Data.DbType.String, couponsCode); adjDbObject.AddInParameter("@Money", System.Data.DbType.Decimal, couponsValue); adjDbObject.AddInParameter("@Youhuima", System.Data.DbType.String, couponsCode); adjDbObject.AddInParameter("@Type", System.Data.DbType.Int32, 0); adjDbObject.AddInParameter("@UseState", System.Data.DbType.Int32, 0); adjDbObject.AddInParameter("@property", System.Data.DbType.Int32, 20); adjDbObject.AddInParameter("@usecount", System.Data.DbType.Int32, 0); adjDbObject.AddInParameter("@Remark", System.Data.DbType.String, partyid); adjDbObject.AddInParameter("@Addtime", System.Data.DbType.DateTime, DateTime.Now); adjDbObject.AddInParameter("@CREATE_USER", System.Data.DbType.String, "Third Party"); adjDbObject.AddInParameter("@ExpiredDate", System.Data.DbType.DateTime, DateTime.Now.AddYears(1)); adjDbObject.AddInParameter("@UsePeople", System.Data.DbType.String, ""); adjDbObject.AddInParameter("@UserPeopleId", System.Data.DbType.String, ci.CustomerId); adjDbObject.AddInParameter("@UserType", System.Data.DbType.String, 1); return adjDbObject.Execute() > 0; }
/// <summary> /// 添加新用户 /// </summary> /// <returns></returns> public bool AddCustomerInfo(CustomerInfoEntity accident) { bool isok = true; AdjDBObject adjdbobject = new AdjDBObject(); try { string cmdtext = "INSERT INTO dbo.D_CustomerInfo( CustomerId ,CustomerName ,RecommendCode ,Cellphone ,Email ,HomeAddress ,CustomerType ,AccountType ,IsNewCustomer ,LastCalledAddress ,Amount ,BusinessmanId ,create_time ,create_user,ParentPhone ) VALUES(@CustomerId ,@CustomerName ,@RecommendCode ,@Cellphone, @Email, @HomeAddress, @CustomerType ,@AccountType ,@IsNewCustomer, @LastCalledAddress, @Amount ,@BusinessmanId ,@create_time, @create_user,@ParentPhone )"; adjdbobject.GetSqlStringCommand(cmdtext); adjdbobject.AddInParameter("@CustomerId", DbType.String, accident.CustomerId); adjdbobject.AddInParameter("@CustomerName", DbType.String, accident.CustomerName); adjdbobject.AddInParameter("@RecommendCode", DbType.String, accident.RecommendCode); adjdbobject.AddInParameter("@Cellphone", DbType.String, accident.Cellphone); adjdbobject.AddInParameter("@ParentPhone", DbType.String, accident.ParentPhone); adjdbobject.AddInParameter("@Email", DbType.String, ""); adjdbobject.AddInParameter("@HomeAddress", DbType.String, accident.HomeAddress); adjdbobject.AddInParameter("@CustomerType", DbType.Int32, accident.CustomerType); adjdbobject.AddInParameter("@AccountType", DbType.Int32, accident.AccountType); adjdbobject.AddInParameter("@IsNewCustomer", DbType.Int32, accident.IsNewCustomer); adjdbobject.AddInParameter("@LastCalledAddress", DbType.String, accident.LastCalledAddress); adjdbobject.AddInParameter("@Amount", DbType.Decimal, accident.Amount); adjdbobject.AddInParameter("@BusinessmanId", DbType.Int32, accident.BusinessmanId); adjdbobject.AddInParameter("@create_time", DbType.DateTime, DateTime.Now); adjdbobject.AddInParameter("@create_user", DbType.String, "ThirdPartyAPI"); adjdbobject.Execute(); } catch (Exception ex) { isok = false; } return isok; }
public string addCoupon(string partyid,string couponCode,string couponValue,CustomerInfoEntity ci) { string coupon = "TP_" + partyid + "_" + couponCode; CouponDAL cd = new CouponDAL(); if (!cd.isExistCoupon(coupon)) { cd.addCoupon(coupon, Convert.ToDouble(couponValue), partyid, ci); } return coupon; }
/// <summary> /// 在线预约,成功返回订单号 /// </summary> /// <param name="request"></param> /// <returns></returns> public string execute(string request) { //1211|1张三|21381234567|3莘凌路211号(小锦江酒店)|421:00|5asdfas1231asd|6IMEI|7MD5串|8lat|9lng|10remark|11youhui|12youhuijine 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()); 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; 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 = 5, //第三方API RegisterVersion = "" }; bool isture = new D_CustomerInfoDal().AddCustomerInfo(customerEn); if (!isture) { //return "0"; throw new Exception("添加新用户失败。"); } cinfo = customerEn; } else { //return "0"; throw new Exception("获取客户种子数失败。"); } } #endregion #region 优惠码操作 string couponCode = ""; if (!WebUtility.ConfigHelper.CloseSign.ToLower().Contains(req[5].ToLower())) { if (req.Length == 13 && parter.url != null) { ThirdPartyCoupon cc = new ThirdPartyCoupon(); if (!cc.check(req[11], req[12], parter.url)) { throw new Exception("优惠码无效"); } couponCode = cc.addCoupon(parter.Id.ToString(), req[11], req[12], cinfo); } log.log("1211IF:【" + request + "】CLOSESIGN【" + WebUtility.ConfigHelper.CloseSign.ToLower() + "】req[5]【" + req[5].ToLower() + "】", System.Web.HttpContext.Current.Server.MapPath("Log/log.txt")); } else { log.log("1211ELSE:【" + request + "】CLOSESIGN【" + WebUtility.ConfigHelper.CloseSign.ToLower() + "】req[5]【" + req[5].ToLower() + "】", System.Web.HttpContext.Current.Server.MapPath("Log/log.txt")); } #endregion #region 调用web service 处理创建预约订单 CreateOrderServiceRequestEntity createOrderEntity = new CreateOrderServiceRequestEntity(); createOrderEntity.Ucode = string.Empty; createOrderEntity.Parterid = parter.Id; createOrderEntity.RecommendCode = "[" + couponCode; createOrderEntity.BusinessType = 1; // 酒后代驾 createOrderEntity.OrderFrom = 5; // 合作商 createOrderEntity.AppointTime = string.Empty; DateTime appointTime; if (DateTime.TryParse(req[4].Trim(), out appointTime)) { createOrderEntity.AppointTime = appointTime.ToString("yyyy-MM-dd HH:mm"); } createOrderEntity.Address = req[3].Trim(); createOrderEntity.FromCellPhone = cinfo.Cellphone; createOrderEntity.CellPhone = cinfo.Cellphone; string latStr = req[8].Trim(); string lngStr = req[9].Trim(); if (parter.Id == 11)//判断是博泰,对坐标进行转换 { ChangeCoords.ChangeCoordinate(ref latStr, ref lngStr, 3, 5); } double lat; double lng; if (double.TryParse(latStr, out lat) && double.TryParse(lngStr, out lng)) { CoordinateHelper.BaiduToScott(ref lng, ref lat); createOrderEntity.Lat = lat; createOrderEntity.Lng = lng; } createOrderEntity.geoType = 1; createOrderEntity.AllUserCount = 1; createOrderEntity.Remark = req[10].Trim(); createOrderEntity.Status = 0; // result = InvokeCreateOrderService(createOrderEntity); string url = string.Format("http://{0}/api/createOrder", ConfigHelper.APIServer); result = new CreateOrder().InvokeCreateOrderService(url ,createOrderEntity); #endregion } else { throw new Exception("商户标识错误。"); } } else { throw new Exception("签名错误。"); } return result; }
public string execute(string request) { //1206|1姓名|2客户手机号|3地址|4司机工号|5lat|6lng|7from|8sign|9IMEI|10MD5串 string result = "0"; string[] req = request.Split('|'); var sign = EncodingUtil.GetMd5(req[2] + "aidaijia", "utf-8"); if (sign.ToLower() == req[10].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[8].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 = 5, //第三方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 创建指定司机派单信息 DriverInfoEntity driverInfo = new D_DriverInfoDal().GetDriverInfoByUcode(req[4].Trim()); if (driverInfo == null) { throw new Exception("指定司机不存在!"); } if (driverInfo.Online == 0) { throw new Exception("该司机已经下线,不能接受您指派的任务!"); } else if (driverInfo.OnService == 1 || driverInfo.OnDOService == 1) { throw new Exception("该司机已经在服务中了,不能接受您指派的任务!"); } else { //直接派单 string distributeOrderId = new DistributeOrderInfoDAL().GenerateDistributeOrderId(new DistributeOrderInfoDAL().SelectSeqOrder()); string lat = req[5].Trim(); string lng = req[6].Trim(); if (parter.Id == 11)//判断是博泰,对坐标进行转换 { ChangeCoords.ChangeCoordinate(ref lat, ref lng, 3, 5); } DistributeOrderInfoEntity model = new DistributeOrderInfoEntity() { Address = req[3].Trim(), AppointOrderId = null, BusinessType = 10, //10酒后代驾 Cellphone = req[2].Trim(), //客户手机号 CustomerId = cusid, CustomerName = req[1].Trim(), CustomerType = CustomerType, AccountType = AccountType, AppointmentTime = DateTime.Now, DistributeOrderId = distributeOrderId, DistributeUser = cusid, DistributeUserType = 3, Fromcellphone = req[2].Trim(), Lat = float.Parse(lat), Lng = float.Parse(lng), OrderFrom = 5,//由8改为5 OrderId = null, OrderType = 1, Status = 11, Create_user = "******", Create_time = DateTime.Now, Remark = "", Ucode = req[4].Trim(), PartyId = parter.Id }; bool istrue = new DistributeOrderInfoDAL().AddDistributeOrderInfo(model); //修改派单状态:派单中 bool isupdate = new DistributeOrderInfoDAL().UpdateOnDoService(1, req[4].Trim()); DistributeOrderDetailEntity detail = new DistributeOrderDetailEntity() { DistributeOrderId = distributeOrderId, Status = 0, Ucode = req[4].Trim(), Create_user = "******" }; bool OrderDetail = new D_DistributeOrderDetailDal().CreateDistributeOrderDetail(detail); DistributeOrderStatusChangeLogEntity log = new DistributeOrderStatusChangeLogEntity() { DistributeOrderId = distributeOrderId, Status = 11, StatusText = "派单已由第三方合作商接口分配给指定司机工号" + req[4].Trim(), Create_user = "******" }; bool OrderStatusChangeLog = new D_DistributeOrderStatusChangeLogDal().CreateDistributeOrderStatusChangeLog(log); if (!istrue || !isupdate) { return "0"; } else { //添加数据 T_ParterDyLog tpl = new T_ParterDyLog(); tpl.sign = req[8]; tpl.lat = "0"; tpl.lng = "0"; tpl.imei = req[9]; tpl.addtime = DateTime.Now; //1:获取司机2:上传通话3:上传预约 tpl.typeid = 3; new T_ParterDyLogDal().AddParterDyLog(tpl); result = "1"; } } #endregion } else { throw new Exception("商户标识错误。"); } } else { throw new Exception("签名错误。"); } return result; }
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; }