Пример #1
0
        /// <summary>
        ///  取消订单时,回退用户易捷币
        /// </summary>
        public static ResultDTO CancelOrder(ContextSession contextSession, CommodityOrder commodityOrder)
        {
            if (commodityOrder.EsAppId != Jinher.AMP.YJB.Deploy.CustomDTO.YJBConsts.YJAppId)
            {
                return(ResultDTO.Successed);
            }

            decimal yjbMoney = OrderPayDetail.ObjectSet()
                               .Where(t => t.OrderId == commodityOrder.Id && (t.ObjectType == 10 || t.ObjectType == 15) && t.Amount > 0)
                               .Select(t => t.Amount).FirstOrDefault();

            if (yjbMoney <= 0)
            {
                return(ResultDTO.Successed);
            }

            var result = YJBSV.RefundAllOrderJournal(commodityOrder.Id);

            if (!result.IsSuccess)
            {
                if (result.Code != "OrderNotFound")
                {
                    LogHelper.Error("取消订单时,回退用户易捷币失败,订单ID:" + commodityOrder.Id + ",错误内容:" + result.Message);
                    LogOrderErrorInfo(contextSession, commodityOrder, "取消订单时,回退用户易捷币失败");
                }
            }
            return(result);
        }
Пример #2
0
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <List <KeyValuePair <Guid, string> > > GetOrderInfoByCouponIdExt(Guid couponId)
        {
            var returnDto = new ResultDTO <List <KeyValuePair <Guid, string> > >()
            {
                isSuccess = true,
                Data      = new List <KeyValuePair <Guid, string> >()
            };

            try
            {
                var listOrder = OrderPayDetail.ObjectSet().Where(o => o.ObjectId == couponId && o.ObjectType == 1).Select(o => o.OrderId); //获取OrderId
                var orderInfo = CommodityOrder.ObjectSet().Where(o => listOrder.Contains(o.Id)).Select(o => new { o.Id, o.Code });
                foreach (var item in orderInfo)
                {
                    returnDto.Data.Add(new KeyValuePair <Guid, string>(item.Id, item.Code));
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("CouponRefundBP.GetOrderInfoByCouponIdExt 异常", ex);
                returnDto.isSuccess = false;
            }

            return(returnDto);
        }
Пример #3
0
        /// <summary>
        /// 取消订单时回退积分
        /// </summary>
        /// <param name="contextSession"></param>
        /// <param name="commodityOrder"></param>
        /// <returns></returns>
        public static bool CommodityOrderCancelSrore(ContextSession contextSession, CommodityOrder commodityOrder)
        {
            if (!commodityOrder.EsAppId.HasValue)
            {
                return(true);
            }
            //获取下订单时用的积分金额
            var sroreMoney = OrderPayDetail.ObjectSet().Where(t => t.OrderId == commodityOrder.Id && t.ObjectType == 2 && t.Amount > 0).Select(t => t.Amount).FirstOrDefault();

            if (sroreMoney <= 0)
            {
                return(true);
            }
            //获取当时的积分汇率
            CostScoreInfoDTO scoreCostDto;
            bool             isscsc = new ScoreSV().GetScoreCost(commodityOrder.EsAppId.Value, out scoreCostDto, commodityOrder.SubTime);

            if (!isscsc)
            {
                return(true);
            }
            int  srore             = (int)(sroreMoney * scoreCostDto.Cost);
            bool refundScoreResult = Instance.RefundScore(commodityOrder.UserId, commodityOrder.EsAppId.Value, srore, commodityOrder.Id, commodityOrder.Code, scoreCostDto.ScoreType);

            if (refundScoreResult)
            {
                return(refundScoreResult);
            }

            LogHelper.Error(string.Format("取消订单时回退积分失败。UserId:{0},EsAppId:{1},srore:{2}", commodityOrder.UserId, commodityOrder.EsAppId.Value, srore));
            ErrorCommodityOrder errorOrder = new ErrorCommodityOrder();

            errorOrder.Id           = Guid.NewGuid();
            errorOrder.ErrorOrderId = commodityOrder.Id;
            errorOrder.ResourceType = 1;
            errorOrder.Source       = commodityOrder.State;
            errorOrder.State        = 0;
            errorOrder.AppId        = commodityOrder.EsAppId.Value;
            errorOrder.UserId       = commodityOrder.UserId;
            errorOrder.OrderCode    = commodityOrder.Code;
            errorOrder.CouponId     = Guid.Empty;
            errorOrder.Score        = srore;
            errorOrder.SubTime      = DateTime.Now;
            errorOrder.ModifiedOn   = DateTime.Now;
            errorOrder.ScoreType    = (int)scoreCostDto.ScoreType;
            errorOrder.EntityState  = System.Data.EntityState.Added;
            contextSession.SaveObject(errorOrder);
            return(refundScoreResult);
        }
Пример #4
0
        /// <summary>
        /// 查询OrderPayDetail信息
        /// </summary>
        /// <param name="search">查询类</param>
        /// <returns>结果</returns>
        public List <Jinher.AMP.BTP.Deploy.OrderPayDetailDTO> GetOrderPayDetailListExt(Guid objectid)
        {
            var orderpayDetail = OrderPayDetail.ObjectSet().Where(p => p.ObjectId == objectid).ToList();
            List <Jinher.AMP.BTP.Deploy.OrderPayDetailDTO> orderpayDetaillist = new List <OrderPayDetailDTO>();

            foreach (var item in orderpayDetail)
            {
                Jinher.AMP.BTP.Deploy.OrderPayDetailDTO model = new OrderPayDetailDTO();
                model.Id           = item.Id;
                model.OrderId      = item.OrderId;
                model.CommodityId  = item.CommodityId;
                model.ObjectType   = item.ObjectType;
                model.Amount       = item.Amount;
                model.ObjectId     = item.ObjectId;
                model.UseType      = item.UseType;
                model.CouponType   = item.CouponType;
                model.CommodityIds = item.CommodityIds;
                model.SubTime      = item.SubTime;
                model.ModifiedOn   = item.ModifiedOn;
                model.SubCode      = item.SubCode;
                orderpayDetaillist.Add(model);
            }
            return(orderpayDetaillist);
        }
Пример #5
0
        /// <summary>
        /// 查询发票信息
        /// </summary>
        /// <param name="search">查询类</param>
        /// <returns>结果</returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <Jinher.AMP.BTP.Deploy.CustomDTO.InvoiceResultDTO> GetInvoiceInfoListExt(Jinher.AMP.BTP.Deploy.CustomDTO.InvoiceSearchDTO search)
        {
            if (search == null || search.AppId == Guid.Empty || search.PageIndex < 0 || search.PageSize < 0)
            {
                return(new ResultDTO <InvoiceResultDTO>()
                {
                    ResultCode = 1, Message = "参数不能为空"
                });
            }
            var result = new ResultDTO <InvoiceResultDTO>();

            result.Data = new InvoiceResultDTO();

            var query = from invoice in Invoice.ObjectSet()
                        join commodityOrder in CommodityOrder.ObjectSet()
                        on invoice.CommodityOrderId equals commodityOrder.Id
                        join dataS in CommodityOrderService.ObjectSet()
                        on invoice.CommodityOrderId equals dataS.Id
                        into tempS
                        from tbS in tempS.DefaultIfEmpty()
                        where commodityOrder.AppId == search.AppId && commodityOrder.State > 0 && invoice.State > 0 && commodityOrder.State != 16 && commodityOrder.State != 17 && commodityOrder.IsDel != 2 && commodityOrder.IsDel != 3
                        select new
            {
                Invoice        = invoice,
                CommodityOrder = new InvoiceCommodityOrderInfo()
                {
                    State           = commodityOrder.State,
                    Code            = commodityOrder.Code,
                    PaymentTime     = commodityOrder.PaymentTime.Value,
                    ReceiptUserName = commodityOrder.ReceiptUserName,
                    ReceiptPhone    = commodityOrder.ReceiptPhone,
                    ReceiptAddress  = commodityOrder.ReceiptAddress,
                    RealPrice       = commodityOrder.RealPrice.Value,
                    Payment         = commodityOrder.Payment,
                    GoldPrice       = commodityOrder.GoldPrice,
                    GoldCoupon      = commodityOrder.GoldCoupon,
                    Province        = commodityOrder.Province,
                    City            = commodityOrder.City,
                    District        = commodityOrder.District,
                    StateAfterSales = tbS.State == null ? -1 : tbS.State,
                    SelfTakeFlag    = commodityOrder.SelfTakeFlag
                }
            };

            if (search.Category > -1)
            {
                query = query.Where(t => t.Invoice.Category == search.Category);
            }
            if (search.State > -1)
            {
                query = query.Where(t => t.Invoice.State == search.State);
            }
            if (!string.IsNullOrWhiteSpace(search.CommodityOrderState) && search.CommodityOrderState != "null" && search.CommodityOrderState != "-1")
            {
                if (search.CommodityOrderState.Contains(","))
                {
                    if (search.CommodityOrderState == "8,9,10,12,14")   //退款中
                    {
                        List <int> beforeState = new List <int>()
                        {
                            8, 9, 10, 12, 14
                        };
                        List <int> afterState = new List <int>()
                        {
                            5, 10, 12
                        };
                        query = query.Where(n => beforeState.Contains(n.CommodityOrder.State) || afterState.Contains(n.CommodityOrder.StateAfterSales));
                    }
                    else
                    {
                        int[] arrystate = Array.ConvertAll <string, int>(search.CommodityOrderState.Split(','), s => int.Parse(s));

                        //等发货且自提
                        if (arrystate.Contains(1) && arrystate.Contains(99))
                        {
                            int[] exceptTmp    = new int[] { 99 };
                            int[] arrystateTmp = arrystate.Except(exceptTmp).ToArray();
                            query = query.Where(a => arrystateTmp.Contains(a.CommodityOrder.State));
                        }
                        else if (arrystate.Contains(1))
                        {
                            if (arrystate.Contains(11))
                            {
                                int[] exceptTmp    = new int[] { 1, 11 };
                                int[] arrystateTmp = arrystate.Except(exceptTmp).ToArray();
                                query = query.Where(a => arrystateTmp.Contains(a.CommodityOrder.State) || ((a.CommodityOrder.State == 1 || a.CommodityOrder.State == 11) && a.CommodityOrder.SelfTakeFlag == 0));
                            }
                            else
                            {
                                int[] exceptTmp    = new int[] { 1 };
                                int[] arrystateTmp = arrystate.Except(exceptTmp).ToArray();
                                query = query.Where(a => arrystateTmp.Contains(a.CommodityOrder.State) || (a.CommodityOrder.State == 1 && a.CommodityOrder.SelfTakeFlag == 0));
                            }
                        }
                        else if (arrystate.Contains(99))
                        {
                            int[] exceptTmp    = new int[] { 99 };
                            int[] arrystateTmp = arrystate.Except(exceptTmp).ToArray();
                            query = query.Where(a => arrystateTmp.Contains(a.CommodityOrder.State) || ((a.CommodityOrder.State == 1 || a.CommodityOrder.State == 11) && a.CommodityOrder.SelfTakeFlag == 1));
                        }
                        else
                        {
                            query = query.Where(a => arrystate.Contains(a.CommodityOrder.State));
                        }
                    }
                }
                else
                {
                    if (search.CommodityOrderState != "-1" && search.CommodityOrderState != null && search.CommodityOrderState != "")
                    {
                        int _state = int.Parse(search.CommodityOrderState);
                        //待发货的
                        if (_state == 1)
                        {
                            query = query.Where(n => n.CommodityOrder.State == _state && n.CommodityOrder.SelfTakeFlag == 0);
                        }
                        //待自提的
                        else if (_state == 99)
                        {
                            query = query.Where(n => (n.CommodityOrder.State == 1 || n.CommodityOrder.State == 11) && n.CommodityOrder.SelfTakeFlag == 1);
                        }
                        else if (search.CommodityOrderState == "3") //交易成功
                        {
                            query = query.Where(n => n.CommodityOrder.State == 3 && (n.CommodityOrder.StateAfterSales == 3 || n.CommodityOrder.StateAfterSales == 15 || n.CommodityOrder.StateAfterSales == -1));
                        }
                        else if (search.CommodityOrderState == "7")
                        {
                            query = query.Where(n => n.CommodityOrder.State == 7 || n.CommodityOrder.StateAfterSales == 7);
                        }
                        else
                        {
                            query = query.Where(n => n.CommodityOrder.State == _state);
                        }
                        //countquery = countquery.Where(n => n.State == _state);
                    }
                }
            }
            if (!string.IsNullOrWhiteSpace(search.SeacrhContent))
            {
                //if (System.Text.RegularExpressions.Regex.IsMatch(search.SeacrhContent, "^[0-9]+$"))
                //{
                //    if (search.SeacrhContent.Length>11)
                //    {
                //        query = query.Where(p => p.CommodityOrder.Code.Contains(search.SeacrhContent));
                //    }
                //    else
                //    {
                //        query = query.Where(p => p.CommodityOrder.ReceiptPhone.Contains(search.SeacrhContent));
                //    }
                //}
                //else
                //{
                //    query = query.Where(p => p.CommodityOrder.ReceiptUserName.Contains(search.SeacrhContent));
                //}
                query = query.Where(p => (p.CommodityOrder.Code.Contains(search.SeacrhContent) || p.CommodityOrder.ReceiptPhone.Contains(search.SeacrhContent) || p.CommodityOrder.ReceiptUserName.Contains(search.SeacrhContent) || p.Invoice.InvoiceTitle.Contains(search.SeacrhContent)));
            }
            result.Data.Count = query.Count();
            var searchResult = query.OrderByDescending(n => n.CommodityOrder.PaymentTime).Skip((search.PageIndex - 1) * search.PageSize).Take(search.PageSize).ToList();

            //地址附值
            if (searchResult.Any())
            {
                foreach (var item in searchResult)
                {
                    item.CommodityOrder.Address = string.Format("{0}{1}{2}{3}", item.CommodityOrder.Province, item.CommodityOrder.City, item.CommodityOrder.District, item.CommodityOrder.ReceiptAddress);
                }
            }
            //由于优惠券与积分存在另一表,所以单独取
            if (searchResult.Any())
            {
                var orderIds = searchResult.Select(t => t.Invoice.CommodityOrderId).ToList();
                //优惠券与花费积分抵现金额 CouponValue SpendScoreCost
                var orderPayDetail = OrderPayDetail.ObjectSet().Where(t => orderIds.Contains(t.OrderId)).ToList();
                if (orderPayDetail.Count > 0)
                {
                    foreach (var item in searchResult)
                    {
                        var couponValue = orderPayDetail.Where(t => t.OrderId == item.Invoice.CommodityOrderId && t.ObjectType == 1).Select(t => t.Amount).FirstOrDefault();
                        item.CommodityOrder.CouponValue = couponValue;
                        var spendScoreMoney = orderPayDetail.Where(t => t.OrderId == item.Invoice.CommodityOrderId && t.ObjectType == 2).Select(t => t.Amount).FirstOrDefault();
                        item.CommodityOrder.SpendScoreMoney = spendScoreMoney;
                    }
                }
            }
            result.Data.InvoiceInfoList = new List <InvoiceInfoDTO>();
            foreach (var item in searchResult)
            {
                InvoiceInfoDTO model = new InvoiceInfoDTO();
                model.Id = item.Invoice.Id;
                model.CommodityOrderId = item.Invoice.CommodityOrderId;
                model.InvoiceTitle     = item.Invoice.InvoiceTitle;
                model.InvoiceContent   = item.Invoice.InvoiceContent;
                model.InvoiceType      = item.Invoice.InvoiceType;
                model.SubTime          = item.Invoice.SubTime;
                model.ModifiedOn       = item.Invoice.ModifiedOn;
                model.ReceiptPhone     = item.Invoice.ReceiptPhone;
                model.ReceiptEmail     = item.Invoice.ReceiptEmail;
                model.State            = item.Invoice.State;
                model.Remark           = item.Invoice.Remark;
                model.Category         = item.Invoice.Category;
                model.SubId            = item.Invoice.SubId;
                model.Code             = item.Invoice.Code;

                InvoiceCommodityOrderInfo orderInfo = new InvoiceCommodityOrderInfo();
                orderInfo.Code            = item.CommodityOrder.Code;
                orderInfo.Payment         = item.CommodityOrder.Payment;
                orderInfo.CouponValue     = item.CommodityOrder.CouponValue;
                orderInfo.GoldPrice       = item.CommodityOrder.GoldPrice;
                orderInfo.GoldCoupon      = item.CommodityOrder.GoldCoupon;
                orderInfo.PaymentTime     = item.CommodityOrder.PaymentTime;
                orderInfo.RealPrice       = item.CommodityOrder.RealPrice;
                orderInfo.ReceiptAddress  = item.CommodityOrder.ReceiptAddress;
                orderInfo.ReceiptPhone    = item.CommodityOrder.ReceiptPhone;
                orderInfo.ReceiptUserName = item.CommodityOrder.ReceiptUserName;
                orderInfo.Province        = item.CommodityOrder.Province;
                orderInfo.City            = item.CommodityOrder.City;
                orderInfo.District        = item.CommodityOrder.District;
                orderInfo.Address         = item.CommodityOrder.Address;
                orderInfo.State           = item.CommodityOrder.State;
                orderInfo.StateAfterSales = item.CommodityOrder.StateAfterSales;
                orderInfo.SelfTakeFlag    = item.CommodityOrder.SelfTakeFlag;

                model.commodityOrderInfo = orderInfo;
                result.Data.InvoiceInfoList.Add(model);
            }
            result.ResultCode = 0;
            result.Message    = "Success";
            return(result);
        }