Beispiel #1
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public int Insert(ExchangeAccount obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     String stmtId = "ExchangeAccount.Insert";
     return SqlMapper.Instance().QueryForObject<int>(stmtId, obj);
 }
Beispiel #2
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(ExchangeAccount obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     String stmtId = "ExchangeAccount.Update";
     int result = SqlMapper.Instance().QueryForObject<int>(stmtId, obj);
     return result > 0 ? true : false;
 }
Beispiel #3
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(ExchangeAccount obj)
 {
     return dal.Update(obj);
 }
Beispiel #4
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public int Insert(ExchangeAccount obj)
 {
     return dal.Insert(obj);
 }
Beispiel #5
0
        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");
        }