コード例 #1
0
ファイル: WcfPayService.cs プロジェクト: powerhai/Jinchen
        public PayData MakePay(int accountId, int projectId)
        {
            using (var db = DbContextFactory.CreateDbContext())
            {
                var xiake =
                    db.Xiakes.FirstOrDefault(a => a.XiakeName == System.Threading.Thread.CurrentPrincipal.Identity.Name);
                if (xiake.UserType != XiakeType.Zhanggui && xiake.UserType != XiakeType.Biaoju)
                    throw new FaultException("管理员不可以充值");

                var settings = db.Settingses.OrderByDescending(a => a.Id).FirstOrDefault();
                if (settings != null)
                {
                    var config = ConfigSettings.GetConfigSettings(settings.ConfigData);
                    var acc = config.ChargeSet.Accounts.FirstOrDefault(a => a.ID == accountId);
                    var pro = config.ChargeSet.Projects.FirstOrDefault(a => a.ID == projectId);
                    if (acc == null)
                        throw new FaultException("未有相关的帐户信息");
                    if (pro == null)
                        throw new FaultException("未有相关的充值项目");
                    var dict = db.PayDicts.FirstOrDefault(a => a.Price == pro.Price);

                    if(dict == null)
                    {
                        dict = new PayDict(){ Price = pro.Price, Num = 0 };
                        db.PayDicts.Add(dict);
                    } else
                    {
                        dict.Num += 1;
                        if(dict.Num > 1000)
                        {
                            dict.Num = 0;
                        }
                    }
                    double cre = (double)pro.Credits + ((double)pro.Credits / (double)pro.Price) * (double)dict.Num;

                    var pay = new Pay()
                    {
                        Xiake = xiake,
                        Account = acc.Account,
                        AccountTitle = acc.AccountTitle,
                        Organization = acc.Organization,
                        Price = pro.Price + dict.Num,
                        Credits = (int)cre ,
                        
                    };

                    db.Pays.Add(pay);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                      return  MakePay(accountId, projectId);
                        
                    } 
                    return new PayData()
                    {
                        Account = pay.Account ,
                        AccountTitle = pay.AccountTitle,
                        Credits = pay.Credits, 
                        Price = pay.Price, 
                        Organization = pay.Organization,
                        Id = pay.Id
                       
                    };
                } else
                {
                    throw new FaultException("服务器错误");
                }
            }

        }
コード例 #2
0
ファイル: Program.cs プロジェクト: powerhai/Jinchen
        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();
            


        }