internal Member_channel_rebatelog GetRebateIncomelog(int proid)
        {
            string sql = "select * from Member_channel_rebatelog where proid=" + proid + " and payment=1";
            var    cmd = sqlHelper.PrepareTextSqlCommand(sql);

            using (var reader = cmd.ExecuteReader())
            {
                Member_channel_rebatelog m = null;
                if (reader.Read())
                {
                    m = new Member_channel_rebatelog
                    {
                        id           = reader.GetValue <int>("id"),
                        channelid    = reader.GetValue <int>("channelid"),
                        orderid      = reader.GetValue <int>("orderid"),
                        ordermoney   = reader.GetValue <decimal>("ordermoney"),
                        over_money   = reader.GetValue <decimal>("over_money"),
                        rebatemoney  = reader.GetValue <decimal>("rebatemoney"),
                        payment      = reader.GetValue <int>("payment"),
                        payment_type = reader.GetValue <string>("payment_type"),
                        proid        = reader.GetValue <string>("proid"),
                        proname      = reader.GetValue <string>("proname"),
                        subdatetime  = reader.GetValue <DateTime>("subdatetime"),
                        comid        = reader.GetValue <int>("comid"),
                    };
                }
                return(m);
            }
        }
 public int Editrebatelog(Member_channel_rebatelog rebatelog)
 {
     using (var helper = new SqlHelper())
     {
         int r = new InternalMember_channel_rebatelog(helper).Editrebatelog(rebatelog);
         return(r);
     }
 }
        internal int Editrebatelog(Member_channel_rebatelog m)
        {
            if (m.id == 0)
            {
                string sql = @"INSERT INTO  [Member_channel_rebatelog]
                               ([subdatetime]
                               ,[orderid]
                               ,[proid]
                               ,[proname]
                               ,[ordermoney]
                               ,[rebatemoney]
                               ,[over_money]
                               ,[channelid]
                              
                               ,[payment]
                               ,[payment_type]
                               ,comid)
                         VALUES
                               (@subdatetime 
                               ,@orderid 
                               ,@proid
                               ,@proname 
                               ,@ordermoney 
                               ,@rebatemoney 
                               ,@over_money 
                               ,@channelid  
                               ,@payment 
                               ,@payment_type
                               ,@comid);select @@identity;";
                var    cmd = sqlHelper.PrepareTextSqlCommand(sql);
                cmd.AddParam("@subdatetime", m.subdatetime);
                cmd.AddParam("@orderid", m.orderid);
                cmd.AddParam("@proid", m.proid);
                cmd.AddParam("@proname", m.proname);
                cmd.AddParam("@ordermoney", m.ordermoney);
                cmd.AddParam("@rebatemoney", m.rebatemoney);
                cmd.AddParam("@over_money", m.over_money);
                cmd.AddParam("@channelid", m.channelid);
                cmd.AddParam("@payment", m.payment);
                cmd.AddParam("@payment_type", m.payment_type);
                cmd.AddParam("@comid", m.comid);

                object o = cmd.ExecuteScalar();
                return(int.Parse(o.ToString()));
            }
            else
            {
                string sql = @"UPDATE  [Member_channel_rebatelog]
                           SET [subdatetime] = @subdatetime 
                              ,[orderid] = @orderid 
                              ,[proid] = @proid 
                              ,[proname] = @proname 
                              ,[ordermoney] = @ordermoney 
                              ,[rebatemoney] = @rebatemoney 
                              ,[over_money] = @over_money 
                              ,[channelid] = @channelid 
                              ,[payment] = @payment 
                              ,[payment_type] = @payment_type 
                              ,comid=@comid
                         WHERE id=@id";
                var    cmd = sqlHelper.PrepareTextSqlCommand(sql);
                cmd.AddParam("@id", m.id);
                cmd.AddParam("@subdatetime", m.subdatetime);
                cmd.AddParam("@orderid", m.orderid);
                cmd.AddParam("@proid", m.proid);
                cmd.AddParam("@proname", m.proname);
                cmd.AddParam("@ordermoney", m.ordermoney);
                cmd.AddParam("@rebatemoney", m.rebatemoney);
                cmd.AddParam("@over_money", m.over_money);
                cmd.AddParam("@channelid", m.channelid);
                cmd.AddParam("@payment", m.payment);
                cmd.AddParam("@payment_type", m.payment_type);
                cmd.AddParam("@comid", m.comid);

                cmd.ExecuteNonQuery();
                return(m.id);
            }
        }
Exemple #4
0
        public static string Channelapplyrebate(int channelid, string applytype, string applydetail, decimal applymoney, int comid)
        {
            Member_Channel m = new MemberChannelData().GetChannelDetail(channelid);

            if (m != null)
            {
                decimal rebatemoney = m.Rebatemoney;
                if (rebatemoney < applymoney)
                {
                    return(JsonConvert.SerializeObject(new { type = 1, msg = "提现金额不可大于账户余额" }));
                }

                Member_channel_rebateApplylog applylog = new Member_channel_rebateApplylog
                {
                    id          = 0,
                    applytime   = DateTime.Now,
                    applytype   = applytype,
                    applydetail = applydetail,
                    applymoney  = applymoney,
                    channelid   = channelid,
                    operstatus  = 0,
                    comid       = comid
                };
                int r = new Member_channel_rebateApplylogData().Insrebateapplylog(applylog);
                if (r > 0)
                {
                    ////账户提现,返佣表和 渠道表变动

                    //获得渠道人的返佣余额
                    decimal channelrebatemoney = new Member_channel_rebatelogData().Getrebatemoney(channelid);
                    //返佣记录
                    Member_channel_rebatelog rebatelog = new Member_channel_rebatelog
                    {
                        id           = 0,
                        channelid    = channelid,
                        orderid      = 0,
                        payment      = 2,
                        payment_type = "返佣提现",
                        proid        = "0",
                        proname      = applytype + "-" + applydetail,
                        subdatetime  = DateTime.Now,
                        ordermoney   = 0,
                        rebatemoney  = -applymoney,
                        over_money   = decimal.Round(channelrebatemoney - applymoney, 2),
                        comid        = comid
                    };
                    //增加返佣记录 同时增加渠道人的返佣金额
                    new Member_channel_rebatelogData().Editrebatelog(rebatelog);
                    new Member_channel_rebatelogData().Editchannelrebate(rebatelog.channelid, rebatelog.over_money);


                    return(JsonConvert.SerializeObject(new { type = 100, msg = "成功" }));
                }
                else
                {
                    return(JsonConvert.SerializeObject(new { type = 1, msg = "意外错误" }));
                }
            }
            else
            {
                return(JsonConvert.SerializeObject(new { type = 1, msg = "意外错误" }));
            }
        }