/// <summary>
        /// 会员微信注册绑卡
        /// </summary>
        /// <param name="vipId"></param>
        /// <param name="vipCode"></param>
        /// <param name="unitId">会籍店</param>
        public void BindVipCard(string vipId, string vipCode, string unitId)
        {
            var vipCardVipMappingBLL      = new VipCardVipMappingBLL(CurrentUserInfo);
            var sysVipCardTypeBLL         = new SysVipCardTypeBLL(CurrentUserInfo);
            var vipCardBLL                = new VipCardBLL(CurrentUserInfo);
            var vipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(CurrentUserInfo);

            UnitService unitServer = new UnitService(CurrentUserInfo);

            if (string.IsNullOrEmpty(unitId))
            {
                unitId = unitServer.GetUnitByUnitTypeForWX("总部", null).Id; //获取总部门店标识
            }
            //根据vipid查询VipCardVipMapping,判断是否有绑卡,没绑卡默认给等级1的卡
            var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
            {
                VIPID = vipId
            }, null).FirstOrDefault();

            if (vipCardMappingInfo == null)
            {
                //判断商户是否有付费的会员卡,有付费会员卡时,不自动绑卡
                List <IWhereCondition> freeCardCon = new List <IWhereCondition> {
                };
                freeCardCon.Add(new EqualsCondition()
                {
                    FieldName = "CustomerID", Value = CurrentUserInfo.ClientID
                });
                freeCardCon.Add(new DirectCondition("VipCardLevel=1"));
                var orderBys = new OrderBy[1];
                orderBys[0] = new OrderBy()
                {
                    FieldName = "VipCardLevel", Direction = OrderByDirections.Asc
                };
                var freeCardTypeInfo = sysVipCardTypeBLL.Query(freeCardCon.ToArray(), orderBys).FirstOrDefault();
                if (freeCardTypeInfo != null)
                {
                    //查询最低等级的会员卡类型
                    var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                    {
                        CustomerID = CurrentUserInfo.ClientID, Category = 0, VipCardLevel = 1
                    }, new OrderBy[] { new OrderBy()
                                       {
                                           FieldName = "vipcardlevel", Direction = OrderByDirections.Asc
                                       } }).FirstOrDefault();
                    if (vipCardTypeInfo != null)
                    {
                        //查询此类型会员卡是否存在
                        var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity()
                        {
                            VipCardTypeID = vipCardTypeInfo.VipCardTypeID, VipCardStatusId = 0, MembershipUnit = ""
                        }, null).FirstOrDefault();
                        //不存在,制卡
                        if (vipCardInfo == null)
                        {
                            vipCardInfo                 = new VipCardEntity();
                            vipCardInfo.VipCardID       = Guid.NewGuid().ToString();
                            vipCardInfo.VipCardTypeID   = vipCardTypeInfo.VipCardTypeID;
                            vipCardInfo.VipCardTypeName = vipCardTypeInfo.VipCardTypeName;
                            vipCardInfo.VipCardCode     = vipCode;
                            vipCardInfo.VipCardStatusId = 1;//正常
                            vipCardInfo.MembershipUnit  = unitId;
                            vipCardInfo.MembershipTime  = DateTime.Now;
                            vipCardInfo.CustomerID      = CurrentUserInfo.ClientID;
                            vipCardBLL.Create(vipCardInfo);
                        }
                        else//存在更新成现在的
                        {
                            vipCardInfo.VipCardStatusId = 1;//正常
                            vipCardInfo.MembershipUnit  = unitId;
                            vipCardInfo.MembershipTime  = DateTime.Now;
                            vipCardInfo.VipCardTypeID   = vipCardTypeInfo.VipCardTypeID;
                            vipCardBLL.Update(vipCardInfo);
                            //存在导入的卡时,更新当前会员的VipCode
                            var vipbll = new VipBLL(CurrentUserInfo);
                            List <IWhereCondition> wheres = new List <IWhereCondition>();
                            wheres.Add(new MoreThanCondition()
                            {
                                FieldName = "status", Value = 0
                            });
                            wheres.Add(new EqualsCondition()
                            {
                                FieldName = "vipid", Value = vipId
                            });
                            wheres.Add(new EqualsCondition()
                            {
                                FieldName = "clientid", Value = CurrentUserInfo.ClientID
                            });
                            var VipInfo = vipbll.Query(wheres.ToArray(), null).FirstOrDefault();
                            if (VipInfo != null && !string.IsNullOrEmpty(VipInfo.VIPID))
                            {
                                VipInfo.VipCode = vipCardInfo.VipCardCode;
                                //更新VipCode信息
                                vipbll.Update(VipInfo);
                            }
                        }
                        //新增会员卡操作状态信息
                        var vipCardStatusChangeLogEntity = new VipCardStatusChangeLogEntity()
                        {
                            LogID           = Guid.NewGuid().ToString().Replace("-", ""),
                            VipCardStatusID = vipCardInfo.VipCardStatusId,
                            VipCardID       = vipCardInfo.VipCardID,
                            Action          = "注册",
                            UnitID          = unitId,
                            CustomerID      = CurrentUserInfo.ClientID
                        };
                        vipCardStatusChangeLogBLL.Create(vipCardStatusChangeLogEntity);

                        //绑定会员卡和会员
                        var vipCardVipMappingEntity = new VipCardVipMappingEntity()
                        {
                            MappingID  = Guid.NewGuid().ToString().Replace("-", ""),
                            VIPID      = vipId,
                            VipCardID  = vipCardInfo.VipCardID,
                            CustomerID = CurrentUserInfo.ClientID
                        };
                        vipCardVipMappingBLL.Create(vipCardVipMappingEntity);
                        //开卡礼
                        var vipCardUpgradeRewardBll        = new VipCardUpgradeRewardBLL(CurrentUserInfo);
                        var vipCardUpgradeRewardEntityList = vipCardUpgradeRewardBll.QueryByEntity(new VipCardUpgradeRewardEntity()
                        {
                            VipCardTypeID = vipCardTypeInfo.VipCardTypeID
                        }, null);
                        var redisVipMappingCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisVipMappingCouponBLL();
                        if (vipCardUpgradeRewardEntityList.Length > 0)
                        {
                            foreach (var vipCardUpgradeRewardEntity in vipCardUpgradeRewardEntityList)
                            {
                                for (int i = 0; i < vipCardUpgradeRewardEntity.CouponNum; i++)
                                {
                                    redisVipMappingCouponBLL.SetVipMappingCoupon(new CC_Coupon()
                                    {
                                        CustomerId   = CurrentUserInfo.ClientID,
                                        CouponTypeId = vipCardUpgradeRewardEntity.CouponTypeId.ToString()
                                    }, vipCardUpgradeRewardEntity.CardUpgradeRewardId.ToString(), vipId, "OpenVipCard");
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new APIException("系统未创建会员卡类型")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              }
                    };
                }
            }
            else //更新旧卡 需要确认旧卡是否为卡体系内的卡
            {
                var oldVipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity()
                {
                    VipCardID = vipCardMappingInfo.VipCardID, CustomerID = CurrentUserInfo.ClientID
                }, null).FirstOrDefault();
                int oldVipCardTypeID = oldVipCardInfo.VipCardTypeID ?? 0;
                //查询最低等级的会员卡类型
                var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                {
                    CustomerID = CurrentUserInfo.ClientID, Category = 0, VipCardLevel = 1
                }, new OrderBy[] { new OrderBy()
                                   {
                                       FieldName = "vipcardlevel", Direction = OrderByDirections.Asc
                                   } }).FirstOrDefault();
                if (vipCardTypeInfo == null)
                {
                    throw new APIException("系统未创建会员卡类型体系")
                          {
                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                          };
                }
                if (oldVipCardInfo != null)
                {
                    //旧卡不为空时,确认当前VipCardTypeID是否属于卡体系
                    var curvipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                    {
                        CustomerID = CurrentUserInfo.ClientID, Category = 0, VipCardTypeID = oldVipCardInfo.VipCardTypeID
                    }, new OrderBy[] { new OrderBy()
                                       {
                                           FieldName = "VipCardTypeID", Direction = OrderByDirections.Asc
                                       } }).FirstOrDefault();
                    if (curvipCardTypeInfo == null)         //若为空  则更新为当前信息
                    {
                        oldVipCardInfo.VipCardStatusId = 1; //正常
                        oldVipCardInfo.MembershipUnit  = unitId;
                        oldVipCardInfo.MembershipTime  = DateTime.Now;
                        oldVipCardInfo.VipCardTypeID   = vipCardTypeInfo.VipCardTypeID;
                        vipCardBLL.Update(oldVipCardInfo);
                        //存在导入的卡时,更新当前会员的VipCode
                        var vipbll = new VipBLL(CurrentUserInfo);
                        List <IWhereCondition> wheres = new List <IWhereCondition>();
                        wheres.Add(new MoreThanCondition()
                        {
                            FieldName = "status", Value = 0
                        });
                        wheres.Add(new EqualsCondition()
                        {
                            FieldName = "vipid", Value = vipId
                        });
                        wheres.Add(new EqualsCondition()
                        {
                            FieldName = "clientid", Value = CurrentUserInfo.ClientID
                        });
                        var VipInfo = vipbll.Query(wheres.ToArray(), null).FirstOrDefault();
                        if (VipInfo != null && !string.IsNullOrEmpty(VipInfo.VIPID))
                        {
                            VipInfo.VipCode = oldVipCardInfo.VipCardCode;
                            //更新VipCode信息
                            vipbll.Update(VipInfo);
                        }
                        //开卡礼
                        var vipCardUpgradeRewardBll        = new VipCardUpgradeRewardBLL(CurrentUserInfo);
                        var vipCardUpgradeRewardEntityList = vipCardUpgradeRewardBll.QueryByEntity(new VipCardUpgradeRewardEntity()
                        {
                            VipCardTypeID = vipCardTypeInfo.VipCardTypeID
                        }, null);
                        var redisVipMappingCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisVipMappingCouponBLL();
                        if (vipCardUpgradeRewardEntityList.Length > 0)
                        {
                            foreach (var vipCardUpgradeRewardEntity in vipCardUpgradeRewardEntityList)
                            {
                                for (int i = 0; i < vipCardUpgradeRewardEntity.CouponNum; i++)
                                {
                                    redisVipMappingCouponBLL.SetVipMappingCoupon(new CC_Coupon()
                                    {
                                        CustomerId   = CurrentUserInfo.ClientID,
                                        CouponTypeId = vipCardUpgradeRewardEntity.CouponTypeId.ToString()
                                    }, vipCardUpgradeRewardEntity.CardUpgradeRewardId.ToString(), vipId, "OpenVipCard");
                                }
                            }
                        }
                    }
                }
                //老卡操作状态信息
                var oldVipCardStatusChangeLogEntity = new VipCardStatusChangeLogEntity()
                {
                    LogID           = Guid.NewGuid().ToString().Replace("-", ""),
                    VipCardStatusID = oldVipCardInfo.VipCardStatusId,
                    VipCardID       = oldVipCardInfo.VipCardID,
                    Action          = "注册",
                    UnitID          = unitId,
                    CustomerID      = CurrentUserInfo.ClientID
                };
                vipCardStatusChangeLogBLL.Create(oldVipCardStatusChangeLogEntity);
            }
            //记录会员信息改变,并且把旧的会员的标识也放在契约里
            var eventService = new EventService();
            var vipMsg       = new EventContract
            {
                Operation  = OptEnum.Update,
                EntityType = EntityTypeEnum.Vip,
                Id         = vipId,
            };

            eventService.PublishMsg(vipMsg);
        }
