Esempio n. 1
0
        /// <summary>
        /// 处理无效的团购订单
        /// </summary>
        /// <returns></returns>
        public void ProcessorInvalidGroupBuySO(SOInfo soInfo)
        {
            if (soInfo == null || !soInfo.SysNo.HasValue)
            {
                return;
            }
            int soSysNo = soInfo.SysNo.Value;

            try
            {
                //获取所有Item
                List <SOItemInfo> items = (from item in soInfo.Items
                                           where item.ActivityType == SOProductActivityType.GroupBuy
                                           select item).ToList();

                if (items == null || items.Count == 0)
                {
                    return;
                }

                //如果含有未处理的团购商品就过
                if (items.Exists(x => x.ReferenceSysNo.HasValue && x.ReferenceSysNo != 0 && !x.SettlementStatus.HasValue))
                {
                    return;
                }
                else if (items.Exists(x => x.SettlementStatus == SettlementStatus.Fail))
                {
                    //更新订单团购处理状态
                    SODA.UpdateGroupBuySOSettlementStatusBySOSysNo(soSysNo, SettlementStatus.Fail);
                }
                else if (items.Exists(x => x.SettlementStatus == SettlementStatus.PlanFail))
                {
                    //只含P,作废
                    if (!items.Exists(x => x.SettlementStatus != SettlementStatus.PlanFail))
                    {
                        ECCentral.BizEntity.Invoice.NetPayInfo netPayInfo = ExternalDomainBroker.GetSOValidNetPay(soSysNo);
                        if (netPayInfo != null)
                        {
                            //ExternalDomainBroker.AuditNetPay(netPayInfo.SysNo.Value);
                            ExternalDomainBroker.AuditNetPay4GroupBuy(netPayInfo.SysNo.Value);
                            ExternalDomainBroker.CreateAOForJob(soSysNo, BizEntity.Invoice.RefundPayType.PrepayRefund, ResourceHelper.Get("Res_SO_Job_GropBuySOAbandon"), null);
                        }

                        ObjectFactory <SOProcessor> .Instance.ProcessSO(new SOAction.SOCommandInfo {
                            Command = SOAction.SOCommand.Abandon, SOInfo = soInfo
                        });
                    }
                    else
                    {
                        //更新订单团购处理状态
                        SODA.UpdateGroupBuySOSettlementStatusBySOSysNo(soSysNo, SettlementStatus.PlanFail);
                    }
                }
                else if (!items.Exists(x => x.ReferenceSysNo.HasValue && x.ReferenceSysNo != 0 && x.SettlementStatus != SettlementStatus.Success))
                {
                    ECCentral.BizEntity.Invoice.NetPayInfo netPayInfo = ExternalDomainBroker.GetSOValidNetPay(soSysNo);
                    //审核NetPay
                    if (netPayInfo != null)
                    {
                        //ExternalDomainBroker.AuditNetPay(netPayInfo.SysNo.Value);
                        ExternalDomainBroker.AuditNetPay4GroupBuy(netPayInfo.SysNo.Value);
                    }

                    SODA.UpdateGroupBuySOSettlementStatusBySOSysNo(soSysNo, SettlementStatus.Success);
                }
            }
            catch (Exception ex)
            {
                SODA.UpdateGroupBuySOSettlementStatusBySOSysNo(soSysNo, SettlementStatus.Fail);
                ExceptionHelper.HandleException(ex);
            }
        }