Example #1
0
        public static string RepairJdOrder(string jdPorderId)
        {
            var commodityorderfacade = new Jinher.AMP.BTP.IBP.Facade.CommodityOrderFacade();

            commodityorderfacade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo();
            var jdorderitemfacade = new Jinher.AMP.BTP.IBP.Facade.JdOrderItemFacade();

            jdorderitemfacade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo();
            var jdjournalfacade = new Jinher.AMP.BTP.IBP.Facade.JdJournalFacade();

            jdjournalfacade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo();

            //开始拆单
            JdOrderItemDTO model = new JdOrderItemDTO();

            model.JdPorderId = jdPorderId;
            model.State      = 1;//
            //获取jdorderitem表中的数据
            var jdorderitem = jdorderitemfacade.GetJdOrderItemList(model).FirstOrDefault();

            if (jdorderitem != null)
            {
                var  getFullOrderInfo = commodityorderfacade.GetFullOrderInfoById(jdorderitem.CommodityOrderId);
                bool flag             = JdHelper.IsjdOrder(jdPorderId);
                if (flag == true)
                {
                    #region 父订单拆单行为
                    var selectJdOrder2 = JdHelper.selectJdOrder2(jdPorderId);
                    if (!string.IsNullOrWhiteSpace(selectJdOrder2))
                    {
                        List <string> list = new List <string>();
                        list.Add(jdPorderId);
                        //删除已有的父类订单
                        var delresult = jdorderitemfacade.DeleteJdOrderItem(list);
                        if (delresult.isSuccess == true)
                        {
                            JArray objson = JArray.Parse(selectJdOrder2);
                            foreach (var item in objson)
                            {
                                JArray objsku = JArray.Parse(item["sku"].ToString());
                                foreach (var ZiJdOrder in objsku)
                                {
                                    #region 子订单包含包含多个商品的情况
                                    string skuId  = ZiJdOrder["skuId"].ToString();
                                    Guid   TempId = Guid.Empty;
                                    Guid   commodityOrderItemId = Guid.Empty;
                                    if (getFullOrderInfo.OrderItems != null && getFullOrderInfo.OrderItems.Count() > 0)
                                    {
                                        var commoditydto = getFullOrderInfo.OrderItems.Where(p => p.JdCode == skuId).FirstOrDefault();
                                        if (commoditydto != null)
                                        {
                                            commodityOrderItemId = commoditydto.Id;
                                            TempId = commoditydto.CommodityId;
                                        }
                                    }
                                    int    State        = Convert.ToInt32(JdEnum.BCF);
                                    string StateContent = new EnumHelper().GetDescription(JdEnum.BCF);
                                    string JdOrderId    = item["jdOrderId"].ToString();
                                    string Name         = "京东下订单" + StateContent;
                                    string Details      = "订单状态由" + jdorderitem.State + "变成" + State;
                                    if (item["orderState"].ToString() == "0")
                                    {
                                        State        = Convert.ToInt32(JdEnum.BCF);
                                        StateContent = new EnumHelper().GetDescription(JdEnum.BCF);
                                        Name         = "京东下订单" + StateContent;
                                        Details      = "订单状态由" + jdorderitem.State + "变成" + State;
                                    }
                                    JdOrderItemDTO jdorderitemdto = new JdOrderItemDTO()
                                    {
                                        Id                   = Guid.NewGuid(),
                                        JdPorderId           = jdPorderId,
                                        TempId               = TempId,
                                        JdOrderId            = JdOrderId,
                                        MainOrderId          = jdorderitem.MainOrderId,
                                        CommodityOrderId     = jdorderitem.CommodityOrderId,
                                        State                = State,
                                        StateContent         = StateContent,
                                        SubTime              = DateTime.Now,
                                        ModifiedOn           = DateTime.Now,
                                        CommoditySkuId       = skuId,
                                        CommodityOrderItemId = commodityOrderItemId
                                    };
                                    var restult = jdorderitemfacade.SaveJdOrderItem(jdorderitemdto);
                                    if (restult.isSuccess == true)
                                    {
                                        JdJournalDTO ex = new JdJournalDTO()
                                        {
                                            JdPorderId       = jdPorderId,
                                            TempId           = TempId,
                                            JdOrderId        = JdOrderId,
                                            MainOrderId      = jdorderitem.MainOrderId,
                                            CommodityOrderId = jdorderitem.CommodityOrderId,
                                            Name             = Name,
                                            Details          = StateContent
                                        };
                                        var res = jdjournalfacade.GetJdJournalList(ex);
                                        if (res.Count() == 0)
                                        {
                                            JdJournalDTO jdjournaldto = new JdJournalDTO()
                                            {
                                                Id               = Guid.NewGuid(),
                                                JdPorderId       = jdPorderId,
                                                TempId           = TempId,
                                                JdOrderId        = JdOrderId,
                                                MainOrderId      = jdorderitem.MainOrderId,
                                                CommodityOrderId = jdorderitem.CommodityOrderId,
                                                Name             = Name,
                                                Details          = StateContent,
                                                SubTime          = DateTime.Now
                                            };
                                            jdjournalfacade.SaveJdJournal(jdjournaldto);
                                        }
                                    }
                                    #endregion
                                }
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    #region  拆单行为
                    var selectJdOrder1 = JdHelper.selectJdOrder1(jdPorderId);
                    if (!string.IsNullOrWhiteSpace(selectJdOrder1))
                    {
                        JObject objs   = JObject.Parse(selectJdOrder1);
                        JArray  objson = JArray.Parse(objs["sku"].ToString());
                        foreach (var ZiJdOrder in objson)
                        {
                            #region 子订单包含包含多个商品的情况
                            string skuId  = ZiJdOrder["skuId"].ToString();
                            Guid   TempId = Guid.Empty;
                            Guid   commodityOrderItemId = Guid.Empty;
                            if (getFullOrderInfo.OrderItems != null && getFullOrderInfo.OrderItems.Count() > 0)
                            {
                                var commoditydto = getFullOrderInfo.OrderItems.Where(p => p.JdCode == skuId).FirstOrDefault();
                                if (commoditydto != null)
                                {
                                    commodityOrderItemId = commoditydto.Id;
                                    TempId = commoditydto.CommodityId;
                                }
                            }
                            int    State        = Convert.ToInt32(JdEnum.BCF);
                            string StateContent = new EnumHelper().GetDescription(JdEnum.BCF);
                            string JdOrderId    = objs["jdOrderId"].ToString();
                            string Name         = "京东下订单" + StateContent;
                            string Details      = "订单状态由" + jdorderitem.State + "变成" + State;
                            jdorderitem.TempId               = TempId;
                            jdorderitem.JdOrderId            = JdOrderId;
                            jdorderitem.State                = State;
                            jdorderitem.StateContent         = StateContent;
                            jdorderitem.CommoditySkuId       = skuId;
                            jdorderitem.CommodityOrderItemId = commodityOrderItemId;
                            var restult = jdorderitemfacade.UpdateJdOrderItem(jdorderitem);
                            if (restult.isSuccess == true)
                            {
                                JdJournalDTO ex = new JdJournalDTO()
                                {
                                    JdPorderId       = jdPorderId,
                                    TempId           = TempId,
                                    JdOrderId        = JdOrderId,
                                    MainOrderId      = jdorderitem.MainOrderId,
                                    CommodityOrderId = jdorderitem.CommodityOrderId,
                                    Name             = Name,
                                    Details          = StateContent
                                };
                                var res = jdjournalfacade.GetJdJournalList(ex);
                                if (res.Count() == 0)
                                {
                                    JdJournalDTO jdjournaldto = new JdJournalDTO()
                                    {
                                        Id               = Guid.NewGuid(),
                                        JdPorderId       = jdPorderId,
                                        TempId           = TempId,
                                        JdOrderId        = JdOrderId,
                                        MainOrderId      = jdorderitem.MainOrderId,
                                        CommodityOrderId = jdorderitem.CommodityOrderId,
                                        Name             = Name,
                                        Details          = StateContent,
                                        SubTime          = DateTime.Now
                                    };
                                    jdjournalfacade.SaveJdJournal(jdjournaldto);
                                }
                            }
                            #endregion
                        }
                    }
                    #endregion
                }

                #region 更新订单信息状态
                Jinher.AMP.BTP.Deploy.CommodityOrderDTO commodity = new Jinher.AMP.BTP.Deploy.CommodityOrderDTO();
                commodity.Id            = Guid.Parse(jdorderitem.CommodityOrderId);
                commodity.State         = 2;
                commodity.ShipmentsTime = DateTime.Now;
                //更新订单状态
                commodityorderfacade.UpdateCommodityOrder(commodity);
                #endregion

                return("ok");
            }
            return("no found");
        }
Example #2
0
 /// <summary>
 /// 修改订单信息
 /// </summary>
 /// <param name="list"></param>
 /// <returns></returns>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO UpdateCommodityOrder(Jinher.AMP.BTP.Deploy.CommodityOrderDTO model)
 {
     base.Do();
     return(this.Command.UpdateCommodityOrder(model));
 }
Example #3
0
 /// <summary>
 /// 修改订单信息
 /// </summary>
 /// <param name="list"></param>
 /// <returns></returns>
 public ResultDTO UpdateCommodityOrder(Jinher.AMP.BTP.Deploy.CommodityOrderDTO model)
 {
     base.Do(false);
     return(this.UpdateCommodityOrderExt(model));
 }