コード例 #1
0
ファイル: TD_Donation_Order.cs プロジェクト: chensanze/simiao
        public int Save(Model.TD_Donation_Order order)
        {
            string tranID = MySqlHelperUtil.BeginTran();

            try
            {
                string orderID = GetOrderID();
                order.OrderID   = orderID;
                order.PayNo     = orderID;
                order.IsPay     = "0";
                order.OrderTime = DateTime.Now;
                decimal result = dal.Add(order, tranID);
                if (result == 0)
                {
                    MySqlHelperUtil.RollbackTran(tranID);
                    return(0);
                }
                MySqlHelperUtil.CommitTran(tranID);
                return(1);
            }
            catch (Exception ex)
            {
                MySqlHelperUtil.RollbackTran(tranID);
                return(0);
            }
        }
コード例 #2
0
        private int SyncShop(Model.TD_Order_WeiXinPay model, string orderID)
        {
            Model.TD_Shop_Order order = shopOrderBLL.GetModel(orderID);
            if (order == null)
            {
                return(0);
            }
            if (order.IsPay == "1")
            {
                return(0);
            }
            DateTime now = DateTime.Now;

            order.PayTime = now;
            order.IsPay   = "1";

            IList <Model.TD_Shop_OrderGoods> orderGoodsList = orderGoodsBLL.GetListByOrderID(orderID);
            string tranID = MySqlHelperUtil.BeginTran();

            try
            {
                decimal result = dal.Sync(model, tranID);
                if (result == 0)
                {
                    MySqlHelperUtil.RollbackTran(tranID);
                    return(0);
                }
                result = goodsBLL.PayOrder(orderID, orderGoodsList, tranID);
                if (result == 0)
                {
                    //商品中不存在  去sell中找
                    result = sellGoods.PayOrderNoFrozen(orderID, orderGoodsList, tranID);
                    if (result == 0)
                    {
                        MySqlHelperUtil.RollbackTran(tranID);
                        return(0);
                    }
                }
                result = shopOrderBLL.PayOrder(order, tranID);
                if (result == 0)
                {
                    MySqlHelperUtil.RollbackTran(tranID);
                    return(0);
                }
                MySqlHelperUtil.CommitTran(tranID);
                return(1);
            }
            catch
            {
                MySqlHelperUtil.RollbackTran(tranID);
                return(0);
            }
        }
コード例 #3
0
ファイル: TD_Shop_Order.cs プロジェクト: chensanze/ShiMiao
        public int Save(Model.TD_Shop_Order order, Model.TD_Shop_Order_Consignee consignee, IList <Model.TD_Shop_OrderGoods> ordderGoodsList)
        {
            string tranID = MySqlHelperUtil.BeginTran();

            try
            {
                string orderID = GetOrderID();
                order.OrderID         = orderID;
                order.PayNo           = orderID;
                order.IsMemberDeleted = "0";
                order.IsPay           = "0";
                order.OrderTime       = DateTime.Now;
                int result = dal.Add(order, tranID);
                if (result == 0)
                {
                    MySqlHelperUtil.RollbackTran(tranID);
                    return(0);
                }
                foreach (var orderGoods in ordderGoodsList)
                {
                    orderGoods.OrderID      = orderID;
                    orderGoods.OrderTime    = order.OrderTime;
                    orderGoods.OrderGoodsID = Guid.NewGuid().ToString();
                    result = orderGoodsBLL.Add(orderGoods, tranID);
                    if (result == 0)
                    {
                        MySqlHelperUtil.RollbackTran(tranID);
                        return(0);
                    }
                    result = goodsBLL.Frozen(orderGoods.GoodsID, orderGoods.Amount.Value, tranID);
                    if (result == 0)
                    {
                        MySqlHelperUtil.RollbackTran(tranID);
                        return(0);
                    }
                }
                MySqlHelperUtil.CommitTran(tranID);
                return(1);
            }
            catch (Exception ex)
            {
                MySqlHelperUtil.RollbackTran(tranID);
                return(0);
            }
        }
