/// <summary>
        /// 设置返利佣金操作
        /// </summary>
        /// <param name="SysNo">返利佣金列表</param>
        /// <remarks>2015-10-19 杨云奕 添加</remarks>
        public override void SetCrCustomerRebatesRecordToCustomerBrokerage(int SysNo)
        {
            string sql = "select * from CrCustomerRebatesRecord where SysNo=" + SysNo;
            CrCustomerRebatesRecord recordMod = Context.Sql(sql).QuerySingle <CrCustomerRebatesRecord>();
            //获取返利列表集合
            List <CBRcReturn> list = Hyt.DataAccess.RMA.IRcReturnDao.Instance.GetRmaReturnListByOrderSysNo(recordMod.OrderSysNo);
            //获取客户信息
            CBCrCustomer customer = Hyt.DataAccess.CRM.ICrCustomerDao.Instance.GetModel(recordMod.RecommendSysNo);

            if (list.Count > 0)
            {
                //更新返利列表状态,作废的部分
                recordMod.Status = "-1";
                Update(recordMod);
                //减去用户的冻结金额部分
                customer.BrokerageFreeze -= recordMod.Rebates;
                Hyt.DataAccess.CRM.ICrCustomerDao.Instance.Update(customer);
            }
            else
            {
                //更新返利列表状态,完成的部分
                recordMod.Status = "1";
                Update(recordMod);
                //增加用户的资金
                customer.BrokerageFreeze -= recordMod.Rebates;
                //customer.BrokerageTotal += recordMod.Rebates;
                customer.Brokerage += recordMod.Rebates;
                Hyt.DataAccess.CRM.ICrCustomerDao.Instance.Update(customer);
            }
        }
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="entity">数据实体</param>
 /// <returns>新增记录编号</returns>
 /// <remarks>2015-08-21  王耀发 创建</remarks>
 public override int Insert(CrCustomerRebatesRecord entity)
 {
     entity.SysNo = Context.Insert("CrCustomerRebatesRecord", entity)
                    .AutoMap(o => o.SysNo)
                    .ExecuteReturnLastId <int>("SysNo");
     return(entity.SysNo);
 }
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="entity">数据实体</param>
 /// <returns>修改记录编号</returns>
 /// <remarks>2015-08-21  王耀发 创建</remarks>
 public override int Update(CrCustomerRebatesRecord entity)
 {
     return(Context.Update("CrCustomerRebatesRecord", entity)
            .AutoMap(o => o.SysNo)
            .Where("SysNo", entity.SysNo)
            .Execute());
 }
Пример #4
0
        /// <summary>
        /// 保存返利记录
        /// </summary>
        /// <param name="model">返利记录</param>
        /// <param name="user">操作人</param>
        /// <returns></returns>
        /// <remarks>2015-08-06 王耀发 创建</remarks>
        public Result SaveCrSellBusinessGrade(CrCustomerRebatesRecord model, SyUser user)
        {
            Result r = new Result()
            {
                Status = false
            };
            CrCustomerRebatesRecord entity = ICrCustomerRebatesRecordDao.Instance.GetEntity(model.SysNo);

            if (entity != null)
            {
                model.SysNo = entity.SysNo;
                ICrCustomerRebatesRecordDao.Instance.Update(model);
                r.Status = true;
            }
            else
            {
                ICrCustomerRebatesRecordDao.Instance.Insert(model);
                r.Status = true;
            }
            return(r);
        }
Пример #5
0
        /// <summary>
        /// 设置返利佣金操作
        /// </summary>
        /// <param name="customerRebatesRecord">返利日志详情</param>
        /// <param name="rcReturnItems">退换货扣除返利列表</param>
        /// <remarks>
        /// 2015-10-19 杨云奕 添加
        /// 2016-1-5 杨浩 重构
        /// </remarks>
        public void SetCrCustomerRebatesRecordToCustomerBrokerage(CrCustomerRebatesRecord customerRebatesRecord, List <CBReurnDeductRebates> rcReturnItems)
        {
            //获取推荐人客户信息
            CBCrCustomer customer = Hyt.DataAccess.CRM.ICrCustomerDao.Instance.GetModel(customerRebatesRecord.RecommendSysNo);

            //获当前的返利记录
            //rcReturnItems = rcReturnItems.Where(x => x.SysNo == customerRebatesRecord.SysNo).ToList();

            foreach (var item in rcReturnItems)
            {
                //item.ReturnStatus=0 代表订单无退换货
                if (item.ReturnStatus == 0 || item.ReturnStatus == (int)RmaStatus.退换货状态.作废)
                {
                    //更新返利列表状态,完成的部分
                    customerRebatesRecord.Status = "1";
                    Hyt.DataAccess.SellBusiness.ICrCustomerRebatesRecordDao.Instance.Update(customerRebatesRecord);
                    //减去用户的冻结资金
                    customer.BrokerageFreeze = customer.BrokerageFreeze - customerRebatesRecord.Rebates;
                    //customer.BrokerageTotal += recordMod.Rebates;

                    //增加用户的可提佣金
                    customer.Brokerage = customer.Brokerage + customerRebatesRecord.Rebates;
                    Hyt.DataAccess.CRM.ICrCustomerDao.Instance.Update(customer);

                    //Hyt.BLL.Distribution.DsPrePaymentItemBo.Instance.UpdatePrePaymentItemStatus(customerRebatesRecord.OrderSysNo,(int)DistributionStatus.预存款明细来源.返利,(int)DistributionStatus.预存款明细状态.完结);
                    //DataAccess.Distribution.IDsPrePaymentDao.Instance.AddAvailableAmount(customerRebatesRecord.DealerSysNo,customerRebatesRecord.Rebates,0);
                }
                else if (item.ReturnStatus == (int)RmaStatus.退换货状态.已完成)
                {
                    //更新返利列表状态,作废的部分
                    customerRebatesRecord.Status = "2";

                    //更新返利记录状态
                    Hyt.DataAccess.SellBusiness.ICrCustomerRebatesRecordDao.Instance.Update(customerRebatesRecord);
                    //减去用户的冻结金额部分
                    customer.BrokerageFreeze = customer.BrokerageFreeze - item.DeductRebates;
                    Hyt.DataAccess.CRM.ICrCustomerDao.Instance.Update(customer);
                }
            }
        }
Пример #6
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="entity">数据实体</param>
 /// <returns>修改记录编号</returns>
 /// <remarks>2015-08-21  王耀发 创建</remarks>
 public abstract int Update(CrCustomerRebatesRecord entity);
Пример #7
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="entity">数据实体</param>
 /// <returns>新增记录编号</returns>
 /// <remarks>2015-08-06 王耀发 创建</remarks>
 public abstract int Insert(CrCustomerRebatesRecord entity);