You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
667 lines
33 KiB
667 lines
33 KiB
using Common;
|
|
using Common.Helper;
|
|
using Common.JsonFileParsing;
|
|
using Common.Language;
|
|
using Common.Model.AutoRefund;
|
|
using Common.Model.PowerCall;
|
|
using log4net;
|
|
using Newtonsoft.Json;
|
|
using PushNotification;
|
|
using Repository.PowerCallRepository;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Business.PowerCall
|
|
{
|
|
public class PowerCallBusiness : IPowerCallBusiness
|
|
{
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(PowerCallBusiness));
|
|
private readonly IPowerCallRepository _repoPowerCall;
|
|
private readonly string branch_id = ApplicationConfig.ReadWebConfig("BRANCH_ID", "");
|
|
private readonly string branch_pwd = ApplicationConfig.ReadWebConfig("BRANCH_PWD", "");
|
|
private readonly string powercall_key = ApplicationConfig.ReadWebConfig("POWER_CALL_KEY", "");
|
|
|
|
public PowerCallBusiness(IPowerCallRepository requestPowerCall)
|
|
{
|
|
_repoPowerCall = requestPowerCall;
|
|
}
|
|
|
|
public JsonRxResponse GetChargeHistory(PowerCallInfo.GetPowerCallChargeHistory getHistory)
|
|
{
|
|
JsonRxResponse res = new JsonRxResponse();
|
|
List<PowerCallInfo.UserChargeInfos> userInfos = new List<PowerCallInfo.UserChargeInfos>();
|
|
DataTable dts = _repoPowerCall.GetUserChageInfo(getHistory.CustomerId, getHistory.FromDate, getHistory.ToDate);
|
|
if (dts == null || dts.Rows.Count <= 0)
|
|
{
|
|
res.ErrorCode = "0";
|
|
res.Msg = "Not Charge Histories";
|
|
res.Data = userInfos.ToArray();
|
|
return res;
|
|
}
|
|
foreach (DataRow row in dts.Rows)
|
|
{
|
|
PowerCallInfo.UserChargeInfos info = new PowerCallInfo.UserChargeInfos();
|
|
var request = row["request"].ToString();
|
|
var errorMsg = row["errorMessage"].ToString();
|
|
var errorCode = row["errorCode"].ToString();
|
|
var requestTime = row["requestTime"].ToString();
|
|
var controllNo = row["orderId"].ToString();
|
|
int splitIndex = controllNo.IndexOf("_");
|
|
controllNo = controllNo.Remove(0, splitIndex + 1);
|
|
var parse = JsonConvert.DeserializeObject<PowerCallInfo.BuyItem>(request);
|
|
|
|
switch (Convert.ToInt32(parse.BuyType))
|
|
{
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.MANGO_INTERNATIONAL_PHONE_CHARGE:
|
|
info.ChargeType = "MANGO CHARGE";
|
|
break;
|
|
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.PPS_NOMAL_CHARGE:
|
|
info.ChargeType = "NOMAL CHARGE";
|
|
break;
|
|
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.PPS_MONTH:
|
|
info.ChargeType = "MONTH CHARGE";
|
|
break;
|
|
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.PPS_DATA:
|
|
info.ChargeType = "DATA CHARGE";
|
|
break;
|
|
}
|
|
info.ProductPrice = parse.ProductPrice;
|
|
info.PhoneNo = parse.PhoneNo;
|
|
info.Status = errorCode;
|
|
info.ErrorMsg = errorMsg;
|
|
info.CardName = parse.CardName;
|
|
info.RequestTime = requestTime;
|
|
info.ControllNo = controllNo;
|
|
userInfos.Add(info);
|
|
}
|
|
|
|
res.ErrorCode = "0";
|
|
res.Msg = "SUCCESS";
|
|
res.Data = userInfos;
|
|
return res;
|
|
}
|
|
|
|
public JsonRxResponse CallBackPowerCall(string callBack)
|
|
{
|
|
JsonRxResponse res = new JsonRxResponse();
|
|
Log.Debug(callBack);
|
|
var callBackRes = JsonConvert.DeserializeObject<PowerCallInfo.callbackJson>(callBack);
|
|
var chargeInfo = JsonConvert.DeserializeObject<PowerCallInfo.BuyItem>(_repoPowerCall.GetChargeInfo(callBackRes.sale_no));
|
|
string fcmId = _repoPowerCall.GetFcmId(chargeInfo.CustomerId);
|
|
var processId = _repoPowerCall.GetProcessId(callBackRes.sale_no);
|
|
string chargeString = "charge_success";
|
|
KJAutoRefundModel model = new KJAutoRefundModel()
|
|
{
|
|
customerId = chargeInfo.CustomerId,
|
|
amount = chargeInfo.UseBalancePrice,
|
|
action = "REQ",
|
|
customerSummary = processId,
|
|
bankAccountNo = "null",
|
|
bankCode = "null",
|
|
actionBy = "",
|
|
actionDate = "",
|
|
rowId = "",
|
|
};
|
|
string restoreMoney = model.amount;
|
|
string mainCategory = null;
|
|
bool isNomal = false;
|
|
switch (Convert.ToInt32(chargeInfo.BuyType))
|
|
{
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.MANGO_INTERNATIONAL_PHONE_CHARGE:
|
|
break;
|
|
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.PPS_DATA:
|
|
mainCategory = "Date";
|
|
break;
|
|
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.PPS_NOMAL_CHARGE:
|
|
mainCategory = "Nomal";
|
|
chargeInfo.ChargeType = "Nomal";
|
|
isNomal = true;
|
|
break;
|
|
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.PPS_MONTH:
|
|
mainCategory = "Month";
|
|
break;
|
|
}
|
|
var commision = _repoPowerCall.GetCommision(mainCategory, chargeInfo.ChargeType);
|
|
|
|
if (callBackRes.result.Equals("0000") == false)
|
|
{
|
|
var errorDic = JsonFileParsing.Deserialize<Dictionary<string, string>>("powerCallErrorCode");
|
|
string errorMsg = null;
|
|
errorDic.TryGetValue(callBackRes.cause, out errorMsg);
|
|
res.ErrorCode = "1";
|
|
res.Msg = errorMsg == null ? callBackRes.cause : errorMsg;
|
|
res.Data = callBackRes;
|
|
chargeString = "charge_fail";
|
|
model.action = "FAIL";
|
|
if (callBackRes.result.Equals("1000") == true)
|
|
{
|
|
if (Convert.ToInt32(chargeInfo.BuyType) == (int)PowerCallInfo.CARD_LIST_TYPE.PPS_NOMAL_CHARGE)
|
|
{
|
|
var convertSuccess_cnt = Convert.ToInt32(callBackRes.success_cnt);
|
|
var convertPrice = convertSuccess_cnt * 10000;
|
|
model.amount = convertPrice.ToString();
|
|
restoreMoney = (Convert.ToInt32(chargeInfo.UseBalancePrice) - convertPrice).ToString();
|
|
res.ErrorCode = "0";
|
|
chargeString = "charge_success";
|
|
res.Msg += "Charge Amount:" + convertPrice;
|
|
var convertComission = Convert.ToDouble(commision);
|
|
convertComission = convertComission * convertSuccess_cnt;
|
|
commision = convertComission.ToString();
|
|
model.action = "SUCCESS";
|
|
var restoreWallet = _repoPowerCall.ReStoreWallet(model, restoreMoney, commision, chargeInfo.PhoneNo);
|
|
if (restoreWallet.ResponseCode == "1")
|
|
{
|
|
res.Msg = restoreWallet.Msg;
|
|
_repoPowerCall.CallBackPowerCallHistory(callBackRes.sale_no, res.ErrorCode, res.Msg, JsonConvert.SerializeObject(res.Data));
|
|
Task.Run(() => FcmNotifier.Notify(fcmId, Languages.GetMessage(chargeString, "en"), Languages.GetTitle("Charge", "en"), false, new { destination = "RechargeHistory" }));
|
|
return res;
|
|
}
|
|
_repoPowerCall.CallBackPowerCallHistory(callBackRes.sale_no, res.ErrorCode, res.Msg, JsonConvert.SerializeObject(res.Data));
|
|
Task.Run(() => FcmNotifier.Notify(fcmId, Languages.GetMessage(chargeString, "en"), Languages.GetTitle("Charge", "en"), false, new { destination = "RechargeHistory" }));
|
|
return res;
|
|
}
|
|
}
|
|
var Fail = _repoPowerCall.FailWallet(model);
|
|
if (Fail.ResponseCode == "1")
|
|
{
|
|
res.Msg = Fail.Msg;
|
|
_repoPowerCall.CallBackPowerCallHistory(callBackRes.sale_no, res.ErrorCode, res.Msg, JsonConvert.SerializeObject(res.Data));
|
|
Task.Run(() => FcmNotifier.Notify(fcmId, Languages.GetMessage(chargeString, "en"), Languages.GetTitle("Charge", "en"), false, new { destination = "RechargeHistory" }));
|
|
return res;
|
|
}
|
|
_repoPowerCall.CallBackPowerCallHistory(callBackRes.sale_no, res.ErrorCode, res.Msg, JsonConvert.SerializeObject(res.Data));
|
|
Task.Run(() => FcmNotifier.Notify(fcmId, Languages.GetMessage(chargeString, "en"), Languages.GetTitle("Charge", "en"), false, new { destination = "RechargeHistory" }));
|
|
return res;
|
|
}
|
|
|
|
if (isNomal)
|
|
{
|
|
var convertPrice = Convert.ToInt32(chargeInfo.ProductPrice);
|
|
var cardCnt = convertPrice / 10000;
|
|
var convertComission = Convert.ToDouble(commision);
|
|
convertComission = convertComission * cardCnt;
|
|
commision = convertComission.ToString();
|
|
}
|
|
res.ErrorCode = "0";
|
|
res.Msg = "Success";
|
|
res.Data = callBackRes;
|
|
_repoPowerCall.ResultWallet(model, commision, chargeInfo.PhoneNo);
|
|
_repoPowerCall.CallBackPowerCallHistory(callBackRes.sale_no, res.ErrorCode, res.Msg, JsonConvert.SerializeObject(res.Data));
|
|
Task.Run(() => FcmNotifier.Notify(fcmId, Languages.GetMessage(chargeString, "en"), Languages.GetTitle("Charge", "en"), false, new { destination = "RechargeHistory" }));
|
|
|
|
return res;
|
|
}
|
|
|
|
public JsonRxResponse GetCardInfo(PowerCallInfo.GetCardInfo getCardInfo)
|
|
{
|
|
PowerCallPostGet requestPowerCall = new PowerCallPostGet();
|
|
JsonRxResponse res = new JsonRxResponse();
|
|
string url = null;
|
|
var getCardType = Convert.ToInt32(getCardInfo.GetcardType);
|
|
var cardTypeInfos = new List<PowerCallInfo.CardTypeInfo>();
|
|
PowerCallInfo.cardListResult cardResult = null;
|
|
var chargeState = _repoPowerCall.GetPowerCallHistory(getCardInfo.CustomerId);
|
|
if (chargeState != null && chargeState["errorCode"].ToString() == "5")
|
|
{
|
|
res.ErrorCode = chargeState["errorCode"].ToString();
|
|
res.Msg = chargeState["errorMessage"].ToString();
|
|
res.Data = cardResult;
|
|
return res;
|
|
}
|
|
if (getCardType == (int)PowerCallInfo.CARD_LIST_TYPE.PPS_MONTH)
|
|
{
|
|
PowerCallInfo.PlanInfo planInfoJson = null;
|
|
var phoneNo = Crypto.Encrypt128(getCardInfo.PhoneNo, powercall_key);
|
|
url = $@"/flatCheck/all?phone_no={phoneNo}&agent_code={branch_id}";
|
|
var respones = requestPowerCall.GetFromPowerCAll(url);
|
|
|
|
var monthInfo = JsonConvert.DeserializeObject<PowerCallInfo.JoinMonthInfo>(respones);
|
|
if (monthInfo.result.Equals("0000"))
|
|
{
|
|
/// PowerCALL API 로 호출 되는 타입이 일정치 않아서, PlanInfo Json 형태로 변경 (josn string 형태가 아니면
|
|
/// null로 전달)
|
|
try
|
|
{
|
|
planInfoJson = JsonConvert.DeserializeObject<PowerCallInfo.PlanInfo>(monthInfo.plan_info);
|
|
}
|
|
catch
|
|
{
|
|
planInfoJson = null;
|
|
}
|
|
var removeCardNameIndex = monthInfo.card_name.IndexOf('(');
|
|
PowerCallInfo.CardTypeInfo cardInfo = new PowerCallInfo.CardTypeInfo();
|
|
cardInfo.CardName = monthInfo.card_name.Remove(removeCardNameIndex);
|
|
cardInfo.CardCode = null;
|
|
cardInfo.FacePrice = null;
|
|
cardInfo.Promotion_price = null;
|
|
|
|
cardInfo.SubInfo = new PowerCallInfo.ProductListInfo[] {
|
|
new PowerCallInfo.ProductListInfo()
|
|
{
|
|
Card_name = monthInfo.card_name,
|
|
Card_type = monthInfo.card_type,
|
|
Face_price = monthInfo.face_price,
|
|
Sale_price = monthInfo.sale_price,
|
|
Mvno_code = monthInfo.mvno_info.mvno_code.ToString(),
|
|
Plan_info = planInfoJson,
|
|
Telecom_code = monthInfo.telecom_code,
|
|
}
|
|
};
|
|
cardResult = new PowerCallInfo.cardListResult()
|
|
{
|
|
CardListType = getCardInfo.GetcardType,
|
|
ButtonsGrid = null,
|
|
CountryPriceCode = null,
|
|
CardInfo = new PowerCallInfo.CardTypeInfo[] { cardInfo }
|
|
};
|
|
Log.Debug(JsonConvert.SerializeObject(respones));
|
|
res.ErrorCode = "0";
|
|
res.Msg = "Success";
|
|
res.Data = cardResult;
|
|
return res;
|
|
}
|
|
|
|
url = $@"/getFlatProductList?agent_code={branch_id}";
|
|
respones = requestPowerCall.GetFromPowerCAll(url);
|
|
|
|
var getShopItems = JsonConvert.DeserializeObject<PowerCallInfo.NotJoinMonthInfo>(respones);
|
|
|
|
var itemGroups = getShopItems.product_list.GroupBy(i => i.Mvno_code).ToArray();
|
|
|
|
List<PowerCallInfo.CardTypeInfo> typeInfos = new List<PowerCallInfo.CardTypeInfo>();
|
|
foreach (var itemGroup in itemGroups)
|
|
{
|
|
/// PowerCALL API 로 호출 되는 타입이 일정치 않아서, PlanInfo Json 형태로 변경 (josn string 형태가 아니면
|
|
/// null로 전달)
|
|
List<PowerCallInfo.ProductListInfo> product_list = new List<PowerCallInfo.ProductListInfo>();
|
|
foreach (var jsonparse in itemGroup)
|
|
{
|
|
try
|
|
{
|
|
planInfoJson = JsonConvert.DeserializeObject<PowerCallInfo.PlanInfo>(jsonparse.Plan_info);
|
|
}
|
|
catch
|
|
{
|
|
planInfoJson = null;
|
|
}
|
|
product_list.Add(new PowerCallInfo.ProductListInfo()
|
|
{
|
|
Card_name = jsonparse.Card_name,
|
|
Card_type = jsonparse.Card_type,
|
|
Face_price = jsonparse.Face_price,
|
|
Mvno_code = jsonparse.Mvno_code,
|
|
Plan_info = planInfoJson,
|
|
Product_name = jsonparse.Product_name,
|
|
Product_type = jsonparse.Product_type,
|
|
Sale_price = jsonparse.Sale_price,
|
|
Telecom_code = jsonparse.Telecom_code
|
|
});
|
|
}
|
|
var getKey = itemGroup.Key;
|
|
var card_name = itemGroup.Select(i => i.Card_name).FirstOrDefault();
|
|
PowerCallInfo.CardTypeInfo cardInfo = new PowerCallInfo.CardTypeInfo();
|
|
var removeIndexStr = card_name.IndexOf('(');
|
|
cardInfo.CardName = card_name.Remove(removeIndexStr);
|
|
cardInfo.Promotion_price = null;
|
|
cardInfo.CardCode = null;
|
|
cardInfo.SubInfo = product_list.ToArray();
|
|
typeInfos.Add(cardInfo);
|
|
}
|
|
cardResult = new PowerCallInfo.cardListResult()
|
|
{
|
|
CardListType = getCardInfo.GetcardType,
|
|
ButtonsGrid = null,
|
|
CountryPriceCode = null,
|
|
CardInfo = typeInfos.ToArray()
|
|
};
|
|
Log.Debug(JsonConvert.SerializeObject(respones));
|
|
}
|
|
else if (getCardType == (int)PowerCallInfo.CARD_LIST_TYPE.MANGO_INTERNATIONAL_PHONE_CHARGE)
|
|
{
|
|
var user_id = Crypto.Encrypt128(branch_id, powercall_key);
|
|
var user_pwd = Crypto.Encrypt128(branch_pwd, powercall_key);
|
|
var phoneNo = Crypto.Encrypt128(getCardInfo.PhoneNo, powercall_key);
|
|
url = $@"/mangoCustInfo?user_id={user_id}&user_pwd={user_pwd}&phone_no={phoneNo}&agent_code={branch_id}";
|
|
var respones = requestPowerCall.GetFromPowerCAll(url);
|
|
Log.Debug(JsonConvert.SerializeObject(respones));
|
|
var parseResnpones = JsonConvert.DeserializeObject<PowerCallInfo.MangoJoinUser>(respones);
|
|
if (parseResnpones == null || parseResnpones.result.Equals("9999"))
|
|
{
|
|
res.ErrorCode = "1";
|
|
res.Msg = "Not Join Mango";
|
|
res.Data = null;
|
|
return res;
|
|
}
|
|
PowerCallInfo.StaticPrice getButton = JsonFileParsing.Deserialize<PowerCallInfo.StaticPrice>();
|
|
if (getButton == null)
|
|
{
|
|
res.ErrorCode = "1";
|
|
res.Msg = "invaild Table Button";
|
|
res.Data = null;
|
|
return res;
|
|
}
|
|
var codePrice = JsonFileParsing.Deserialize<PowerCallInfo.CountryPriceCode>();
|
|
if (codePrice == null)
|
|
{
|
|
res.ErrorCode = "1";
|
|
res.Msg = "invaild Table codePrice";
|
|
res.Data = null;
|
|
return res;
|
|
}
|
|
PowerCallInfo.CardTypeInfo cardInfo = new PowerCallInfo.CardTypeInfo();
|
|
cardInfo.CardCode = "MANGO_001";
|
|
cardInfo.CardName = "MANGO_CARD";
|
|
cardInfo.SubInfo = null;
|
|
cardTypeInfos.Add(cardInfo);
|
|
cardResult = new PowerCallInfo.cardListResult()
|
|
{
|
|
CardListType = getCardInfo.GetcardType,
|
|
ButtonsGrid = getButton.ButtonPriceType.NomalGirld,
|
|
CountryPriceCode = codePrice.countryPriceCode.ToArray(),
|
|
CardInfo = cardTypeInfos.ToArray()
|
|
};
|
|
}
|
|
else if (getCardType == (int)PowerCallInfo.CARD_LIST_TYPE.PPS_NOMAL_CHARGE)
|
|
{
|
|
PowerCallInfo.ButtonType[] getButtonGrid = null;
|
|
res = new JsonRxResponse();
|
|
var getButton = JsonFileParsing.Deserialize<PowerCallInfo.StaticPrice>();
|
|
if (getButton == null)
|
|
{
|
|
res.ErrorCode = "1";
|
|
res.Msg = "invaild Table Button";
|
|
res.Data = null;
|
|
return res;
|
|
}
|
|
getButtonGrid = getButton.ButtonPriceType.NomalGirld.ToArray();
|
|
cardResult = new PowerCallInfo.cardListResult()
|
|
{
|
|
CardListType = getCardInfo.GetcardType,
|
|
ButtonsGrid = getButtonGrid,
|
|
CountryPriceCode = null,
|
|
CardInfo = null,
|
|
};
|
|
}
|
|
else
|
|
{
|
|
var user_id = Crypto.Encrypt128(branch_id, powercall_key);
|
|
var user_pwd = Crypto.Encrypt128(branch_pwd, powercall_key);
|
|
var card_type = Crypto.Encrypt128(getCardInfo.GetcardType, powercall_key);
|
|
url = $@"/getPdsCardList?user_id={user_id}&user_pwd={user_pwd}&card_type={card_type}&agent_code={branch_id}";
|
|
var respones = requestPowerCall.GetFromPowerCAll(url);
|
|
Log.Debug(JsonConvert.SerializeObject(respones));
|
|
var parseRespones = JsonConvert.DeserializeObject<PowerCallInfo.GetGetCardByPowerCall[]>(respones);
|
|
if (parseRespones == null || parseRespones.Count() == 0)
|
|
{
|
|
res.ErrorCode = "1";
|
|
res.Msg = "Invaild Info CardList";
|
|
res.Data = null;
|
|
return res;
|
|
}
|
|
var enableItems = parseRespones.Where(i => i.ct_enable == "Y").ToArray();
|
|
|
|
foreach (var enableItem in enableItems)
|
|
{
|
|
PowerCallInfo.CardTypeInfo cardInfo = new PowerCallInfo.CardTypeInfo();
|
|
cardInfo.CardName = enableItem.ct_card_name;
|
|
cardInfo.CardCode = enableItem.ct_card_type;
|
|
cardInfo.FacePrice = enableItem.ct_face_price.ToString();
|
|
cardInfo.Promotion_price = enableItem.ct_promotion.ToString();
|
|
cardInfo.SubInfo = null;
|
|
cardTypeInfos.Add(cardInfo);
|
|
}
|
|
cardResult = new PowerCallInfo.cardListResult()
|
|
{
|
|
CardListType = PowerCallInfo.CARD_LIST_TYPE.PPS_DATA.ToString("d"),
|
|
ButtonsGrid = null,
|
|
CountryPriceCode = null,
|
|
CardInfo = cardTypeInfos.ToArray()
|
|
};
|
|
}
|
|
|
|
res.ErrorCode = "0";
|
|
res.Msg = "Success";
|
|
res.Data = cardResult;
|
|
return res;
|
|
}
|
|
|
|
public JsonRxResponse VerificationAndBuy(PowerCallInfo.BuyItem buyItem)
|
|
{
|
|
JsonRxResponse res = new JsonRxResponse();
|
|
var buyType = Convert.ToInt32(buyItem.BuyType);
|
|
var useBalncePrice = Convert.ToInt32(buyItem.UseBalancePrice);
|
|
if ((int)PowerCallInfo.CARD_LIST_TYPE.PPS_NOMAL_CHARGE == buyType)
|
|
{
|
|
buyItem.ChargeType = "Nomal";
|
|
}
|
|
var request = _repoPowerCall.Request(buyItem.CustomerId, buyItem.BuyType, buyItem.ChargeType, buyItem.CardName, buyItem.ProductPrice, buyItem.PhoneNo, JsonConvert.SerializeObject(buyItem), MethodBase.GetCurrentMethod().Name);
|
|
var powerCallRowId = Convert.ToInt64(request.Id);
|
|
var orderId = request.Extra2;
|
|
if (Enum.IsDefined(typeof(PowerCallInfo.CARD_LIST_TYPE), Convert.ToInt32(buyItem.BuyType)) == false)
|
|
{
|
|
res.ErrorCode = "1";
|
|
res.Msg = "Invaild BuyType";
|
|
res.Data = null;
|
|
_repoPowerCall.PowerCallHistory(powerCallRowId, res.ErrorCode, res.Msg, "");
|
|
return res;
|
|
}
|
|
if (string.IsNullOrWhiteSpace(buyItem.PhoneNo) == true || Convert.ToInt32(buyItem.UseBalancePrice) <= 0
|
|
|| Convert.ToInt32(buyItem.ProductPrice) <= 0 || (Convert.ToInt32(buyItem.ProductPrice) - Convert.ToInt32(buyItem.UseBalancePrice)) != 0)
|
|
{
|
|
res.ErrorCode = "1";
|
|
res.Msg = "Invaild PhoneNo or Price";
|
|
res.Data = null;
|
|
_repoPowerCall.PowerCallHistory(powerCallRowId, res.ErrorCode, res.Msg, "");
|
|
return res;
|
|
}
|
|
|
|
KJAutoRefundModel model = new KJAutoRefundModel()
|
|
{
|
|
flag = "useWalletMoney",
|
|
customerId = buyItem.CustomerId,
|
|
amount = buyItem.UseBalancePrice,
|
|
action = "REQ",
|
|
customerSummary = request.Extra,
|
|
bankAccountNo = "null",
|
|
bankCode = "null",
|
|
actionBy = "",
|
|
actionDate = "",
|
|
};
|
|
try
|
|
{
|
|
string commision = string.Empty;
|
|
switch (buyType)
|
|
{
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.PPS_NOMAL_CHARGE:
|
|
commision = _repoPowerCall.GetCommision("Nomal", "Nomal");
|
|
break;
|
|
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.PPS_DATA:
|
|
commision = _repoPowerCall.GetCommision("Data", buyItem.ChargeType);
|
|
break;
|
|
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.PPS_MONTH:
|
|
commision = _repoPowerCall.GetCommision("Month", buyItem.ChargeType);
|
|
break;
|
|
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.MANGO_INTERNATIONAL_PHONE_CHARGE:
|
|
commision = _repoPowerCall.GetCommision("cardCailng", "cardCailng");
|
|
break;
|
|
}
|
|
if (string.IsNullOrEmpty(commision))
|
|
{
|
|
res.ErrorCode = "1";
|
|
res.Msg = "Not Setting CardList";
|
|
res.Data = null;
|
|
_repoPowerCall.PowerCallHistory(powerCallRowId, res.ErrorCode, res.Msg, "");
|
|
return res;
|
|
}
|
|
var result = _repoPowerCall.CheckWallet(model, buyItem.PassWord);
|
|
if (result.ResponseCode == "1")
|
|
{
|
|
res.ErrorCode = result.ResponseCode;
|
|
res.Msg = result.Msg;
|
|
res.Data = null;
|
|
_repoPowerCall.PowerCallHistory(powerCallRowId, res.ErrorCode, res.Msg, "");
|
|
return res;
|
|
}
|
|
_repoPowerCall.PowerCallHistory(powerCallRowId, "5", "W", "");
|
|
// request 요청
|
|
switch (buyType)
|
|
{
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.PPS_NOMAL_CHARGE:
|
|
int charge_cnt = Convert.ToInt32(buyItem.ProductPrice) / 10000;
|
|
res = BuyNomalCharge(charge_cnt.ToString(), "2", orderId, buyItem.PhoneNo, powerCallRowId);
|
|
break;
|
|
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.PPS_DATA:
|
|
res = BuyDataCharge("1", buyItem.ChargeType, "2", orderId, buyItem.PhoneNo, powerCallRowId);
|
|
break;
|
|
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.PPS_MONTH:
|
|
res = BuyMonthCharge("1", buyItem.ChargeType, "2", orderId, buyItem.PhoneNo, powerCallRowId);
|
|
break;
|
|
|
|
case (int)PowerCallInfo.CARD_LIST_TYPE.MANGO_INTERNATIONAL_PHONE_CHARGE:
|
|
res = BuyMangoCharge(buyItem.ProductPrice, buyItem.ChargeType, orderId, buyItem.PhoneNo, powerCallRowId);
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception ex) { }
|
|
|
|
if (res.ErrorCode == "1")
|
|
{
|
|
model.action = "FAIL";
|
|
_repoPowerCall.FailWallet(model);
|
|
return res;
|
|
}
|
|
res.ErrorCode = "0";
|
|
res.Msg = "Success Request";
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 일반 요금 충전
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public JsonRxResponse BuyNomalCharge(string chargeCnt, string flag, string orderNo, string phoneNo, long rowId)
|
|
{
|
|
JsonRxResponse res = new JsonRxResponse();
|
|
PowerCallPostGet requestPowerCall = new PowerCallPostGet();
|
|
var user_id = Crypto.Encrypt128(branch_id, powercall_key);
|
|
var user_pwd = Crypto.Encrypt128(branch_pwd, powercall_key);
|
|
var charge_cnt = Crypto.Encrypt128(chargeCnt, powercall_key);
|
|
var sales_no = Crypto.Encrypt128(orderNo, powercall_key);
|
|
var sale_flag = Crypto.Encrypt128(flag, powercall_key);
|
|
var phone_no = Crypto.Encrypt128(phoneNo, powercall_key);
|
|
var url = $@"/autoCharge?user_id={user_id}&user_pwd={user_pwd}&charge_cnt={charge_cnt}&sale_no={sales_no}&sale_flag={sale_flag}&phone_no={phone_no}&agent_code={branch_id}";
|
|
_repoPowerCall.PowercallLog(rowId, url);
|
|
requestPowerCall.GetFromPowerCAll(url);
|
|
res.ErrorCode = "5";
|
|
res.Msg = "W";
|
|
res.Data = null;
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 데이터충전
|
|
/// </summary>
|
|
/// <param name="chargeCnt"></param>
|
|
/// <param name="flag"></param>
|
|
/// <param name="orderNo"></param>
|
|
/// <param name="phoneNo"></param>
|
|
/// <returns></returns>
|
|
public JsonRxResponse BuyDataCharge(string chargeCnt, string cardType, string flag, string orderNo, string phoneNo, long rowId)
|
|
{
|
|
JsonRxResponse res = new JsonRxResponse();
|
|
PowerCallPostGet requestPowerCall = new PowerCallPostGet();
|
|
var user_id = Crypto.Encrypt128(branch_id, powercall_key);
|
|
var user_pwd = Crypto.Encrypt128(branch_pwd, powercall_key);
|
|
var charge_cnt = Crypto.Encrypt128(chargeCnt.ToString(), powercall_key);
|
|
var card_type = Crypto.Encrypt128(cardType, powercall_key);
|
|
var sales_no = Crypto.Encrypt128(orderNo, powercall_key);
|
|
var sale_flag = Crypto.Encrypt128(flag, powercall_key);
|
|
var phone_no = Crypto.Encrypt128(phoneNo, powercall_key);
|
|
var url = $@"/dataCharge?user_id={user_id}&user_pwd={user_pwd}&card_type={card_type}&charge_cnt={charge_cnt}&sale_no={sales_no}&sale_flag={sale_flag}&phone_no={phone_no}&agent_code={branch_id}";
|
|
_repoPowerCall.PowercallLog(rowId, url);
|
|
requestPowerCall.GetFromPowerCAll(url);
|
|
res.ErrorCode = "5";
|
|
res.Msg = "W";
|
|
res.Data = null;
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 월충전 구매
|
|
/// </summary>
|
|
/// <param name="chargeCnt"></param>
|
|
/// <param name="flag"></param>
|
|
/// <param name="orderNo"></param>
|
|
/// <param name="phoneNo"></param>
|
|
/// <returns></returns>
|
|
public JsonRxResponse BuyMonthCharge(string chargeCnt, string cardType, string flag, string orderNo, string phoneNo, long rowId)
|
|
{
|
|
JsonRxResponse res = new JsonRxResponse();
|
|
PowerCallPostGet requestPowerCall = new PowerCallPostGet();
|
|
var user_id = Crypto.Encrypt128(branch_id, powercall_key);
|
|
var user_pwd = Crypto.Encrypt128(branch_pwd, powercall_key);
|
|
var charge_cnt = Crypto.Encrypt128(chargeCnt, powercall_key);
|
|
var card_type = Crypto.Encrypt128(cardType, powercall_key);
|
|
var sales_no = Crypto.Encrypt128(orderNo, powercall_key);
|
|
var sale_flag = Crypto.Encrypt128(flag, powercall_key);
|
|
var phone_no = Crypto.Encrypt128(phoneNo, powercall_key);
|
|
var url = $@"/flatCharge?user_id={user_id}&user_pwd={user_pwd}&card_type={card_type}&charge_cnt={charge_cnt}&sale_no={sales_no}&sale_flag={sale_flag}&phone_no={phone_no}&agent_code={branch_id}";
|
|
_repoPowerCall.PowercallLog(rowId, url);
|
|
requestPowerCall.GetFromPowerCAll(url);
|
|
res.ErrorCode = "5";
|
|
res.Msg = "W";
|
|
res.Data = null;
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 망고 상품 구매
|
|
/// </summary>
|
|
/// <param name="chargeCnt"></param>
|
|
/// <param name="flag"></param>
|
|
/// <param name="orderNo"></param>
|
|
/// <param name="phoneNo"></param>
|
|
/// <returns></returns>
|
|
public JsonRxResponse BuyMangoCharge(string price, string cardType, string orderNo, string phoneNo, long rowId)
|
|
{
|
|
JsonRxResponse res = new JsonRxResponse();
|
|
PowerCallPostGet requestPowerCall = new PowerCallPostGet();
|
|
var user_id = Crypto.Encrypt128(branch_id, powercall_key);
|
|
var user_pwd = Crypto.Encrypt128(branch_pwd, powercall_key);
|
|
var sale_price = Crypto.Encrypt128(price, powercall_key);
|
|
var card_type = Crypto.Encrypt128(cardType, powercall_key);
|
|
var sale_no = Crypto.Encrypt128(orderNo, powercall_key);
|
|
var phone_no = Crypto.Encrypt128(phoneNo, powercall_key);
|
|
var url = $@"/mangoCharge?user_id={user_id}&user_pwd={user_pwd}&card_type={card_type}&sale_price={sale_price}&sale_no={sale_no}&phone_no={phone_no}&agent_code={branch_id}";
|
|
_repoPowerCall.PowercallLog(rowId, url);
|
|
var respones = requestPowerCall.GetFromPowerCAll(url);
|
|
var responesbyPowerCall = JsonConvert.DeserializeObject<PowerCallInfo.ChargePowerCall>(respones);
|
|
if (responesbyPowerCall == null || responesbyPowerCall.result.Equals("0000") == false) // PowerCallInfo.cs
|
|
{
|
|
res.ErrorCode = "1";
|
|
res.Msg = responesbyPowerCall == null ? "PowerCall Respones Null" : responesbyPowerCall.cause;
|
|
res.Data = "";
|
|
return res;
|
|
}
|
|
res.ErrorCode = "0";
|
|
res.Msg = "Success";
|
|
res.Data = responesbyPowerCall;
|
|
return res;
|
|
}
|
|
}
|
|
}
|