コード例 #1
0
ファイル: TOrderDao.cs プロジェクト: qiuliang/tumumi
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(TOrder obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     String stmtId = "TOrder.Update";
     int result = SqlMapper.Instance().QueryForObject<int>(stmtId, obj);
     return result > 0 ? true : false;
 }
コード例 #2
0
ファイル: TOrderBLL.cs プロジェクト: qiuliang/tumumi
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(TOrder obj)
 {
     return dal.Update(obj);
 }
コード例 #3
0
ファイル: TOrderDao.cs プロジェクト: qiuliang/tumumi
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public void Insert(TOrder obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     String stmtId = "TOrder.Insert";
     SqlMapper.Instance().Insert(stmtId, obj);
 }
コード例 #4
0
ファイル: TOrderBLL.cs プロジェクト: qiuliang/tumumi
 /// <summary>
 /// 保存订单和订单明细
 /// </summary>
 /// <param name="obj"></param>
 public void SaveOrder(TOrder obj)
 {
     foreach (TOrderDetail d in obj.OrderDetails) {
         dalDetail.Insert(d);
     }
     Insert(obj);
 }
コード例 #5
0
ファイル: TOrderBLL.cs プロジェクト: qiuliang/tumumi
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public void Insert(TOrder obj)
 {
     dal.Insert(obj);
 }
コード例 #6
0
ファイル: MyController.cs プロジェクト: qiuliang/tumumi
        public void DoExchange(
            int accountType,string accountName,string accountNo,int amount,int exchangeAccId,
            string bankName,string provinceName,string areaName,int? provinceId,int? areaId
            )
        {
            try
            {
                #region 参数检测
                if (string.IsNullOrEmpty(accountName))
                    throw new TmmException("账户名不能为空");
                if (string.IsNullOrEmpty(accountNo))
                    throw new TmmException("账号不能为空");
                if (amount == 0)
                    throw new TmmException("兑换金额不能为0");
                int toExchange = (int)Helper.FormatHelper.ExchangeValue(amount);
                if (toExchange == 0 || toExchange % ConfigHelper.MinExchange != 0)
                    throw new TmmException("兑换金额只能为" + ConfigHelper.MinExchange.ToString() + "的倍数");

                #endregion
                OrderService os = Context.GetService<OrderService>();
                U_UserInfo u = base.GetUser();
                if (exchangeAccId == 0)
                {
                    //新增兑换账户ID
                    ExchangeAccount ea = new ExchangeAccount()
                    {
                        AccountName = accountName,
                        AccountNo = accountNo,
                        AccountType = accountType,
                        AreaId = areaId,
                        AreaName = areaName,
                        BankName = bankName,
                        ProvinceId = provinceId,
                        ProvinceName = provinceName,
                        CreateTime = DateTime.Now,
                        UserId = u.UserId
                    };
                    exchangeAccId = os.ExchangeAccountBll.Insert(ea);
                }
                else
                {
                   //更新账户信息
                    ExchangeAccount oldEa = os.ExchangeAccountBll.Get(exchangeAccId);
                    oldEa.AccountName = accountName;
                    oldEa.AccountNo = accountNo;
                    oldEa.AreaId = areaId;
                    oldEa.AreaName = areaName;
                    oldEa.ProvinceId = provinceId;
                    oldEa.ProvinceName = provinceName;
                    oldEa.BankName = bankName;
                    os.ExchangeAccountBll.Update(oldEa);
                    //如果因为用户自己更改了兑换账户信息而可能产生的纠纷,管理员在后台处理的时候需要把相关账户信息写进管理员备注
                }

                //冻结账户部分余额
                os.MAccountBll.FrozenSomeAmount(amount, u.UserId);
                //生成订单
                decimal orderId = Utils.TmmUtils.GenOrderId();
                TOrderDetail detail = new TOrderDetail()
                {
                    DocId = -2, //-2代表兑换,-1代表直接充值
                    DocTitle = "兑换:" + amount.ToString(),
                    GoodsCount = 1,
                    Price = amount,
                    OrderId = orderId
                };
                TOrder o = new TOrder()
                {
                    CreateTime = DateTime.Now,
                    Email = u.Email,
                    ExchangeAccId = exchangeAccId,
                    Ip = Utils.TmmUtils.IPAddress(),
                    OrderDetails = new List<TOrderDetail>() { detail },
                    OrderId = orderId,
                    OrderType = (int)OrderType.Exchange,
                    PayWay = 0,
                    Remark = accountType.ToString(),    //此处备注字段用户保存是支付宝兑换,还是银行账户兑换
                    Status = (int)OrderStatus.FrozenSomeAmount,
                    Total = amount,
                    UserId = u.UserId,
                    //把生成订单时填写的账户信息写入管理员备注
                    AdminRemark = string.Format("户名:【{0}】,账号:【{2}{1}】",accountName,accountNo,bankName + ",")
                };
                os.TOrderBll.SaveOrder(o);
                Flash["exchangeResult"] = true;

            }
            catch (TmmException te) {
                AddError(te.Message);
            }
            Redirect("Exchange.do");
        }
