






















最近在做一个多租户的云SAAS软件自助服务平台,途中遇到很多问题,我会将一些心得、体会逐渐分享出来,和大家一起探讨。这是本系列的第一篇文章。
大家知道,要做一个全自助服务的SAAS云平台是比较复杂的,稍微有些漏洞,就会被不法分子钻漏洞,牵涉到一些金钱上的纠纷。因此,一开始的设计就比较重要了。说到云自助服务平台,可能和网上购物、在线商城有些类似,但里面提供的是相关服务,还是有些区别的,我在这里先讲几个概念:
总体的概念流程是 服务->产品->购物车->订单->服务
上一张购物车验证规则的流程图

一些类(还没有全部完成):

对实体类的操作大都采用工厂方式:

购物车类代码:

1 public class UserCart 2 { 3 public string UserId { get; set; } 4 /// <summary> 5 /// 设置域名 6 /// </summary> 7 public string ServiceIndentify { get; set; } 8 public OrderType OrderType { get; set; } 9 public IList<UserCartProduct> UserCartProducts { get; set; } 10 public float TotalPrice 11 { 12 get 13 { 14 if (OrderType == OrderType.Experience) 15 { 16 return 0; 17 } 18 else 19 { 20 return UserCartProducts.Sum(p => p.Price); 21 } 22 } 23 } 24 public virtual IList<UserCartProduct> UserCartProduct { get; set; } 25 } 26 27 public class UserCartProduct 28 { 29 public string ProductId { get; set; } 30 public int ProductBasePrice { get; set; } 31 public Period Period { get; set; } 32 public DateTime StartDate { get; set; } 33 public DateTime EndDate { get; set; } 34 public IList<string> UserCartProductBasicModules { get; set; } 35 public IList<UserCartAddtionalModule> UserCartProductAddtionalModules { get; set; } 36 public IList<UserCartAddtionalService> UserCartAddtionalServices { get; set; } 37 public IList<UserCartOption> UserCartOptions { get; set; } 38 public float Price 39 { 40 get 41 { 42 return ProductBasePrice 43 + UserCartProductAddtionalModules.Sum(m => m.UintPrice.GetPriceByPeriod(Period)) 44 + UserCartAddtionalServices.Sum(m => m.UintPrice.GetPriceByPeriod(new Period(PeriodType.Times, m.Quantity))) 45 + UserCartOptions.Sum(m => m.UintPrice.GetPriceByPeriod(Period)); 46 } 47 } 48 public virtual UserCart UserCart { get; set; } 49 } 50 51 public class ModuleBase 52 { 53 public string ModuleId { get; set; } 54 55 public PeriodPrice UintPrice { get; set; } 56 57 } 58 59 public class UserCartAddtionalModule: ModuleBase 60 { 61 } 62 63 public class UserCartAddtionalService : ModuleBase 64 { 65 public int Quantity { get; set; } 66 } 67 68 public class UserCartOption: ModuleBase 69 { 70 public string CheckId { get; set; } 71 public string OriginCheckedId { get; set; } 72 public PeriodPrice OriginPeriodPrice { get; set; } 73 }
View Code
其他类类似。
大家对这块有什么好的意见和建议,希望能够提出来。
SAAS云平台搭建札记系列文章:
SAAS云平台搭建札记: (一)浅论SAAS多租户自助云服务平台的产品、服务和订单
SAAS云平台搭建札记: (二)Linux Unbutu下.Net Core整套运行环境的搭建
SAAS云平台搭建札记: (三) AntDesign + .Net Core WebAPI权限控制、动态菜单的生成
SAAS云平台搭建札记: (四) AntD For React使用react-router-dom路由接收不同参数页面不刷新的问题
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。