public object Get(GetSettlement request) { // Get the contract for the Settlement by specifying the settlement address var contract = AppServices.web3.Eth.GetContract(AppModelConfig.SETTLEMENT.abi, AppServices.GetEcosystemAdr(request.ContractAdr).SettlementContractAdr); // SettlementListEntry entry = contract.GetFunction("get").CallDeserializingToObjectAsync<SettlementListEntry>(i).Result; // If no settlement hash has been provided as part of the request get the corresponding hash that belongs to the provided idx if (request.Hash.IsEmpty() == true) { request.Hash = AppModelConfig.convertToHex(contract.GetFunction("get").CallAsync <byte[]>(request.Idx).Result); } // Retrieve the settlement details from the Blockchain SettlementDetail settlement = contract.GetFunction("dataStorage").CallDeserializingToObjectAsync <SettlementDetail>(request.Hash.HexToByteArray()).Result; // Set the settlement hash to the requested has as specified in the request settlement.Hash = request.Hash; settlement.EventLogs = new List <SettlementEventLog>(); // If settlement hash is set retrieve the logs for the settlement if (AppModelConfig.isEmptyHash(settlement.Hash) == false) { settlement.EventLogs = ((SettlementLogs)this.Get( new GetSettlementLogs { ContractAdr = request.ContractAdr, SettlementHash = request.Hash })).EventLogs; // Just for the Settlement specific event logs reverse the order to have the events in ascending order settlement.EventLogs.Reverse(); } // Return the settlement return(settlement); }
/// <summary> /// Parses a settlement detail record. /// </summary> /// <remarks> /// A null item may be added. /// </remarks> private void ParseSettlementDetailRecord() { SettlementDetail settlementDetail = SettlementDetailParser.Parse(Line, NumberOfSettlementDetailRecords++); if (settlementDetail == null) { Log.Error("Record in line #{0} from file \"{1}\" could not be parsed.", null, (int)ResultCode.CorruptSettlementRecord, LineNumber, FileName); } Extract.SettlementDetailRecords.Add(settlementDetail); }
/// <summary> /// If the calling thread is the currently authorized thread, processes the redeemed deal record received from a partner /// against the redeemed deals in the data store. /// </summary> /// <param name="partner"> /// The Partner from which the redeemed deal record originated. /// </param> /// <param name="record"> /// The redeemed deal record to process. /// </param> /// <param name="redeemedDealOperations"> /// The object to use to perform redeemed deal operations. /// </param> /// <param name="context"> /// The context of the worker action being executed. /// </param> /// <param name="threadId"> /// The ID of the thread attempting to perform this action. /// </param> /// <returns> /// The ResultCode describing the result of the operation. /// </returns> /// <exception cref="ArgumentNullException"> /// * Parameter redeemedDealOperations cannot be null. /// -OR- /// * Parameter context cannot be null. /// </exception> public static ResultCode ProcessPartnerRedeemedDealRecord(Partner partner, SettlementDetail record, IRedeemedDealOperations redeemedDealOperations, CommerceContext context) { if (redeemedDealOperations == null) { throw new ArgumentNullException("redeemedDealOperations", "Parameter redeemedDealOperations cannot be null."); } if (context == null) { throw new ArgumentNullException("context", "Parameter context cannot be null."); } ResultCode result = ResultCode.None; try { context.Log.Verbose("Processing partner redeemed deal record."); context[Key.Partner] = partner; context[Key.SettlementDetail] = record; result = redeemedDealOperations.ProcessPartnerRedeemedDealRecord(); if (result == ResultCode.Success) { context.Log.Verbose("Partner redeemed deal record processed successfully."); } else { context.Log.Warning("Partner redeemed deal record unsuccessfully processed.\r\n\r\nResultCode: {0}" + "\r\n\r\nExplanation: {1}", (int)result, result, ResultCodeExplanation.Get(result)); } } catch (Exception ex) { context.Log.Critical("Partner redeemed deal record processing ended with an error.", ex); } return(result); }
/// <summary> /// Process the rewards if applicable /// </summary> /// <param name="settlementDetail"> /// Settlement Details /// </param> /// <returns> /// Async Task Wrapper /// </returns> internal async Task ProcessRewardPayoutAsync(SettlementDetail settlementDetail) { if (settlementDetail.TransactionType == TransactionType.SettlementRedemption) { // First add a redemption reward to the redeeming user if they're enabled. if (EnableRedemptionRewards == true && WorkerActions.RewardRedemption(RewardOperations, Context) == ResultCode.Success) { // Add job to process the reward payout. Note that this job will be scheduled 30 minutes in the // future to guard against applying a reward for a transaction that was reversed in a later // record. ConcurrentDictionary <string, string> payload = new ConcurrentDictionary <string, string>(); payload[Key.RewardPayoutId.ToString()] = ((Guid)Context[Key.RewardPayoutId]).ToString(); payload[Key.PartnerCardId.ToString()] = (string)Context[Key.PartnerCardId]; payload[Key.PartnerRedeemedDealId.ToString()] = settlementDetail.TransactionId; IScheduler scheduler = PartnerFactory.Scheduler(CommerceWorkerConfig.Instance.SchedulerQueueName, CommerceWorkerConfig.Instance.SchedulerTableName, CommerceWorkerConfig.Instance); ScheduledJobDetails scheduledJobDetails = new ScheduledJobDetails { JobId = Guid.NewGuid(), JobType = ScheduledJobType.ApplyRedemptionReward, JobDescription = settlementDetail.ConsumerId, Orchestrated = true, StartTime = DateTime.UtcNow.AddMinutes(30), Payload = payload }; await scheduler.ScheduleJobAsync(scheduledJobDetails).ConfigureAwait(false); } // Then add a referred redemption reward to the user who referred the redeeming user. WorkerActions.RewardReferredRedemption(RewardOperations, Context); } else { Context.Log.Verbose("No Bing Reward can be given for a reversed transaction."); } }
public ErrCode SaveSettlement(SettlementDetail _settlement, out int settlement_id) { ErrCode err = SiteProvider.CurrentProvider.SaveSettlement(_settlement, out settlement_id); return err; }
public WMSSettlementDetailToDb(SettlementDetail wmsInfo) : base(s_metadata) { SetSqlInt64(0, wmsInfo.ID); SetSqlInt64(1, wmsInfo.WSID); SetSqlInt64(2, wmsInfo.CustomerID); SetSqlString(3, wmsInfo.CustomerName); SetSqlInt64(4, wmsInfo.WarehouseID); SetSqlString(5, wmsInfo.WarehouseName); SetSqlString(6, wmsInfo.SettlementNumber); SetSqlInt32(7, wmsInfo.WhetherToSettle); SetSqlString(8, wmsInfo.LineNumber); SetSqlDateTime(9, wmsInfo.OrderDate); SetSqlString(10, wmsInfo.TransportatioType); SetSqlString(11, wmsInfo.OrderNumber); SetSqlString(12, wmsInfo.DeliveryStoreCode); SetSqlString(13, wmsInfo.DeliveryStoreName); SetSqlString(14, wmsInfo.ReceivingStoreCode); SetSqlString(15, wmsInfo.ReceivingStoreName); SetSqlDouble(16, wmsInfo.BoxQty); SetSqlDouble(17, wmsInfo.Qty); SetSqlDouble(18, wmsInfo.SafelockQty); SetSqlDouble(19, wmsInfo.HangerQty); SetSqlString(20, wmsInfo.Settler); SetSqlDateTime(21, wmsInfo.SettlementTime); SetSqlString(22, wmsInfo.CancelSettler); SetSqlDateTime(23, wmsInfo.CancelSettlementTime); SetSqlString(24, wmsInfo.ReClearingSettler); SetSqlDateTime(25, wmsInfo.ReClearingTime); SetSqlString(26, wmsInfo.Creator); SetSqlDateTime(27, wmsInfo.CreateTime ?? SqlTypes.SqlDateTime.Null); SetSqlString(28, wmsInfo.Updator); SetSqlDateTime(29, wmsInfo.UpdateTime ?? SqlTypes.SqlDateTime.Null); SetSqlString(30, wmsInfo.Remark); SetSqlString(31, wmsInfo.str1); SetSqlString(32, wmsInfo.str2); SetSqlString(33, wmsInfo.str3); SetSqlString(34, wmsInfo.str4); SetSqlString(35, wmsInfo.str5); SetSqlString(36, wmsInfo.str6); SetSqlString(37, wmsInfo.str7); SetSqlString(38, wmsInfo.str8); SetSqlString(39, wmsInfo.str9); SetSqlString(40, wmsInfo.str10); SetSqlString(41, wmsInfo.str11); SetSqlString(42, wmsInfo.str12); SetSqlString(43, wmsInfo.str13); SetSqlString(44, wmsInfo.str14); SetSqlString(45, wmsInfo.str15); SetSqlString(46, wmsInfo.str16); SetSqlString(47, wmsInfo.str17); SetSqlString(48, wmsInfo.str18); SetSqlString(49, wmsInfo.str19); SetSqlString(50, wmsInfo.str20); SetSqlDateTime(51, wmsInfo.DateTime1 ?? SqlTypes.SqlDateTime.Null); SetSqlDateTime(52, wmsInfo.DateTime2 ?? SqlTypes.SqlDateTime.Null); SetSqlDateTime(53, wmsInfo.DateTime3 ?? SqlTypes.SqlDateTime.Null); SetSqlDateTime(54, wmsInfo.DateTime4 ?? SqlTypes.SqlDateTime.Null); SetSqlDateTime(55, wmsInfo.DateTime5 ?? SqlTypes.SqlDateTime.Null); SetSqlInt32(56, wmsInfo.Int1 ?? SqlTypes.SqlInt32.Null); SetSqlInt32(57, wmsInfo.Int2 ?? SqlTypes.SqlInt32.Null); SetSqlInt32(58, wmsInfo.Int3 ?? SqlTypes.SqlInt32.Null); SetSqlInt32(59, wmsInfo.Int4 ?? SqlTypes.SqlInt32.Null); SetSqlInt32(60, wmsInfo.Int5 ?? SqlTypes.SqlInt32.Null); }
/// <summary> /// Parses the specified record text into a settlement detail object if possible. /// </summary> /// <param name="record"> /// The record text to parse into a settlement detail object. /// </param> /// <param name="recordNumber"> /// The number of the record of this type from the extract file being parsed. /// </param> /// <returns> /// * The SettlementDetail object if successful. /// * Else returns null. /// </returns> internal SettlementDetail Parse(string record, int recordNumber) { SettlementDetail result = new SettlementDetail(); RecordNumber = recordNumber; int recordPos = 0; bool recordValid = true; string stringField = null; DateTime dateField = DateTime.MinValue; decimal decimalField = Decimal.MinValue; ParsingUtilities parsingUtilities = new ParsingUtilities(RecordTypeDescriptor, RecordNumber, FileName, ExtractConstants.TimeFieldLength, Log); // RecordType recordValid = parsingUtilities.VerifyString(record, ref recordPos, "Record Type", RecordType, ExtractConstants.RecordTypeLength, recordValid); // ProviderId recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.ProviderIdLength, recordValid); result.ProviderId = stringField; // ProviderLevelNumber recordValid = parsingUtilities.VerifyString(record, ref recordPos, "Hierarchy Level No.", ExtractConstants.ProviderLevelNumber, ExtractConstants.ProviderLevelNumberLength, recordValid); // LocationMid recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.LocationMidLength, recordValid); result.LocationMid = stringField; // ChainId recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.ChainIdLength, recordValid); result.ChainId = stringField; // CorporateId recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.CorporateIdLength, recordValid); result.CorporateId = stringField; // TerminalId recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.TerminalIdLength, recordValid); result.TerminalId = stringField; // BankMarker recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.BankMarkerLength, recordValid); result.BankMarker = stringField; // CardSuffix recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.CardSuffixLength, recordValid); result.CardSuffix = stringField; // OfferId recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.OfferIdLength, recordValid); result.OfferId = stringField; // ConsumerId recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.ConsumerIdLength, recordValid); result.ConsumerId = stringField; // TransactionId recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.TransactionIdLength, recordValid); result.TransactionId = stringField; // TransactionType recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.TransactionTypeLength, recordValid); TransactionType transactionType; recordValid = DetermineTransactionType(stringField, "Transaction Type", out transactionType, recordValid); result.TransactionType = transactionType; // TransactionDateTime recordValid = parsingUtilities.PopulateDateTime(record, ref recordPos, "Transaction Date\" and \"Transaction Time", out dateField, true, true, recordValid); result.TransactionDateTime = dateField; // TotalTransactionAmount recordValid = parsingUtilities.PopulateDecimal(record, ref recordPos, "Total Transaction Amount", out decimalField, ExtractConstants.TotalTransactionAmountLength, recordValid); result.TotalTransactionAmount = decimalField; // RedemptionDiscountAmount recordValid = parsingUtilities.PopulateDecimal(record, ref recordPos, "Redemption Discount Amount", out decimalField, ExtractConstants.RedemptionDiscountAmountLength, recordValid); result.RedemptionDiscountAmount = decimalField; // CurrencyCode recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.CurrencyCodeLength, recordValid); result.CurrencyCode = stringField; // InvoiceId recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.InvoiceIdLength, recordValid); result.InvoiceId = stringField; // AcquirerReferenceNumber recordValid = parsingUtilities.PopulateString(record, ref recordPos, out stringField, ExtractConstants.AcquirerReferenceNumberLength, recordValid); result.AcquirerReferenceNumber = stringField; // Record end parsingUtilities.VerifyRecordEnd(record, ref recordPos, FillerLength, true, recordValid); // If the record is not valid, return a null value. if (recordValid == false) { result = null; } return(result); }