Пример #1
0
 public JsonResult PublishBiao(PublishBiaoPostModel model)
 {
     var result = new PublishBiaoPostResult();
     using (var db = DbContextFactory.CreateDbContext())
     {
         Xiake xiake;
         TokenXCodeValidation.Validate(model, db, out xiake);
         var dianpu = db.Dianpus.FirstOrDefault(a => a.Id == model.DianpuID);
         var biao = new Biao()
         {
             CreateTime = DateTime.Now,
             UpdatedTime = DateTime.Now,
             Details = model.Details,
             GoodsId = model.GoodsID,
             IsSaleOver = false,
             PlanCount = model.PlanCount,
             PlanTime = model.StartDate,
             Price = model.Price,
             Dianpu = dianpu,
             Zhanggui = xiake,
             RealCount = 0,
             Sku = model.Sku,
             SearchWord = model.SearchWords,
             Salary = model.Salary,
             YqBindPhone = model.YqBindPhone,
             YqBindSfz = model.YqBindSfz,
             YqManualCheck = model.YqManualCheck,
             YqMonthCount = model.YqMonthCount,
             YqRegisterDate = model.YqRegisterDate,
             YqUserLevel = model.YqUserLevel,
             YqWeekCount = model.YqWeekCount
         };
         db.Biaos.Add(biao);
         db.SaveChanges();
         result.ID = biao.Id;
     }
     return new JsonResult() { Data = result };
 }
