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.
|
|
using Common; using Common.Helper; using Common.Model; using Common.Model.Reward; using log4net; using Repository.Reward; using System; using System.Threading.Tasks;
namespace Business.Reward { public class RewardServices : IRewardServices { private readonly IRewardRepository requestServices; private static readonly ILog Log = LogManager.GetLogger(typeof(RewardServices));
public RewardServices(RewardRepository requestServices) { this.requestServices = requestServices; }
JsonRxResponse IRewardServices.GetProductLists(string rooturl) { var jsonResult = requestServices.GetProductLists(rooturl); if (jsonResult.ErrorCode == "0") { Log.Debug("Get Products success."); } else { Log.Debug("Get Products failed."); }
return jsonResult; }
JsonRxResponse IRewardServices.BuyProduct(RequestedOrderDetail orderRequest) { JsonRxResponse jsonResult = new JsonRxResponse(); var checkresult = checkBuyProduct(orderRequest); Log.Debug("[REWARD-POINT] BuyProduct : CheckResult.ErrorCode =" + checkresult.ErrorCode + ",CheckResult.Msg =" + checkresult.Msg);
if (checkresult.ErrorCode == "0") { try { jsonResult = requestServices.BuyProduct(orderRequest); Log.Debug("[REWARD-POINT] BuyProduct : jsonResult.ErrorCode =" + jsonResult.ErrorCode + ",jsonResult.Msg =" + jsonResult.Msg);
if (jsonResult.ErrorCode == "0") { string branchemail = jsonResult.Extra; if (string.IsNullOrEmpty(branchemail)) { jsonResult.ErrorCode = "1"; jsonResult.Msg = "branch email is null"; jsonResult.Data = new System.Collections.ArrayList(); } else { var dbvar = jsonResult.Extra2.Split(',');
EmailParameters _emailParams = new EmailParameters() { To = branchemail, To_1 = GetStatic.ReadWebConfig("RewardAdminEmail", ""), MsgSubject = "Reward Product is orderd_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm"), MsgBody = "Hello, Reward Product is orderd. <br>" + "Customer Id : " + orderRequest.userId + "<br> Mobile Number : " + dbvar[2] + "<br> Branch Name : " + dbvar[0] + "<br> Product : " + dbvar[1] }; Task.Run(() => GetStatic.SendMultipleEmail(_emailParams)); jsonResult.Extra = ""; jsonResult.Extra2 = ""; } }
if (jsonResult.ErrorCode == "0") { Log.Debug("Buy Products success."); } else { Log.Debug("Buy Products failed."); } } catch (Exception e) { Log.DebugFormat($"Exception : {e.ToString()}"); jsonResult.ErrorCode = "1"; jsonResult.Msg = e.ToString(); jsonResult.Data = new System.Collections.ArrayList(); return jsonResult; }
return jsonResult; } else { return checkresult; } }
JsonRxResponse IRewardServices.OrderedProductList(RequestedOrderDetail orderRequest) { if (string.IsNullOrEmpty(orderRequest.userId)) { JsonRxResponse jsonRx = new JsonRxResponse { ErrorCode = "1", Msg = "No UserId", Data = new System.Collections.ArrayList() }; return jsonRx; } if (!string.IsNullOrEmpty(orderRequest.startDate) && !string.IsNullOrEmpty(orderRequest.endDate)) { if (!Utilities.CheckDateType(orderRequest.startDate) || !Utilities.CheckDateType(orderRequest.endDate)) { JsonRxResponse jsonRx = new JsonRxResponse { ErrorCode = "1", Msg = "No DateType", Data = new System.Collections.ArrayList() }; return jsonRx; } } else { orderRequest.endDate = DateTime.Now.ToString("yyyy-MM-dd"); orderRequest.startDate = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd"); }
var jsonResult = requestServices.OrderedProductList(orderRequest);
if (jsonResult.ErrorCode == "0") { Log.Debug("Get Ordered Products list success."); } else { Log.Debug("Get Ordered Products list failed."); }
return jsonResult; }
JsonRxResponse IRewardServices.GetAgentInfo() { var jsonResult = requestServices.GetAgentInfo(); if (jsonResult.ErrorCode == "0") { Log.Debug("Get Agent Infos success."); } else { Log.Debug("Get Agent Infos failed."); }
return jsonResult; }
private JsonRxResponse checkBuyProduct(RequestedOrderDetail orderRequest) { JsonRxResponse jsonRx = new JsonRxResponse(); if (string.IsNullOrEmpty(orderRequest.userId)) { jsonRx.ErrorCode = "1"; jsonRx.Msg = "No UserId"; jsonRx.Data = new System.Collections.ArrayList(); return jsonRx; } if (string.IsNullOrEmpty(orderRequest.productCode)) { jsonRx.ErrorCode = "1"; jsonRx.Msg = "No productCode"; jsonRx.Data = new System.Collections.ArrayList(); return jsonRx; } if (string.IsNullOrEmpty(orderRequest.usePoint)) { jsonRx.ErrorCode = "1"; jsonRx.Msg = "No usePoint"; jsonRx.Data = new System.Collections.ArrayList(); return jsonRx; } if (orderRequest.orderType != "1" && orderRequest.orderType != "9") { jsonRx.ErrorCode = "1"; jsonRx.Msg = "No orderType"; jsonRx.Data = new System.Collections.ArrayList(); return jsonRx; } if (orderRequest.recvType != "1" && orderRequest.recvType != "2") { jsonRx.ErrorCode = "1"; jsonRx.Msg = "No recvType"; jsonRx.Data = new System.Collections.ArrayList(); return jsonRx; } if (orderRequest.recvType == "1") { if (string.IsNullOrEmpty(orderRequest.recvAddress)) { jsonRx.ErrorCode = "1"; jsonRx.Msg = "No recvAddress"; jsonRx.Data = new System.Collections.ArrayList(); return jsonRx; } if (string.IsNullOrEmpty(orderRequest.recvZipCode)) { jsonRx.ErrorCode = "1"; jsonRx.Msg = "No recvZipCode"; jsonRx.Data = new System.Collections.ArrayList(); return jsonRx; } if (string.IsNullOrEmpty(orderRequest.recvPhoneNumber)) { jsonRx.ErrorCode = "1"; jsonRx.Msg = "No recvPhoneNumber"; jsonRx.Data = new System.Collections.ArrayList(); return jsonRx; } if (string.IsNullOrEmpty(orderRequest.recvName)) { jsonRx.ErrorCode = "1"; jsonRx.Msg = "No recvName"; jsonRx.Data = new System.Collections.ArrayList(); return jsonRx; } } else if (orderRequest.recvType == "2") { if (string.IsNullOrEmpty(orderRequest.branchCode)) { jsonRx.ErrorCode = "1"; jsonRx.Msg = "No branchCode"; jsonRx.Data = new System.Collections.ArrayList(); return jsonRx; } } jsonRx.ErrorCode = "0"; jsonRx.Msg = null; jsonRx.Data = new System.Collections.ArrayList(); return jsonRx; } } }
|