public static CardCounponModel Convert(this CardCounponViewModel viewModel, MerchantModel merchant) { var model = new CardCounponModel() { BrandName = viewModel.Choose <ICardCoupon>().BaseInfo.Title, CreatedTime = viewModel.CreatedTime, LastUpdateTime = DateTime.UtcNow.ToUnixStampDateTime(), ErrMsg = string.Empty, Id = viewModel.Id, Merchant = merchant, Quantity = (int)viewModel.Choose <ICardCoupon>().BaseInfo.Sku.Quantity, State = viewModel.State, Type = viewModel.CardType, WxNo = viewModel.WxNo }; viewModel.Choose <ICardCoupon>().AdvancedInfo.WitFixedSettings(viewModel.CardType); viewModel.Choose <ICardCoupon>().BaseInfo.WithFixedSettings(viewModel.CardType, merchant); model.CardCoupon = viewModel.Choose(); model.CardCoupon.Set((ctx) => { ctx.CardType = viewModel.CardType; ctx.CardId = viewModel.WxNo; }); var json = model.CardCoupon.SerializeToJson(); return(model); }
public static WxUserCardCouponModel Generate(this GetCardCouponWeChatEventArgs arg, CardCounponModel model, long ownWxUser, long?gotfrom, bool gifting = false) { var result = new WxUserCardCouponModel() { FriendUserName = arg.FriendUserName, Gotfrom = gotfrom == null ? null : new WxUserModel() { Id = gotfrom.Value }, IsGiveByFriend = arg.IsGiveByFriend, LastActivityTime = DateTime.UtcNow.ToUnixStampDateTime(), Merchant = model.Merchant, IsGiftingToFriend = gifting, OldUserCardCode = arg.OldUserCardCode, CardCounpon = model, Owner = new WxUserModel() { Id = ownWxUser }, Type = model.Type, UserCardCode = arg.UserCardCode }; return(result); }
public static CardCounponModel Initialize(this CardTypes type, MerchantModel merchant) { var model = new CardCounponModel(); model.Merchant = merchant; model.CreatedTime = DateTime.UtcNow.ToUnixStampDateTime(); model.Type = type; switch (type) { case CardTypes.CASH: model.CardCoupon = new CashCoupon(); break; case CardTypes.DISCOUNT: model.CardCoupon = new DiscountCoupon(); break; case CardTypes.GENERAL_COUPON: model.CardCoupon = new GeneralCoupon(); break; case CardTypes.GIFT: model.CardCoupon = new GiftCoupon(); break; case CardTypes.GROUPON: model.CardCoupon = new Groupon(); break; case CardTypes.MEMBER_CARD: model.CardCoupon = new MemberCard() { SupplyBonus = false, AutoActivate = false, BonusRule = new BonusRule(), CustomCell = new CustomCell(), CustomField1 = new CustomField() { }, Discount = 10, Prerogative = string.Empty, SupplyBanlance = false, WxActivate = true }; break; } model.CardCoupon.AdvancedInfo = new AdvancedInfo().WithInitializeSettings(type, merchant); model.CardCoupon.BaseInfo = new BaseInfo().WithInitializeSettings(type, merchant); model.CardCoupon.CardId = string.Empty; model.CardCoupon.CardType = type; return(model); }
public CardCouponWithoutWapperViewModel(CardCounponModel model) { this.Id = model.Id; this.BrandName = model.BrandName; this.Merchant = model.Merchant.BrandName; this.CreatedTime = model.CreatedTime.ToDateTimeString(); this.LastUpdateTime = model.LastUpdateTime.ToDateTimeString(); this.Quantity = model.Quantity; this.Type = model.Type.TextOf(); this.WxNo = model.WxNo; this.StateWithName = model.State.WithDisplayName(); this.CardType = model.Type; this.State = model.State; //this.DelAble = !((model.Status & CCStatus.Published) == CCStatus.Published); }
public static CardCounponViewModel Convert(this CardCounponModel card) { var viewModel = new CardCounponViewModel() { Cash = card.CardCoupon.ToCardCoupon <CashCoupon>(), Discount = card.CardCoupon.ToCardCoupon <DiscountCoupon>(), General = card.CardCoupon.ToCardCoupon <GeneralCoupon>(), Groupon = card.CardCoupon.ToCardCoupon <Groupon>(), Gift = card.CardCoupon.ToCardCoupon <GiftCoupon>(), MerberCard = card.CardCoupon.ToCardCoupon <MemberCard>(), CreatedTime = card.CreatedTime, MerchantId = card.Merchant.Id, WxNo = card.WxNo, CardType = card.Type, Id = card.Id, State = card.State, SubMerchantBrandName = card.Merchant.BrandName, }; return(viewModel); }