/// <summary> /// /// </summary> /// <param name="codetype"> /// Code展示类型, /// "CODE_TYPE_TEXT",文本; /// "CODE_TYPE_BARCODE",一维码 ; /// "CODE_TYPE_QRCODE",二维码; /// "CODE_TYPE_ONLY_QRCODE",二维码无code显示; /// "CODE_TYPE_ONLY_BARCODE",一维码无code显示; /// </param> /// <param name="logo_url"> /// 卡券的商户logo,建议像素为300*300 /// </param> /// <param name="brand_name"> /// 商户名字,字数上限为12个汉字 /// </param> /// <param name="title"> /// 卡券名,字数上限为9个汉字。(建议涵盖卡券属性、服务及金额)。 /// </param> /// <param name="sub_title"> /// 券名,字数上限为18个汉字。 /// </param> /// <param name="color"> /// 券颜色。按色彩规范标注填写Color010-Color100 /// </param> /// <param name="notice"> /// 卡券使用提醒,字数上限为16个汉字。 /// </param> /// <param name="description"> /// 卡券使用说明,字数上限为1024个汉字。 /// </param> /// <param name="sku"> /// 商品信息。 /// </param> /// <param name="quantity"> /// 卡券库存的数量,不支持填写0,上限为100000000。 /// </param> /// <param name="date_info"> /// 使用日期,有效期的信息。 /// </param> /// <param name="type"> /// DATE_TYPE_FIX_TIME_RANGE 表示固定日期区间, /// DATE_TYPE_FIX_TERM表示固定时长(自领取后按天算。 /// </param> /// <param name="begin_timestamp"> /// type为DATE_TYPE_FIX_TIME_RANGE时专用,表示起用时间。 /// 从1970年1月1日00:00:00至起用时间的秒数,最终需转换为字符串形态传入。 /// (东八区时间,单位为秒) /// </param> /// <param name="end_timestamp"> /// type为DATE_TYPE_FIX_TIME_RANGE时专用,表示结束时间, /// 建议设置为截止日期的23:59:59过期。(东八区时间,单位为秒) /// </param> /// <param name="fixed_term"> /// type为DATE_TYPE_FIX_TERM时专用,表示自领取后多少天内有效,领取后当天有效填写0。(单位为天) /// </param> /// <param name="fixed_begin_term"> /// type为DATE_TYPE_FIX_TERM时专用,表示自领取后多少天开始生效。(单位为天) /// </param> public static WeiXinCard.base_info iniBase_Info(Code_Type codetype, string logo_url, string brand_name, string title, string sub_title, string color, string notice, string description, int quantity, string date_info, Type type, uint begin_timestamp, uint end_timestamp, int fixed_term, int fixed_begin_term) { WeiXinCard.base_info info = new base_info(); info.logo_url = logo_url; info.code_type = codetype.ToString(); info.brand_name = brand_name; info.title = title; info.sub_title = sub_title; info.color = color; info.notice = notice; info.description = description; sku s = new sku(); s.quantity = quantity; info.sku = s; date_info date = new WeiXinCard.date_info(); date.type = type.ToString(); date.begin_timestamp = begin_timestamp; date.end_timestamp = end_timestamp; date.fixed_term = fixed_term; date.fixed_begin_term = fixed_begin_term; info.date_info = date; return(info); }
public static void Mapto(this sku sku1, SkuDTO sku2) { sku1.id = sku2.id; sku1.seller_sku = sku2.seller_sku; sku1.available = sku2.available; sku1.quantity = sku2.quantity; sku1.color = sku2.color; sku1.size = sku2.size; sku1.height = sku2.height; sku1.width = sku2.width; sku1.length = sku2.length; sku1.weight = sku2.weight; sku1.price = sku2.price; sku1.productId = sku2.productId; }
public static SkuDTO toskuDTO(this sku sku1) { return(new SkuDTO() { id = sku1.id, seller_sku = sku1.seller_sku, available = sku1.available, quantity = sku1.quantity, color = sku1.color, size = sku1.size, height = sku1.height, width = sku1.width, length = sku1.length, weight = sku1.weight, price = sku1.price, productId = sku1.productId }); }
public void SaveNewArticle(Product Record, int countryId) { country cou = _context.country.Where(c => c.id == countryId).FirstOrDefault(); webshop webshop = _context.webshop.Where(w => w.url == Record.Webshop).FirstOrDefault(); if (webshop == default(webshop)) { return; } if (cou == default(country)) { Console.WriteLine("Could not find country id {0}, aborting the save.", countryId); return; } article art = new article { description = Record.Description, brand = Record.Brand, image_loc = Record.Image_Loc }; // Do not modify this as this is neccessary to get the last id. _context.article.Add(art); ean ean = new ean { ean1 = Record.EAN, article_id = art.id }; _context.ean.Add(ean); title title = new title { title1 = Record.Title, country_id = (short)countryId, article_id = art.id, country = cou }; _context.title.Add(title); title_synonym ts = new title_synonym { title = Record.Title, title_id = title.id, occurrences = 1 }; _context.title_synonym.Add(ts); if (Record.SKU != "") { sku sku = new sku { sku1 = Record.SKU, article_id = art.id }; _context.sku.Add(sku); } decimal castedShipCost; decimal castedPrice; if (!(decimal.TryParse(Record.DeliveryCost, NumberStyles.Any, CultureInfo.InvariantCulture, out castedShipCost))) Console.WriteLine("Cannot cast shipping cost " + Record.DeliveryCost + " to decimal."); if (!(decimal.TryParse(Record.Price, NumberStyles.Any, CultureInfo.InvariantCulture, out castedPrice))) Console.WriteLine("Cannot cast price " + Record.Price + " to decimal."); product product = new product { article_id = art.id, ship_cost = castedShipCost, ship_time = Record.DeliveryTime, price = castedPrice, webshop_url = webshop.url, direct_link = Record.Url, affiliate_name = Record.Affiliate, affiliate_unique_id = Record.AffiliateProdID }; _context.product.Add(product); _context.SaveChanges(); }