/// <summary> /// 插入我的酒豆log /// </summary> public bool insertHuoliLog(MyHL myHL) { string sql = @" INSERT INTO HuoLiLog ( UserId, Direction, OriginalHuoLi, ChangedHuoLi, CurrentHuoLi, [Description], TradeCode, CreateTime ) VALUES ( @UserId, @Direction, @OriginalHuoLi, @ChangedHuoLi, @CurrentHuoLi, @Description, @TradeCode, @CreateTime )"; try { var parameters = DbSFO2ORead.CreateParameterCollection(); parameters.Append("@UserId", myHL.userId); parameters.Append("@Direction", myHL.Direction); parameters.Append("@OriginalHuoLi", myHL.OriginalHuoLi); parameters.Append("@ChangedHuoLi", myHL.ChangedHuoLi); parameters.Append("@CurrentHuoLi", myHL.CurrentHuoLi); parameters.Append("@Description", myHL.Description); parameters.Append("@TradeCode", myHL.TradeCode); parameters.Append("@CreateTime", myHL.addTime); return(DbSFO2OMain.ExecuteSqlNonQuery(sql, parameters) > 0); } catch (Exception ex) { LogHelper.Error(ex); return(false); } }
/// <summary> /// 确认订单 /// </summary> /// <param name="userId"></param> /// <param name="country"></param> /// <param name="language"></param> /// <param name="orderCode"></param> /// <returns></returns> public bool ConfirmOrder(int userId, int country, int language, string orderCode) { var model = dal.GetMyOrderInfo(userId, country, language, orderCode).AsDto(); string startTime = System.Web.Configuration.WebConfigurationManager.AppSettings["PinStartTime"].ToString(); string endTime = System.Web.Configuration.WebConfigurationManager.AppSettings["PinEndTime"].ToString(); string PinHuoLiStartTime = System.Web.Configuration.WebConfigurationManager.AppSettings["PinHuoLiStartTime"].ToString(); string PinHuoLiEndTime = System.Web.Configuration.WebConfigurationManager.AppSettings["PinHuoLiEndTime"].ToString(); string LiveTime = System.Web.Configuration.WebConfigurationManager.AppSettings["HuoLiLiveTime"].ToString(); bool istrue = dal.getOrderInfoCount(model.UserId, startTime, endTime); if (model.OrderStatus == OrderStatusEnum.Shipped.As(0)) { var isOk = dal.ConfirmOrder(orderCode); //查询userId 的酒豆值 MyHL myHL = new MyHL(); myHL = dal.getMyHL(model.UserId); if (myHL == null) { dal.insertHuoLiTotal(model.UserId); } myHL = dal.getMyHL(model.UserId); //增加赠送酒豆的判断 如果为团长就增加酒豆 //if (!string.IsNullOrEmpty(model.TeamCode)) //{ // TeamInfoEntity teamInfo = new TeamInfoEntity(); // teamInfo = new TeamBll().GetTeamInfoByTeamCode(model.TeamCode); // //增加判断 是否实在酒豆有效期内 Convert.ToDateTime(startTime) // bool isInHuoLi = teamInfo.StartTime >= Convert.ToDateTime(PinHuoLiStartTime) && teamInfo.StartTime <= Convert.ToDateTime(PinHuoLiEndTime); // if (teamInfo.UserID == model.UserId && !istrue && isInHuoLi) // { // //update // var isUpdate = dal.updateHuoLiTotal(model.ProductTotalAmount * 100, model.UserId); // //insert into HuoLidetail 表 // OrderInfoDal orderdal=new OrderInfoDal(); // HuoliDetailEntity huoliDetail=new HuoliDetailEntity(); // huoliDetail.UserId = model.UserId; // huoliDetail.AddHuoLi = model.ProductTotalAmount * 100; // huoliDetail.DeadLine = Convert.ToDateTime(LiveTime); // orderdal.insertIntoHuoliDetail(huoliDetail); // MyHL InsertMyHL=dal.getMyHL(model.UserId); // myHL.userId = model.UserId; // myHL.Direction = 1; // myHL.OriginalHuoLi = InsertMyHL.countHL; // myHL.ChangedHuoLi = model.ProductTotalAmount * 100; // myHL.CurrentHuoLi = InsertMyHL.usableHL; // myHL.Description = "拼生活奖励"; // myHL.TradeCode = model.OrderCode; // myHL.addTime = DateTime.Now; // var isTrue = dal.insertHuoliLog(myHL); // LogHelper.Info("--------ConfirmOrder团长获得酒豆----获取订单的商品图片开始---model.OrderCode:" + model.OrderCode); // ProductInfoModel productInfoModel = orderManager.GetOrderImage(model.OrderCode); // LogHelper.Info("--------ConfirmOrder团长获得酒豆----获取订单的商品图片结束---model.OrderCode:" + model.OrderCode); // LogHelper.Info("--------ConfirmOrder团长获得酒豆----设置对象参数开始"); // InformationEntity InformationEntity = new InformationEntity(); // InformationEntity.InfoType = 1; // InformationEntity.WebInnerType = 4; // InformationEntity.SendDest = CommonBll.GetUserRegion(userId); // InformationEntity.SendUserId = model.UserId; // InformationEntity.TradeCode = model.TeamCode; // InformationEntity.Title = InformationUtils.HuoliTransferedSuccTitle; // InformationEntity.InfoContent = InformationUtils.HuoliTransferedSuccContent_Prefix // + Decimal.Parse((model.ProductTotalAmount * 100).ToString("0")) // + InformationUtils.HuoliTransferedSuccContent_suffix; // if (productInfoModel != null) // { // InformationEntity.ImagePath = productInfoModel.ImagePath; // } // else // { // InformationEntity.ImagePath = null; // } // InformationEntity.Summary = null; // InformationEntity.LinkUrl = "my/myHL"; // InformationEntity.StartTime = null; // InformationEntity.EndTime = null; // InformationEntity.LongTerm = 0; // InformationEntity.CreateTime = DateTime.Now; // LogHelper.Info("--------ConfirmOrder团长获得酒豆----设置对象参数结束"); // LogHelper.Info("--------ConfirmOrder团长获得酒豆----执行消息插入方法开始"); // InformationBll.AddInformation(InformationEntity); // LogHelper.Info("--------ConfirmOrder团长获得酒豆----执行消息插入方法结束"); // } //} if (isOk) { try { bool isFinish = GenerateSettleForOrder(userId, language, orderCode); if (isFinish) { return(true); } else { LogHelper.Error(string.Format("确认订单生成结算单失败!orderCode:{0}", orderCode)); } } catch (Exception ex) { LogHelper.Error(string.Format("确认订单生成结算单失败!orderCode:{0}", orderCode), ex); } } return(isOk); } else { LogHelper.Error(string.Format("订单状态已经改变,无法确认订单!orderCode:{0},status:{1}", orderCode, model.OrderStatus)); throw new SFO2OException("订单状态已经改变,无法确认订单,请联系客服人员"); } }