大閘蟹在線提貨系統會要求支持很多家快遞公司,來進行產品的發貨。對于像圓通,中通這樣的快遞來說,他們家的單號是有規律的加一,我們只需要錄入起始單號(在線提貨系統源代碼實現起來也非常的簡單),后面的單號,只要連續加一就可以愉快的實現了。
提貨系統源代碼-順豐快遞模塊
但是,順豐快遞的單號,卻不是簡單的加一了。看上去毫無規律,卻又有規律的感覺,一會兒加9,一會兒加1,這個問題應該困擾了不少朋友。
下面我們公開在線提貨系統源代碼的順豐快遞單號生成部分的代碼部分。
public static string Gen_Next_Sf_ExpressNumber(string SeedCode)
{
string currentNo = SeedCode;
if (currentNo.Length == 12)
{
string Recin_BFBit = “”;
string Recin_FEB = currentNo.Substring(0, 11);
string Recin_BFB = currentNo.Substring(11, 1);
string Recin_BSB = currentNo.Substring(10, 1);
string Recin_BTB = currentNo.Substring(9, 1);
if (Recin_BSB == “9”)
{
switch (Recin_BTB)
{
/*倒數第三位0,1,2,4,5,7,8 跳轉 4 */
case “0”:
case “1”:
case “2”:
case “4”:
case “5”:
case “7”:
case “8”:
Recin_BFBit = MakeLastBit(Recin_BFB, 4);
break;
/*倒數第三位 3,6 跳轉 5 */
case “3”:
case “6”:
Recin_BFBit = MakeLastBit(Recin_BFB, 5);
break;
/*倒數第三位 9 跳轉 7 */
case “9”:
Recin_BFBit = MakeLastBit(Recin_BFB, 7);
break;
}
}
else
{
Recin_BFBit = MakeLastBit(Recin_BFB, 1);
}
int tempLength = Recin_FEB.Length;
double temp = double.Parse(Recin_FEB) + 1;
currentNo = ((temp.ToString().Length < tempLength) ? “0” + temp.ToString() : temp.ToString()) + Recin_BFBit;
return currentNo;
}
return “”;
}