Ejemplo n.º 1
0
 public async Task <DefaultEventHandlerResponse> ExpireCancelOrder(EventHandleRequest <OperateOrderSuccDto> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(ExpireCancelOrder), input.GetDataJson(), async() =>
     {
         var eventData = input.GetData();
         var order = await repository.GetAsync(eventData.OrderId);
         if (order == null)
         {
             throw new ApplicationServiceException($"没有找到订单");
         }
         var cancelOrderService = new CancelOrderService(UnDeductionGoodsStock);
         if (await cancelOrderService.Cancel(order))
         {
             repository.Update(order);
             var tradeLog = new TradeLog();
             tradeLog.CreateTradeLog(TradeLogState.CancelOrder, eventData.OrderId, order.OrderNo, null, null, Guid.Empty, null);
             tradeLogRepository.Add(tradeLog);
             await unitofWork.CommitAsync();
         }
     }));
 }
Ejemplo n.º 2
0
 public async Task <DefaultEventHandlerResponse> RecordTradeLogByOrderPay(EventHandleRequest <OperateOrderSuccDto> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(RecordTradeLogByOrderPay), input.GetDataJson(), async() =>
     {
         var eventData = input.GetData();
         var order = await repository.GetAsync(eventData.OrderId);
         if (order == null)
         {
             throw new ApplicationServiceException($"没有找到订单");
         }
         var tradeLog = new TradeLog();
         tradeLog.CreateTradeLog(TradeLogState.PayOrder, eventData.OrderId, order.OrderNo, null, null, eventData.UserId, eventData.UserName);
         tradeLogRepository.Add(tradeLog);
         await unitofWork.CommitAsync();
     }));
 }
Ejemplo n.º 3
0
 public async Task <DefaultEventHandlerResponse> RecordTradeLogByLogisticsReceiveSucc(EventHandleRequest <CreateLogisticsSuccDto> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(RecordTradeLogByOrderPay), input.GetDataJson(), async() =>
     {
         var eventData = input.GetData();
         var order = await repository.GetAsync(eventData.OrderId);
         if (order == null)
         {
             throw new ApplicationServiceException($"没有找到订单");
         }
         var log = await logisticsRepository.GetAsync(eventData.LogisticsId);
         if (log == null)
         {
             throw new ApplicationServiceException($"没有找到物流单");
         }
         var tradeLog = new TradeLog();
         tradeLog.CreateTradeLog(TradeLogState.ReceivingGoods, eventData.OrderId, order.OrderNo, log.Id, log.LogisticsNo, eventData.UserId, eventData.UserName);
         tradeLogRepository.Add(tradeLog);
         await unitofWork.CommitAsync();
     }));
 }
 public async Task <DefaultEventHandlerResponse> InitRoleBasedAccessControler(EventHandleRequest <LoginSuccessDto> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(InitRoleBasedAccessControler), input.GetDataJson(), async() =>
     {
         InitUserOauthDto.Github data = default;
         if (!string.IsNullOrEmpty(input.GetData().Token))
         {
             data = System.Text.Json.JsonSerializer.Deserialize <InitUserOauthDto.Github>(input.GetData().Token);
         }
         var role = new Role();
         role.SetRole("超级管理员", true);
         roleRepository.Add(role);
         var admin = new Account();
         var defpwd = "x1234567";
         admin.CreateAccount(data?.login ?? "eshopadmin", data?.name ?? "商城管理员", defpwd, Common.GetMD5SaltCode);
         if (data != null)
         {
             admin.User.CreateOrUpdateUser(data?.name ?? "商城管理员", data?.avatar_url ?? "", "", "", UserGender.Male, Convert.ToDateTime("1980-01-01"));
         }
         admin.SetRoles(new List <Guid>()
         {
             role.Id
         });
         var defbuyer = new Account();
         defbuyer.CreateAccount("eshopuser", "白云苍狗", defpwd, Common.GetMD5SaltCode);
         defbuyer.User.CreateOrUpdateUser("张老三", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.huabanimg.com%2F0830450561b24f4573bed70d7f74bd43f39302e11bee-s2tj6i_fw658&refer=http%3A%2F%2Fhbimg.huabanimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1618110799&t=b215598f3b458ad7c08aee2b4614622b", "北京市海淀区太平路1号", "13000000000", UserGender.Male, Convert.ToDateTime("1980-01-01"));
         accountRepository.Add(admin);
         accountRepository.Add(defbuyer);
         if (await new UniqueSuperRoleSpecification(roleRepository).IsSatisfiedBy(role))
         {
             await unitofWork.CommitAsync();
         }
         await stateManager.SetState(new RoleBaseInitCheckCache(true));
     }));
 public async Task <DefaultEventHandlerResponse> LoginCacheExpire(EventHandleRequest <LoginSuccessDto> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(LoginCacheExpire), input.GetDataJson(), async() =>
     {
         await stateManager.DelState(new AccountLoginAccessToken(input.GetData().Token));
     }));
 }
Ejemplo n.º 6
0
 public async Task <DefaultEventHandlerResponse> EventHandleSetDefMallSetting(EventHandleRequest <string> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(EventHandleSetDefMallSetting), input.GetDataJson(), async() =>
     {
         var entity = new MallSetting();
         entity.CreateOrUpdate("粥品香坊", "蜂鸟专送/38分钟送达", "http://static.galileo.xiaojukeji.com/static/tms/seller_avatar_256px.jpg", "粥品香坊其烹饪粥料的秘方源于中国千年古法,在融和现代制作工艺,由世界烹饪大师屈浩先生领衔研发。坚守纯天然、0添加的良心品质深得消费者青睐,发展至今成为粥类的引领品牌。是2008年奥运会和2013年园博会指定餐饮服务商。", "李老二", "北京市海淀区太平路13号粥品香坊");
         mallsettingRepository.Add(entity);
         await unitofWork.CommitAsync();
     }));
 }
