internal static bool IsPossibleCode(string codeNumber) { BlackBoxServiceClient clientService = new BlackBoxServiceClient(); bool isPossible = clientService.IsPossible(codeNumber); ///clientService.Close(); // Lỗi khi đang gọi bị đóng seviceClient return isPossible; }
internal static PacificCodeViewModel GetPacificCodeViewModel(string partCodeNumber) { BlackBoxServiceClient clientService = new BlackBoxServiceClient(); PacificCodeViewModel model = clientService.GetPacificCodeViewModel(partCodeNumber); ///clientService.Close(); // Lỗi khi đang gọi bị đóng seviceClient return model; }
internal static DateTime GetExpireDate(string partCodeNumber) { BlackBoxServiceClient clientService = new BlackBoxServiceClient(); DateTime result = clientService.GetExpireDate(partCodeNumber); ///clientService.Close(); // Lỗi khi đang gọi bị đóng seviceClient return result; }
internal static bool IsExist(string codeNumber) { BlackBoxServiceClient clientService = new BlackBoxServiceClient(); bool isExist = clientService.IsExist(codeNumber); ///clientService.Close(); // Lỗi khi đang gọi bị đóng seviceClient return isExist; }
internal static double GetActualAmount(string partCodeNumber) { BlackBoxServiceClient clientService = new BlackBoxServiceClient(); double result = (double)clientService.GetValue(partCodeNumber); ///clientService.Close(); // Lỗi khi đang gọi bị đóng seviceClient return result; }
internal static bool IsExist(string partCodeNumber) { BlackBoxServiceClient clientService = new BlackBoxServiceClient(); // Kiểm tra tồn tại trong BlackBox & trong Security bool result = clientService.IsExist(partCodeNumber); result = result & PartPacificCodeDAO.IsExist(partCodeNumber); return result; }
internal static int GetTotalAmount(Guid userId) { List<PartPacificCode> lstPPC = PartPacificCodeDAO.GetList(userId); int iAmount = 0; BlackBoxServiceClient clientService = new BlackBoxServiceClient(); foreach (PartPacificCode ppc in lstPPC) { iAmount += clientService.GetValue(ppc.PartCodeNumber); } return iAmount; }
/// <summary> /// Tạo 1 PacificCode có giá trị amountBuy /// Lấy 12/16 lưu lại trong PartPacificCode /// </summary> internal static PartPacificCode GetNewPacificCode(Guid storeGuid, Guid customerGuid, int amountBuy) { BlackBoxServiceClient clientService = new BlackBoxServiceClient(); PartPacificCode newPartPacificCode = new PartPacificCode(); string codeNumber = clientService.NewPacificCode(amountBuy); newPartPacificCode.PartCodeNumber = GetPartCodeNumber(codeNumber); newPartPacificCode.StoreUserId = storeGuid; newPartPacificCode.CustomerId = customerGuid; PartPacificCodeDAO.AddNew(newPartPacificCode); ///clientService.Close(); // Lỗi khi đang gọi bị đóng seviceClient return newPartPacificCode; }
internal static PacificCodeViewModel SendMoney(string codeNumber, string phoneNumber, double amount) { BlackBoxServiceClient clientService = new BlackBoxServiceClient(); string newCodeNumber = clientService.MakePayment(codeNumber, (int)amount); /// Lưu thông tin liên quan đến khách hàng PartPacificCode newPartPacficiCode = new PartPacificCode(); Customer existCustomer = CustomerBUS.GetCustomerOrCreateNotYetBuy(phoneNumber); newPartPacficiCode.CustomerId = existCustomer.UserId; newPartPacficiCode.StoreUserId = null; // Lấy ID tự động? PartPacificCodeDAO.AddNew(newPartPacficiCode); /// Lấy payment model, trả ra kết quả PacificCodeViewModel model = clientService.GetPacificCodeViewModel(newCodeNumber); return model; }
internal static PacificCodeViewModel GetLastPacificCode(Guid customerUserId) { string[] arrCodeNumber = PartPacificCodeDAO.GetArray(customerUserId); if (arrCodeNumber.Count() > 0) { BlackBoxServiceClient clientService = new BlackBoxServiceClient(); PacificCodeViewModel[] arrPCVM = clientService.GetArrayPacificCodeViewModel(arrCodeNumber); PacificCodeViewModel lastPCVM = arrPCVM[0]; foreach (PacificCodeViewModel item in arrPCVM) { if (item.CreateDate > lastPCVM.CreateDate) { lastPCVM = item; } } return lastPCVM; } return null; }
internal static int GetMoneyForPayMent(string codeNumber, int amount) { try { /// Ví dụ: PacificCode có giá trị 5000, mà gia tri can thanh toan là 6000 /// => chỉ thanh toan 5000 //PartPacificCodeBUS.GetActualAmount int actualAmount = (int)GetActualAmount(codeNumber.Substring(0, 12)); int min = Utility.Min(actualAmount, amount); BlackBoxServiceClient clientService = new BlackBoxServiceClient(); // Lỗi khi thanh toán bằng nhiều PacificCode => sửa sau // clientService.MakePayment(codeNumber, min); if (min > 0) { clientService.MakePayment(codeNumber, min); } return min; } catch { throw new Exception("Money Pacific: Error payment service!.."); } }
// codeNumber phải đủ 16 số.. internal static string ChangeCode(string oldCodeNumber) { string newCodeNumber; BlackBoxServiceClient clientService = new BlackBoxServiceClient(); newCodeNumber = clientService.ChangeCode(oldCodeNumber); if (newCodeNumber != null) { PartPacificCode existPPC = PartPacificCodeDAO.GetObject(oldCodeNumber); existPPC.PartCodeNumber = newCodeNumber.Substring(0, 12); PartPacificCodeDAO.Update(existPPC); return newCodeNumber; } return null; }