Ejemplo n.º 1
0
        /// <summary>
        /// 新增提现记录
        /// 窦海超
        /// 2015年3月23日 11:40:56
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddWtihdrawRecords(WithdrawRecordsModel model)
        {
            string        sql  = @"
                        INSERT INTO dbo.WtihdrawRecords
                                ( [Platform] ,
                                  UserId ,
                                  Amount ,
                                  Balance ,
                                  CreateTime ,
                                  Status ,
                                  AdminId
                                )
                        VALUES  ( @Platform , -- Platform - int
                                  @UserId , -- UserId - int
                                  @Amount , -- Amount - decimal
                                  @Balance , -- Balance - decimal
                                  GETDATE() , -- CreateTime - datetime
                                  1 , -- Status - int
                                  @AdminId  -- AdminId - int
                                )
                        ";
            IDbParameters parm = DbHelper.CreateDbParameters();

            parm.AddWithValue("@Platform", model.Platform);
            parm.AddWithValue("@UserId", model.UserId);
            parm.AddWithValue("@Amount", model.Amount);
            parm.AddWithValue("@Balance", model.Balance);
            parm.AddWithValue("@AdminId", model.AdminId);
            return(DbHelper.ExecuteNonQuery(SuperMan_Write, sql, parm) > 0 ? true : false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 新增提现流水记录
        /// 窦海超
        /// 2015年3月23日 11:40:56
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddRecords(WithdrawRecordsModel model)
        {
            string        sql  = @"
                INSERT INTO dbo.Records
                        ( [Platform] ,
                          UserId ,
                          Amount ,
                          Balance ,
                          CreateTime ,
                          AdminId,
                          IsDel,
                          Remark,
                          OrderId,
                          RecordType
                        )
                VALUES  ( @Platform , -- Platform - int
                          @UserId , -- UserId - int
                          @Amount , -- Amount - decimal
                          @Balance , -- Balance - decimal
                          getdate() , -- CreateTime - datetime
                          @AdminId,  -- AdminId - int
                          @IsDel,
                          @Remark,
                          @OrderId,
                          @RecordType
                        )
                ";
            IDbParameters parm = DbHelper.CreateDbParameters();

            parm.AddWithValue("@Platform", model.Platform);
            parm.AddWithValue("@UserId", model.UserId);
            parm.AddWithValue("@Amount", model.Amount);
            parm.AddWithValue("@Balance", model.Balance);
            parm.AddWithValue("@AdminId", model.AdminId);
            parm.AddWithValue("@IsDel", model.IsDel);
            parm.AddWithValue("@Remark", model.Remark == null ? "" : model.Remark);
            parm.AddWithValue("@OrderId", model.OrderId);
            parm.AddWithValue("@RecordType", model.RecordType);
            return(DbHelper.ExecuteNonQuery(SuperMan_Write, sql, parm) > 0 ? true : false);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 跨店补贴
        /// 徐鹏程
        /// 20150414
        /// </summary>
        public bool CrossShop(List <GlobalConfigSubsidies> SubsidiesList)
        {
            IList <GrabOrderModel> list = subsidyDao.GetBusinessCount();
            WtihdrawRecordsDao     withdrawRecordsDao = new WtihdrawRecordsDao();
            ClienterDao            clienterDao        = new ClienterDao();

            int    MaxSubsidiesShop  = SubsidiesList.Max(t => ParseHelper.ToInt(t.Value1));                                                                //最大数量
            double MaxSubsidiesPrice = ParseHelper.ToDouble(SubsidiesList.Where(t => ParseHelper.ToInt(t.Value1) == MaxSubsidiesShop).ToList()[0].Value2); //最大金额

            foreach (GrabOrderModel item in list)
            {
                //Ets.Model.DomainModel.Clienter.ClienterModel cliterModel = new ClienterDao().GetUserInfoByUserId(item.ClienterId);//获取当前用户余额
                WithdrawRecordsModel withdraw = new WithdrawRecordsModel();
                #region 写流水
                withdraw.Platform = 1;
                withdraw.AdminId  = 0;
                withdraw.UserId   = item.ClienterId;
                int businessCount = item.BusinessCount;
                //var findSubsidie = SubsidiesList.OrderByDescending(t => ParseHelper.ToInt(t.Value1)).ToList().Where(t => ParseHelper.ToInt(t.Value1) >= businessCount).First();
                //double businessPrice = findSubsidie == null ? 0 : ParseHelper.ToDouble(findSubsidie.Value2);

                //ParseHelper.ToDouble(SubsidiesList.Select(t => ParseHelper.ToInt(t.Value1) == businessCount));
                double businessPrice = 0;
                if (businessCount > MaxSubsidiesShop)
                {
                    businessPrice = MaxSubsidiesPrice;
                }
                else
                {
                    var tmpPrice = SubsidiesList.Where(t => ParseHelper.ToInt(t.Value1) == businessCount).ToList();
                    if (tmpPrice == null || tmpPrice.Count <= 0)
                    {
                        continue;
                    }
                    businessPrice = ParseHelper.ToDouble(tmpPrice[0].Value2);//当前金额
                }

                withdraw.Amount  = ParseHelper.ToDecimal(businessPrice, 0);
                withdraw.Balance = ParseHelper.ToDecimal(item.AccountBalance, 0) + withdraw.Amount;
                withdraw.Remark  = string.Format("跨店抢单奖励{0}元", withdraw.Amount);

                //记录跨店日志
                CrossShopModel crossShopModel = new CrossShopModel()
                {
                    Amount        = withdraw.Amount,
                    BusinessCount = businessCount,
                    ClienterId    = withdraw.UserId,
                    Platform      = 2,
                    Remark        = withdraw.Remark,
                    InsertTime    = DateTime.Now
                };
                #endregion

                ClienterBalanceRecord cbrm = new ClienterBalanceRecord()
                {
                    ClienterId = withdraw.UserId,
                    Amount     = withdraw.Amount,                    //奖励的金额
                    Status     = ClienterBalanceRecordStatus.Success.GetHashCode(),
                    Balance    = withdraw.Balance + withdraw.Amount, //奖励后的金额
                    RecordType = ClienterBalanceRecordRecordType.SystemReward.GetHashCode(),
                    Operator   = "系统服务",
                    RelationNo = "",
                    Remark     = "跨店骑士奖励"
                };

                using (IUnitOfWork tran = EdsUtilOfWorkFactory.GetUnitOfWorkOfEDS())
                {
                    //修改records表增加记录作废,改为 新表ClienterBalanceRecord
                    // withdrawRecordsDao.AddRecords(withdraw);
                    clienterBalanceRecordDao.Insert(cbrm);
                    clienterDao.UpdateAccountBalanceAndWithdraw(withdraw);//更改用户金额
                    subsidyDao.InsertCrossShopLog(crossShopModel);
                    tran.Complete();
                }
            }
            return(true);
        }