| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using System.Data;
- using Common;
- using Database;
- using Database.Database;
- using Microsoft.EntityFrameworkCore.Internal;
- using MyKungKangWorker.Utils;
- using Newtonsoft.Json;
- using Quartz;
- namespace CMS.Worker;
- public class LogicUtils
- {
- private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(LogicUtils));
- //public static async Task<bool> AddingPointForUserAsync(
- // IConfiguration configuration,
- // ModelContext dbContext,
- // string msisdn,
- // decimal point,
- // Term term,
- // Prize prize
- //)
- //{
- // try
- // {
- // // calculate prize for user with
- // PaymentTransaction paymentTransaction = new PaymentTransaction()
- // {
- // Id = (decimal)await DbLogic.GenIdAsync(dbContext, "payment_transaction_seq"),
- // TransactionId = CommonLogic.GenerateUUID(),
- // Money = prize.Amount,
- // Status = "1",
- // CreatedTime = DateTime.Now,
- // PartnerTransactionId = "0"
- // };
- // dbContext.PaymentTransactions.Add(paymentTransaction);
- // await dbContext.SaveChangesAsync();
- // TermUserPrize termUserPrize = new TermUserPrize()
- // {
- // Id = (decimal)await DbLogic.GenIdAsync(dbContext, "term_user_prize_seq"),
- // Msisdn = msisdn,
- // Priority = prize.Priority,
- // TermId = term.Id,
- // PrizeId = prize.Id,
- // TimeCalculate = DateTime.Now,
- // Status = CommonErrorCode.AddPointWaiting,
- // TotalPoints = point,
- // PaymentTransactionId = paymentTransaction.Id
- // };
- // dbContext.TermUserPrizes.Add(termUserPrize);
- // await dbContext.SaveChangesAsync();
- // AddDataReq request = new AddDataReq
- // {
- // refTrans = paymentTransaction.TransactionId,
- // msisdn = msisdn,
- // packageCode = prize.Code
- // };
- // string bodyString = JsonConvert.SerializeObject(request);
- // PaymentTransactionLog paymentTransactionLog = new PaymentTransactionLog()
- // {
- // Id = (decimal)await DbLogic.GenIdAsync(dbContext, "payment_transaction_log_seq"),
- // PaymentTransactionId = paymentTransaction.Id,
- // Type = "REQUEST",
- // RequestUrl = configuration.GetSection("UrlAddData").Value ?? "",
- // RequestBody = bodyString
- // };
- // // add point to user
- // var addPointRes = AddingPointLogic.AddingPointHandler(
- // log,
- // configuration,
- // msisdn,
- // paymentTransaction.TransactionId,
- // prize.Code
- // );
- // // var addPointRes = new AddDataRes("{\"success\":\"true\", \"result\":{\"id\":\"1\"}}");
- // if (addPointRes != null && addPointRes.success == true)
- // {
- // termUserPrize.Status = CommonErrorCode.AddPointSuccess;
- // termUserPrize.TimeReceived = DateTime.Now;
- // paymentTransaction.Status = "0";
- // paymentTransaction.PartnerTransactionId = addPointRes.result!.id!;
- // // send sms to user
- // var msg = dbContext
- // .Configs.Where(
- // x => x.ParamName == (CommonConstants.Weekly + "_" + prize.Amount)
- // )
- // .FirstOrDefault();
- // if (msg != null)
- // {
- // List<List<DateTime>> timeWeekly = CommonLogic.GetTimeWeekly(1);
- // string? message = null;
- // string? messageData =
- // msg.ParamValueFr != null ? msg.ParamValueFr : msg.ParamValue;
- // if (messageData != null)
- // {
- // message = messageData
- // .Replace(
- // "%from%",
- // timeWeekly[0][0].ToString(CommonConstants.DateTimeFormar12)
- // )
- // .Replace(
- // "%to%",
- // timeWeekly[0][1].ToString(CommonConstants.DateTimeFormar12)
- // );
- // }
- // await CommonLogic.SendMtToUserAsync(dbContext, msisdn, message);
- // }
- // }
- // else
- // {
- // termUserPrize.Status = CommonErrorCode.AddPointFailure;
- // }
- // paymentTransactionLog.Status =
- // addPointRes != null && addPointRes.success == true ? "0" : "-1";
- // paymentTransactionLog.ResponseBody = JsonConvert.SerializeObject(addPointRes);
- // dbContext.TermUserPrizes.Update(termUserPrize);
- // dbContext.PaymentTransactions.Update(paymentTransaction);
- // dbContext.PaymentTransactionLogs.Add(paymentTransactionLog);
- // await dbContext.SaveChangesAsync();
- // return true;
- // }
- // catch (Exception ex)
- // {
- // log.Error("Exception: ", ex);
- // }
- // return true;
- //}
- }
|