public CardPaymentRequestStatus ProcessCardPaymentRequest(CardPayment cardPayment, int retryCount)
        {
            var result = CardPaymentRequestStatus.NotRequest;
            // SZXResult szxResult = PaymentsService.YeepayCardPayments(cardPayment); //卡内金额全部充值
            SZXResult szxResult = PaymentsService.YeepayCardPartialPayments(cardPayment); //部分充值


            LogHelper.WriteInfo(string.Format("Processing card payment with OrderNo : {0}, request result : {1}", cardPayment.OrderNo, szxResult == null ? "null" : szxResult.R1_Code));
            if (szxResult == null || string.IsNullOrEmpty(szxResult.R1_Code)) // retry
            {
                if (retryCount == -1)
                {
                    result = CardPaymentRequestStatus.RequestFailed;
                }
                else
                {
                    cardPayment.RequestDateTime = DateTime.Now;
                    retryCount++;
                    result = CardPaymentRequestStatus.RequestFailed;

                    if (retryCount <= retryTimesLimitation)
                    {
                        RedisService.AddItemToQueue <CardPayment>(BillingConsts.KEY_CARD_PAYMENT_REQUEST_RETRY_QUEUE + retryCount, cardPayment);
                    }
                    else // final failed
                    {
                        Order currentOrder = oracleRepo.Single <Order>(cardPayment.OrderID);
                        SetFailedOrderStatus(CardPaymentRequestStatus.RequestFailed, currentOrder);
                        //record the info for retry manually
                        var cardPaymentInfoForRetry = EntityMapping.Auto <CardPayment, CardPaymentRetry>(cardPayment);
                        var AddRes = oracleRepo.Add <CardPaymentRetry>(cardPaymentInfoForRetry);
                    }
                }
            }
            else
            {
                CardPaymentRequestStatus requestStatus = (CardPaymentRequestStatus)szxResult.R1_Code.ToInt32();
                Order currentOrder = oracleRepo.Single <Order>(cardPayment.OrderID);

                if (currentOrder != null)
                {
                    switch (requestStatus)
                    {
                    case CardPaymentRequestStatus.Success:
                        SetSuccessOrderStatus(currentOrder);
                        result = requestStatus;
                        break;

                    default:
                        SetFailedOrderStatus(requestStatus, currentOrder);
                        result = requestStatus;
                        break;
                    }
                }
            }
            return(result);
        }
        private void FailedNofity(PaymentNotification callbackInfo, Order currentOrder)
        {
            currentOrder.OrderStatus = OrderStatus.Stoped;
            var updateRet = oracleRepo.Update <Order>(currentOrder);

            var callbackNotifyDetails = EntityMapping.Auto <PaymentNotification, CallbackNotification>(callbackInfo);

            callbackNotifyDetails.IsNotifySuccess = false;
            callbackNotifyDetails.LastRequestDate = DateTime.Now;
            var addRet = oracleRepo.Add <CallbackNotification>(callbackNotifyDetails);
        }
        private void SuccessNofity(PaymentNotification callbackInfo, Order currentOrder)
        {
            currentOrder.OrderStatus = OrderStatus.Complete;
            var updateRet = oracleRepo.Update <Order>(currentOrder);
            //成功    从通知队列中把通知model删除 记录成功信息
            var callbackNotifyDetails = EntityMapping.Auto <PaymentNotification, CallbackNotification>(callbackInfo);

            callbackNotifyDetails.IsNotifySuccess = true;
            callbackNotifyDetails.LastRequestDate = DateTime.Now;
            var addRet = oracleRepo.Add <CallbackNotification>(callbackNotifyDetails);
        }
Esempio n. 4
0
        public void should_map_from_imsi_info()
        {
            var imsi = new IMSIInfo()
            {
                IMSI = "12343545", Mobile = "223232"
            };

            var ret = EntityMapping.Auto <IMSIInfo, IMSIInfoViewModel>(imsi);

            Assert.Equal(imsi.IMSI, ret.IMSI);
            Assert.Equal(imsi.Mobile, ret.Mobile);
        }
