最近在作一个多租户的云SAAS软件自助服务平台,途中遇到不少问题,我会将一些心得、体会逐渐分享出来,和你们一块儿探讨。这是本系列的第一篇文章。html
你们知道,要作一个全自助服务的SAAS云平台是比较复杂的,稍微有些漏洞,就会被不法分子钻漏洞,牵涉到一些金钱上的纠纷。所以,一开始的设计就比较重要了。说到云自助服务平台,可能和网上购物、在线商城有些相似,但里面提供的是相关服务,仍是有些区别的,我在这里先讲几个概念:ide
整体的概念流程是 服务->产品->购物车->订单->服务spa
上一张购物车验证规则的流程图设计
一些类(尚未所有完成):日志
对实体类的操做大都采用工厂方式:code
购物车类代码:htm
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 }
其余类相似。blog
你们对这块有什么好的意见和建议,但愿可以提出来。get
SAAS云平台搭建札记系列文章:权限控制
SAAS云平台搭建札记: (一)浅论SAAS多租户自助云服务平台的产品、服务和订单