示例#2
0
        /// <summary>
        /// 批量发货
        /// </summary>
        /// <param name="OrderID"></param>
        public int BatchInvalidShip(List <InoutInfo> OrderList, string Remark, LoggingSessionInfo LoggingSessionInfo)
        {
            var UpdateOrderList = new List <InoutInfo>();

            foreach (var item in OrderList)
            {
                var result = this._currentDAO.GetByID(item.order_id);
                if (result != null)
                {
                    var Entity = new InoutInfo()
                    {
                        order_id    = result.order_id,
                        Field2      = item.Field2,
                        carrier_id  = item.carrier_id,
                        status      = "600",
                        status_desc = "已发货"
                    };
                    UpdateOrderList.Add(Entity);
                }
            }
            //更新订单状态
            int Num = this._currentDAO.BatchChangeOrderStatus(UpdateOrderList);

            if (Num > 0)
            {//添加状态操作记录
                var inoutStatus  = new TInoutStatusBLL(LoggingSessionInfo);
                var vipBll       = new VipBLL(LoggingSessionInfo);
                var inoutService = new Inout3Service(LoggingSessionInfo);
                var CommonBLL    = new CommonBLL();
                foreach (var itemes in UpdateOrderList)
                {
                    var info = new TInoutStatusEntity()
                    {
                        InoutStatusID = Guid.Parse(Utils.NewGuid()),
                        OrderID       = itemes.order_id,
                        CustomerID    = LoggingSessionInfo.ClientID,
                        Remark        = Remark,
                        OrderStatus   = 600,
                        StatusRemark  = "订单状态从未发货变为已发货[操作人:" + LoggingSessionInfo.CurrentUser.User_Name + "]"
                    };
                    //执行
                    inoutStatus.Create(info);

                    #region 发送微信模板消息
                    //获取订单
                    var OerderInfoData = this._currentDAO.GetByID(itemes.order_id);
                    if (OerderInfoData != null)
                    {
                        //获取会员信息
                        var vipInfo = vipBll.GetByID(OerderInfoData.vip_no);
                        if (vipInfo != null)
                        {
                            //物流公司
                            itemes.carrier_name = "";//inoutService.GetCompanyName(itemes.carrier_id);
                            //  CommonBLL.SentShipMessage(itemes, vipInfo.WeiXinUserId, itemes.vip_no, LoggingSessionInfo);
                            new SendOrderSendMsgBLL().SentShipMessage(itemes, vipInfo.WeiXinUserId, itemes.vip_no, LoggingSessionInfo);
                        }
                    }
                    #endregion
                }
                //
                Num = UpdateOrderList.Count();
            }
            return(Num);
        }