Esempio n. 5
0
        public List <IMSIInfoViewModel> GetMobiles(IEnumerable <string> imsiList)
        {
            var imsiModels = new List <IMSIInfoViewModel>();

            if (imsiList != null)
            {
                foreach (var imsi in imsiList)
                {
                    if (!imsi.IsNullOrEmpty())
                    {
                        var imsiInfo = this.GetMobile(imsi);
                        if (imsiInfo != null)
                        {
                            imsiModels.Add(EntityMapping.Auto <IMSIInfo, IMSIInfoViewModel>(imsiInfo));
                        }
                    }
                }
            }
            return(imsiModels);
        }
Esempio n. 6
0
        public CardPaymentRequestStatus RetryRequest(string id)
        {
            var cardPaymentRetry = Repository.Single <CardPaymentRetry>(id);

            var cp  = EntityMapping.Auto <CardPaymentRetry, CardPayment>(cardPaymentRetry);
            var res = CardPaymentProcessor.ProcessCardPaymentRequest(cp, -1);

            switch (res)
            {
            case CardPaymentRequestStatus.RequestFailed:
                break;

            case CardPaymentRequestStatus.NotRequest:
                break;

            default:
                Repository.Delete <CardPaymentRetry>(id);
                break;
            }
            return(res);
        }
Esempio n. 7
0
        public void AddMenu(DataDicUI Data)
        {
            DataDic menuModel = EntityMapping.Auto <DataDicUI, DataDic>(Data);

            DataDicContext.Add(menuModel);
        }
Esempio n. 8
0
 public List <RoleUI> GetRoleInfoByPage(int startPage, int pageSize, out int totalCount)
 {
     return(EntityMapping.Auto <List <Role>, List <RoleUI> >(RoleContext.GetRoleListByPage(startPage, pageSize, out totalCount)));
 }
Esempio n. 9
0
 public UserUI GetUserInfoByNo(string No)
 {
     return(EntityMapping.Auto <User, UserUI>(LoginContext.FirstOrDefault(x => x.UserNo == No)));
 }
Esempio n. 10
0
 public List <UserUI> GetUserInfoById(int Id)
 {
     return(EntityMapping.Auto <List <User>, List <UserUI> >(LoginContext.GetUserInfoById(Id)));
 }
Esempio n. 11
0
 public StudentBasicInfoUI GetStudengInfoById(int Id)
 {
     return(EntityMapping.Auto <StudentBasicInfo, StudentBasicInfoUI>(StudentBasicInfoContext.GetStudentInfoById(Id)));
 }
Esempio n. 12
0
 public TeacherBasicInfoUI GetTeacherInfoById(int Id)
 {
     return(EntityMapping.Auto <TeacherBasicInfo, TeacherBasicInfoUI>(TeacherBasicInfoContext.GetTeacherInfoById(Id)));
 }
Esempio n. 13
0
 public List <TeacherBasicInfoUI> GetTeacherInfoByPage(int startPage, int pageSize, out int totalCount)
 {
     return(EntityMapping.Auto <List <TeacherBasicInfo>, List <TeacherBasicInfoUI> >(TeacherBasicInfoContext.GetTeacherInfoByPage(startPage, pageSize, out totalCount)));
 }
Esempio n. 14
0
 public List <DataDicUI> GetDataInfoByPage(int startPage, int pageSize, out int totalCount)
 {
     return(EntityMapping.Auto <List <DataDic>, List <DataDicUI> >(DataDicContext.GetDateListByPage(startPage, pageSize, out totalCount)));
 }
Esempio n. 15
0
        public void AddDataDic(DataDicInfoUI dataInfo)
        {
            DataDicInfo dataInfoModel = EntityMapping.Auto <DataDicInfoUI, DataDicInfo>(dataInfo);

            DataDicinfoContext.Add(dataInfoModel);
        }
Esempio n. 16
0
 public List <DataDicInfoUI> GetDataDicInfoById(int Id)
 {
     return(EntityMapping.Auto <List <DataDicInfo>, List <DataDicInfoUI> >(DataDicinfoContext.GetDataDicInfoById(Id)));
 }
Esempio n. 17
0
        public RoleUI GetRoleByRoleId(int Id)

        {
            return(EntityMapping.Auto <Role, RoleUI>(RoleContext.GetRoleByRoleId(Id)));
        }