Пример #2
0
        public long PublishBiao (long dianpuId, string goodsId, int price, int planCount, string searchWords, int salary, string sku, string details, bool yqBindSfz, bool yqBindPhone, bool yqCheckRegDate, DateTime yqRegisterDate, bool yqManualCheck, int yqWeekCount, int yqMonthCount, int yqUserLevel, string runningModelData,
            AllowXiakeType allowXiakeType, int maxFinishDaysForOldCustomer, bool rejectOneBiaoju)
        {
            using(var db = DbContextFactory.CreateDbContext())
            { 
                var xiake = db.Xiakes.Include(a=>a.Credits).Include(a=>a.Dianpus).FirstOrDefault(a => a.XiakeName == System.Threading.Thread.CurrentPrincipal.Identity.Name);
                if(xiake.UserType != XiakeType.Zhanggui)
                    throw new FaultException("非掌柜不可以发镖");
                var dianpu = xiake.Dianpus.FirstOrDefault(a => a.Id == dianpuId );
                var settings = ConfigSettings.GetConfigSettings(  db.Settingses.FirstOrDefault().ConfigData) ;
                 
                var spend = settings.CreditsPolicySet.CreditsSpendDatas.Count>0?   settings.CreditsPolicySet.CreditsSpendDatas.FirstOrDefault(  a => a.Bangpai == dianpu.Bangpai && price >= a.Begin && price < a.End).Spend * planCount:0;
                var crerv = xiake.Credits.FreeCredits - spend;
                if(crerv <0)
                    throw new FaultException("您的帐户余额不足,请调整数量或充值后继续。");
                xiake.Credits.FreeCredits = crerv;

                var biao = new Biao()
                {  
                    Bangpai = dianpu.Bangpai,
                    Details =details ,
                    GoodsId = goodsId ,
                    IsSaleOver = false,
                    PlanCount = planCount , 
                    Price = price ,
                    Dianpu = dianpu,
                    Zhanggui = xiake,
                    RealCount = 0,
                    Sku = sku ,
                    SearchWord = searchWords,
                    Salary = salary,
                    YqBindPhone = yqBindPhone,
                    YqBindSfz = yqBindSfz,
                    YqManualCheck = yqManualCheck,
                    YqMonthCount = yqMonthCount,
                    YqRegisterDate = yqRegisterDate,
                    YqUserLevel = yqUserLevel,
                    YqWeekCount = yqWeekCount,
                    YqCheckRegDate = yqCheckRegDate,
                    Steps = runningModelData,
                    IsEnable = true,
                    SpendCredits = spend,  
                    AllowXiakeType=  allowXiakeType,
                    MaxFinishDaysForOldCustomer = maxFinishDaysForOldCustomer,
                    RejectOneBiaoju = rejectOneBiaoju,
                    
                };
                db.Biaos.Add(biao);
                try
                {
                     db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException )
                {
                    return PublishBiao(dianpuId, goodsId, price, planCount, searchWords, salary, sku, details, yqBindSfz,
                        yqBindPhone, yqCheckRegDate, yqRegisterDate, yqManualCheck, yqWeekCount, yqMonthCount, yqUserLevel,
                        runningModelData, allowXiakeType, maxFinishDaysForOldCustomer, rejectOneBiaoju); 
                }
               
                mWcfMasterServiceProxy.PushCreditsChangeMessage(xiake.Id, xiake.Credits.FreeCredits, xiake.Credits.FreezeCredits);
                OnlineXiakeManager.SendBiaoAsync(new BiaoData()
                { 
                    ID = biao.Id ,
                    Price = biao.Price,
                    BangpaiType = biao.Bangpai , 
                    SearchWord = biao.SearchWord, 
                    CreateTime = biao.CreateTime,
                    Salary = biao.Salary,
                    IsSaleOver = biao.IsSaleOver,
                    YqBindSfz = biao.YqBindSfz,
                    YqBindPhone = biao.YqBindPhone,
                    YqManualCheck = biao.YqManualCheck,
                    YqMonthCount = biao.YqMonthCount,
                    YqRegisterDate = biao.YqRegisterDate,
                    YqUserLevel = biao.YqUserLevel,
                    YqWeekCount = biao.YqWeekCount,
                    Details = biao.Details,
                    IsEnable = biao.IsEnable,
                    Running = biao.Running,
                    Finished = biao.Finished,
                    Steps = biao.Steps
                });

                return biao.Id;
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("准备创建模拟数据,请先删除原始数据库,回车后继续...");
            Console.ReadLine();
            var db = DbContextFactory.CreateDbContext();

            #region 创建管理员帐号
            Console.WriteLine("请输入管理员帐号名称");
            var adminName = Console.ReadLine().Trim();
            var u_admin = new Xiake()
            { 
                Credits = new XiakeCredits(),
                IsAuthorized = true,
                IsFrozen = false,
                XiakeName = adminName,
                Password = "******",
                UserType = XiakeType.Mengzhu,
                Status = XiakeStatus.Enabled,
                QQ = "12345",
                Mail = "*****@*****.**",
                Tel = "18686225002",
                LastLoginTime = DateTime.Now
            };
            db.Xiakes.Add(u_admin);
            var inte = new InviteStorage() {Credits = 0, Xiake = u_admin};
            db.InviteStorages.Add(inte);
            Console.WriteLine("管理员帐号:admin password: ok1234 ");
            #endregion
            #region 创建服务器列表
            {
                Console.WriteLine("请输入服务器URL (net.tcp://xxx:1981/)");
                var url = Console.ReadLine();
                if(string.IsNullOrEmpty(url))
                    url = "net.tcp://*****:*****@qq.com",
                    Tel = "18686225003",
                    LastLoginTime = DateTime.Now 
                };
                db.Xiakes.Add(u_shop);
                var inte2 = new InviteStorage() {Credits = 0, Xiake = u_shop};
                db.InviteStorages.Add(inte2);
                Console.WriteLine("店铺帐号: shop1 , ok1234");
                #endregion
                #region 创建店铺
    {
                
                    //创建三个店铺
                    db.Dianpus.Add(new Dianpu()
                    { 
                        Bangpai= BangpaiType.Taobao,
                        Name="江山水货店",
                        Url="http://js.taobao.com",
                        Zhanggui= u_shop
                    });
                    db.Dianpus.Add(new Dianpu()
                    { 
                        Bangpai = BangpaiType.Taobao,
                        Name = "丽水山货店",
                        Url = "http://ls.taobao.com",
                        Zhanggui = u_shop
                    });
                    db.Dianpus.Add(new Dianpu()
                    {  
                        Bangpai = BangpaiType.Taobao,
                        Name = "温州水货店",
                        Url = "http://wz.taobao.com",
                        Zhanggui = u_shop
                    });
                }
                #endregion
                #region 创建一个刷手帐号
                var u_customer = new Xiake()
                { 
                    Credits = new XiakeCredits(),
                    IsAuthorized = true,
                    IsFrozen = false,
                    XiakeName = "customer",
                    Password = "******",
                    UserType = XiakeType.Biaoju,
                    Status = XiakeStatus.Enabled,
                    QQ = "123456",
                    Mail = "*****@*****.**",
                    Tel = "18686225003",
                    LastLoginTime = DateTime.Now 
              
                };
            
                    db.Xiakes.Add(u_customer);
                    var inte3 = new InviteStorage() { Credits = 0, Xiake = u_customer };
                    db.InviteStorages.Add(inte3);
                Console.WriteLine("刷手: custmoer , ok1234");
            
                #endregion
                #region 创建镖
                var appBiao = new Biao();
                {
                
                    var rundata = string.Format("{0}@{1:D}=1;{2:D}=2;{3:D}=3", "刷单", JubenType.TaobaoCollect , JubenType.TaobaoBuy, JubenType.TaobaoPay);
                    for(var i = 0; i < 120; i++)
                    {
                        var biao = new Biao()
                        {
                            Dianpu = u_shop.Dianpus.First(), 
                            GoodsId = "ASDFASDF321234ASDf",
                            PlanCount = 10,
                            Price = 10,
                            RealCount = 0,
                            Zhanggui = u_shop,
                         
                            Salary = 3,
                            SearchWord= "男 内衣 " + i.ToString(), 
                            Sku = "XL;红色",
                            YqBindPhone = true ,
                            YqBindSfz = false,
                            YqManualCheck = false,
                            YqMonthCount = 10,
                            YqRegisterDate= DateTime.Now,
                            YqUserLevel = 200,
                            YqWeekCount = 5,
                            Steps = rundata,
                            IsEnable = true,
                            Bangpai  = BangpaiType.Taobao,
                            AllowXiakeType = AllowXiakeType.Both
                        };
                        db.Biaos.Add(biao);
                        appBiao = biao;
                    }
                 
                }
                #endregion
                #region 创建镖师
                Biaoshi BS = null;
                {
                
                    for(var i = 0; i < 5; i++)
                    {
                         var biaoshi = new Biaoshi()
                        {
                            Biaoju = u_customer, 
                            Bangpai = BangpaiType.Taobao,
                            Title = "Hai" + i.ToString()
                        };
                        db.Biaoshis.Add(biaoshi);
                        BS = biaoshi;
                    } 
                }
                #endregion
            
                #region 创建帮助
                {
                    var trf = @"{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset134 \'ce\'a2\'c8\'ed\'d1\'c5\'ba\'da;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\cf0 \cf0\ql{\f2 {\ltrch sdfasdfsd}\li0\ri0\sa0\sb0\fi0\ql\par}  }  }";
                    var help1 = new Help()
                    {
                        Group = "帐户",
                        SortNum = 0,
                        Title = "怎么注册帐号?", 
                        UpdatedTime= DateTime.Now,
                        RtfData = trf  };
                    db.Helps.Add(help1);
               
                    var help2 = new Help()
                    {
                        Group = "帐户",
                        SortNum = 0,
                        Title = "我为什么不能注册帐号?",
                        UpdatedTime = DateTime.Now,
                        RtfData = trf
                    };
                    db.Helps.Add(help2);
                    var help3 = new Help()
                    {
                        Group = "刷单",
                        SortNum = 0,
                        Title = "我要怎么样才可以刷单?",
                        UpdatedTime = DateTime.Now,
                        RtfData = trf
                    };
                    db.Helps.Add(help3);

                    var help4 = new Help()
                    {
                        Group = "刷单",
                        SortNum = 0,
                        Title = "刷单要钱吗?",
                        UpdatedTime = DateTime.Now,
                        RtfData = trf
                    };
                    db.Helps.Add(help4);

                }

                #endregion

                #region 创建公告
                {
                    var trf = @"{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset134 \'ce\'a2\'c8\'ed\'d1\'c5\'ba\'da;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\cf0 \cf0\ql{\f2 {\ltrch welcome!}\li0\ri0\sa0\sb0\fi0\ql\par}  }  }";
                    var gg = new Gonggao() {    RtfData = trf};
                    db.Gonggaos.Add(gg);
                }
                #endregion

                #region 创建任务
                {
                    var biaos = u_shop.Biaos.ToArray();


                    for(var i = 0; i < 100; i++)
                    {
                        var biao = biaos[RandomObj.Next(0, biaos.Length)];
                        var rw = new Renwu()
                        {
                            Biao = biao ,
                            Biaoju = u_customer,
                            Biaoshi = u_customer.Biaoshis.First(), 
                            RunTime = DateTime.Now.AddMinutes(2) ,
                            NextStep= JubenType.TaobaoCollect,
                            Steps = "刷单@2=0;1=1;3=0;",
                            Bangpai = biao.Bangpai 
                        };
                        db.Renwus.Add(rw);
                    }
                }
                #endregion
                #region 创建定单
                {
                    for(var i = 0; i < 200; i++)
                    {
                        var biaoshi = u_customer.Biaoshis.First();
                        var dan = new Dingdan()
                        {
                            BiaojuMarkInfo = "ok",
                            BiaojuMarkType = MarkType.Blue,
                            Biaoshi = biaoshi,
                            DateTime = DateTime.Now,
                            Dianpu = u_shop.Dianpus.First(),
                            Goods = "男士内衣" + i.ToString(),
                            Price = 32,
                            Salary = 5,
                            Bangpai = biaoshi.Bangpai
                        };
                        db.Dingdans.Add(dan);
                    }
                }
                #endregion
                #region 创建验证
                {
                    for (var i = 0; i < 5; i++)
                    {
                        var biao = appBiao;
                        var biaoshi = BS;

                        var val = new Validation()
                        {
                            Biao = biao,
                            Biaoshi = biaoshi, 
                            Details = "xxxxx xxx",
                            Zhanggui = biao.Zhanggui,

                        };
                        db.Validations.Add(val);
                    }

                }
                #endregion
                #region 创建付款
                for(var i = 0; i < 100; i++)
                {
                    var pay = new Pay()
                    {
                        Organization = "中国银行",
                        AccountTitle = "12341 2342 32323",
                        Account = "黄药帅" + i ,
                        Price = 32 + i,
                        Credits = 20 + i,
                        Xiake = u_shop
                    };
                    db.Pays.Add(pay);
                }
                #endregion

                #region 创建错误日志
            
                for(var i = 0; i < 10; i++)
                {

                    var log = new JubenErrorLog()
                    {
                        JubenType = JubenType.TaobaoBuy,
                        JubenErrorType = JubenErrorType.Exception,
                        Logs = "asdfsd, asdfa, asdfas",
                        Xiake = u_customer,
                        JubenName = "okokas" + i.ToString()
                    };
                    db.JubenErrorLogs.Add(log);
                }

                for (var i = 0; i < 80; i++)
                {

                    var log = new JubenErrorLog()
                    {
                        JubenType = JubenType.TaobaoGetGoods,
                        JubenErrorType = JubenErrorType.UnCorrect,
                        Logs = "asdfsd, asdfa, asdfas",
                        Xiake = u_shop,
                        JubenName = "ohaisdf as" + i.ToString()
                    };
                    db.JubenErrorLogs.Add(log);
                }

                #endregion 
            }
            
            db.SaveChanges();            
            Console.WriteLine("任务完成");
            Console.ReadLine();
            


        }