//public int ChangePrintPriorityByOrderCode(string orderCode, string priority)
        //{
        //    return PrintMadeOrderDao.ChangePrintPriorityByOrderCode(orderCode, priority);
        //}

        //#endregion HighPrint - 우선출력

        //private void RollBackPrintMadeStatus(int orderId)
        //{
        //    IList<PrintMadeOrderItem> printMadeList = PrintMadeOrderDao.FindByOrderId(orderId);
        //    foreach (PrintMadeOrderItem item in printMadeList)
        //    {
        //        OrderHistoryService.RollbackPrintMadeStatus(item.Id);
        //    }
        //}

        //private void RollBackReadyMadeStatus(int orderId)
        //{
        //    IList<ReadyMadeOrderItem> readyMadeList = ReadyMadeOrderDao.FindByOrderId(orderId);
        //    foreach (ReadyMadeOrderItem item in readyMadeList)
        //    {
        //        OrderHistoryService.RollbackReadyMadeStatus(item.Id);
        //    }
        //}

        //public int InsertOrder(string userId)
        //{
        //    OrderItem orderItem = new OrderItem();
        //    orderItem.UserId = userId;
        //    int orderId = OrderDao.Insert(orderItem);
        //    return orderId;
        //}

        //public string GetOrderCode(int orderId)
        //{
        //    OrderItem item = OrderDao.FindById(orderId);
        //    return item.Code;
        //}

        //public OrderItem CreateNewOrderItem(string userId)
        //{
        //    OrderItem orderItem = new OrderItem();
        //    orderItem.UserId = userId;
        //    int orderId = OrderDao.Insert(orderItem);
        //    return OrderDao.FindById(orderId);
        //}

        //public BasicOrderParam GetBasicOrderParam(int orderId)
        //{
        //    return GetBasicOrderParamByType(orderId, "LIVING");
        //}

        //public BasicOrderParam GetBasicOrderParamWithComplete(int orderId)
        //{
        //    return GetBasicOrderParamByType(orderId, "ALL");
        //}

        //private BasicOrderParam GetBasicOrderParamByType(int orderId, string type)
        //{
        //    IList<ReadyMadeOrderItem> readyMadeOrderList = GetReaderMadeOrderListByType(orderId, type);
        //    IList<PrintMadeOrderItem> printMadeOrderList = GetPrintMadeOrderListByType(orderId, type);
        //    OrderItem orderItem = OrderDao.FindById(orderId);

        //    BasicOrderParam basicOrderParam = new BasicOrderParam();
        //    basicOrderParam.PrintMadeOrderList = printMadeOrderList;
        //    basicOrderParam.ReadyMadeOrderList = readyMadeOrderList;
        //    basicOrderParam.OrderItem = orderItem;

        //    return basicOrderParam;
        //}

        //private IList<ReadyMadeOrderItem> GetReaderMadeOrderListByType(int orderId, string type)
        //{
        //    if (type.Equals("LIVING")) return ReadyMadeOrderDao.FindLivingByOrderId(orderId);
        //    return ReadyMadeOrderDao.FindCompleteListByOrderId(orderId);
        //}

        //private IList<PrintMadeOrderItem> GetPrintMadeOrderListByType(int orderId, string type)
        //{
        //    if (type.Equals("LIVING")) return PrintMadeOrderDao.FindLivingByOrderId(orderId);
        //    return PrintMadeOrderDao.FindCompleteListByOrderId(orderId);
        //}

        //public int GetTaxAddedPrice(int orderId)
        //{
        //    IList<ReadyMadeOrderItem> readyMadeOrderList = ReadyMadeOrderDao.FindValidByOrderId(orderId);
        //    IList<PrintMadeOrderItem> printMadeOrderList = PrintMadeOrderDao.FindValidByOrderId(orderId);
        //    int readyMadeOrderPrice = readyMadeOrderList.Sum(item => item.TaxAddedTotalPrice);
        //    int printMadeOrderPrice = printMadeOrderList.Sum(item => item.TaxAddedTotalPrice);

        //    return readyMadeOrderPrice + printMadeOrderPrice;
        //}

        //public int GetTotalPrice(int orderId)
        //{
        //    PayInfoParam param = new PayInfoParam();

        //    IList<ReadyMadeOrderItem> readyMadeOrderList = ReadyMadeOrderDao.FindValidByOrderId(orderId);
        //    IList<PrintMadeOrderItem> printMadeOrderList = PrintMadeOrderDao.FindValidByOrderId(orderId);
        //    int readyMadeOrderPrice = readyMadeOrderList.Sum(item => item.TotalPrice);
        //    int printMadeOrderPrice = printMadeOrderList.Sum(item => item.TotalPrice);

        //    return readyMadeOrderPrice + printMadeOrderPrice;
        //}

        //public void SetPriceInPayInfoParam(int orderId, PayInfoParam param)
        //{
        //    IList<ReadyMadeOrderItem> readyMadeOrderList = ReadyMadeOrderDao.FindValidByOrderId(orderId);
        //    IList<PrintMadeOrderItem> printMadeOrderList = PrintMadeOrderDao.FindValidByOrderId(orderId);
        //    int readyMadeOrderPriceWithTax = readyMadeOrderList.Sum(item => item.TaxAddedTotalPrice);
        //    int printMadeOrderPriceWithTax = printMadeOrderList.Sum(item => item.TaxAddedTotalPrice);
        //    param.TaxAddedPrice = readyMadeOrderPriceWithTax + printMadeOrderPriceWithTax;

        //    int readyMadeOrderPrice = readyMadeOrderList.Sum(item => item.TaxAddedTotalPrice - item.Tax);
        //    int printMadeOrderPrice = printMadeOrderList.Sum(item => item.TaxAddedTotalPrice - item.Tax);
        //    param.GoodsPrice = readyMadeOrderPrice + printMadeOrderPrice;
        //}

        //[Transaction()]
        //public void ResetCanProductDateToMinDate(int id)
        //{
        //    OrderDao.UpdateCanProductDateToMinDate(id);
        //    PrintMadeOrderDao.UpdateProductRequestDateToMinDate(id);
        //    ReadyMadeOrderDao.UpdateProductRequestDateToMinDate(id);
        //}

        //public bool CanProduct(int id)
        //{
        //    IList<PrintMadeOrderItem> printMadeOrderList = PrintMadeOrderDao.FindLivingByOrderId(id);
        //    foreach (PrintMadeOrderItem item in printMadeOrderList)
        //    {
        //        if (!item.FileChecked()) return false;
        //    }

        //    OrderItem orderItem = OrderDao.FindById(id);
        //    if (!orderItem.PayStatus.Equals("PAID")) return false;

        //    return true;
        //}

        //[Transaction()]
        //public bool UpdateOrderStatusToProduct(int id)
        //{
        //    if (!CanProduct(id)) return false;
        //    OrderDao.UpdateOrderStatusToProduct(id);
        //    PrintMadeOrderDao.UpdateWorkStatusToGoodsOrderRequestByOrderId(id);
        //    ReadyMadeOrderDao.UpdateWorkStatusToGoodsOrderRequestByOrderId(id);

        //    UpdateOrderExpectDate.DoAction(id);

        //    OrderItem orderItem = OrderDao.FindById(id);
        //    string title = orderItem.Code + "の商品をただ今より出力に入らせていただきます。";
        //    MailService.SendOrderMailWithPhoneMail(orderItem, title);
        //    return true;
        //}

        //public OrderItem FindByMadeOrder(int madeOrderId, string orderType)
        //{
        //    if (orderType.Equals("PRINTMADE"))
        //    {
        //        return GetOrderItemByPrintMadeOrderId(madeOrderId);
        //    }
        //    return GetOrderItemByReadyMadeOrderId(madeOrderId);
        //}

        //private OrderItem GetOrderItemByPrintMadeOrderId(int printMadeOrderId)
        //{
        //    PrintMadeOrderItem item = PrintMadeOrderDao.FindById(printMadeOrderId);
        //    return OrderDao.FindById(item.OrderId);
        //}

        //private OrderItem GetOrderItemByReadyMadeOrderId(int readyMadeOrderId)
        //{
        //    ReadyMadeOrderItem item = ReadyMadeOrderDao.FindById(readyMadeOrderId);
        //    return OrderDao.FindById(item.OrderId);
        //}

        //public void UpdateOrderStatusByPrintMadeFileType(int id)
        //{
        //    UpdateOrderStatusByPrintMadeFileTypeUpdate.DoAction(id);
        //}

        //[Transaction()]
        //public void CancleOrder(int id)
        //{
        //    string workStatus = "CANCEL";

        //    OrderDao.UpdateOrderStatus(id, workStatus);
        //    PrintMadeOrderDao.UpdateWorkStatusByOrderId(id, workStatus);
        //    ReadyMadeOrderDao.UpdateWorkStatusByOrderId(id, workStatus);

        //    OrderItem orderItem = OrderDao.FindById(id);
        //    if (orderItem.PayInfoId == 0) return;
        //    PayInfoItem payInfoItem = PayInfoDao.FindById(orderItem.PayInfoId);
        //    SetCancelOrderProc(orderItem.Code, orderItem, payInfoItem, payInfoItem.TotalCharge);
        //}

        //[Transaction()]
        //public void CancleOrderWithTelegram(int id)
        //{
        //    var paygentRequestItem = PaygentRequestDao.RetrievePaymentRequestLatestItemByOrderId(id, "MK");
        //    Paygent_TELEGRAM_KIND telegramKind = Paygent_TELEGRAM_KIND.TELEGRAM_CARD_REQUEST;

        //    if (!Enum.TryParse<Paygent_TELEGRAM_KIND>(paygentRequestItem.Telegram_kind_code, out telegramKind))
        //    {
        //        CancleOrder(id);
        //        return;
        //    }
        //    if (telegramKind != Paygent_TELEGRAM_KIND.TELEGRAM_CARD_REQUEST)
        //    {
        //        CancleOrder(id);
        //        return;
        //    }

        //    var telegram = new PaygentTelegramRequest_DEFAULT();

        //    // Paygent로 부터 현재 상태 조회
        //    PaygentResult Result = PaygentService.ProcPaygentTelegramRequestManual(paygentRequestItem, Paygent_TELEGRAM_KIND.TELEGRAM_GENERAL_PAYMENT_INFO_SEARCH, telegram.ToRequestDictionary());
        //    if (Result.Result != PaygentResultStatus.SUCCESS)
        //    {
        //        if ("13001".Equals(Result.Response?.RESPONSE_HEADER_CODE)) // 해당 결제 정보가 존재하지 않습니다.
        //        {
        //            // 전표처리 하지 않는다.
        //            CancleOrder(id);
        //            return;
        //        }
        //        else
        //        {
        //            throw BizException.CreateMakumakuServiceException("エラーが発生しました。", "PG社から決済システムの応答がありません。\nしばらくお待ちになってから、もう一度行なってください。\nこの問題が続く場合、お手数ですが顧客センターまでご連絡お願いいたします。\n顧客センター(050-8882-5225)" + (Result.Response?.RESPONSE_HEADER_CODE ?? "."));
        //        }
        //    }

        //    PaygentResult cancelResult = null;
        //    string pg_payment_status = (Result.Response?.RESPONSE_DICTIONARY_LIST.FirstOrDefault()?["payment_status"] ?? "").ToString();
        //    switch (paygentRequestItem.LatestPaymentStatus)
        //    {
        //        case "":
        //            throw BizException.CreateMakumakuServiceException("エラーが発生しました。", "決済代行会社からお支払い情報を確認しています。しばらくお待ち頂いてから、再度お試しください。");
        //        case "10":
        //        case "11":
        //            // 전표처리 하지 않는다.
        //            break;

        //        case "20":
        //            if (!pg_payment_status.Equals(paygentRequestItem.LatestPaymentStatus)) throw BizException.CreateMakumakuServiceException("ORDCAN0004", "決済代行会社からお支払い情報を確認しています。しばらくお待ち頂いてから、再度お試しください。");
        //            cancelResult = PaygentService.ProcPaygentTelegramRequestManual(paygentRequestItem, Paygent_TELEGRAM_KIND.TELEGRAM_CARD_CANCEL, telegram.ToRequestDictionary());
        //            break;

        //        case "40":
        //            if (!pg_payment_status.Equals(paygentRequestItem.LatestPaymentStatus)) throw BizException.CreateMakumakuServiceException("ORDCAN0004", "決済代行会社からお支払い情報を確認しています。しばらくお待ち頂いてから、再度お試しください。");
        //            cancelResult = PaygentService.ProcPaygentTelegramRequestManual(paygentRequestItem, Paygent_TELEGRAM_KIND.TELEGRAM_CARD_SALES_CANCEL, telegram.ToRequestDictionary());
        //            break;

        //        default:
        //            // 그 외, 취소할 수 없는 상태 상세 메시지를 얻기 위해서 PG사로 전표 취소요청후 메시지를 응답 받는다.
        //            cancelResult = PaygentService.ProcPaygentTelegramRequestManual(paygentRequestItem, Paygent_TELEGRAM_KIND.TELEGRAM_CARD_SALES_CANCEL, telegram.ToRequestDictionary());
        //            break;
        //    }

        //    if (cancelResult != null && cancelResult.Result != PaygentResultStatus.SUCCESS)
        //    {
        //        string addMsg = cancelResult.Result.ToString();
        //        if (cancelResult.ManagedException != null) { addMsg += cancelResult.ManagedException.Message; }
        //        if (cancelResult.Response != null) { addMsg += cancelResult.Response.RESPONSE_HEADER_CODE; }
        //        throw BizException.CreateMakumakuServiceException("エラーが発生しました。", "PG社から決済システムの応答がありません。\nしばらくお待ちになってから、もう一度行なってください。\nこの問題が続く場合、お手数ですが顧客センターまでご連絡お願いいたします。\n顧客センター(050-8882-5225)" + addMsg);
        //    }

        //    CancleOrder(id);
        //}

        //public void SetUserWriteInfo(int id)
        //{
        //    OrderItem item = OrderDao.FindById(id);
        //    if (item.IsCustomerWriteStatus()) return;

        //    item.UserWriteDate = DateTime.Now;
        //    item.CommentWriteStatus = "CUSTOMER";
        //    OrderDao.Update(item);
        //}

        //public void SetManagerWriteInfo(int id)
        //{
        //    OrderItem item = OrderDao.FindById(id);

        //    item.ManagerWriteDate = DateTime.Now;
        //    item.CommentWriteStatus = "MANAGER";
        //    item.UserReadStatus = "NEW";
        //    item.UserReadDate = SqlDateTime.MinValue;
        //    OrderDao.Update(item);
        //}

        //public void ClearManagerWriteInfo(int id)
        //{
        //    OrderItem item = OrderDao.FindById(id);

        //    item.ManagerWriteDate = DateTime.Now;
        //    item.CommentWriteStatus = "MANAGER";
        //    item.UserReadStatus = "READ";
        //    item.UserReadDate = SqlDateTime.MinValue;
        //    OrderDao.Update(item);
        //}

        //public ListParam<OrderItem> GetOrderCommentListParam(string fieldName, string searchValue, int page, int pageSize, string type)
        //{
        //    int startNum = (page - 1) * pageSize + 1;
        //    int endNum = page * pageSize;
        //    int itemCount = OrderDao.GetTotalCountByCommentWriteStatus(fieldName, searchValue, type);

        //    ListParam<OrderItem> param = new ListParam<OrderItem>();
        //    param.ItemList = OrderDao.FindByCommentWriteStatus(fieldName, searchValue, type, startNum, endNum);
        //    param.FieldSelectList = GetFieldSelectList(fieldName);
        //    param.SearchValue = searchValue;
        //    param.Type = type;

        //    IPager pager = new ButtonPager() { TotalCount = itemCount, CurrentPage = page, PageSize = pageSize, CountOfListPage = BoardUtil.countOfPageList };
        //    param.Pager = pager;
        //    return param;
        //}

        //private SelectList GetFieldSelectList(string fieldName)
        //{
        //    IList<ListItem> list = new List<ListItem>();
        //    list.Add(new ListItem() { Value = "code", Text = "주문번호" });
        //    list.Add(new ListItem() { Value = "userName", Text = "주문자명" });
        //    return new SelectList(list, "Value", "Text", fieldName);
        //}

        //public OrderItem InsertReproductOrderItem(int id)
        //{
        //    OrderItem prevOrderItem = OrderDao.FindById(id);
        //    OrderItem newOrderItem = GetReProductOrderItem(prevOrderItem);

        //    int newOrderId = OrderDao.Insert(newOrderItem);
        //    newOrderItem = OrderDao.FindById(newOrderId);
        //    return newOrderItem;
        //}

        //private OrderItem GetReProductOrderItem(OrderItem prevOrderItem)
        //{
        //    OrderItem item = new OrderItem();
        //    item.UserId = prevOrderItem.UserId;

        //    item.DeliveryInfoId = GetDeliveryInfoIdForReRroduct(prevOrderItem.DeliveryInfoId);
        //    item.PayInfoId = GetPayInfoIdForReProduct(prevOrderItem.PayInfoId);

        //    item.OrderDate = DateTime.Now;
        //    return item;
        //}

        //private int GetDeliveryInfoIdForReRroduct(int prevDeliveryInfoId)
        //{
        //    DeliveryInfoItem item = DeliveryInfoDao.FindById(prevDeliveryInfoId);
        //    item.Id = 0;
        //    return DeliveryInfoDao.Insert(item);
        //}

        //private int GetPayInfoIdForReProduct(int prevPayInfoId)
        //{
        //    PayInfoItem item = PayInfoDao.FindById(prevPayInfoId);
        //    item.Id = 0;
        //    item.ProductCharge = 0;
        //    item.ShippingCharge = 0;
        //    item.ManPaidCharge = 0;
        //    item.CashPrice = 0;
        //    item.PointPaid = 0;
        //    item.BankUserName = "";
        //    item.PayType = "MAN";
        //    item.BankType = "";

        //    return PayInfoDao.Insert(item);
        //}

        //[Transaction()]
        //public void DeletePrintMadeOrder(int id, int printMadeOrderId)
        //{
        //    PrintMadeOrderItem printMadeOrderItem = PrintMadeOrderDao.FindById(printMadeOrderId);
        //    OrderItem orderItem = OrderDao.FindById(id);
        //    PayInfoItem payInfoItem = PayInfoDao.FindById(orderItem.PayInfoId);

        //    int madeOrderPrice = printMadeOrderItem.TaxAddedTotalPrice;

        //    if (HasLivingMadeOrder(id))
        //    {
        //        SetCancelOrderProc(printMadeOrderItem.Code, orderItem, payInfoItem, madeOrderPrice);
        //    }

        //    PrintMadeOrderDao.UpdateWorkStatus(printMadeOrderId, "CANCEL");

        //    if (!HasLivingMadeOrder(id))
        //    {
        //        OrderDao.UpdateOrderStatus(id, "CANCEL");
        //    }
        //    else
        //    {
        //        UpdateOrderStatusToProduct(id);
        //    }
        //}

        //[Transaction()]
        //public void DeletePrintMadeOrderByManager(int id, int printMadeOrderId)
        //{
        //    GoodsOrderInfo orderInfo = GetLivingGoodsOrderInfo(id);
        //    if (orderInfo.HasSingleGoods()) return;

        //    PrintMadeOrderItem printMadeOrderItem = PrintMadeOrderDao.FindById(printMadeOrderId);
        //    OrderItem orderItem = OrderDao.FindById(id);
        //    PayInfoItem payInfoItem = PayInfoDao.FindById(orderItem.PayInfoId);

        //    int madeOrderPrice = printMadeOrderItem.TaxAddedTotalPrice;
        //    SetCancelOrderProc(printMadeOrderItem.Code, orderItem, payInfoItem, madeOrderPrice);
        //    PrintMadeOrderDao.UpdateWorkStatus(printMadeOrderId, "CANCEL");
        //}

        private void SetCancelOrderProc(string code, OrderItem orderItem, PayInfoItem payInfoItem, int reducePrice)
        {
            int returnPoint = 0;

            if (payInfoItem.IsBank() && orderItem.IsPaid())
            {
                returnPoint = PayInfoService.ReducePayInfoWhenDepositChecked(payInfoItem, reducePrice);
            }
            else if (payInfoItem.PayType.StartsWith("TELEGRAM"))
            {
                if (payInfoItem.PayType.Equals("TELEGRAM_CARD_REQUEST") && orderItem.IsPaid())
                {
                    returnPoint = payInfoItem.PointPaid;
                }
                else
                {
                    returnPoint = orderItem.IsPaid() ? payInfoItem.CashPrice : payInfoItem.PointPaid;
                }
            }
            else
            {
                returnPoint = PayInfoService.ReducePayInfoWhenDepositUnChecked(payInfoItem, reducePrice);
            }

            PayInfoDao.Update(payInfoItem);

            if (returnPoint > 0)
            {
                string title = "[" + code + "]注文取り消しによる返金ポイント";
                PointService.AddPoint(title, returnPoint, orderItem.UserId);
            }
        }
