/// <summary>
 /// 新增退货物流跟踪数据(商家确认退款时间)
 /// </summary>
 /// <param name="retd"></param>
 /// <returns></returns>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO AddRefundExpressTraceExt(Jinher.AMP.BTP.Deploy.RefundExpressTraceDTO retd)
 {
     try
     {
         RefundExpressTrace ret = new RefundExpressTrace
         {
             OrderId         = retd.OrderId,
             OrderItemId     = retd.OrderItemId,
             AgreeRefundTime = retd.AgreeRefundTime,
             EntityState     = System.Data.EntityState.Added
         };
         ContextFactory.CurrentThreadContext.SaveObject(ret);
         var result = ContextFactory.CurrentThreadContext.SaveChanges();
         if (result > 0)
         {
             return(new ResultDTO {
                 ResultCode = 0, isSuccess = true, Message = "退货物流跟踪数据添加成功(商家确认退款时间)"
             });
         }
         LogHelper.Error(string.Format("新增退货物流跟踪数据失败(商家确认退款时间)。AddRefundExpressTraceExt:{0}", JsonHelper.JsonSerializer(retd)));
         return(new ResultDTO {
             ResultCode = 1, isSuccess = false, Message = "退货物流跟踪数据添加失败"
         });
     }
     catch (Exception ex)
     {
         LogHelper.Error(string.Format("新增退货物流跟踪数据异常(商家确认退款时间)。AddRefundExpressTraceExt:{0}", JsonHelper.JsonSerializer(retd)), ex);
         return(new ResultDTO {
             ResultCode = 2, isSuccess = false, Message = "退货物流跟踪数据添加异常"
         });
     }
 }
 /// <summary>
 /// 新增退货物流跟踪中的物流信息
 /// </summary>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO UpdateRefundExpressExt(Jinher.AMP.BTP.Deploy.RefundExpressTraceDTO retd)
 {
     try
     {
         var rets = RefundExpressTrace.ObjectSet().Where(t => t.OrderId == retd.OrderId);
         if (rets == null)
         {
             LogHelper.Error(string.Format("更新退货物流跟踪数据不存在。UpdateRefundExpressExt:{0}", JsonHelper.JsonSerializer(retd)));
             return(new ResultDTO {
                 ResultCode = 1, isSuccess = false, Message = "更新数据不存在"
             });
         }
         RefundExpressTrace ret = null;
         //整单退货
         if (retd.OrderItemId == null || retd.OrderItemId == Guid.Empty)
         {
             ret = rets.FirstOrDefault();
         }
         //单商品退货
         else
         {
             ret = rets.FirstOrDefault(r => r.OrderItemId == retd.OrderItemId);
         }
         if (ret != null)
         {
             ret.RefundExpCo        = retd.RefundExpCo;
             ret.RefundExpOrderNo   = retd.RefundExpOrderNo;
             ret.UploadExpOrderTime = retd.UploadExpOrderTime;
             ret.EntityState        = System.Data.EntityState.Modified;
             ContextFactory.CurrentThreadContext.SaveObject(ret);
             var result = ContextFactory.CurrentThreadContext.SaveChanges();
             if (result > 0)
             {
                 return(new ResultDTO {
                     ResultCode = 0, isSuccess = true, Message = "退货物流跟踪数据更新成功"
                 });
             }
             LogHelper.Error(string.Format("更新退货物流跟踪数据失败。UpdateRefundExpressExt:{0}", JsonHelper.JsonSerializer(retd)));
             return(new ResultDTO {
                 ResultCode = 1, isSuccess = false, Message = "退货物流跟踪数据更新失败"
             });
         }
         else
         {
             LogHelper.Error(string.Format("更新退货物流跟踪数据不存在。UpdateRefundExpressExt:{0}", JsonHelper.JsonSerializer(retd)));
             return(new ResultDTO {
                 ResultCode = 1, isSuccess = false, Message = "更新数据不存在"
             });
         }
     }
     catch (Exception ex)
     {
         LogHelper.Error(string.Format("更新退货物流跟踪数据(商家确认退款时间)异常。UpdateRefundExpressExt:{0}", JsonHelper.JsonSerializer(retd)), ex);
         return(new ResultDTO {
             ResultCode = 1, isSuccess = false, Message = "退货物流跟踪数据更新失败"
         });
     }
 }
示例#3
0
 /// <summary>
 /// 更新退货物流跟踪数据(物流公司及物流单号)
 /// </summary>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO UpdateRefundExpress(Jinher.AMP.BTP.Deploy.RefundExpressTraceDTO retd)
 {
     base.Do();
     return(this.Command.UpdateRefundExpress(retd));
 }
