Exemplo n.º 1
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);
        }
        public void HighPrintCancel(int orderId)
        {
            var    orderItem = OrderDao.FindById(orderId);
            string procType  = XMLUtil.GetString(orderItem.Content, "PARENTHIGHPRINT", "PROCTYPE");
            int    addPrice  = XMLUtil.GetInt32(orderItem.Content, "PARENTHIGHPRINT", "ADDPRICE");

            if ("NEWGOODS".Equals(procType))
            {
                var highOrder = OrderDao.FIndByHighPrintId(orderItem.Id);
                PrintMadeOrderDao.ChangePrintPriorityByOrderCode(orderItem.Code, "");
                var payInfo = PayInfoDao.FindById(highOrder.Id);
                if (payInfo != null && payInfo.PayType.StartsWith("TELEGRAM"))
                {
                    CancleOrderWithTelegram(highOrder.Id);
                }
                else
                {
                    CancleOrder(highOrder.Id);
                }
            }
            if ("ADDPRICE".Equals(procType))
            {
                string firstItemType = string.Empty;
                int    firstItemId   = 0;
                foreach (var item in PrintMadeOrderDao.FindByOrderId(orderItem.Id))
                {
                    firstItemType = "PRINTMADE";
                    firstItemId   = item.Id;
                    break;
                }
                foreach (var item in ReadyMadeOrderDao.FindByOrderId(orderItem.Id))
                {
                    firstItemType = "READMADE";
                    firstItemId   = item.Id;
                    break;
                }

                if ("PRINTMADE".Equals(firstItemType))
                {
                    var madeItem = PrintMadeOrderDao.FindById(firstItemId);
                    int orgPrice = madeItem.TaxAddedTotalPrice;
                    madeItem.ExtraPrice -= addPrice;
                    PrintMadeOrderDao.Update(madeItem);
                    DeliveryInfoItem DeliveryInfoItem = DeliveryInfoDao.FindById(orderItem.DeliveryInfoId);
                    PayInfoService.UpdateChangeProductCharge(orderItem.PayInfoId, "MINUS", orgPrice, DeliveryInfoItem);
                    PayInfoService.UpdateChangeProductCharge(orderItem.PayInfoId, "PLUS", madeItem.TaxAddedTotalPrice, DeliveryInfoItem);
                }
                else if ("READYMADE".Equals(firstItemType))
                {
                    var madeItem = ReadyMadeOrderDao.FindById(firstItemId);
                    int orgPrice = madeItem.TaxAddedTotalPrice;
                    madeItem.ExtraPrice -= addPrice;
                    ReadyMadeOrderDao.Update(madeItem);
                    DeliveryInfoItem DeliveryInfoItem = DeliveryInfoDao.FindById(orderItem.DeliveryInfoId);
                    PayInfoService.UpdateChangeProductCharge(orderItem.PayInfoId, "MINUS", orgPrice, DeliveryInfoItem);
                    PayInfoService.UpdateChangeProductCharge(orderItem.PayInfoId, "PLUS", madeItem.TaxAddedTotalPrice, DeliveryInfoItem);
                }
            }

            DbParam param = new DbParam();

            param.Add("content", new XDocument());
            OrderDao.Update(param, orderItem.Id);
        }
        public void HighPrintProc(int orderId, int addPrice, string procType)
        {
            DateTime now           = DateTime.Now;
            var      orderItem     = OrderDao.FindById(orderId);
            var      payInfo       = PayInfoDao.FindById(orderItem.PayInfoId);
            string   firstItemType = string.Empty;
            string   newOrderCode  = string.Empty;
            int      firstItemId   = 0;

            foreach (var item in PrintMadeOrderDao.FindByOrderId(orderItem.Id))
            {
                firstItemType = "PRINTMADE";
                firstItemId   = item.Id;
                break;
            }
            foreach (var item in ReadyMadeOrderDao.FindByOrderId(orderItem.Id))
            {
                firstItemType = "READMADE";
                firstItemId   = item.Id;
                break;
            }
            if ("ADDPRICE".Equals(procType))
            {
                if (payInfo.PayType.StartsWith("TELEGRAM") || (orderItem.IsPaid() && !payInfo.PayType.Equals("MAN")))
                {
                    throw BizException.CreateMakumakuServiceException("관리자 우선출력 오류", "PG사 결제나 입금완료주문의 경우\n금액 추가타입의 우선출력 요청은 할 수 없습니다.");
                }

                if ("PRINTMADE".Equals(firstItemType))
                {
                    var madeItem = PrintMadeOrderDao.FindById(firstItemId);
                    int orgPrice = madeItem.TaxAddedTotalPrice;
                    madeItem.ExtraPrice = addPrice;
                    PrintMadeOrderDao.Update(madeItem);
                    DeliveryInfoItem DeliveryInfoItem = DeliveryInfoDao.FindById(orderItem.DeliveryInfoId);
                    PayInfoService.UpdateChangeProductCharge(orderItem.PayInfoId, "MINUS", orgPrice, DeliveryInfoItem);
                    PayInfoService.UpdateChangeProductCharge(orderItem.PayInfoId, "PLUS", madeItem.TaxAddedTotalPrice, DeliveryInfoItem);
                }
                else if ("READYMADE".Equals(firstItemType))
                {
                    var madeItem = ReadyMadeOrderDao.FindById(firstItemId);
                    int orgPrice = madeItem.TaxAddedTotalPrice;
                    madeItem.ExtraPrice = addPrice;
                    ReadyMadeOrderDao.Update(madeItem);
                    DeliveryInfoItem DeliveryInfoItem = DeliveryInfoDao.FindById(orderItem.DeliveryInfoId);
                    PayInfoService.UpdateChangeProductCharge(orderItem.PayInfoId, "MINUS", orgPrice, DeliveryInfoItem);
                    PayInfoService.UpdateChangeProductCharge(orderItem.PayInfoId, "PLUS", madeItem.TaxAddedTotalPrice, DeliveryInfoItem);
                }
            }
            else if ("NEWGOODS".Equals(procType))
            {
                var newItemDoc = XMLUtil.CreateDocment();
                XMLUtil.SetValue(newItemDoc, "HIGHPRINT", orderItem.Code, "PARENTCODE");

                var newItem = new OrderItem();
                newItem.UserId      = orderItem.UserId;
                newItem.OrderDate   = now;
                newItem.OrderStatus = "DESIGN_INFO";
                newItem.PayStatus   = "UNPAID";
                newItem.HighPrintId = orderItem.Id;
                newItem.Content     = newItemDoc;
                var newOrderId = OrderDao.Insert(newItem);
                OrderDao.UpdateOrderStatus(newOrderId, "DESIGN_INFO");
                newItem      = OrderDao.FindById(newOrderId);
                newOrderCode = newItem.Code;
                var rdItem = new ReadyMadeOrderItem();
                rdItem.ReadyMadeId = "R199";
                rdItem.Title       = orderItem.Code + "追加/商品金額";
                rdItem.OrderId     = newItem.Id;
                rdItem.Code        = newItem.Code + "-S01";
                rdItem.OrderCode   = newItem.Code;
                rdItem.OrderCount  = 1;
                rdItem.TotalPrice  = 0;
                rdItem.GoodsPrice  = addPrice;

                ReadyMadeOrderDao.Insert(rdItem);
            }

            PrintMadeOrderDao.ChangePrintPriorityByOrderCode(orderItem.Code, "HIGH");

            DbParam param = new DbParam();
            var     doc   = XMLUtil.CreateDocment();

            XMLUtil.SetValue(doc, "PARENTHIGHPRINT", procType, "PROCTYPE");
            XMLUtil.SetValue(doc, "PARENTHIGHPRINT", addPrice, "ADDPRICE");
            if ("NEWGOODS".Equals(procType))
            {
                XMLUtil.SetValue(doc, "PARENTHIGHPRINT", newOrderCode, "NEWORDERCODE");
            }
            param.Add("content", doc);
            OrderDao.Update(param, orderItem.Id);
        }