public static string CreateCode(string orignalCode, TotalBillTypeEnum billType) { var codePrefix = GetCodePrifix(billType); var codeArray = GetCodeArray(orignalCode, billType); var billCode = CombinBillCode(codeArray, codePrefix); return(billCode); }
private static List <string> GetCodeArray(string orignalCode, TotalBillTypeEnum billType) { var nowDay = DateTime.Now.ToString("yyyyMMdd").ToLower(); if (orignalCode.IsInValid()) { orignalCode = $"{GetCodePrifix(billType)}-{nowDay}-0000"; } var codeArray = orignalCode.Split('-').ToList(); if (codeArray.Count != 3) { throw new CreateCodeException(); } codeArray[2] = (codeArray[1].ToInt32() == nowDay.ToInt32()) ? codeArray[2] : "0000"; codeArray[1] = nowDay; return(codeArray); }
private static string GetCodePrifix(TotalBillTypeEnum billType) { var codePrifix = EnumUtility.GetCodePrifix(billType); return(codePrifix); }