コード例 #7
0
ファイル: OrderCallBack.cs プロジェクト: qiuliang/tumumi
        protected void CheckOrder(TOrder m, OrderStatus[] status,U_UserInfo u)
        {
            if (m == null)
                throw new Exception("无效的订单");

            bool checkStatus = false;
            foreach (OrderStatus os in status)
            {
                if (m.Status == (int)os)
                {
                    checkStatus = true;
                    break;
                }
            }
            if (!checkStatus)
                throw new Exception("错误的订单状态");

            if (m.UserId != u.UserId)
                throw new Exception("请从正确的地址访问");
        }
コード例 #8
0
ファイル: PayController.cs プロジェクト: qiuliang/tumumi
        public void GotoPay(string PayWay, decimal total, string pname, int docId,int chargeType)
        {
            OrderService os = Context.GetService<OrderService>();
            AccountService accs = Context.GetService<AccountService>();
            U_UserInfo logonUser = base.GetUser();
            decimal orderId = Utils.TmmUtils.GenOrderId();

            DDocInfo doc = new DDocInfo();
            TOrder order = new TOrder();
            TOrderDetail detail = new TOrderDetail();

            int orderType = 0;  //订单类型

            if (chargeType == 1)
            {
                doc = os.DDocInfoBll.Get(docId);
                orderType = (int)OrderType.DownDocOrder;
            }
            else if (chargeType == 0) {
                //如果是直接充值,这里虚拟一个doc对象,来作为订单的商品
                doc = new DDocInfo() {
                    DocId = -1,
                    Title = "直接充值:" + total.ToString(),
                    Price = total
                };
                orderType = (int)OrderType.DirectCharge;
            }

            detail = new TOrderDetail()
            {
                DocId = doc.DocId,
                DocTitle = doc.Title,
                GoodsCount = 1,
                Price = doc.Price,
                OrderId = orderId
            };
            order = new TOrder()
            {
                OrderType = orderType,
                OrderId = orderId,
                UserId = logonUser.UserId,
                Email = logonUser.Email,
                Total = detail.Price * detail.GoodsCount,
                Ip = Context.Request.UserHostAddress,
                Status = (int)OrderStatus.NewOrder,
                CreateTime = DateTime.Now,
                PayWay = Helper.FormatHelper.GetPayWay(PayWay),
                OrderDetails = new List<TOrderDetail>() { detail }
            };
            os.TOrderBll.SaveOrder(order);

            TOrder o = os.TOrderBll.Get(orderId);

            decimal amount = 0;//除扣除账户余额外还需要支付金额
            amount = total;

            //if (total > minfo.Amount)
            //{
            //    amount = total - minfo.Amount;
            //}
            //else {
            //    //账户支付
            //}

            #region 转至支付接口
            if (PayWay.ToLower() == "tenpay")
            {
                TenPay pay = new TenPay();
                pay.UserId = logonUser.UserId;
                pay.Send(orderId.ToString(), amount.ToString(), pname);

            }

            if (PayWay.ToLower() == "chinabank")
            {
                ChinaBankPay pay = new ChinaBankPay();
                pay.Send(orderId.ToString(), amount.ToString(), pname);

                // Response.Write("ChinaBank");
            }
            if (PayWay.ToLower() == "alipay")
            {
                AliPay pay = new AliPay();
                pay.Send(orderId.ToString(), amount.ToString(), pname,logonUser.UserId);

                // Response.Write("ChinaBank");
            }
            if (PayWay.ToLower() == "useraccount")
            {
                MAccount minfo = accs.MAccountBll.GetByUserId(logonUser.UserId);    //账户

                if (o.Total <= minfo.Amount && (o.Status == (int)OrderStatus.NewOrder))
                {
                    //ms.MAccount.AccountExpend(o.OrderId);
                    ////ms.MOrder.UpdateOrder2Paid(o.OrderId, 0, "账户支付", (int)Models.MOrderStateInfo.己付款);
                    //Web.Common.OrderCallBack oCallBack = new MamShare.Mall.Web.Common.OrderCallBack(
                    //            o.UserId, o.OrderId, 0, (int)Models.MOrderStateInfo.己付款, "账户支付");
                    //oCallBack.Update2Paid();

                    //Hashtable p = new Hashtable();
                    //p.Add("OrderId", o.OrderId);
                    //RedirectToAction("payok.do", p);
                    os.MAccountBll.AccountExpend(o.OrderId, Utils.TmmUtils.IPAddress());    //账户花销
                    Common.OrderCallBack oCallBack = new TMM.Core.Common.OrderCallBack();
                    oCallBack.UserId = o.UserId;
                    oCallBack.OrderId = o.OrderId;
                    oCallBack.PayWay = 0;
                    oCallBack.Status = (int)OrderStatus.IsPaied;
                    oCallBack.PayDetail = "账户支付";
                    oCallBack.GotoUrl = "/my/purchase.do";

                    oCallBack.ExecAfterPaid();

                }
                else
                {

                    Redirect("NetPay.do?orderid=" + o.OrderId);
                }

            }
            #endregion
            RenderView("pay");
        }