public bool SetOrderIntegralInfo(OrderIntegralEntity pEntity, string customerId, out string res) { decimal integral = this.itemService.GetItemIntegral(pEntity.ItemID); decimal integralAmmount = pEntity.Quantity.Value * integral; //使用积分 decimal userIntegral = ToDecimal(this.itemService.GetVipValidIntegral(pEntity.VIPID)); //用户剩余积分 if (userIntegral - integralAmmount < 0) { res = "用户剩余积分不足"; return(false); } IDbTransaction tran = new TransactionHelper(loggingSessionInfo).CreateTransaction(); using (tran.Connection) { try { /*插入订单积分、修改订单积分数据*/ //获取商品积分信息 pEntity.Integral = integral; pEntity.IntegralAmmount = integralAmmount; new OrderIntegralBLL(loggingSessionInfo).Create(pEntity, tran); VipIntegralBLL vipIntegralServer = new VipIntegralBLL(loggingSessionInfo); vipIntegralServer.ProcessPoint(18, customerId, pEntity.VIPID, "", null, "", -integralAmmount); //VipIntegralDetailEntity integralDetailEntity = new VipIntegralDetailEntity(); //integralDetailEntity.VipIntegralDetailID = Guid.NewGuid().ToString().Replace("-", ""); //integralDetailEntity.VIPID = pEntity.VIPID; //integralDetailEntity.Integral = integralAmmount; //integralDetailEntity.IntegralSourceID = "18";//兑礼减积分 //integralDetailEntity.CreateBy = "system"; //integralDetailEntity.EffectiveDate = DateTime.Now; //integralDetailEntity.ObjectId = pEntity.OrderIntegralID; //new VipIntegralDetailBLL(loggingSessionInfo).Create(integralDetailEntity, tran); //this.itemService.UpdateVIPIntegral(userIntegral - integralAmmount, pEntity.VIPID, (SqlTransaction)tran); tran.Commit(); } catch { tran.Rollback(); throw; } } res = "操作成功"; return(true); }
/// <summary> /// 关注或者注册日志 /// </summary> /// <param name="strCTWEventId">主题活动标识</param> /// <param name="strVipId">注册操作的vipid</param> /// <param name="strFocusVipId">关注操作的vipid</param> public void CTWRegOrFocusLog(string strCTWEventId, string strRegVipId, string strFocusVipId, LoggingSessionInfo loggingSession, string strType) { string strVipId = string.Empty; if (strType == "Reg") { strVipId = strRegVipId; } if (strType == "Focus") { strVipId = strFocusVipId; } BaseService.WriteLogWeixin(" 创意仓库日志:" + strCTWEventId + "+" + strVipId + "+" + strType); try { int intResult = this._currentDAO.IsExistsLog(strCTWEventId, strVipId, strType, loggingSession.ClientID); if (intResult == 0) { T_LEventsRegVipLogEntity entityRegVipLog = new T_LEventsRegVipLogEntity(); entityRegVipLog.BusTypeCode = "CTW"; entityRegVipLog.ObjectId = strCTWEventId; entityRegVipLog.RegVipId = strRegVipId; entityRegVipLog.FocusVipId = strFocusVipId; entityRegVipLog.CustomerId = loggingSession.ClientID; this._currentDAO.Create(entityRegVipLog); //触点奖励 ContactEventBLL bllContactEvent = new ContactEventBLL(loggingSession); var entityContact = bllContactEvent.QueryByEntity(new ContactEventEntity() { EventId = strCTWEventId, IsDelete = 0, IsCTW = 1, ContactTypeCode = strType }, null).SingleOrDefault(); if (entityContact != null) { LPrizesBLL bllPrize = new LPrizesBLL(loggingSession); var prize = DataTableToObject.ConvertToList <LPrizesEntity>(bllPrize.GetCouponTypeIDByEventId(entityContact.ContactEventId.ToString()).Tables[0]).FirstOrDefault(); if (prize != null) { CouponBLL bllCoupon = new CouponBLL(loggingSession); if (prize.PrizeTypeId == "Coupon") { bllCoupon.CouponBindVip(strVipId, prize.CouponTypeID, entityContact.ContactEventId.ToString(), strType); } if (prize.PrizeTypeId == "Point") { #region 调用积分统一接口 var salesReturnBLL = new T_SalesReturnBLL(loggingSession); VipIntegralBLL bllVipIntegral = new VipIntegralBLL(loggingSession); var vipBLL = new VipBLL(loggingSession); var vipInfo = vipBLL.GetByID(strVipId); string strIntegralSourceID = string.Empty; switch (entityContact.ContactTypeCode.ToString().TrimEnd()) { case "Reg": strIntegralSourceID = "2"; break; case "Focus": strIntegralSourceID = "3"; break; case "Share": strIntegralSourceID = "28"; break; default: strIntegralSourceID = "22"; break; } var IntegralDetail = new VipIntegralDetailEntity() { Integral = prize.Point, IntegralSourceID = strIntegralSourceID, ObjectId = entityContact.ContactEventId.ToString() }; //变动前积分 string OldIntegral = (vipInfo.Integration ?? 0).ToString(); //变动积分 string ChangeIntegral = (IntegralDetail.Integral ?? 0).ToString(); var vipIntegralDetailId = bllVipIntegral.AddIntegral(ref vipInfo, null, IntegralDetail, null, loggingSession); //发送微信积分变动通知模板消息 if (!string.IsNullOrWhiteSpace(vipIntegralDetailId)) { var CommonBLL = new CommonBLL(); CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, loggingSession); } #endregion } //LPrizeWinnerEntity entityPrizeWinner = new LPrizeWinnerEntity() //{ // PrizeWinnerID = Guid.NewGuid().ToString(), // VipID = strVipId, // PrizeID = prize.PrizesID, // PrizeName = prize.PrizeName, // PrizePoolID = entityPrizePool == null ? "" : entityPrizePool.PrizePoolsID, // CreateBy = this.CurrentUserInfo.UserID, // CreateTime = DateTime.Now, // IsDelete = 0 //}; //bllPrizeWinner.Create(entityPrizeWinner); } } } } catch (Exception ex) { BaseService.WriteLogWeixin(" 创意仓库日志:" + ex.ToString() + "+"); } }