示例#3
0
        /// <summary>
        /// 取消订单(Api和后台通用)
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="userType">0=会员;1=后台用户</param>
        /// <param name="loggingSessionInfo"></param>
        public void SetCancelOrder(string orderId, int userType, LoggingSessionInfo loggingSessionInfo)
        {
            var vipBll         = new VipBLL(loggingSessionInfo);                                                                           //会员业务实例化
            var inoutDetailBLL = new Inout3Service(loggingSessionInfo);                                                                    //订单业务实例化
            var refundOrderBll = new T_RefundOrderBLL(loggingSessionInfo);                                                                 //退货业务实例化
            var inoutBll       = new T_InoutBLL(loggingSessionInfo);                                                                       //订单业务实例化
            PanicbuyingEventBLL panicbuyingEventBLL = new PanicbuyingEventBLL(loggingSessionInfo);                                         //活动订单业务实例化
            T_SuperRetailTraderItemMappingBLL superRetailTraderItemMappingBll = new T_SuperRetailTraderItemMappingBLL(loggingSessionInfo); //分销商业务实例化

            //获取订单详情
            var inoutInfo = inoutBll.GetInoutInfo(orderId, loggingSessionInfo);

            //处理积分、余额、返现和优惠券
            vipBll.ProcSetCancelOrder(loggingSessionInfo.ClientID, inoutInfo.order_id, inoutInfo.vip_no);
            //获取订单明细
            var inoutDetailList = inoutDetailBLL.GetInoutDetailInfoByOrderId(inoutInfo.order_id, loggingSessionInfo.ClientID);

            #region 处理退款业务
            if (inoutInfo != null)
            {
                //if (inoutInfo.Field1 == "1" && (inoutInfo.actual_amount - inoutInfo.DeliveryAmount) > 0)//已付款,并且实付款-运费>0
                if (inoutInfo.Field1 == "1" && inoutInfo.actual_amount > 0)//已付款,并且实付款>0,未发货所以不用减运费
                {
                    #region 新增退货单(默认状态为确认收货)
                    var salesReturnBLL = new T_SalesReturnBLL(loggingSessionInfo);
                    var historyBLL     = new T_SalesReturnHistoryBLL(loggingSessionInfo);
                    T_SalesReturnEntity        salesReturnEntity = null;
                    T_SalesReturnHistoryEntity historyEntity     = null;

                    var       userBll   = new T_UserBLL(loggingSessionInfo); //店员BLL实例化
                    VipEntity vipEntity = null;                              //会员信息

                    salesReturnEntity = new T_SalesReturnEntity();
                    salesReturnEntity.SalesReturnNo = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                    salesReturnEntity.VipID         = loggingSessionInfo.UserID;
                    salesReturnEntity.ServicesType  = 1; //退货
                    salesReturnEntity.DeliveryType  = 1; //快递送回;
                    salesReturnEntity.OrderID       = inoutInfo.order_id;
                    var inoutDetailInfo = inoutDetailList.FirstOrDefault();
                    if (inoutDetailInfo != null)
                    {
                        salesReturnEntity.ItemID = inoutDetailInfo.item_id;
                        salesReturnEntity.SkuID  = inoutDetailInfo.sku_id;
                    }
                    salesReturnEntity.Qty       = 0;
                    salesReturnEntity.ActualQty = 0;
                    if (inoutInfo != null)
                    {
                        salesReturnEntity.UnitID = inoutInfo.sales_unit_id;
                        //salesReturnEntity.UnitName = para.UnitName;
                        //salesReturnEntity.UnitTel = para.UnitTel;
                        salesReturnEntity.Address  = inoutInfo.Field4;
                        salesReturnEntity.Contacts = inoutInfo.Field14 != null ? inoutInfo.Field14 : "";
                        salesReturnEntity.Phone    = inoutInfo.Field6 != null ? inoutInfo.Field6 : "";
                    }
                    salesReturnEntity.Reason = "取消订单";
                    //if (inoutInfo.actual_amount - inoutInfo.DeliveryAmount > 0)
                    if (inoutInfo.actual_amount > 0)
                    {
                        salesReturnEntity.Status = 6; //已完成(待退款)
                    }
                    else
                    {
                        salesReturnEntity.Status = 7; //已完成(已退款)
                    }
                    salesReturnEntity.CustomerID = loggingSessionInfo.ClientID;
                    salesReturnBLL.Create(salesReturnEntity);

                    string userName = string.Empty; //操作人姓名
                    if (userType == 0)              //会员操作
                    {
                        vipEntity = vipBll.GetByID(loggingSessionInfo.UserID);
                        userName  = vipEntity != null ? vipEntity.VipName : "";
                    }
                    else//后台用户操作
                    {
                        userName = loggingSessionInfo.CurrentUser.User_Name;
                    }
                    historyEntity = new T_SalesReturnHistoryEntity()
                    {
                        SalesReturnID = salesReturnEntity.SalesReturnID,
                        OperationType = 14,
                        OperationDesc = "取消订单",
                        OperatorID    = loggingSessionInfo.UserID,
                        HisRemark     = "取消订单",
                        OperatorName  = userName,
                        OperatorType  = userType  //0=会员;1=管理用户
                    };
                    historyBLL.Create(historyEntity);
                    #endregion

                    #region 新增退款单
                    //if (inoutInfo.actual_amount - inoutInfo.DeliveryAmount > 0)
                    if (inoutInfo.actual_amount > 0)
                    {
                        T_RefundOrderEntity refundOrderEntity = new T_RefundOrderEntity()
                        {
                            RefundNo      = DateTime.Now.ToString("yyyyMMddhhmmfff"),
                            VipID         = inoutInfo.vip_no,
                            SalesReturnID = salesReturnEntity.SalesReturnID,
                            //ServicesType = 1,//退货
                            DeliveryType = 1,//快递送回
                            ItemID       = inoutDetailInfo.item_id,
                            SkuID        = inoutDetailInfo.sku_id,
                            Qty          = 0,
                            ActualQty    = 0,
                            UnitID       = inoutInfo.sales_unit_id,
                            //salesReturnEntity.UnitName = para.UnitName;
                            //salesReturnEntity.UnitTel = para.UnitTel;
                            Address       = inoutInfo.Field4,
                            Contacts      = inoutInfo.Field14,
                            Phone         = inoutInfo.Field6,
                            OrderID       = inoutInfo.order_id,
                            PayOrderID    = inoutInfo.paymentcenter_id,
                            RefundAmount  = inoutInfo.total_amount,
                            ConfirmAmount = inoutInfo.total_amount,
                            //ActualRefundAmount = inoutInfo.actual_amount - inoutInfo.DeliveryAmount,//实退金额=实付款-运费
                            ActualRefundAmount = inoutInfo.actual_amount,//实退金额=实付款
                            Points             = inoutInfo.pay_points == null ? 0 : Convert.ToInt32(inoutInfo.pay_points),
                            ReturnAmount       = inoutInfo.ReturnAmount,
                            Amount             = inoutInfo.VipEndAmount,
                            Status             = 1,//待退款
                            CustomerID         = loggingSessionInfo.ClientID
                        };
                        refundOrderBll.Create(refundOrderEntity);
                    }
                    #endregion
                }
            }
            #endregion

            //普通订单库存处理
            if (inoutInfo.order_reason_id == "2F6891A2194A4BBAB6F17B4C99A6C6F5")
            {
                inoutBll.SetStock(orderId, inoutDetailList, 2, loggingSessionInfo);
            }
            //团购抢购订单库存处理
            if (inoutInfo.order_reason_id == "CB43DD7DD1C94853BE98C4396738E00C" || inoutInfo.order_reason_id == "671E724C85B847BDA1E96E0E5A62055A")
            {
                panicbuyingEventBLL.SetEventStock(orderId, inoutDetailList.ToList());
            }
            //砍价订单库存处理
            if (inoutInfo.order_reason_id == "096419BFDF394F7FABFE0DFCA909537F")
            {
                panicbuyingEventBLL.SetKJEventStock(orderId, inoutDetailList.ToList());
            }
            //超级分销商库存处理
            if (inoutInfo.data_from_id == "35" || inoutInfo.data_from_id == "36")
            {
                superRetailTraderItemMappingBll.DeleteSuperRetailTraderItemStock(inoutDetailList.ToList());
            }
        }
