60 lines
2.5 KiB
C#
60 lines
2.5 KiB
C#
using AllBase;
|
||
using AllBase.Model.Result;
|
||
using NaiBa.Util.Extension;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace Work.BLL
|
||
{
|
||
public class ShopBLL
|
||
{
|
||
public static List<ShopLoginInfo> DeserializationShop(string shopJson, string shopDataName = "data")
|
||
{
|
||
List<ShopLoginInfo> list = new List<ShopLoginInfo>();
|
||
if (!shopJson.Contains(shopDataName))
|
||
return list;
|
||
|
||
var jArr = JObject.Parse(shopJson)[shopDataName];
|
||
if (jArr.Count() == 0)
|
||
return list;
|
||
|
||
foreach (JObject jObj in jArr)
|
||
{
|
||
var shop = DeserializationShop(jObj);
|
||
if (shop != null)
|
||
list.Add(shop);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
public static ShopLoginInfo DeserializationShop(JObject shopObj)
|
||
{
|
||
string shopStr = shopObj.ToString();
|
||
ShopLoginInfo shop = new ShopLoginInfo();
|
||
shop.DbId = BaseRegex.GetStringJson(ref shopStr, "id");
|
||
if (shop.DbId == null)
|
||
return null;
|
||
shop.LoginName = BaseRegex.GetStringJson(ref shopStr, "login_name");
|
||
shop.Password = BaseRegex.GetStringJson(ref shopStr, "login_pass");
|
||
shop.ShopId = BaseRegex.GetStringJson(ref shopStr, "shop_id");
|
||
shop.ShopAccount = BaseRegex.GetStringJson(ref shopStr, "shop_account");
|
||
shop.SubUserName = BaseRegex.GetStringJson(ref shopStr, "sub_user_name");
|
||
shop.GroupName = BaseRegex.GetStringJson(ref shopStr, "group_name");
|
||
shop.Cookies = shopObj["cookie"].ParseToString().Replace("&", "&").Replace("%", "%").Replace("+", "+").Replace(""", "\"");
|
||
shop.CompanyName = BaseRegex.GetStringJson(ref shopStr, "company_name");
|
||
shop.Notes = BaseRegex.GetStringJson(ref shopStr, "notes");
|
||
shop.LoginStatus = BaseRegex.GetStringJson(ref shopStr, "login_status");
|
||
shop.AddTime = BaseRegex.GetStringJson(ref shopStr, "add_time") == null ? DateTime.MinValue : Convert.ToDateTime(BaseRegex.GetStringJson(ref shopStr, "add_time"));
|
||
shop.is_point_shop_expire = BaseRegex.GetBoolJson(ref shopStr, "is_point_shop_expire");
|
||
shop.expire_time = BaseRegex.GetIntJson(ref shopStr, "expire_time");
|
||
shop.ErpShopId = BaseRegex.GetStringJson(ref shopStr, "erp_shop_id");
|
||
|
||
return shop;
|
||
}
|
||
}
|
||
}
|