示例#4
0
 /// <summary>
 /// 新增退货物流跟踪数据(商家确认退款时间)
 /// </summary>
 /// <param name="retd"></param>
 /// <returns></returns>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO AddRefundExpressTrace(Jinher.AMP.BTP.Deploy.RefundExpressTraceDTO retd)
 {
     base.Do();
     return(this.AddRefundExpressTraceExt(retd));
 }
示例#5
0
 /// <summary>
 /// 更新退货物流跟踪数据(物流相关时间)
 /// </summary>
 /// <param name="retd"></param>
 /// <param name="appId"></param>
 /// <returns></returns>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO UpdateRefundExpressTrace(Jinher.AMP.BTP.Deploy.RefundExpressTraceDTO retd, System.Guid appId)
 {
     base.Do();
     return(this.UpdateRefundExpressTraceExt(retd, appId));
 }
        /// <summary>
        /// 更新退货物流跟踪数据
        /// </summary>
        /// <param name="retd"></param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO UpdateRefundExpressTraceExt(Jinher.AMP.BTP.Deploy.RefundExpressTraceDTO retd, Guid appId)
        {
            try
            {
                var rets = RefundExpressTrace.ObjectSet().Where(t => t.OrderId == retd.OrderId);
                if (rets == null)
                {
                    LogHelper.Error(string.Format("更新退货物流跟踪数据不存在。UpdateRefundExpressTraceExt:{0}", JsonHelper.JsonSerializer(retd)));
                    return(new ResultDTO {
                        ResultCode = 1, isSuccess = false, Message = "更新数据不存在"
                    });
                }
                RefundExpressTrace ret = null;
                //整单退货
                if (retd.OrderItemId == null || retd.OrderItemId == Guid.Empty)
                {
                    ret = rets.FirstOrDefault();
                }
                //单商品退货
                else
                {
                    ret = rets.FirstOrDefault(r => r.OrderItemId == retd.OrderItemId);
                }
                if (ret == null)
                {
                    LogHelper.Error(string.Format("更新退货物流跟踪数据不存在。UpdateRefundExpressTraceExt:{0}", JsonHelper.JsonSerializer(retd)));
                    return(new ResultDTO {
                        ResultCode = 1, isSuccess = false, Message = "更新数据不存在"
                    });
                }

                //查询物流信息
                var     expressInfo = GetWuliuJson(ret.RefundExpCo, ret.RefundExpOrderNo, appId);
                JObject obj         = JObject.Parse(expressInfo);
                if (obj["status"].ToString() == null || obj["status"].ToString() != "0")
                {
                    LogHelper.Error(string.Format("更新退货物流跟踪数据时未查到物流信息。UpdateRefundExpressTraceExt:{0}", JsonHelper.JsonSerializer(retd)));
                    return(new ResultDTO {
                        ResultCode = 1, isSuccess = false, Message = "更新退货物流跟踪数据时未查到物流信息"
                    });
                }

                JArray arr = (JArray)JsonConvert.DeserializeObject(obj["result"]["list"].ToString());
                ret.ExpressDeliveryTime = arr.Last() != null?Convert.ToDateTime(arr.Last()["time"]) : default(DateTime?);                                            //快递收揽时间

                int deliverystatus = Convert.ToInt32(obj["result"]["deliverystatus"].ToString());                                                                    //快递状态
                ret.ExpressSDTime = deliverystatus != 3 ? default(DateTime?) : (arr.First() != null ? Convert.ToDateTime(arr.First()["time"]) : default(DateTime?)); //快递送达时间
                ret.EntityState   = System.Data.EntityState.Modified;
                ContextFactory.CurrentThreadContext.SaveObject(ret);
                var result = ContextFactory.CurrentThreadContext.SaveChanges();
                if (result > 0)
                {
                    return(new ResultDTO {
                        ResultCode = 0, isSuccess = true, Message = "退货物流跟踪数据更新成功"
                    });
                }

                LogHelper.Error(string.Format("更新退货物流跟踪数据失败。UpdateRefundExpressTraceExt:{0}", JsonHelper.JsonSerializer(retd)));
                return(new ResultDTO {
                    ResultCode = 1, isSuccess = false, Message = "退货物流跟踪数据更新失败"
                });
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("更新退货物流跟踪数据异常。UpdateRefundExpressTraceExt:{0}", JsonHelper.JsonSerializer(retd)), ex);
                return(new ResultDTO {
                    ResultCode = 1, isSuccess = false, Message = "退货物流跟踪数据更新失败"
                });
            }
        }