コード例 #1
0
ファイル: OrderPrintBPExt.cs プロジェクト: GSIL-Monitor/BTP
        /// <summary>
        /// 更新订单成功回调函数
        /// </summary>
        /// <param name="commodityOrder"></param>
        public void UpdateOrderStateTo2CallBack(List <CommodityOrder> commodityOrders, UpdatePrintDTO orders)
        {
            try
            {
                #region 异步发送消息
                System.Threading.ThreadPool.QueueUserWorkItem(
                    a =>
                {
                    commodityOrders.ForEach(commodityOrder =>
                    {
                        try
                        {
                            AddMessage addmassage = new AddMessage();
                            string type           = "order";
                            Guid esAppId          = commodityOrder.EsAppId.HasValue ? commodityOrder.EsAppId.Value : commodityOrder.AppId;
                            addmassage.AddMessages(commodityOrder.Id.ToString(), commodityOrder.UserId.ToString(), esAppId, commodityOrder.Code, commodityOrder.State, "", type);
                        }
                        catch (Exception ex)
                        {
                        }
                    });
                });
                #endregion

                #region 向第三方“快递鸟”发送物流订阅请求
                List <OrderExpressRoute> oers = new List <OrderExpressRoute>();

                orders.Orders.ForEach(r =>
                {
                    if (!string.IsNullOrEmpty(r.ExpressOrder) && !oers.Exists(o => o.ExpOrderNo == r.ExpressOrder))
                    {
                        //TODO dzc 向第三方“快递鸟”发送物流订阅请求。
                        oers.Add(new OrderExpressRoute()
                        {
                            ShipExpCo  = orders.ShipName,
                            ExpOrderNo = r.ExpressOrder
                        });
                    }
                });
                OrderExpressRouteBP oerBP = new OrderExpressRouteBP();
                oerBP.BatchSubscribeOneOrderExpressExt(oers);
                #endregion
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("更新打印订单成功回调函数。UpdateOrderStateTo2CallBack:{0}", JsonHelper.JsonSerializer(orders)), ex);
            }
        }
コード例 #2
0
ファイル: ReviewBPExt.cs プロジェクト: GSIL-Monitor/BTP
        /// <summary>
        /// 回复评价
        /// </summary>
        /// <param name="userId">被回复人ID</param>
        /// <param name="reviewId">评价ID</param>
        /// <param name="commodityId">商品ID</param>
        /// <param name="replyerDetails">回复内容</param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO RespondCommentExt(System.Guid userId, System.Guid reviewId, System.Guid appId, string replyerDetails)
        {
            try
            {
                int aa = Review.ObjectSet().Where(n => n.Id == reviewId).Count();
                //判断评价是否存在
                if (aa == 0)
                {
                    return(new ResultDTO {
                        ResultCode = 1, Message = "评价ID错误"
                    });
                }

                var esAppId = (from r in Review.ObjectSet()
                               join m in OrderItem.ObjectSet()
                               on r.OrderItemId equals m.Id
                               join o in CommodityOrder.ObjectSet()
                               on m.CommodityOrderId equals o.Id
                               where r.Id == reviewId
                               select o.EsAppId).FirstOrDefault();

                ContextSession contextSession = ContextFactory.CurrentThreadContext;

                Reply reply = new Reply();
                reply.Id           = Guid.NewGuid();
                reply.Name         = "回复";
                reply.SubTime      = DateTime.Now;
                reply.PreUserId    = userId;
                reply.ReviewId     = reviewId;
                reply.UserName     = "******";
                reply.ReplyDetails = replyerDetails;
                reply.ReplyerId    = appId;
                reply.Type         = 0;
                reply.EntityState  = System.Data.EntityState.Added;
                contextSession.SaveObject(reply);
                int result = contextSession.SaveChanges();
                if (result > 0)
                {
                    AddMessage addmassage = new AddMessage();
                    string     type       = "review";

                    //发送消息,异步执行
                    System.Threading.ThreadPool.QueueUserWorkItem(
                        a =>
                    {
                        var EsAppId = esAppId.HasValue ? esAppId.Value : appId;
                        addmassage.AddMessages(reply.Id.ToString(), userId.ToString(), EsAppId, "", 0, "", type);
                        ////正品会发送消息
                        //if (new ZPHSV().CheckIsAppInZPH(appId))
                        //{
                        //    addmassage.AddMessages(reply.Id.ToString(), userId.ToString(), CustomConfig.ZPHAppId, "", 0, "", type);
                        //}
                    });
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("回复评价服务异常。userId:{0},reviewId:{1},appId:{2},replyerDetails:{3}", userId, reviewId, appId, replyerDetails), ex);
                return(new ResultDTO {
                    ResultCode = 1, Message = "Error"
                });
            }
            return(new ResultDTO {
                ResultCode = 0, Message = "Success"
            });
        }