public void Deal(EventContract msg) { var bus = MqBusMgr.GetInstance(); OptEnum operation; Enum.TryParse(msg.Operation.ToString(), out operation); var vipContract = new VipContract { Operation = operation, VipId = msg.Id }; if (msg.Operation != Zmind.EventBus.Contract.OptEnum.Delete) { var vipFacade = new VipFacade(); var vipEntity = vipFacade.GetById(msg.Id); if (vipEntity == null) { return; } vipContract.VipName = vipEntity.VipName; vipContract.VipCode = vipEntity.VipCode; vipContract.CreateTime = vipEntity.CreateTime; vipContract.ModifyTime = vipEntity.LastUpdateTime; vipContract.Phone = vipEntity.Phone; vipContract.IdType = vipEntity.IDType; vipContract.IdNumber = vipEntity.IDNumber; if (string.IsNullOrEmpty(vipEntity.Birthday)) { vipContract.Birthday = null; } else { vipContract.Birthday = DateTime.Parse(vipEntity.Birthday); } vipContract.Gender = vipEntity.Gender != null ? vipEntity.Gender.Value : 1; vipContract.Email = vipEntity.Email; vipContract.OpenID = vipEntity.WeiXinUserId; vipContract.WeiXinID = vipEntity.WeiXin; // vipContract.VipLevel = vipEntity.VipLevel != null ? vipEntity.VipLevel.Value : 1; //获取会员对应的卡类别 //查询最低等级的会员卡类型 SysVipCardTypeFacade _SysVipCardTypeFacade = new SysVipCardTypeFacade(); SysVipCardTypeEntity vipCardTypeInfo = _SysVipCardTypeFacade.GetVipCardTypeByVipID(msg.Id); if (vipCardTypeInfo != null) { vipContract.VipCardTypeID = (int)vipCardTypeInfo.VipCardTypeID; } vipContract.OldVipID = msg.OtherCon; } bus.Publish <IZmindToXgx>(vipContract); }
public void Deal(VipContract contract) { var dbEntity = Convert(contract); var facade = new VipFacade(); if (contract.Operation != OptEnum.Delete) { if (facade.GetById(contract.VipId) == null) { contract.Operation = OptEnum.Create; } else { contract.Operation = OptEnum.Update; } } switch (contract.Operation) { case OptEnum.Create: facade.Create(dbEntity); //创建卡 SysVipCardTypeFacade _SysVipCardTypeFacade = new SysVipCardTypeFacade(); //查询最低等级的会员卡类型 // SysVipCardTypeEntity vipCardTypeInfo = _SysVipCardTypeFacade.GetMinVipCardType(ConfigMgr.CustomerId); //查询某个级别的卡,都用金卡 SysVipCardTypeEntity vipCardTypeInfo = _SysVipCardTypeFacade.GetCardTypeIDByVipCardLevel(3, ConfigMgr.CustomerId); if (vipCardTypeInfo != null) { var vipCardInfo = new VipCardEntity(); vipCardInfo.VipCardID = Guid.NewGuid().ToString(); vipCardInfo.VipCardTypeID = vipCardTypeInfo.VipCardTypeID; vipCardInfo.VipCardName = vipCardTypeInfo.VipCardTypeName; vipCardInfo.VipCardCode = dbEntity.VipCode; vipCardInfo.VipCardStatusId = 1; //正常 // vipCardInfo.MembershipUnit = unitId; // vipCardInfo.MembershipTime = DateTime.Now; vipCardInfo.CustomerID = ConfigMgr.CustomerId; vipCardInfo.IsDelete = 0; var _VipCardFacade = new VipCardFacade(); //创建处理类 _VipCardFacade.Create(vipCardInfo); //创建会员与卡之间的关系 //绑定会员卡和会员 var vipCardVipMappingEntity = new VipCardVipMappingEntity() { MappingID = Guid.NewGuid().ToString().Replace("-", ""), VIPID = dbEntity.VIPID, VipCardID = vipCardInfo.VipCardID, CustomerID = ConfigMgr.CustomerId, IsDelete = 0 }; var _VipCardVipMappingFacade = new VipCardVipMappingFacade(); //创建处理类 _VipCardVipMappingFacade.Create(vipCardVipMappingEntity); } break; case OptEnum.Update: facade.Update(dbEntity); break; case OptEnum.Delete: facade.Delete(dbEntity); break; } }
private T_InoutEntity ConvertToT_Inout(OrderContract contract) { var vipFacade = new VipFacade(); var vipEntity = vipFacade.GetById(contract.VipNo); var carrierId = contract.Delivery == EnumDelivery.HomeDelivery ? string.Empty : contract.CreateUnit; var statusStr = ((int)contract.Status).ToString(); var result = new T_InoutEntity { order_id = contract.OrderId, order_no = contract.OrderNo, VipCardCode = vipEntity.VipCode, order_type_id = GetEnumOrderType(contract.OrderType), order_reason_id = GetEnumOrderReason(contract.OrderReason), red_flag = red_flag, warehouse_id = "", order_date = contract.OrderDate, request_date = string.Empty, complete_date = contract.CompleteDate, create_unit_id = contract.CreateUnit, unit_id = contract.CreateUnit, related_unit_id = string.Empty, related_unit_code = string.Empty, pos_id = string.Empty, shift_id = string.Empty, sales_user = string.Empty, total_amount = contract.TotalAmount, discount_rate = contract.DiscountRate, actual_amount = contract.ActualAmount, receive_points = contract.ReceivePoints, pay_points = contract.PayPoints, pay_id = string.Empty, print_times = 0, carrier_id = carrierId, remark = contract.Remark, status = statusStr, status_desc = GetStatusDescByStatus(contract.Status), total_qty = contract.TotalQty, total_retail = contract.TotalRetail, keep_the_change = contract.KeepTheChange, wiping_zero = contract.WipingZero, vip_no = contract.VipNo, create_time = contract.CreateTime, create_user_id = contract.CreateUserId, approve_time = contract.ApproveTime, approve_user_id = contract.ApproveUserId, send_user_id = contract.SendUserId, send_time = contract.SendTime, accpect_user_id = contract.AccpectUserId, accpect_time = contract.AccpectTime, modify_user_id = contract.ModifyUserId, modify_time = contract.ModifyTime, data_from_id = "3", sales_unit_id = contract.SalesUnt, purchase_unit_id = contract.PurchaseUnit, if_flag = "0", customer_id = ConfigMgr.CustomerId, sales_warehouse_id = contract.SalesWarehouse, purchase_warehouse_id = contract.PurchaseWarehouse, Field1 = ((int)contract.IsPay).ToString(), Field2 = contract.TrackingNumber, Field3 = contract.BalancePayment, Field4 = contract.Address, Field6 = contract.Phone, Field7 = statusStr, Field8 = ((int)contract.Delivery).ToString(), Field9 = contract.DeliveryDateTime, Field10 = GetStatusDescByStatus(contract.Status), Field11 = string.Empty, Field12 = string.Empty, Field13 = vipEntity.WeiXinUserId, Field14 = contract.UserName, Field15 = string.Empty, Field16 = string.Empty, Field17 = string.Empty, Field18 = string.Empty, Field19 = string.Empty, Field20 = string.Empty, reserveQuantum = contract.RequestDateQuantum, reserveDay = contract.RequestDate, paymentcenter_id = null, ReturnCash = contract.CashBack, }; return(result); }