字符串数据:
20000:3275069:颜色分类:酒红色;1753146:3485013:尺码:39;30606:112030:上市时间:2008年
格式:
属性ID:属性值ID:属性:属性值;属性ID:属性值ID:属性:属性值
/// <summary>
/// 转换颜色和尺码
/// 钟遵沐,2015-07-08
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public string[] GetData_ColorAndSize(string data,string type)
{
string[] Data = data.Split(';');
string[] ColorAndSize = new string[2];
string color_id = "无颜色", size_id = "无尺码";
for (int i = 0; i < Data.Length; i++) {
string[] arrColor=Data[i].Split(':');
if (type == "sku")
{
if (arrColor[2].Contains("颜色"))
{
color_id = arrColor[3];
}
if (arrColor[2].Contains("尺码"))
{
size_id = arrColor[3];
}
}
else if (type == "orderitems")
{
if (arrColor[0].Contains("颜色"))
{
color_id = arrColor[1];
}
if (arrColor[0].Contains("尺码"))
{
size_id = arrColor[1];
}
}
}
ColorAndSize[0] = color_id;
ColorAndSize[1] = size_id;
return ColorAndSize;
}