コード例 #4
0
        public int SyncDonation(Model.TD_Order_WeiXinPay model, string orderID)
        {
            Model.TD_Donation_Order order = donationOrderBLL.GetModel(orderID);
            if (order == null)
            {
                return(0);
            }
            if (order.IsPay == "1")
            {
                return(0);
            }
            DateTime now = DateTime.Now;

            order.PayTime = now;
            order.IsPay   = "1";

            string tranID = MySqlHelperUtil.BeginTran();

            try
            {
                decimal result = dal.Sync(model, tranID);
                if (result == 0)
                {
                    MySqlHelperUtil.RollbackTran(tranID);
                    return(0);
                }
                result = donationOrderBLL.PayOrder(order, tranID);
                if (result == 0)
                {
                    MySqlHelperUtil.RollbackTran(tranID);
                    return(0);
                }
                MySqlHelperUtil.CommitTran(tranID);
                return(1);
            }
            catch
            {
                MySqlHelperUtil.RollbackTran(tranID);
                return(0);
            }
        }
コード例 #5
0
        public bool insertBills(List <WXBill> _BillList)
        {
            bool   ret     = false;
            string transid = MySqlHelperUtil.BeginTran();

            try
            {
                foreach (WXBill _bill in _BillList)
                {
                    //通过商户订单号查找记录
                    WXBill oldOne = selectOneBillBySHDDH(_bill);
                    if (null != oldOne)
                    {
                        if (!oldOne.Equals(_bill))
                        {//若存在记录且数据不一直 更新
                            ret = updateBillByID(oldOne.RecordID, _bill, transid);
                            if (false == ret)
                            {
                                break;
                            }
                        }
                        else
                        {
                            ret = true;
                        }
                    }
                    else
                    {//不存在记录 插入
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into TD_Order_WeiXinPay_dz(");
                        strSql.Append("RecordID, TranDate, AppID, MCHID, SubMCHID, DeviceID, TransactionID, OutTradeNo, UserInfo, TranType , TranSta, PayBank , Currency , Cost , EnterpriseLuckyMoney , RefundID , OutRefundNo , RefundMoney , EnterpriseRefundLuckyMoney, RefundType , RefundSta , GoodsName , MerchantData , ExFee , Rates");
                        strSql.Append(") values (");
                        strSql.Append("@RecordID, @TranDate,@AppID, @MCHID, @SubMCHID, @DeviceID, @TransactionID, @OutTradeNo, @UserInfo, @TranType , @TranSta, @PayBank , @Currency , @Cost , @EnterpriseLuckyMoney , @RefundID , @OutRefundNo , @RefundMoney , @EnterpriseRefundLuckyMoney, @RefundType , @RefundSta , @GoodsName , @MerchantData , @ExFee , @Rates");
                        strSql.Append(") ");

                        MySqlParameter[] parameters =
                        {
                            new MySqlParameter("@RecordID",                   Guid.NewGuid().ToString()),
                            new MySqlParameter("@TranDate",                   _bill.TranDate),
                            new MySqlParameter("@AppID",                      _bill.AppID),
                            new MySqlParameter("@MCHID",                      _bill.MCHID),
                            new MySqlParameter("@SubMCHID",                   _bill.SubMCHID),
                            new MySqlParameter("@DeviceID",                   _bill.DeviceID),
                            new MySqlParameter("@TransactionID",              _bill.TransactionID),
                            new MySqlParameter("@OutTradeNo",                 _bill.OutTradeNo),
                            new MySqlParameter("@UserInfo",                   _bill.UserInfo),
                            new MySqlParameter("@TranType",                   _bill.TranType),
                            new MySqlParameter("@TranSta",                    _bill.TranSta),
                            new MySqlParameter("@PayBank",                    _bill.PayBank),
                            new MySqlParameter("@Currency",                   _bill.Currency),
                            new MySqlParameter("@Cost",                       _bill.Cost),
                            new MySqlParameter("@EnterpriseLuckyMoney",       _bill.EnterpriseLuckyMoney),
                            new MySqlParameter("@RefundID",                   _bill.RefundID),
                            new MySqlParameter("@OutRefundNo",                _bill.OutRefundNo),
                            new MySqlParameter("@RefundMoney",                _bill.RefundMoney),
                            new MySqlParameter("@EnterpriseRefundLuckyMoney", _bill.EnterpriseRefundLuckyMoney),
                            new MySqlParameter("@RefundType",                 _bill.RefundType),
                            new MySqlParameter("@RefundSta",                  _bill.RefundSta),
                            new MySqlParameter("@GoodsName",                  _bill.GoodsName),
                            new MySqlParameter("@MerchantData",               _bill.MerchantData),
                            new MySqlParameter("@ExFee",                      _bill.ExFee),
                            new MySqlParameter("@Rates",                      _bill.Rates)
                        };
                        if (MySqlHelperUtil.ExecuteNonQuery(transid, strSql.ToString(), parameters) != 1)
                        {
                            MySqlHelperUtil.RollbackTran(transid);
                            ret = false;
                            break;
                        }
                        else
                        {
                            ret = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MySqlHelperUtil.RollbackTran(transid);
                throw ex;
            }
            if (!ret)
            {
                MySqlHelperUtil.RollbackTran(transid);
            }
            else
            {
                MySqlHelperUtil.CommitTran(transid);
            }
            return(ret);
        }
コード例 #6
0
ファイル: TD_Shop_Order.cs プロジェクト: chensanze/simiao
        public int Save(Model.TD_Shop_Order order, Model.TD_Shop_Order_Consignee consignee, IList <Model.TD_Shop_OrderGoods> ordderGoodsList)
        {
            string tranID    = MySqlHelperUtil.BeginTran();
            bool   isNotFind = true;

            try
            {
                string orderID = GetOrderID();
                order.OrderID         = orderID;
                order.PayNo           = orderID;
                order.IsMemberDeleted = "0";
                order.IsPay           = "0";
                order.OrderTime       = DateTime.Now;
                int result = dal.Add(order, tranID);
                if (result == 0)
                {
                    MySqlHelperUtil.RollbackTran(tranID);
                    return(0);
                }
                consignee.OrderID = orderID;
                result            = dl_consignee.Add(consignee, tranID);
                if (result == 0)
                {
                    MySqlHelperUtil.RollbackTran(tranID);
                    return(0);
                }
                foreach (var orderGoods in ordderGoodsList)
                {
                    isNotFind               = true;
                    orderGoods.OrderID      = orderID;
                    orderGoods.OrderTime    = order.OrderTime;
                    orderGoods.OrderGoodsID = Guid.NewGuid().ToString();
                    result = orderGoodsBLL.Add(orderGoods, tranID);
                    if (result == 0)
                    {
                        MySqlHelperUtil.RollbackTran(tranID);
                        return(0);
                    }
                    var ShopGoodsModel = goodsBLL.GetModel(orderGoods.GoodsID);
                    if (null != ShopGoodsModel)
                    {
                        //商城商品处理冻结
                        result = goodsBLL.Frozen(orderGoods.GoodsID, orderGoods.Amount.Value, tranID);
                        if (result == 0)
                        {
                            MySqlHelperUtil.RollbackTran(tranID);
                            return(0);
                        }
                        isNotFind = false;
                    }
                    else
                    {
                        var SellGoodsModel = sellgoods.GetModel(orderGoods.GoodsID);
                        if (null != SellGoodsModel)
                        {
                            if (!bl_Config.noFrozen.Contains(orderGoods.GoodsID))
                            {//义卖商品处理冻结
                                result = sellgoods.Frozen(orderGoods.GoodsID, orderGoods.Amount.Value, tranID);
                                if (result == 0)
                                {
                                    MySqlHelperUtil.RollbackTran(tranID);
                                    return(0);
                                }
                            }
                            isNotFind = false;
                        }
                    }
                    if (isNotFind)
                    {
                        throw new Exception("认领失败了,请重新认领!");
                    }
                }
                MySqlHelperUtil.CommitTran(tranID);
                return(1);
            }
            catch (Exception ex)
            {
                MySqlHelperUtil.RollbackTran(tranID);
                return(0);
            }
        }