Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="PointType">1-充值 2-消费</param>
        /// <param name="OrderTotalAmount"></param>
        /// <param name="Title"></param>
        /// <param name="Summary"></param>
        /// <param name="CategoryType">1-积分购买消费 2-购买商品赠与 3-积分购买退货返回 4-购买商品退货扣除 5-充值赠与 6-消费赠与</param>
        /// <param name="AddUserName"></param>
        /// <param name="PointStatus">0-未入账 1-已入账</param>
        /// <param name="TradeNo"></param>
        /// <param name="OrderID"></param>
        /// <param name="PointValue"></param>
        /// <param name="RelatedID"></param>
        public static void Insert_Mall_UserJiXiaoPoint(int UserID, int PointType, decimal OrderTotalAmount, string Title, string Summary, int CategoryType, string AddUserName, int PointStatus, SqlHelper helper, string TradeNo = "", int OrderID = 0, int FixedPointMonth = 0, DateTime?FixedPointDateTime = null, int PointValue = 0, int RelatedID = 0, int AmountRuleID = 0, int RuleID = 0, int InfoID = 0, string InfoName = "", string CategoryName = "", int EarnType = 0, string ApproveUserName = "", DateTime?ApproveTime = null, string ApproveRemark = "", string Remark = "", decimal BeforePointValue = 0)
        {
            if (UserID <= 0)
            {
                return;
            }
            var data = new Mall_UserJiXiaoPoint();

            data.UserID          = UserID;
            data.PointType       = PointType;
            data.PointValue      = PointValue;
            data.Title           = Title;
            data.Summary         = Summary;
            data.CategoryType    = CategoryType;
            data.AddUserName     = AddUserName;
            data.PointStatus     = PointStatus;
            data.AddTime         = DateTime.Now;
            data.TradeNo         = TradeNo;
            data.RelatedID       = RelatedID;
            data.AmountRuleID    = AmountRuleID;
            data.FixedPointMonth = FixedPointMonth > 0 ? FixedPointMonth : DateTime.Now.Month;
            if (FixedPointDateTime.HasValue)
            {
                DateTime _FixedPointDateTime = Convert.ToDateTime(FixedPointDateTime);
                data.FixedPointDateTime = _FixedPointDateTime > DateTime.MinValue ? _FixedPointDateTime : DateTime.Now;
            }
            data.InfoID          = InfoID;
            data.InfoName        = InfoName;
            data.CategoryName    = CategoryName;
            data.EarnType        = EarnType;
            data.ApproveUserName = ApproveUserName;
            if (ApproveTime.HasValue)
            {
                data.ApproveTime = Convert.ToDateTime(ApproveTime);
            }
            data.ApproveRemark = ApproveRemark;
            data.Remark        = Remark;
            Mall_PointCovertRecord record = null;

            if (data.EarnType == 2)
            {
                record                 = new Mall_PointCovertRecord();
                record.UserID          = data.UserID;
                record.PointValue      = (int)BeforePointValue;
                record.CheckPointValue = data.PointValue;
                record.PointRuleID     = data.RelatedID;
                record.Status          = 2;
                record.AddTime         = DateTime.Now;
                record.AddUserName     = data.AddUserName;
            }
            Mall_PointWithDrawRecord withdrawrecord = null;

            if (data.EarnType == 3)
            {
                withdrawrecord             = new Mall_PointWithDrawRecord();
                withdrawrecord.UserID      = data.UserID;
                withdrawrecord.PointValue  = data.PointValue;
                withdrawrecord.Status      = 2;
                withdrawrecord.AddTime     = DateTime.Now;
                withdrawrecord.AddUserName = data.AddUserName;
            }
            data.Save(helper);
            if (record != null)
            {
                //积分兑换扣除
                var userPoint = Mall_UserPoint.Insert_Mall_UserPoint(data.UserID, 2, 0, "积分兑换扣除", "Mall_PointCovertRecordID:" + record.ID, 8, data.AddUserName, 1, "", 0, helper, PointValue: -record.PointValue, RelatedID: record.ID);
                record.Mall_UserPointID       = userPoint.ID;
                record.Mall_UserJiXiaoPointID = data.ID;
                record.Save(helper);
                data.PointStatus  = 0;
                data.CategoryType = 3;
                data.RelatedID    = record.ID;
            }
            if (withdrawrecord != null)
            {
                withdrawrecord.Mall_UserJiXiaoPointID = data.ID;
                withdrawrecord.Save(helper);
                data.PointStatus  = 1;
                data.CategoryType = 4;
                data.RelatedID    = withdrawrecord.ID;
            }
            data.Save(helper);
        }