Ejemplo n.º 7
0
 public async Task <DefaultEventHandlerResponse> EventHandleSetDefMallSetting(EventHandleRequest <string> input)
 {
     return(await new DefaultEventHandlerResponse().RunAsync(nameof(EventHandleSetDefMallSetting), input.GetDataJson(), async() =>
     {
         var categorys = new List <GoodsCategory>()
         {
             new GoodsCategory()
             {
                 CategoryName = "精选热菜", Sort = 0
             },
             new GoodsCategory()
             {
                 CategoryName = "爽口凉菜", Sort = 1
             },
             new GoodsCategory()
             {
                 CategoryName = "小吃主食", Sort = 2
             },
             new GoodsCategory()
             {
                 CategoryName = "特色粥品", Sort = 3
             }
         };
         categoryRepository.Add(categorys[0]);
         categoryRepository.Add(categorys[1]);
         categoryRepository.Add(categorys[2]);
         categoryRepository.Add(categorys[3]);
         var willSend = new List <Goods>();
         Goods createGoods(string name, string url, decimal price, Guid categoryid)
         {
             var goods = new Goods();
             goods.CreateOrUpdateGoods(name, url, price, categoryid);
             goods.UpOrDownShelf(true);
             goods.ChangeStock(100);
             repository.Add(goods);
             willSend.Add(goods);
             return goods;
         }
         void createLimit(Goods goods)
         {
             var entity = new LimitedTimeActivitie();
             entity.CreateOrUpdate(goods.GoodsName, goods.Id, goods.Price - new Random(Guid.NewGuid().GetHashCode()).Next(1, 4), DateTime.Now, DateTime.Now.AddDays(30));
             entity.UpOrDownShelf(true);
             limitrepository.Add(entity);
         }
         createGoods("娃娃菜炖豆腐", "http://fuss10.elemecdn.com/d/2d/b1eb45b305635d9dd04ddf157165fjpeg.jpeg?imageView2/1/w/114/h/114", 17, categorys[0].Id);
         createGoods("手撕包菜", "http://fuss10.elemecdn.com/9/c6/f3bc84468820121112e79583c24efjpeg.jpeg?imageView2/1/w/114/h/114", 16, categorys[0].Id);
         var goods1 = createGoods("香酥黄金鱼/3条", "http://fuss10.elemecdn.com/4/e7/8277a6a2ea0a2e97710290499fc41jpeg.jpeg?imageView2/1/w/114/h/114", 11, categorys[0].Id);
         createGoods("八宝酱菜", "http://fuss10.elemecdn.com/9/b5/469d8854f9a3a03797933fd01398bjpeg.jpeg?imageView2/1/w/114/h/114", 4, categorys[1].Id);
         createGoods("拍黄瓜", "http://fuss10.elemecdn.com/6/54/f654985b4e185f06eb07f8fa2b2e8jpeg.jpeg?imageView2/1/w/114/h/114", 9, categorys[1].Id);
         createGoods("扁豆焖面", "http://fuss10.elemecdn.com/c/6b/29e3d29b0db63d36f7c500bca31d8jpeg.jpeg?imageView2/1/w/114/h/114", 14, categorys[2].Id);
         createGoods("葱花饼", "http://fuss10.elemecdn.com/f/28/a51e7b18751bcdf871648a23fd3b4jpeg.jpeg?imageView2/1/w/114/h/114", 10, categorys[2].Id);
         var goods2 = createGoods("牛肉馅饼", "http://fuss10.elemecdn.com/d/b9/bcab0e8ad97758e65ae5a62b2664ejpeg.jpeg?imageView2/1/w/114/h/114", 14, categorys[2].Id);
         createGoods("招牌猪肉白菜锅贴/10个", "http://fuss10.elemecdn.com/7/72/9a580c1462ca1e4d3c07e112bc035jpeg.jpeg?imageView2/1/w/114/h/114", 7, categorys[2].Id);
         createGoods("皮蛋瘦肉粥", "http://fuss10.elemecdn.com/c/cd/c12745ed8a5171e13b427dbc39401jpeg.jpeg?imageView2/1/w/114/h/114", 10, categorys[3].Id);
         var goods3 = createGoods("红豆薏米美肤粥", "http://fuss10.elemecdn.com/d/22/260bd78ee6ac6051136c5447fe307jpeg.jpeg?imageView2/1/w/114/h/114", 12, categorys[3].Id);
         createGoods("红枣山药糙米粥", "http://fuss10.elemecdn.com/9/b5/469d8854f9a3a03797933fd01398bjpeg.jpeg?imageView2/1/w/114/h/114", 10, categorys[3].Id);
         var goods4 = createGoods("鲜蔬菌菇粥", "http://fuss10.elemecdn.com/e/a3/5317c68dd618929b6ac05804e429ajpeg.jpeg?imageView2/1/w/114/h/114", 11, categorys[3].Id);
         createLimit(goods1);
         createLimit(goods2);
         createLimit(goods3);
         createLimit(goods4);
         if (await unitofWork.CommitAsync())
         {
             await localEventBus.SendEvent(EventTopicDictionary.Goods.Loc_WriteToElasticsearch, willSend);
         }
     }));