示例#4
0
        /// <summary>
        /// 计算销售会员卡分润
        /// </summary>
        /// <param name="loggingSessionInfo"></param>
        /// <param name="orderInfo"></param>
        public void CalculateSalesVipCardOrder(LoggingSessionInfo loggingSessionInfo, T_InoutEntity orderInfo)
        {
            if (orderInfo != null)
            {
                if (orderInfo.Field17 != null && orderInfo.Field18 != null && orderInfo.Field17.Length > 0 && orderInfo.Field18.Length > 0)
                {
                    VipBLL bllVip = new VipBLL(loggingSessionInfo);

                    T_Inout_DetailBLL           bllInoutDetail            = new T_Inout_DetailBLL(loggingSessionInfo);
                    T_VirtualItemTypeSettingBLL bllVirtualItemTypeSetting = new T_VirtualItemTypeSettingBLL(loggingSessionInfo);

                    var entityInoutDetail = bllInoutDetail.QueryByEntity(new T_Inout_DetailEntity()
                    {
                        order_id = orderInfo.order_id
                    }, null).FirstOrDefault();
                    var vipCardType = bllVirtualItemTypeSetting.QueryByEntity(new T_VirtualItemTypeSettingEntity()
                    {
                        SkuId = entityInoutDetail.sku_id, IsDelete = 0
                    }, null).FirstOrDefault();
                    if (vipCardType != null)
                    {
                        VipCardUpgradeRuleBLL bllVipCardUpgradeRule = new VipCardUpgradeRuleBLL(loggingSessionInfo);

                        int intVipCardTypeID         = Convert.ToInt32(vipCardType.ObjecetTypeId);
                        var entityVipCardUpgradeRule = bllVipCardUpgradeRule.QueryByEntity(new VipCardUpgradeRuleEntity()
                        {
                            VipCardTypeID = intVipCardTypeID, IsPurchaseUpgrade = 1, IsDelete = 0
                        }, null).SingleOrDefault();
                        #region
                        //if (entityVipCardUpgradeRule != null)
                        //{
                        //    VipCardGradeChangeLogEntity entityVipCardGradeChangeLog = new VipCardGradeChangeLogEntity();
                        //    VipCardStatusChangeLogEntity entityVipCardStatusChangeLog = new VipCardStatusChangeLogEntity();

                        //    VipCardGradeChangeLogBLL bllVipCardGradeChangeLog = new VipCardGradeChangeLogBLL(loggingSessionInfo);
                        //    VipCardStatusChangeLogBLL bllVipCardStatusChangeLog = new VipCardStatusChangeLogBLL(loggingSessionInfo);
                        //    VipCardVipMappingBLL vipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo);

                        //    //会员等级改变以及如日志
                        //    DataSet dsVipInfo = bllVip.GetVipCardLevel(orderInfo.vip_no, loggingSessionInfo.ClientID);
                        //    if(dsVipInfo.Tables.Count>0 && dsVipInfo.Tables[0].Rows.Count>0)
                        //    {
                        //        //会员升级
                        //        vipCardVipMappingBLL.BindVirtualItem(orderInfo.vip_no, orderInfo.VipCardCode, "", intVipCardTypeID);
                        //        //日志
                        //        entityVipCardGradeChangeLog = new VipCardGradeChangeLogEntity()
                        //        {
                        //            ChangeLogID=Guid.NewGuid().ToString(),
                        //            VipCardUpgradeRuleId=entityVipCardUpgradeRule.VipCardUpgradeRuleId,
                        //            OrderType = "SalesCard",
                        //            OrderId=orderInfo.order_id,
                        //            VipCardID = dsVipInfo.Tables[0].Rows[0]["VipCardID"].ToString(),
                        //            ChangeBeforeVipCardID = dsVipInfo.Tables[0].Rows[0]["VipCardID"].ToString(),
                        //            ChangeBeforeGradeID = Convert.ToInt32(dsVipInfo.Tables[0].Rows[0]["VipCardTypeID"].ToString()),
                        //            NowGradeID = intVipCardTypeID,
                        //            ChangeReason="Upgrade",
                        //            OperationType = 2,
                        //            ChangeTime=DateTime.Now,
                        //            UnitID=orderInfo.sales_unit_id,
                        //            OperationUserID=orderInfo.sales_user
                        //        };
                        //        bllVipCardGradeChangeLog.Create(entityVipCardGradeChangeLog);
                        //    }
                        //}
                        #endregion
                        //计算分润
                        VipCardProfitRuleBLL bllVipCardProfitRule = new VipCardProfitRuleBLL(loggingSessionInfo);
                        var entityVipCardProfitRule = bllVipCardProfitRule.QueryByEntity(new VipCardProfitRuleEntity()
                        {
                            VipCardTypeID = intVipCardTypeID, IsDelete = 0
                        }, null);
                        if (entityVipCardProfitRule != null)
                        {
                            VipAmountBLL       bllVipAmount       = new VipAmountBLL(loggingSessionInfo);
                            VipAmountDetailBLL bllVipAmountDetail = new VipAmountDetailBLL(loggingSessionInfo);
                            VipAmountEntity    entityVipAmount    = new VipAmountEntity();

                            foreach (var ProfitRule in entityVipCardProfitRule)
                            {
                                decimal amount            = 0;
                                string  strAmountSourceId = string.Empty;
                                string  strVipId          = string.Empty;

                                if (ProfitRule.ProfitOwner == "Employee")
                                {
                                    strAmountSourceId = "37";
                                    strVipId          = orderInfo.sales_user;
                                }
                                if (ProfitRule.ProfitOwner == "Unit")
                                {
                                    strAmountSourceId = "40";
                                    strVipId          = orderInfo.sales_unit_id;
                                }
                                if (ProfitRule.IsApplyAllUnits == 0)
                                {
                                    VipCardProfitRuleUnitMappingBLL bllVipCardProfitRuleUnitMapping = new VipCardProfitRuleUnitMappingBLL(loggingSessionInfo);
                                    var vipCardProfitRuleUnitMapping = bllVipCardProfitRuleUnitMapping.QueryByEntity(new VipCardProfitRuleUnitMappingEntity()
                                    {
                                        CardBuyToProfitRuleId = ProfitRule.CardBuyToProfitRuleId, UnitID = orderInfo.sales_unit_id, IsDelete = 0, CustomerID = loggingSessionInfo.ClientID
                                    }, null).SingleOrDefault();
                                    if (vipCardProfitRuleUnitMapping != null)
                                    {
                                        amount = (decimal)ProfitRule.FirstCardSalesProfitPct * (decimal)orderInfo.actual_amount * (decimal)0.01;
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }

                                amount = (decimal)ProfitRule.FirstCardSalesProfitPct * (decimal)orderInfo.actual_amount * (decimal)0.01;
                                if (amount > 0)
                                {
                                    IDbTransaction tran = new JIT.CPOS.BS.DataAccess.Base.TransactionHelper(loggingSessionInfo).CreateTransaction();

                                    VipAmountDetailEntity entityVipAmountDetail = new VipAmountDetailEntity
                                    {
                                        VipAmountDetailId = Guid.NewGuid(),
                                        VipId             = strVipId,
                                        Amount            = amount,
                                        UsedReturnAmount  = 0,
                                        EffectiveDate     = DateTime.Now,
                                        DeadlineDate      = Convert.ToDateTime("9999-12-31 23:59:59"),
                                        AmountSourceId    = strAmountSourceId,
                                        ObjectId          = orderInfo.order_id,
                                        CustomerID        = loggingSessionInfo.ClientID,
                                        Reason            = "超级分销商"
                                    };
                                    bllVipAmountDetail.Create(entityVipAmountDetail, (SqlTransaction)tran);

                                    entityVipAmount = new VipAmountEntity
                                    {
                                        VipId                  = strVipId,
                                        BeginAmount            = 0,
                                        InAmount               = amount,
                                        OutAmount              = 0,
                                        EndAmount              = amount,
                                        TotalAmount            = amount,
                                        BeginReturnAmount      = 0,
                                        InReturnAmount         = 0,
                                        OutReturnAmount        = 0,
                                        ReturnAmount           = 0,
                                        ImminentInvalidRAmount = 0,
                                        InvalidReturnAmount    = 0,
                                        ValidReturnAmount      = 0,
                                        TotalReturnAmount      = 0,
                                        IsLocking              = 0,
                                        CustomerID             = loggingSessionInfo.ClientID,
                                        VipCardCode            = ""
                                    };
                                    bllVipAmount.Create(entityVipAmount, tran);
                                }
                                else
                                {
                                    entityVipAmount.InReturnAmount    = (entityVipAmount.InReturnAmount == null ? 0 : entityVipAmount.InReturnAmount.Value) + amount;
                                    entityVipAmount.TotalReturnAmount = (entityVipAmount.TotalReturnAmount == null ? 0 : entityVipAmount.TotalReturnAmount.Value) + amount;

                                    entityVipAmount.ValidReturnAmount = (entityVipAmount.ValidReturnAmount == null ? 0 : entityVipAmount.ValidReturnAmount.Value) + amount;
                                    entityVipAmount.ReturnAmount      = (entityVipAmount.ReturnAmount == null ? 0 : entityVipAmount.ReturnAmount.Value) + amount;
                                    bllVipAmount.Update(entityVipAmount);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#5
0
        public bool SetEventWXPush(LEventsEntity eventInfo, string WeiXin, string OpenId, string VipId, string msgUrl, out string strError, string AuthUrl, int iRad)
        {
            try
            {
                MarketSendLogBLL logServer = new MarketSendLogBLL(this.CurrentUserInfo);
                Random           rad       = new Random();
                if (eventInfo == null || eventInfo.ModelId == null || eventInfo.ModelId.Equals(""))
                {
                    strError = "获取信息不全,缺少模板。";
                    return(false);
                }
                #region
                WEventUserMappingBLL eventUserMapping = new WEventUserMappingBLL(CurrentUserInfo);
                int eventPersonCount = 0;
                eventPersonCount = eventUserMapping.GetEventSignInCount(eventInfo.EventID);


                #endregion
                WApplicationInterfaceBLL wAServer = new WApplicationInterfaceBLL(this.CurrentUserInfo);
                var wxArray = wAServer.QueryByEntity(new WApplicationInterfaceEntity
                {
                    WeiXinID = WeiXin
                    ,
                    IsDelete = 0
                    ,
                    CustomerId = this.CurrentUserInfo.CurrentUser.customer_id
                }, null);
                if (wxArray == null || wxArray.Length == 0 || wxArray[0].AppID == null || wxArray[0].AppID.Equals(""))
                {
                    strError = "不存在对应的微信帐号";
                    return(false);
                }
                else
                {
                    WApplicationInterfaceEntity wxInfo = wxArray[0];
                    WX.CommonBLL server = new WX.CommonBLL();
                    JIT.CPOS.BS.Entity.WX.SendMessageEntity sendMessageInfo = new Entity.WX.SendMessageEntity();

                    WMaterialTextBLL            wTextServer = new WMaterialTextBLL(this.CurrentUserInfo);
                    IList <WMaterialTextEntity> textlist    = new List <WMaterialTextEntity>();
                    textlist = wTextServer.GetMaterialTextListByModelId(eventInfo.ModelId);

                    if (textlist != null && textlist.Count > 0 && textlist[0].TextId != null)
                    {
                        #region
                        VipBLL    vipServer = new VipBLL(CurrentUserInfo);
                        VipEntity vipInfo   = vipServer.GetByID(VipId);
                        sendMessageInfo.msgtype = "news";
                        sendMessageInfo.touser  = OpenId;
                        List <JIT.CPOS.BS.Entity.WX.NewsEntity> newsList = new List <JIT.CPOS.BS.Entity.WX.NewsEntity>();
                        foreach (var info in textlist)
                        {
                            JIT.CPOS.BS.Entity.WX.NewsEntity newsInfo = new Entity.WX.NewsEntity();
                            newsInfo.title = info.Title;
                            if (vipInfo != null && !vipInfo.VIPID.Equals(""))
                            {
                                newsInfo.description = info.Author.Replace("#VIPNAME#", vipInfo.VipName);
                            }
                            else
                            {
                                newsInfo.description = info.Author;
                            }

                            newsInfo.description = newsInfo.description.Replace("#PERSONCOUNT#", Convert.ToString(eventPersonCount));
                            //string url = info.OriginalUrl;
                            //JIT.Utility.Log.Loggers.Debug(new DebugLogInfo()
                            //{
                            //    Message = string.Format("处理原文链接出错:{0},url:{1};Status:{2};",)
                            //});
                            if (info.OriginalUrl != null && !info.OriginalUrl.Equals("") && vipInfo.Status != null && !vipInfo.Status.ToString().Equals(""))
                            {
                                if (vipInfo.Status.Equals(1) && info.OriginalUrl.IndexOf("Fuxing") > 0)
                                {
                                    newsInfo.description = info.Text;
                                }
                                else
                                {
                                }
                            }

                            if (info.OriginalUrl.IndexOf("?") > 0)
                            {
                                newsInfo.url = info.OriginalUrl + "&rnd=" + rad.Next(1000, 100000) + "";
                            }
                            else
                            {
                                string goUrl = info.OriginalUrl + "?1=1&applicationId=" + wxInfo.ApplicationId + "&eventId=" + eventInfo.EventID + "&openId=" + OpenId + "&userId=" + VipId + "";
                                goUrl = HttpUtility.UrlEncode(goUrl);

                                newsInfo.url = AuthUrl + "OnlineClothing/go.htm?customerId=" + this.CurrentUserInfo.CurrentUser.customer_id
                                               + "&applicationId=" + wxInfo.ApplicationId
                                               + "&openId=" + OpenId
                                               + "&userId=" + VipId
                                               + "&backUrl=" + goUrl + "";
                            }
                            //OnlineClothing/go.htm?customerId=" + customerId + "&openId=" + OpenId + "&userId=" + vipId + "&backUrl=" + HttpUtility.UrlEncode(goUrl) + "";
                            newsInfo.picurl = info.CoverImageUrl;
                            newsList.Add(newsInfo);
                        }
                        sendMessageInfo.articles = newsList;
                        #endregion
                        #region 发送日志

                        MarketSendLogEntity logInfo1 = new MarketSendLogEntity();
                        logInfo1.LogId         = BaseService.NewGuidPub();
                        logInfo1.IsSuccess     = 1;
                        logInfo1.MarketEventId = eventInfo.EventID;
                        logInfo1.SendTypeId    = "2";
                        logInfo1.Phone         = iRad.ToString();
                        if (sendMessageInfo.ToJSON().ToString().Length > 2000)
                        {
                            logInfo1.TemplateContent = sendMessageInfo.ToJSON().ToString().Substring(1, 1999);
                        }
                        else
                        {
                            logInfo1.TemplateContent = sendMessageInfo.ToJSON().ToString();
                        }
                        logInfo1.VipId        = VipId;
                        logInfo1.WeiXinUserId = OpenId;
                        logInfo1.CreateTime   = System.DateTime.Now;
                        logServer.Create(logInfo1);
                        #endregion
                    }

                    var ResultEntity = server.SendMessage(sendMessageInfo, wxInfo.AppID, wxInfo.AppSecret, this.CurrentUserInfo, true);


                    #region Jermyn20140110 处理复星年会的座位信息,是临时的
                    //FStaffBLL staffServer = new FStaffBLL(this.CurrentUserInfo);
                    //bool bReturn = staffServer.SetStaffSeatsPush(VipId, eventInfo.EventID, out strError);
                    //MarketSendLogEntity logInfo2 = new MarketSendLogEntity();
                    //logInfo2.LogId = BaseService.NewGuidPub();
                    //logInfo2.IsSuccess = 1;
                    //logInfo2.MarketEventId = eventInfo.EventID;
                    //logInfo2.SendTypeId = "2";
                    //logInfo2.TemplateContent = strError;
                    //logInfo2.Phone = iRad.ToString();
                    //logInfo2.VipId = VipId;
                    //logInfo2.WeiXinUserId = OpenId;
                    //logInfo2.CreateTime = System.DateTime.Now;
                    //logServer.Create(logInfo2);

                    #endregion
                    strError = "ok";
                    return(true);
                }
            }
            catch (Exception ex) {
                strError = ex.ToString();
                return(false);
            }
        }
        /// <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() + "+");
            }
        }
示例#7
0
        /// <summary>
        /// 创建潜在分经销商
        /// </summary>
        /// <param name="loggingSessionInfo">loggingSessionInfo</param>
        /// <param name="vip_no">vip_no</param>
        public void CreatePrepRetailTrader(LoggingSessionInfo loggingSessionInfo, string vip_no)
        {
            VipEntity       vipEntity       = new VipBLL(loggingSessionInfo).GetVipDetailByVipID(vip_no);
            RetailTraderDAO retailTraderDao = new RetailTraderDAO(loggingSessionInfo);

            if (vipEntity == null || string.IsNullOrWhiteSpace(vipEntity.Col20))
            {
                return;
            }

            /// 判断当前vip会员手机号是否存在经销记录
            var entiryList = this.QueryByEntity(new RetailTraderEntity()
            {
                RetailTraderLogin = vipEntity.Phone
            }, null);

            if (entiryList != null && entiryList.Length > 0)
            {
                return;
            }

            t_unitEntity unitEntity = new t_unitBLL(loggingSessionInfo).GetMainUnit(loggingSessionInfo.ClientID);

            int RetailTraderCode = getMaxRetailTraderCode(loggingSessionInfo.ClientID);

            RetailTraderEntity pEntity = new RetailTraderEntity();

            pEntity.RetailTraderID      = Guid.NewGuid().ToString();
            pEntity.RetailTraderType    = "MultiLevelSaler";
            pEntity.RetailTraderCode    = RetailTraderCode + 1;
            pEntity.RetailTraderName    = vipEntity.VipName;
            pEntity.RetailTraderLogin   = vipEntity.Phone;
            pEntity.RetailTraderPass    = MD5Helper.Encryption("888888");
            pEntity.SalesType           = "";
            pEntity.RetailTraderMan     = "";
            pEntity.RetailTraderPhone   = vipEntity.Phone;
            pEntity.RetailTraderAddress = "";
            pEntity.CooperateType       = "";
            pEntity.SellUserID          = "";
            pEntity.UnitID = unitEntity.unit_id;

            pEntity.MultiLevelSalerFromVipId = vip_no;
            if (!string.IsNullOrEmpty(vipEntity.Col20))
            {
                pEntity.HigheRetailTraderID = vipEntity.Col20;
            }
            pEntity.CreateTime     = DateTime.Now;;
            pEntity.CreateBy       = "sys";
            pEntity.LastUpdateBy   = "sys";
            pEntity.LastUpdateTime = DateTime.Now;
            pEntity.IsDelete       = 0;
            pEntity.CustomerId     = loggingSessionInfo.ClientID;
            pEntity.Status         = "2";
            retailTraderDao.Create(pEntity);
            this.Create2Ap(pEntity);//ap库里的RetailTraderID和商户里的RetailTraderID是一样的

            new ObjectImagesBLL(loggingSessionInfo).SaveRetailTraderHeadImg(vipEntity, pEntity);

            // todo
            CommonBLL commonBll = new CommonBLL();
            string    content   = "您的帐号:" + pEntity.RetailTraderLogin + ",密码:888888,已经在连锁掌柜注册成功,请在地址http://app.chainclouds.com/download/chengguo/下载一起发码APP,早下载早成为经销商赚钱";

            JIT.CPOS.BS.Entity.WX.SendMessageEntity messageEntity = new JIT.CPOS.BS.Entity.WX.SendMessageEntity();
            messageEntity.content = content;
            messageEntity.touser  = vipEntity.WeiXinUserId;
            messageEntity.msgtype = "text";
            WApplicationInterfaceEntity[] wApplicationInterfaceEntities = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity {
                CustomerId = loggingSessionInfo.ClientID
            }, null);
            commonBll.SendMessage(messageEntity, wApplicationInterfaceEntities[0].AppID, wApplicationInterfaceEntities[0].AppSecret, loggingSessionInfo);
        }
示例#8
0
        public SuccessResponse <IAPIResponseData> VipConsume(APIRequest <VipConsumeRP> rp)
        {
            var cardDepositBLL            = new CardDepositBLL(CurrentUserInfo);
            var registerValidationCodeBLL = new RegisterValidationCodeBLL(CurrentUserInfo);
            var vipBLL = new VipBLL(CurrentUserInfo);
            var rd     = new EmptyRD();
            var rsp    = new SuccessResponse <IAPIResponseData>(rd);

            string phone = "";

            var vip = vipBLL.Query(new IWhereCondition[] { new EqualsCondition()
                                                           {
                                                               FieldName = "VipID", Value = rp.Parameters.VipID
                                                           } }, null);

            if (vip.Length > 0)
            {
                phone = vip[0].Phone;

                if (string.IsNullOrEmpty(phone))
                {
                    rsp.ResultCode = 202;
                    rsp.Message    = "会员未注册手机号!";
                }
                else if (string.IsNullOrEmpty(rp.Parameters.SMSCode))
                {
                    //发送验证码
                    registerValidationCodeBLL.SendCode(phone);
                }
                else
                {
                    //验证验证码
                    var codeEntity = registerValidationCodeBLL.Query(new IWhereCondition[] {
                        new EqualsCondition()
                        {
                            FieldName = "Mobile", Value = phone
                        }
                        , new EqualsCondition()
                        {
                            FieldName = "Code", Value = rp.Parameters.SMSCode
                        }
                        , new EqualsCondition()
                        {
                            FieldName = "IsValidated", Value = 0
                        }
                        , new EqualsCondition()
                        {
                            FieldName = "IsDelete", Value = 0
                        }
                    }, new OrderBy[] {
                        new OrderBy()
                        {
                            FieldName = "CreateTime", Direction = OrderByDirections.Desc
                        }
                    });

                    if (codeEntity != null && codeEntity.Length > 0)
                    {
                        System.Data.SqlClient.SqlTransaction tran = GetTran();
                        using (tran.Connection)
                        {
                            registerValidationCodeBLL.DeleteByMobile(phone, 1, tran);

                            string       errorMessage = "";
                            VipAmountBLL vipAmountBLL = new VipAmountBLL(CurrentUserInfo);
                            vipAmountBLL.SetVipAmountChange(CurrentUserInfo.ClientID, 5, rp.Parameters.VipID, rp.Parameters.Amount, CurrentUserInfo.CurrentUserRole.UnitId, "Prepaid card consumption" + "~" + (rp.Parameters.DocumentCode ?? ""), "Out", out errorMessage, tran);

                            tran.Commit();
                        }
                    }
                    else
                    {
                        rsp.ResultCode = 203;
                        rsp.Message    = "请先获取验证码!";
                    }
                }
            }
            else
            {
                rsp.ResultCode = 201;
                rsp.Message    = "会员不存在!";
            }

            return(rsp);
        }
示例#9
0
        /// <summary>
        /// 发送微信消息
        /// </summary>
        /// <param name="VipId">用户标识</param>
        /// <param name="EventId">活动标识</param>
        /// <param name="strError">错误提示</param>
        /// <returns></returns>
        public bool SetEventVipSeatPush(string VipId, string EventId, out string strError)
        {
            strError = "成功.";
            #region //1.判断用户是否关注过活动
            WEventUserMappingBLL eventServer = new WEventUserMappingBLL(this.CurrentUserInfo);
            var eventList = eventServer.QueryByEntity(new WEventUserMappingEntity
            {
                UserID = VipId
                ,
                IsDelete = 0
                ,
                EventID = EventId
            }, null);
            if (eventList == null || eventList.Length == 0)
            {
                #region
                WEventUserMappingEntity eventUserMappingInfo = new WEventUserMappingEntity();
                eventUserMappingInfo.Mapping = Common.Utils.NewGuid();
                eventUserMappingInfo.EventID = EventId;
                eventUserMappingInfo.UserID  = VipId;
                eventServer.Create(eventUserMappingInfo);
                #endregion
            }
            #endregion

            #region //2.判断用户是否注册
            VipBLL    vipServer = new VipBLL(this.CurrentUserInfo);
            VipEntity vipInfo   = new VipEntity();
            vipInfo = vipServer.GetByID(VipId);
            if (vipInfo == null || vipInfo.VIPID.Equals(""))
            {
                strError = "用户不存在";
                return(false);
            }
            #endregion
            else
            {
                #region
                EventVipEntity eventVipInfo = new EventVipEntity();
                var            eventVipList = _currentDAO.QueryByEntity(new EventVipEntity
                {
                    Phone = vipInfo.Phone
                    ,
                    IsDelete = 0
                }, null);
                if (eventVipList == null || eventVipList.Length == 0)
                {
                    strError = "没有合适的员工.";
                    return(false);
                }
                else
                {
                    eventVipInfo = eventVipList[0];
                }
                #endregion

                LEventsEntity lEventsEntity = new LEventsEntity();
                lEventsEntity = new LEventsBLL(this.CurrentUserInfo).GetByID(EventId);

                //string message = "尊贵的" + eventVipInfo.VipName + "先生/女士:\r\n 诚挚地欢迎您参加复星集团2014年全球工作会议,本次会议将于8:30正式开始。请您至5楼静安大宴会厅" + eventVipInfo.Seat + "区域就坐,或参见胸卡背面提示.";

                string message = new WMaterialWritingBLL(this.CurrentUserInfo).GetWMaterialWritingByModelId(EventId).Content;
                message = ReplaceTemplate(message, eventVipList[0], vipInfo, lEventsEntity);

                //组织消息
                string code = JIT.CPOS.BS.BLL.WX.CommonBLL.SendWeixinMessage(message, VipId, this.CurrentUserInfo, vipInfo);
                switch (code)
                {
                case "103":
                    strError = "未查询到匹配的公众账号信息";
                    break;

                case "203":
                    strError = "发送失败";
                    break;

                default:
                    break;
                }
            }
            return(true);
        }