Exemplo n.º 2
0
        private void UpdatePayInfo(OrderItem orderItem, int payInfoId, PayInfoItem payInfoItem)
        {
            PayInfoItem prevPayInfoItem = PayInfoDao.FindById(payInfoId);

            if (prevPayInfoItem.PointPaid > 0)
            {
                string title = "[" + orderItem.Code + "]支払方法変更による返金ポイント";
                PointService.AddPoint(title, prevPayInfoItem.PointPaid, orderItem.UserId);
            }

            payInfoItem.Id = payInfoId;

            if (!orderItem.OrderStatus.Equals("ORDER_CONFIRM"))
            {
                OrderDao.UpdateOrderStatus(orderItem.Id, "PAY_INFO");
            }

            if (payInfoItem.IsMan() || (payInfoItem.PayType.Equals("TELEGRAM_CARD_REQUEST") && orderItem.IsPaid()))
            {
                OrderDao.UpdatePayStatus(orderItem.Id, "PAID");
            }
            else if (payInfoItem.IsBank() && (prevPayInfoItem.IsMan() || prevPayInfoItem.IsBank() || (payInfoItem.PayType.Equals("TELEGRAM_CARD_REQUEST") && !orderItem.IsPaid())))
            {
                OrderDao.UpdatePayStatus(orderItem.Id, "UNPAID");
            }

            PayInfoDao.Update(payInfoItem);

            if (payInfoItem.PointPaid > 0)
            {
                SubtractPoint(orderItem, payInfoItem);
            }
            OrderService.UpdateOrderStatusToProduct(orderItem.Id);
        }