/// <summary> /// 验证 /// </summary> /// <returns></returns> public MResult Verify() { var result = new MResult(); MResult dataSuccess = null, toKenSuccess = null, systemIdSuccess = null; dataSuccess = VerifyData(); if (IsVerifyToKen) { toKenSuccess = VerifyToKen(Uid, Token); } if (IsVerifySystemId) { systemIdSuccess = VerifySystemId(Sid); } if ((!IsVerifyData || (dataSuccess != null && dataSuccess.status == MResultStatus.Success)) && (!IsVerifyToKen || (toKenSuccess != null && toKenSuccess.status == MResultStatus.Success)) && (!IsVerifySystemId || (systemIdSuccess != null && systemIdSuccess.status == MResultStatus.Success))) { result.status = MResultStatus.Success; } else { result.status = MResultStatus.LogicError; } return(result); }
/// <summary> /// 获取购物车商品信息 /// </summary> /// <param name="guid"> </param> /// <param name="channelId"></param> /// <param name="uid"></param> /// <param name="user_id"> </param> /// <returns></returns> public static MResult <ItemShoppingCartGoodsSmall> GetShoppingCartGoodsNum(string guid, int channelId, string uid, int user_id) { var result = new MResult <ItemShoppingCartGoodsSmall>(); try { if (!string.IsNullOrWhiteSpace(guid) || user_id > 0) { var shopping = DALFactory.ShoppingCartDal(); result.info = new ItemShoppingCartGoodsSmall { goods_count = shopping.GetShoppingCartGoodsNum(guid, channelId, uid, user_id), goods_total = shopping.GetShoppingTotal(user_id, guid, channelId) }; result.status = Core.Enums.MResultStatus.Success; } else { result.status = Core.Enums.MResultStatus.ParamsError; result.msg = "参数错误!"; } } catch (Exception) { result.status = Core.Enums.MResultStatus.ExecutionError; result.msg = "获取购物车商品信息 出错!"; } return(result); }
public static bool Intersect(Rectangle rect1, Rectangle rect2) { bool isSeparated = false; //prepare the normals List <Vector2> normal_box1 = rect1.GetNormals(); List <Vector2> normal_box2 = rect2.GetNormals(); List <Vector2> vecs_box1 = rect1.PrepareVector(); List <Vector2> vecs_box2 = rect2.PrepareVector(); MResult result_P1 = getMinMax(vecs_box1, normal_box1[1]); MResult result_P2 = getMinMax(vecs_box2, normal_box1[1]); MResult result_Q1 = getMinMax(vecs_box1, normal_box1[0]); MResult result_Q2 = getMinMax(vecs_box2, normal_box1[0]); MResult result_R1 = getMinMax(vecs_box1, normal_box2[1]); MResult result_R2 = getMinMax(vecs_box2, normal_box2[1]); MResult result_S1 = getMinMax(vecs_box1, normal_box2[0]); MResult result_S2 = getMinMax(vecs_box2, normal_box2[0]); bool separate_p = result_P1.m_max_proj < result_P2.m_min_proj || result_P2.m_max_proj < result_P1.m_min_proj; bool separate_Q = result_Q1.m_max_proj < result_Q2.m_min_proj || result_Q2.m_max_proj < result_Q1.m_min_proj; bool separate_R = result_R1.m_max_proj < result_R2.m_min_proj || result_R2.m_max_proj < result_R1.m_min_proj; bool separate_S = result_S1.m_max_proj < result_S2.m_min_proj || result_S2.m_max_proj < result_S1.m_min_proj; isSeparated = separate_p || separate_Q || separate_R || separate_S; return(!isSeparated); }
/// <summary> /// 修改密码 /// </summary> /// <param name="sType"> </param> /// <param name="loginPassword"> </param> /// <returns></returns> public static MResult ChangeLoginPassword(SystemType sType, LoginPasswordEntity loginPassword) { var result = new MResult(); if (loginPassword != null && !string.IsNullOrEmpty(loginPassword.email) && !string.IsNullOrEmpty(loginPassword.emailkey) && loginPassword.emailid > 0) { var changeSuccess = false; string message; using (var bbHome = new BbHomeServiceClient()) { bbHome.Open(); int mailId; string mailKey; if (bbHome.CheckPswKeyStatusByEmail(out mailId, out mailKey, out message, loginPassword.email)) { changeSuccess = bbHome.ChangePassWordByEmail(out message, loginPassword.email, loginPassword.password); } bbHome.Close(); } if (changeSuccess) { result.status = MResultStatus.Success; } else { result.status = MResultStatus.LogicError; result.msg = message; } } return(result); }
/// <summary> /// 设置用户默认收货地址 /// </summary> /// <param name="userId"></param> /// <param name="addressId"></param> /// <returns></returns> public static MResult SetDefaultAddress(int userId, int addressId) { var result = new MResult(); try { var member = DALFactory.Member(); var success = member.SetDefaultAddress(userId, addressId); if (success) { result.status = MResultStatus.Success; } else { result.status = MResultStatus.ExecutionError; result.msg = "设置默认收货地址失败!"; } } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "设置用户默认收货地址 出错!"; } return(result); }
/// <summary> /// 设置购物车商品数量 /// </summary> /// <param name="userId"></param> /// <param name="guid"></param> /// <param name="shoppingCartId"></param> /// <param name="gid"> </param> /// <param name="num"></param> /// <returns></returns> public static MResult SetShoppingCartGoodsNum(int userId, string guid, int shoppingCartId, int gid, int num) { var result = new MResult(); try { var shopping = DALFactory.ShoppingCartDal(); var goods = DALFactory.Goods(); if (goods.CheckProductStockByProductID(gid, num)) { result.status = shopping.SetShoppingCartGoodsNum(userId, guid, shoppingCartId, num) ? MResultStatus.Success : MResultStatus.ExecutionError; } else { result.status = MResultStatus.LogicError; result.msg = "该商品库存已不足!"; } } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "设置购物车商品数量 出错!"; } return(result); }
/// <summary> /// 移除用户 Session /// </summary> /// <param name="uid"></param> /// <param name="token"></param> /// <returns></returns> public static MResult RemoveUserCache(string uid, string token) { var result = new MResult(); var memberObj = Factory.DALFactory.Member(); if (memberObj != null) { var userInfo = new UserEntity(); if (MCacheManager.GetCacheObj(MCaching.Provider.Redis).RemoveByKey(token, MCaching.CacheGroup.Member)) { result.status = MResultStatus.Success; } else { result.status = MResultStatus.ExecutionError; result.msg = "[" + uid + "]移除用户缓存失败!"; } } else { result.status = MResultStatus.ParamsError; result.msg = "[" + uid + "]用户不存在!"; } return(result); }
/// <summary> /// 提取特征值 /// </summary> /// <param name="image"></param> /// <param name="singleFaceInfo"></param> /// <param name="registerOrNot"></param> /// <returns></returns> public FaceFeaturePro FaceFeatureExtractEx(ImageInfo image, SingleFaceInfo singleFaceInfo, ASF_RegisterOrNot registerOrNot) { if (_version == 2) { return(FaceFeatureExtract(image, singleFaceInfo)); } MResult result = MResult.MOK; ASF_FaceFeature feature = new ASF_FaceFeature { }; if (_version >= 4) { result = ASFFunctions.ASFFaceFeatureExtractEx(EngineHandler, image.ASFImageData, singleFaceInfo.ASFSingleFaceInfo, registerOrNot, singleFaceInfo.Mask ? 1 : 0, out feature); } else { result = ASFFunctions.Compatible.ASFFaceFeatureExtractEx(EngineHandler, image.ASFImageData, singleFaceInfo.ASFSingleFaceInfo, out feature); } if (result == MResult.MOK) { var entity = new FaceFeaturePro(); entity.Size = feature.featureSize; var buffers = new byte[feature.featureSize]; Marshal.Copy(feature.feature, buffers, 0, feature.featureSize); entity.Buffers = buffers; entity.ASFFaceFeature = feature; return(entity); } return(null); }
/// <summary> /// 获取购物车所有商品信息 /// </summary> /// <param name="userId">用户ID</param> /// <param name="guid">用户全局变量</param> /// <param name="channelId">渠道ID</param> /// <returns></returns> public static MResult <ShoppingCartResult> GetShoppingCartProductInfosByUserIDGuidChannelID(int userId, string guid, int channelId) { var result = new MResult <ShoppingCartResult>(true); var shoppingCart = Factory.DALFactory.ShoppingCartDal(); result.info.shoppingcart_list = shoppingCart.GetShoppingCartProductInfosByUserIDGuidChannelID(userId, guid, channelId); result.info.shoppingcart_total = result.info.shoppingcart_list.Sum(item => item.intBuyCount * item.numSalePrice); result.status = Core.Enums.MResultStatus.Success; return(result); }
public void createResult(int x) { string win; string[] hero = new string[10]; int rads; int ds; Random rnd = new Random(); int w = rnd.Next(1); if (w == 0) { win = "Radient"; } else { win = "Dire"; } List <int> li = new List <int>(); for (int i = 0; li.Count() < 10; i++) { int h = rnd.Next(1007, LastHero()); if (!li.Contains(h)) { li.Add(h); } } for (int i = 0; i < 10; i++) { hero[i] = getHeroName(li.ElementAt(i)); } rads = rnd.Next(5, 60); ds = rnd.Next(5, 60); MResult mr = new MResult(); mr.MatchId = x; mr.Win = win; mr.RadientScore = rads; mr.DireScore = ds; mr.Hero1 = hero[0]; mr.Hero2 = hero[1]; mr.Hero3 = hero[2]; mr.Hero4 = hero[3]; mr.Hero5 = hero[4]; mr.Hero6 = hero[5]; mr.Hero7 = hero[6]; mr.Hero8 = hero[7]; mr.Hero9 = hero[8]; mr.Hero10 = hero[9]; cntx.MResults.InsertOnSubmit(mr); cntx.SubmitChanges(); }
public void OrderPaymentTest() { SystemType sType = SystemType.MobileWebSite; int userId = 616732; string uid = "*****@*****.**"; string oCode = "5437140"; int payId = 20049; MResult <string> expected = null; MResult <string> actual; actual = PaymentBLL.OrderPayment(sType, userId, uid, oCode, payId); }
/// <summary> /// 获取会员信息 /// </summary> /// <param name="uid"></param> /// <returns></returns> public static MResult <UserEntity> GetMemberInfo(string uid) { var result = new MResult <UserEntity>(); var memberObj = Factory.DALFactory.Member(); var orderDal = DALFactory.Order(); var userInfo = new UserEntity(); var memberEntity = memberObj.GetMemberInfo(uid); if (memberEntity != null) { var orderInfo = orderDal.GetMemberOrderStatistics(memberEntity.membNo); var memberLevelInfo = memberObj.GetMemberLevelInfo(memberEntity, orderInfo); userInfo.user_id = memberEntity.membNo; userInfo.uid = memberEntity.email; userInfo.sex = memberEntity.sex.ToString(); userInfo.nick = memberEntity.userName; userInfo.location = new Location { zip = "200000" }; userInfo.created = memberEntity.regTime; userInfo.birthday = DateTime.Now; userInfo.babybirthday = DateTime.Now; userInfo.type = "网站用户"; userInfo.status = "正常"; userInfo.avatar = ""; userInfo.email = memberEntity.email; userInfo.mobile = memberEntity.mobileTel; userInfo.registertype = memberEntity.regType.ToString(); if (memberLevelInfo != null) { userInfo.userlevel = memberLevelInfo.NextLevelName; userInfo.locky = memberLevelInfo.NextLevelRemark; userInfo.consumetotal = memberLevelInfo.OrdersTotal; } else { userInfo.userlevel = memberEntity.userLevel.ToString(); } result.info = userInfo; result.status = MResultStatus.Success; } else { result.status = MResultStatus.LogicError; result.msg = "该用户不存在!"; } return(result); }
/// <summary> /// 语音识别,语音转文本 /// </summary> public static async Task <SpeechResult> Asr(string filepath) { SpeechResult result = new SpeechResult(); if (File.Exists(filepath)) { //var APP_ID = "14965195"; //var API_KEY = "R2qXXgwr9xKtge3kxU5U7up2"; //var SECRET_KEY = "Gnm2KhHcgZEDDLwy0Qtl66y4fFc8FmTj"; var client = new Baidu.Aip.Speech.Asr(APP_ID, API_KEY, SECRET_KEY); client.Timeout = 60000; // 修改超时时间 //读取文件 //string rootPath = Directory.GetCurrentDirectory(); var data = File.ReadAllBytes(filepath); //识别语种,英文1737; Dictionary <string, object> op = new Dictionary <string, object>(); op["dev_pid"] = 1737; //client.Timeout = 120000; // 若语音较长,建议设置更大的超时时间. ms var res = Task.Run(() => { var result1 = client.Recognize(data, "amr", 16000, op); MResult mResult = JsonConvert.DeserializeObject <MResult>(result1.ToString()); if (mResult.err_no == 0) { //设置成功返回数据 result.status = 0; result.text = mResult.result[0].ToString(); } else { //设置失败返回数据 result.status = 1; result.error = "语音错误:" + mResult.err_no.ToString(); } }); await res; } else { //失败数据 result.status = 1; result.error = "语音错误:无语音"; } return(result); }
public MResult AddGoodsToShoppingCart(string sid, string token, string guid, string user_id, string uid, string area_id, string gid, string num) { var result = new MResult(); try { result = ShoppingCartBll.InsertShoppingCart((int)SystemType, token, guid, user_id, uid, area_id, gid, num); } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return result; }
public MResult AddGoodsToShoppingCart(string sid, string token, string guid, string user_id, string uid, string area_id, string gid, string num) { var result = new MResult(); try { result = ShoppingCartBll.InsertShoppingCart((int)SystemType, token, guid, user_id, uid, area_id, gid, num); } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult <int> RegisterMember(string sid, string token, string guid, string user_id, string uid, UserRegister user) { var result = new MResult <int>(); try { result = MemberBLL.RegisterMember(guid, (int)SystemType, user); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult <ShoppingCartResult> GetShoppingCartGoodsList(string sid, string token, string guid, string user_id, string uid) { var result = new MResult <ShoppingCartResult>(); try { result = ShoppingCartBll.GetShoppingCartGoodsList(UserId, guid, (int)SystemType); } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult <ItemShoppingCartGoodsSmall> GetShoppingCartGoodsNum(string sid, string token, string guid, string user_id, string uid) { var result = new MResult <ItemShoppingCartGoodsSmall>(); try { result = ShoppingCartBll.GetShoppingCartGoodsNum(guid, (int)SystemType, Uid, base.UserId); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult <string> OrderPaymentSuccess(string sid, string token, string guid, string user_id, string uid, string getdata, string postdata) { var result = new MResult <string>(); try { result = OrderBLL.OrderPaymentSuccess(SystemType, UserId, Uid, getdata, postdata); } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult<ItemOrderDetails> GetOrderInfo(string sid, string token, string guid, string user_id, string uid, string orderCode) { var result = new MResult<ItemOrderDetails>(); try { result = OrderBLL.GetOrderinfo((int)SystemType, Uid, UserId, orderCode); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return result; }
public MResult <int> LoginMember(string sid, string token, string guid, string user_id, string uid, LoginEntity loginEntity) { var result = new MResult <int>(); try { result = MemberBLL.LoginMember(guid, (int)SystemType, loginEntity.uid, loginEntity.pwd); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult LogOut(string sid, string token, string guid, string user_id, string uid) { var result = new MResult(); try { result = MemberBLL.LogOut(sid, uid, token); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult ResetLoginPassword(string sid, string token, string guid, string user_id, string uid, string email) { var result = new MResult(); try { result = MemberBLL.ResetLoginPassword(SystemType, email); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult ChangeLoginPassword(string sid, string token, string guid, string user_id, string uid, LoginPasswordEntity loginPassword) { var result = new MResult(); try { result = MemberBLL.ChangeLoginPassword(SystemType, loginPassword); } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理 数据出错!"; } return(result); }
public MResult <UserEntity> GetMemberInfo(string sid, string token, string guid, string user_id, string uid) { var result = new MResult <UserEntity>(); try { result = MemberBLL.GetMemberInfo(uid); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult RemoveShoppingCartByScId(string sid, string token, string guid, string user_id, string uid, string shoppingcarid) { var result = new MResult(); try { var shoppcartId = MCvHelper.To <int>(shoppingcarid); result = ShoppingCartBll.DeleteShoppingCartByProductIdUserID(shoppcartId); } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult <ItemOrderDetails> GetOrderInfo(string sid, string token, string guid, string user_id, string uid, string orderCode) { var result = new MResult <ItemOrderDetails>(); try { result = OrderBLL.GetOrderinfo((int)SystemType, Uid, UserId, orderCode); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult <OrderResult> GetTempOrderInfo(string sid, string token, string guid, string user_id, string uid, OrderEntity order) { var result = new MResult <OrderResult>(); try { result = OrderBLL.GetTempOrderInfo(guid, (int)SystemType, Uid, UserId, order); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult<ItemOrder> CreateOrder(string sid, string token, string guid, string user_id, string uid, OrderEntity order) { var result = new MResult<ItemOrder>(); try { result = OrderBLL.CreateOrder(guid, (int)SystemType, Uid, UserId, order); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return result; }
public MResult <AddressEntity> GetDefaultAddress(string sid, string token, string guid, string user_id, string uid) { var result = new MResult <AddressEntity>(); try { result = MemberBLL.GetDefaultAddress(UserId); } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
internal static ObjectResult Create(HttpStatusCode status, string message = "", object result = null) { if (result == null) { result = new { }; } var mResult = new MResult { Message = message, Result = result }; return(new ObjectResult(mResult) { StatusCode = (int)status }); }
public MResult<ItemGoodsDetails> GetGoodsInfo(string sid, string token, string guid, string user_id, string uid, string gid) { var result = new MResult<ItemGoodsDetails>(true); try { var iGid = MCvHelper.To<int>(gid); result = GoodsBLL.GetGoodsInfo(base.SystemType.ToString(), base.Uid, (int)base.SystemType, iGid); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return result; }
public MResult <ItemGoodsDetails> GetGoodsInfo(string sid, string token, string guid, string user_id, string uid, string gid) { var result = new MResult <ItemGoodsDetails>(true); try { var iGid = MCvHelper.To <int>(gid); result = GoodsBLL.GetGoodsInfo(base.SystemType.ToString(), base.Uid, (int)base.SystemType, iGid); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult <int> SetAddress(string sid, string token, string guid, string user_id, string uid, AddressEntity address) { var result = new MResult <int>(); try { result = MemberBLL.SetAddress(sid, token, UserId, uid, address); } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return(result); }
public MResult<List<ItemGoodsCategory>> GetGoodsCategoryList(string sid, string token, string guid, string user_id, string uid) { var result = new MResult<List<ItemGoodsCategory>>(); try { result = GoodsBLL.GetGoodsCategoryList(SystemType); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return result; }
public MResult<string> OrderPayment(string sid, string token, string guid, string user_id, string uid, string ocode, string payid) { var result = new MResult<string>(); try { var payId = MCvHelper.To<int>(payid, 0); result = PaymentBLL.OrderPayment(SystemType, UserId, uid, ocode, payId); } catch (Exception ex) { result.status = Core.Enums.MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return result; }
/// <summary> /// 订单支付成功 /// </summary> /// <param name="sType"></param> /// <param name="userId"></param> /// <param name="uid"></param> /// <param name="getData"></param> /// <param name="postData"></param> /// <returns></returns> public static MResult<string> OrderPaymentSuccess(SystemType sType, int userId, string uid, string getData, string postData) { var result = new MResult<string>(); try { if (!string.IsNullOrWhiteSpace(getData)) { var getDataForNameValue = HttpUtility.ParseQueryString(getData); #region 解析 query 参数集合 组成 SortedDictionary var sortDict = new SortedDictionary<string, string>(); foreach (string name in getDataForNameValue) sortDict.Add(name, getDataForNameValue.Get(name)); #endregion #region 解析参数 var outTradeNo = getDataForNameValue.Get("out_trade_no"); var requestToken = getDataForNameValue.Get("request_token"); var resultStatus = getDataForNameValue.Get("result"); var tradeNo = getDataForNameValue.Get("trade_no"); #endregion #region 验证 签名是否合法 var alipayPayment = new AlipayWapPayment(); var validationPass = alipayPayment.ValidationSign(sortDict); #endregion #region 解析订单编号和用户编号 var orderCode = string.Empty; var userCode = string.Empty; var tradeNosplit = (outTradeNo ?? "").Split('-'); if (tradeNosplit.Length == 2) { orderCode = tradeNosplit[0]; userCode = tradeNosplit[1]; } #endregion if (!string.IsNullOrEmpty(orderCode) && !string.IsNullOrEmpty(userCode) && resultStatus.Equals("success", StringComparison.InvariantCultureIgnoreCase) && validationPass) { #region 更新订单状态 var orderDal = DALFactory.Order(); var orderInfo = orderDal.GetOrderInfo(orderCode); if (orderInfo != null && orderInfo.orderNo > 0) { if (orderInfo.payStatus == 2 || orderInfo.payStatus == 1) { result.status = MResultStatus.LogicError; result.msg = "该订单已经支付 或正在支付中!"; } else { result.info = orderCode; orderDal.UpdateOrderPayStatusSuccess(orderCode, userCode); result.status = MResultStatus.Success; } } #endregion } else { result.status = MResultStatus.LogicError; result.msg = "支付失败!"; } } } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理订单支付成功 出现异常!"; } return result; }
/// <summary> /// 创建订单 /// </summary> /// <param name="guid"></param> /// <param name="channelId"></param> /// <param name="uid"></param> /// <param name="userId"></param> /// <param name="orderEntity"></param> /// <returns></returns> public static MResult<ItemOrder> CreateOrder(string guid, int channelId, string uid, int userId, OrderEntity orderEntity) { var result = new MResult<ItemOrder>(true); try { var memberDal = DALFactory.Member(); var baseDataDal = DALFactory.BaseData(); var shoppingCartDal = DALFactory.ShoppingCartDal(); var orderDal = DALFactory.Order(); var payId = MCvHelper.To<int>(orderEntity.payid, -1); #region 验证数据 #region 用户是否登录 if (userId <= 0) { result.msg = "请登录后再操作!"; result.status = MResultStatus.ParamsError; return result; } #endregion #region 收货地址 if (orderEntity.addressid <= 0) { result.msg = "请选择收货地址!"; result.status = MResultStatus.ParamsError; return result; } #endregion #region 支付方式 if (payId < 0) { result.msg = "请选择支付方式!"; result.status = MResultStatus.ParamsError; return result; } #endregion #region 配送方式 if (orderEntity.logisticsid <= 0) { result.msg = "请选择配送方式!"; result.status = MResultStatus.ParamsError; return result; } #endregion #region 发票信息是否完整 if (orderEntity.titletype == null) { result.msg = "请选择发票类型!"; result.status = MResultStatus.ParamsError; return result; } if (orderEntity.titletype != Entity.Enum.Invoice.TitleType.NoNeed) { if (orderEntity.invoicecategory == null) { result.msg = "请选择发票分类!"; result.status = MResultStatus.ParamsError; return result; } if (orderEntity.titletype == Entity.Enum.Invoice.TitleType.Company && string.IsNullOrEmpty(orderEntity.invoicetitle)) { result.msg = "请填写发票抬头!"; result.status = MResultStatus.ParamsError; return result; } } #endregion #endregion var memberInfo = memberDal.GetMemberInfo(uid); #region 验证用户是否存在 if (memberInfo == null || memberInfo.membNo <= 0) { result.msg = "该用户不存在!"; result.status = MResultStatus.ParamsError; return result; } #endregion //购物车商品数据 List<ShoppingCartEntity> norMalShoppingCartList = null; #region 判断购物车是否有商品 var shoppingCartList = shoppingCartDal.GetShoppingCartProductInfosByUserIDGuidChannelID(userId, guid, channelId); if (shoppingCartList == null || !shoppingCartList.Any()) { result.msg = "购物车没有商品!"; result.status = MResultStatus.LogicError; return result; } norMalShoppingCartList = (from a in shoppingCartList where a.intIsDelete == 0 select a).ToList(); if (!norMalShoppingCartList.Any()) { result.msg = "购物车没有商品!"; result.status = MResultStatus.LogicError; return result; } #endregion #region 该用户是否是黑名单 var isExistBacklist = memberDal.CheckUserIdInBackList(userId); if (isExistBacklist) { result.msg = "您的用户出现异常,请联系我们的客服人员进行解决!"; result.status = MResultStatus.LogicError; return result; } #endregion //收货地址信息 var addressInfo = memberDal.GetMemberAddressInfo(orderEntity.addressid); #region 验证收货地址 #region 是否存在 if (addressInfo == null || addressInfo.intAddressID <= 0 || addressInfo.intCityID <= 0 && payId <= 0 && orderEntity.logisticsid <= 0) { result.msg = "收货地址信息不正确!"; result.status = MResultStatus.ParamsError; return result; } #endregion #endregion //配送方式 var deliverInfo = baseDataDal.GetDeliverInfo(orderEntity.logisticsid); #region 验证配送方式 if (deliverInfo == null || deliverInfo.intDeliverID == 0) { result.msg = "验证配送方式信息不正确!"; result.status = MResultStatus.ParamsError; return result; } #endregion #region 检查商品销售区域 var checkGoodsSaleAreaState = CheckGoodsSaleArea(norMalShoppingCartList, userId, MCvHelper.To<int>(addressInfo.intCityID), channelId); if (checkGoodsSaleAreaState.Any()) { result.msg = "有部分商品不在您选择的区域内销售!"; result.status = MResultStatus.LogicError; result.data = String.Join(",", checkGoodsSaleAreaState.ToArray()); return result; } #endregion var summaryOrderInfo = SummaryOrderInfo(norMalShoppingCartList, channelId, userId, payId, orderEntity.logisticsid, MCvHelper.To<int>(addressInfo.intCityID)); #region 开始创建订单 if (summaryOrderInfo != null && summaryOrderInfo.TotalGoodsFee > 0) { var order = new Sale_Order(); #region 订单主表信息 order.dtCreateDate = DateTime.Now; order.dtSendDate = CheckDateTime(orderEntity.posttimetype, orderEntity.logisticsid); //处理送货日期 order.intChannel = channelId; order.intCreaterID = 555; order.intDeliverID = orderEntity.logisticsid; order.intLogisticsID = 21; order.intOrderState = 1; order.intOrderType = 1; order.intPayID = payId; order.intPayState = 0; order.intStockID = 100; order.intTotalStars = summaryOrderInfo.TotalScore; order.intUserID = userId; order.numAddAmount = 0; order.numCarriage = summaryOrderInfo.TotalFreight; order.numChange = 0; order.numGoodsAmount = summaryOrderInfo.TotalGoodsFee; order.numCouponAmount = summaryOrderInfo.TotalDiscountFee; order.numReceAmount = summaryOrderInfo.TotalOrderFee; order.numWeight = summaryOrderInfo.TotalWeight; order.vchSendTime = order.dtSendDate.ToShortTimeString(); order.vchUserCode = memberInfo.userCode; order.vchOrderCode = GetOrderCode(); #endregion #region 配送信息 var deliver = new Sale_Order_Deliver(); deliver.intAddressID = addressInfo.intAddressID; deliver.intCityID = MCvHelper.To<int>(addressInfo.intCityID, 0); deliver.vchCityName = addressInfo.vchCityName; deliver.vchConsignee = addressInfo.vchConsignee; deliver.intCountyID = MCvHelper.To<int>(addressInfo.intCountyID, 0); deliver.vchCountyName = addressInfo.vchCountyName; deliver.vchDetailAddr = addressInfo.vchStateName + "," + addressInfo.vchCityName + "," + addressInfo.vchCountyName + "," + addressInfo.vchDetailAddr; deliver.vchHausnummer = addressInfo.vchHausnummer; deliver.vchMobile = addressInfo.vchMobile; deliver.vchPhone = addressInfo.vchPhone; deliver.vchPostCode = addressInfo.vchPostCode; deliver.vchRoadName = addressInfo.vchRoadName; deliver.intStateID = MCvHelper.To<int>(addressInfo.intStateID, 0); deliver.vchStateName = addressInfo.vchStateName; deliver.vchUserMemo = orderEntity.remark; deliver.vchOrderCode = order.vchOrderCode; #endregion #region 发票信息 var invoice = new Sale_Order_Invoice(); if (orderEntity.titletype != null && orderEntity.titletype != Invoice.TitleType.NoNeed) { if (orderEntity.titletype == Invoice.TitleType.Personal) { invoice.vchInvoicTitile = "个人"; } else if (orderEntity.titletype == Invoice.TitleType.Company) { invoice.vchInvoicTitile = orderEntity.invoicetitle; } invoice.intInvoiceType = (int)orderEntity.invoicecategory; invoice.intInvoiceKind = 1; invoice.numAmount = order.numReceAmount; invoice.dtBillingTime = DateTime.Now; invoice.dtCreateDate = DateTime.Now; invoice.intIsBilling = 1; invoice.intIsDetail = 0; invoice.vchOrderCode = order.vchOrderCode; invoice.vchPhone = addressInfo.vchPhone; invoice.intUserID = userId; } #endregion #region 保存订单 string message; result.info.oid = orderDal.SaveWebOrder(order, invoice, deliver, null, userId, guid, channelId, MCvHelper.To<int>(memberInfo.clusterId, 0), -1, out message); if (result.info.oid > 0) { #region 清空购物车 shoppingCartDal.ClearShoppingCart(userId); #endregion #region 同步订单信息到 BBHome orderDal.SyncOrderInfoToBBHome(order.vchOrderCode); #endregion result.status = MResultStatus.Success; var payType = string.Empty; if (payId == 0) payType = "货到付款"; else if (payId == 1) payType = "在线支付"; var postTimetype = string.Empty; switch (orderEntity.posttimetype) { case 1: postTimetype = "工作日送货"; break; case 2: postTimetype = "工作日、双休日均可送货"; break; case 3: postTimetype = "只双休日送货"; break; } result.info.ocode = order.vchOrderCode; result.info.paytype = payType; result.info.logisticstype = deliverInfo.vchDeliverName; result.info.total_fee = order.numGoodsAmount; result.info.total_freight = order.numCarriage; result.info.total_order = order.numReceAmount; result.info.posttimetype = postTimetype; } #endregion } #endregion } catch (Exception ex) { result.status = MResultStatus.ExecutionError; MLogManager.Error(MLogGroup.Order.创建订单, null, "", ex); } return result; }
public MResult<Dictionary<string, string>> GenneratorModelList(MDataBaseDefine db, string namespaceStr) { MResult<Dictionary<string, string>> ret = new MResult<Dictionary<string, string>>(); return ret; }
public MResult SetShoppingCartGoodsNum(string sid, string token, string guid, string user_id, string uid, string shoppingcarid, string gid, string num) { var result = new MResult(); try { var Gid = MCvHelper.To<int>(gid); var shoppcartId = MCvHelper.To<int>(shoppingcarid); var Num = MCvHelper.To<int>(num); result = ShoppingCartBll.SetShoppingCartGoodsNum(UserId, guid, shoppcartId, Gid, Num); } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return result; }
public MResult<ItemShoppingCartGoodsSmall> GetShoppingCartGoodsNum(string sid, string token, string guid, string user_id, string uid) { var result = new MResult<ItemShoppingCartGoodsSmall>(); try { result = ShoppingCartBll.GetShoppingCartGoodsNum(guid, (int)SystemType, Uid, base.UserId); } catch (Exception ex) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return result; }
/// <summary> /// 获取订单信息 /// </summary> /// <param name="sid"></param> /// <param name="uid"></param> /// <param name="userId"></param> /// <param name="orderCode"></param> /// <returns></returns> public static MResult<ItemOrderDetails> GetOrderinfo(int sid, string uid, int userId, string orderCode) { var result = new MResult<ItemOrderDetails>(); try { #region 参数判断 if (userId <= 0) { result.status = MResultStatus.ParamsError; result.msg = "用户标识错误!"; } if (string.IsNullOrEmpty(orderCode)) { result.status = MResultStatus.ParamsError; result.msg = "订单标识错误!"; } #endregion var orderDal = DALFactory.Order(); var baseDataDal = DALFactory.BaseData(); var orderInfo = orderDal.GetOrderInfo(userId, orderCode); if (orderInfo != null && orderInfo.OrderNo > 0) { orderInfo.PayType = orderInfo.PayId == 0 ? "货到付款" : "在线支付"; orderInfo.InvoiceType = (int)(string.IsNullOrEmpty(orderInfo.InvoiceTitle) ? Invoice.TitleType.NoNeed : orderInfo.InvoiceTitle.StartsWith("个人") ? Invoice.TitleType.Personal : Invoice.TitleType.Company); orderInfo.PayStatus = orderInfo.PayStatusId == 2 ? "已付款" : "未付款"; #region 订单状态 string orderStatus; switch (orderInfo.OrderStatusId) { case 0: orderStatus = "付款未审核"; break; case 1: orderStatus = "未确定"; break; case 4: orderStatus = "客户已确认"; break; case 5: orderStatus = "生成配货单"; break; case 7: orderStatus = "已出库"; break; case 20: orderStatus = "完成"; break; default: orderStatus = "未知"; break; } #endregion orderInfo.OrderStatus = orderStatus; var invoiceCategory = MCvHelper.To<int>(orderInfo.InvoiceCategory, 0); result.info = new ItemOrderDetails { oid = orderInfo.OrderNo, ocode = orderInfo.OrderCode, status = orderInfo.OrderStatus, addr = orderInfo.AddressInfo, province = orderInfo.Provinces, city = orderInfo.City, county = orderInfo.County, contact_name = orderInfo.Consignee, invoicecategory = invoiceCategory, invoicetitle = orderInfo.InvoiceTitle, phone = orderInfo.Phone, titletype = orderInfo.InvoiceType, mobile = orderInfo.Mobile, paytype = orderInfo.PayType, paytypeid = orderInfo.PayId, statusid = orderInfo.OrderStatusId, zip = orderInfo.Zip, paystatus = orderInfo.PayStatus, paystatusid = orderInfo.PayStatusId, deliverytype = orderInfo.DeliveryType }; result.status = MResultStatus.Success; } else { result.status = MResultStatus.Undefined; result.msg = "没有数据!"; } } catch (Exception ex) { result.status = MResultStatus.ExecutionError; MLogManager.Error(MLogGroup.Order.获取订单信息, null, "获取订单信息", ex); } return result; }
public MResult<ShoppingCartResult> GetShoppingCartGoodsList(string sid, string token, string guid, string user_id, string uid) { var result = new MResult<ShoppingCartResult>(); try { result = ShoppingCartBll.GetShoppingCartGoodsList(UserId, guid, (int)SystemType); } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return result; }
public MResult RemoveShoppingCartByScId(string sid, string token, string guid, string user_id, string uid, string shoppingcarid) { var result = new MResult(); try { var shoppcartId = MCvHelper.To<int>(shoppingcarid); result = ShoppingCartBll.DeleteShoppingCartByProductIdUserID(shoppcartId); } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return result; }
/// <summary> /// 获取临时订单信息 /// </summary> /// <param name="guid"></param> /// <param name="channelId"> </param> /// <param name="uid"></param> /// <param name="userId"></param> /// <param name="order"></param> /// <returns></returns> public static MResult<OrderResult> GetTempOrderInfo(string guid, int channelId, string uid, int userId, OrderEntity order) { var result = new MResult<OrderResult>(true); try { if (order.addressid > 0) { var memberDal = DALFactory.Member(); var shoppingCartDal = DALFactory.ShoppingCartDal(); //获取用户选择的收货地址 var addressInfo = memberDal.GetMemberAddressInfo(order.addressid); //判断地址是否存在,并且判断 支付方式和配送方式是否已选择 if (addressInfo != null && addressInfo.intCityID > 0 && order.payid != null && order.logisticsid > 0) { //查询该用户购物车所有商品 var shoppingCartList = shoppingCartDal.GetShoppingCartProductInfosByUserIDGuidChannelID(userId, guid, channelId); if (shoppingCartList.Any()) { //排除 已删除的商品 var notDelShoppingCart = (from a in shoppingCartList where a.intIsDelete == 0 select a).ToList(); if (notDelShoppingCart.Any()) { var summaryOrderInfo = SummaryOrderInfo(notDelShoppingCart, channelId, userId, MCvHelper.To<int>(order.payid, -1), order.logisticsid, MCvHelper.To<int>(addressInfo.intCityID)); if (summaryOrderInfo != null) { result.info.total_discount_fee = summaryOrderInfo.TotalDiscountFee; result.info.total_freight = summaryOrderInfo.TotalFreight; result.info.total_goods_fee = summaryOrderInfo.TotalGoodsFee; result.info.total_order_fee = summaryOrderInfo.TotalOrderFee; result.info.total_original = summaryOrderInfo.TotalOriginal; result.info.total_score = summaryOrderInfo.TotalScore; result.info.total_weight = summaryOrderInfo.TotalWeight; } } else { result.status = Core.Enums.MResultStatus.LogicError; result.msg = "购物车没有商品!"; } } else { result.status = Core.Enums.MResultStatus.LogicError; result.msg = "购物车没有商品!"; } } else { result.status = Core.Enums.MResultStatus.LogicError; result.msg = "请选择支付方式和配送方式!"; } } else { result.status = Core.Enums.MResultStatus.LogicError; result.msg = "请选择收货地址!"; } } catch (Exception ex) { result.status = MResultStatus.ExecutionError; MLogManager.Error(MLogGroup.Order.获取临时订单信息, null, "", ex); } return result; }
/// <summary> /// 订单支付 /// </summary> /// <param name="sType"></param> /// <param name="userId"></param> /// <param name="uid"></param> /// <param name="oCode"></param> /// <param name="payId"></param> /// <returns></returns> public static MResult<string> OrderPayment(SystemType sType, int userId, string uid, string oCode, int payId) { var result = new MResult<string>(); try { if (userId > 0 && !string.IsNullOrEmpty(oCode) && payId > 0) { var orderDal = DALFactory.Order(); var baseDataDal = DALFactory.BaseData(); var memberDal = DALFactory.Member(); var memberInfo = memberDal.GetMemberInfo(userId); #region 验证用户id if (memberInfo == null || memberInfo.membNo <= 0) { result.status = Core.Enums.MResultStatus.LogicError; result.msg = "用户不存在!"; return result; } #endregion var orderInfo = orderDal.GetOrderInfo(oCode); //订单编码正确 if (orderInfo != null && orderInfo.orderNo > 0) { #region 验证订单创建用户 if (orderInfo.userCode != memberInfo.userCode) { result.status = Core.Enums.MResultStatus.LogicError; result.msg = "该订单不属于次用户!"; return result; } #endregion #region 验正 订单状态 if (orderInfo.flowStatus < 0) { result.status = Core.Enums.MResultStatus.LogicError; result.msg = "订单状态错误!"; return result; } #endregion #region 验证 订单支付状态 if (orderInfo.payStatus != 0) { result.status = Core.Enums.MResultStatus.LogicError; result.msg = "订单支付状态错误!"; return result; } #endregion var payInfo = baseDataDal.GetPaymentInfo(payId); #region 验证支付信息 if (payInfo == null) { result.status = Core.Enums.MResultStatus.LogicError; result.msg = "支付方式错误!"; return result; } #endregion var payCofnig = new PayConfigs() { OutTradeNo = string.Format("{0}-{1}", orderInfo.orderCode, orderInfo.userCode), OutUser = memberInfo.email, Subject = "母婴之家订单支付", RequestIdentity = string.Format("{0}_{1}", orderInfo.userCode, memberInfo.email), //TotalFee = MCvHelper.To(orderInfo.shouldPay, "0.00") //TODO: 测试支付的时候请取消注视 TotalFee = MCvHelper.To("0.01", "0.00") }; switch (payInfo.intPayID) { #region 支付宝(手机)支付 case 20049: { var paymentManage = new AlipayWapPayment(payCofnig); result.info = paymentManage.Init().CreateRequestUrl(); result.status = Core.Enums.MResultStatus.Success; break; } #endregion #region 默认值 default: result.status = Core.Enums.MResultStatus.LogicError; result.msg = "该支付方式wcf 不支持! 请联系客服!"; break; #endregion } } else { result.status = Core.Enums.MResultStatus.LogicError; result.msg = "订单编码错误!"; } } else { result.status = Core.Enums.MResultStatus.ParamsError; result.msg = "参数错误!"; } } catch (Exception) { result.status = Core.Enums.MResultStatus.ExceptionError; result.msg = "订单支付 执行出现异常!"; } return result; }
public MResult<string> OrderPaymentSuccess(string sid, string token, string guid, string user_id, string uid, string getdata, string postdata) { var result = new MResult<string>(); try { result = OrderBLL.OrderPaymentSuccess(SystemType, UserId, Uid, getdata, postdata); } catch (Exception) { result.status = MResultStatus.ExceptionError; result.msg = "处理数据出错!"; } return result; }