Example #1
0
        /// <summary>
        /// 更新支付单、订单支付通道
        /// </summary>
        /// <param name="view">订单支付信息(PaymentOrderID,PayChannel)</param>
        /// <returns>Sql语句</returns>
        public ResultModel UpdatePayChannel(Domain.WebModel.Models.Orders.PaymentOrderView view)
        {
            ResultModel result = new ResultModel();

            List <string> sqls = new List <string>();

            sqls.Add(string.Format(" UPDATE PaymentOrder SET PayChannel={0},OrderNO='{1}',RechargeAmount={2} WHERE PaymentOrderID='{3}'",
                                   view.PayChannel,
                                   view.OrderNO,
                                   view.RechargeAmount,
                                   SqlFilterUtil.ReplaceSqlChar(view.PaymentOrderID)));
            int payType = view.PayChannel == (int)OrderEnums.PayChannel.Balance
                                                ? (int)OrderEnums.PayType.BalancePay
                                                : (int)OrderEnums.PayType.ThirdPay;
            string orderSql = string.Format(@" UPDATE dbo.[Order] SET PayChannel='{0}', PayType='{1}' WHERE OrderID IN (SELECT b.OrderID FROM PaymentOrder  
                                            AS a INNER JOIN dbo.PaymentOrder_Orders AS b ON a.PaymentOrderID=b.PaymentOrderID AND a.PaymentOrderID='{2}')"
                                            , view.PayChannel, payType, view.PaymentOrderID);

            sqls.Add(orderSql);

            string sql = SqlTransactionUtil.GenerateTransSql(sqls);

            //执行sql
            var     queryResult = _database.RunSqlQuery(x => x.ToResultSets(sql));
            dynamic source      = queryResult[0][0];

            result.IsValid = source.Count > 0;
            return(result);
        }
Example #2
0
        /// <summary>
        /// 货到付款 支付处理
        /// </summary>
        /// <param name="view">支付单信息(PaymentOrderID,UserID)</param>
        /// <returns></returns>
        public ResultModel PaymentCODOrder(PaymentOrderView view)
        {
            ResultModel result = new ResultModel();

            dynamic orderDetails = base._database.Db.PaymentOrder.All()
                                   .Join(base._database.Db.PaymentOrder_Orders,
                                         PaymentOrderID: base._database.Db.PaymentOrder.PaymentOrderID)
                                   .Join(base._database.Db.Order, OrderID: base._database.Db.PaymentOrder_Orders.OrderID)
                                   .Join(base._database.Db.OrderDetails, OrderID: base._database.Db.PaymentOrder_Orders.OrderID)
                                   .Where(base._database.Db.PaymentOrder.PaymentOrderID == view.PaymentOrderID &&
                                          base._database.Db.PaymentOrder.UserID == view.UserID &&
                                          base._database.Db.Order.OrderStatus == (int)OrderEnums.OrderStatus.Obligation
                                          )
                                   .Select(base._database.Db.OrderDetails.ProductId, base._database.Db.OrderDetails.Quantity, base._database.Db.OrderDetails.OrderID).ToList();

            List <string> sqls     = new List <string>();
            List <string> orderIds = new List <string>();

            foreach (var orderDetail in orderDetails)
            {
                sqls.Add(
                    productService.GenerateUpdateSaleCountSql(new ProductView()
                {
                    ProductId = orderDetail.ProductId,
                    SaleCount = orderDetail.Quantity
                }));
                if (!orderIds.Any(x => x == orderDetail.OrderID))
                {
                    orderIds.Add(orderDetail.OrderID);
                }
            }
            foreach (string orderId in orderIds)
            {
                sqls.Add(orderService.GenerateUpdateOrderStatusSql(new OrderView()
                {
                    OrderID = orderId, OrderStatus = (int)OrderEnums.OrderStatus.WaitDeliver
                }));
            }

            string sql = SqlTransactionUtil.GenerateTransSql(sqls);

            //执行sql
            var     queryResult = _database.RunSqlQuery(x => x.ToResultSets(sql));
            dynamic source      = queryResult[0][0];

            result.IsValid = source.Count > 0;
            return(result);
        }
Example #3
0
        /// <summary>
        /// 支付商城订单
        /// </summary>
        /// <param name="view">支付单实体</param>
        /// <returns>支付结果</returns>
        private ResultModel PaymentMallOrder(PaymentOrderView view)
        {
            var           result = new ResultModel();
            DateTime      now    = DateTime.Now; //操作时间
            List <string> sqls   = new List <string>();

            //查询需要更新的商品集合
            List <OrderDetailsViewT1> orderDetails = base._database.Db.PaymentOrder.Query()
                                                     .LeftJoin(_database.Db.PaymentOrder_Orders,
                                                               PaymentOrderID: base._database.Db.PaymentOrder.PaymentOrderID)
                                                     .LeftJoin(_database.Db.OrderDetails, OrderID: _database.Db.PaymentOrder_Orders.OrderID)
                                                     .Where(base._database.Db.PaymentOrder.PaymentOrderID == view.PaymentOrderID)
                                                     .Select(
                _database.Db.OrderDetails.OrderID,
                _database.Db.OrderDetails.ProductId,
                _database.Db.OrderDetails.Quantity).ToList <OrderDetailsViewT1>();


            if (orderDetails != null && orderDetails.Count > 0)
            {
                List <string> orderIds = orderDetails.Select(x => x.OrderID).Distinct().ToList();

                //更新订单状态
                foreach (var orderId in orderIds)
                {
                    sqls.Add(orderService.GenerateUpdateOrderStatusSql(new OrderView()
                    {
                        OrderID = orderId, OrderStatus = (int)OrderEnums.OrderStatus.WaitDeliver, PaidDate = now
                    }));
                    sqls.Add(orderTrackingLogService.GenerateInsertSql(new OrderTrackingLogView()
                    {
                        CreateBy        = "用户",
                        CreateTime      = now,
                        OrderID         = orderId,
                        OrderTrackingId = MemCacheFactory.GetCurrentMemCache().Increment("commonId"),
                        TrackingContent = "用户付款",
                        OrderStatus     = (int)OrderEnums.OrderStatus.WaitDeliver
                    }));
                }

                //更新产品销售量
                foreach (var orderDetail in orderDetails)
                {
                    sqls.Add(productService.GenerateUpdateSaleCountSql(new ProductView()
                    {
                        SaleCount = orderDetail.Quantity, ProductId = orderDetail.ProductId
                    }));
                }
            }

            view.PaymentDate = now;
            view.Flag        = (int)OrderEnums.PaymentFlag.Paid;

            //更新支付单状态
            sqls.Add(this.GenerateUpdatePaymentSuccessSql(view));
            string sql = SqlTransactionUtil.GenerateTransSql(sqls);

            //执行sql
            var     queryResult = _database.RunSqlQuery(x => x.ToResultSets(sql));
            dynamic source      = queryResult[0][0];

            result.IsValid = source.Count > 0;
            return(result);
        }