Ejemplo n.º 1
0
        //平台红包存储
        private void DepositToRegister(MemberOpenIdInfo openInfo)
        {
            //获取某个OpenId对应的红包记录(在Mall3.3版本,考虑到小程序首页配置了现金红包跳转到红包页面的情况,将之前的openId改为UnionId,并兼容以前的数据)
            var receives = DbFactory.Default.Get <BonusReceiveInfo>().Where(p => (p.OpenId.ToLower() == openInfo.OpenId.ToLower() || p.OpenId.ToLower() == openInfo.UnionId.ToLower()) && p.IsTransformedDeposit == false);
            var list     = receives.ToList();
            List <CapitalDetailModel> capitals = new List <CapitalDetailModel>();

            //存在数据则证明有可用红包,可以存到预存款里
            if (list.Count > 0)
            {
                foreach (var model in list)
                {
                    model.IsTransformedDeposit = true;
                    model.UserId = openInfo.UserId;
                    DbFactory.Default.Update(model);

                    CapitalDetailModel capital = new CapitalDetailModel()
                    {
                        UserId     = openInfo.UserId,
                        SourceType = Mall.Entities.CapitalDetailInfo.CapitalDetailType.RedPacket,
                        Amount     = model.Price,
                        CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                    };
                    new MemberCapitalService().AddCapital(capital);
                }
            }
            IMemberCapitalService capitalServicer = Mall.ServiceProvider.Instance <IMemberCapitalService> .Create;

            foreach (var c in capitals)
            {
                capitalServicer.AddCapital(c);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 将红包金额存到预存款里  (领取红包时执行)
        /// 只会出现一条红包记录
        /// </summary>
        private void DepositToMember(string openId, decimal price, string unionId = "")
        {
            //查看用户、OpenId关联表里是否存在数据,存在则证明已经绑定过OpenId
            MemberOpenIdInfo model = DbFactory.Default.Get <MemberOpenIdInfo>().Where(p => p.OpenId.ToLower() == openId.ToLower()).FirstOrDefault();

            if (model == null && !string.IsNullOrEmpty(unionId))
            {
                model = DbFactory.Default.Get <MemberOpenIdInfo>().Where(p => p.UnionId.ToLower() == unionId.ToLower()).FirstOrDefault();
            }
            if (model != null)
            {
                var receive = DbFactory.Default.Get <BonusReceiveInfo>().Where(p => (p.OpenId.ToLower() == openId.ToLower() || p.OpenId.ToLower() == model.UnionId.ToLower()) && p.IsTransformedDeposit == false).FirstOrDefault();
                if (receive == null || receive.Id <= 0)
                {
                    return;//没有未领取红包提前跳出
                }
                receive.IsTransformedDeposit = true;
                receive.UserId = model.UserId;
                DbFactory.Default.Update(receive);

                IMemberCapitalService capitalServicer = Mall.ServiceProvider.Instance <IMemberCapitalService> .Create;
                CapitalDetailModel    capita          = new CapitalDetailModel
                {
                    UserId     = model.UserId,
                    SourceType = Mall.Entities.CapitalDetailInfo.CapitalDetailType.RedPacket,
                    Amount     = price,
                    CreateTime = ((DateTime)receive.ReceiveTime).ToString("yyyy-MM-dd HH:mm:ss")
                };
                capitalServicer.AddCapital(capita);
            }
        }
Ejemplo n.º 3
0
        //平台红包存储
        private void DepositToRegister(MemberOpenIdInfo openInfo, Entities efContext)
        {
            //获取某个OpenId对应的红包记录
            var receives = efContext.BonusReceiveInfo.Where(p => p.OpenId == openInfo.OpenId && !p.IsTransformedDeposit);
            var list     = receives.ToList();
            List <CapitalDetailModel> capitals = new List <CapitalDetailModel>();

            //存在数据则证明有可用红包,可以存到预存款里
            if (list.Count > 0)
            {
                foreach (var model in list)
                {
                    model.IsTransformedDeposit = true;
                    model.Himall_Members       = efContext.UserMemberInfo.FirstOrDefault(p => p.Id == openInfo.UserId);


                    CapitalDetailModel capital = new CapitalDetailModel()
                    {
                        UserId     = openInfo.UserId,
                        SourceType = CapitalDetailInfo.CapitalDetailType.RedPacket,
                        Amount     = model.Price,
                        CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                    };
                    new MemberCapitalService().AddCapital(capital);
                }
                efContext.SaveChanges();
            }
            IMemberCapitalService capitalServicer = Himall.ServiceProvider.Instance <IMemberCapitalService> .Create;

            foreach (var c in capitals)
            {
                capitalServicer.AddCapital(c);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 将红包金额存到预存款里  (领取红包时执行)
        /// 只会出现一条红包记录
        /// </summary>
        private void DepositToMember(string openId, decimal price)
        {
            Entities efContext = new Entities();
            //查看用户、OpenId关联表里是否存在数据,存在则证明已经绑定过OpenId
            MemberOpenIdInfo model = efContext.MemberOpenIdInfo.Where(p => p.OpenId == openId).FirstOrDefault();

            if (model != null)
            {
                var receive = efContext.BonusReceiveInfo.Where(p => p.OpenId == openId && !p.IsTransformedDeposit).FirstOrDefault();
                receive.IsTransformedDeposit = true;
                receive.Himall_Members       = efContext.UserMemberInfo.FirstOrDefault(p => p.Id == model.UserId);
                efContext.SaveChanges();

                IMemberCapitalService capitalServicer = Himall.ServiceProvider.Instance <IMemberCapitalService> .Create;
                CapitalDetailModel    capita          = new CapitalDetailModel
                {
                    UserId     = model.UserId,
                    SourceType = CapitalDetailInfo.CapitalDetailType.RedPacket,
                    Amount     = price,
                    CreateTime = ((DateTime)receive.ReceiveTime).ToString("yyyy-MM-dd HH:mm:ss")
                };
                capitalServicer.AddCapital(capita);
            }
            efContext.Dispose();
        }
Ejemplo n.º 5
0
        private void DepositToRegister(MemberOpenIdInfo openInfo, Entities efContext)
        {
            IQueryable <BonusReceiveInfo> bonusReceiveInfo =
                from p in efContext.BonusReceiveInfo
                where (p.OpenId == openInfo.OpenId) && !p.IsTransformedDeposit
                select p;
            List <BonusReceiveInfo>   list = bonusReceiveInfo.ToList();
            List <CapitalDetailModel> capitalDetailModels = new List <CapitalDetailModel>();

            if (list.Count > 0)
            {
                foreach (BonusReceiveInfo bonusReceiveInfo1 in list)
                {
                    bonusReceiveInfo1.IsTransformedDeposit = true;
                    bonusReceiveInfo1.ChemCloud_Members    = efContext.UserMemberInfo.FirstOrDefault((UserMemberInfo p) => p.Id == openInfo.UserId);
                    CapitalDetailModel capitalDetailModel = new CapitalDetailModel()
                    {
                        UserId = openInfo.UserId,
                        //SourceType = CapitalDetailInfo.CapitalDetailType.RedPacket,
                        Amount     = bonusReceiveInfo1.Price,
                        CreateTime = bonusReceiveInfo1.ReceiveTime.Value.ToString("yyyy-MM-dd HH:mm:ss")
                    };
                    capitalDetailModels.Add(capitalDetailModel);
                }
                efContext.SaveChanges();
            }
            IMemberCapitalService create = Instance <IMemberCapitalService> .Create;

            foreach (CapitalDetailModel capitalDetailModel1 in capitalDetailModels)
            {
                create.AddCapital(capitalDetailModel1);
            }
        }
Ejemplo n.º 6
0
        private void DepositToMember(string openId, decimal price)
        {
            Entities         entity           = new Entities();
            MemberOpenIdInfo memberOpenIdInfo = (
                from p in entity.MemberOpenIdInfo
                where p.OpenId == openId
                select p).FirstOrDefault();

            if (memberOpenIdInfo != null)
            {
                BonusReceiveInfo bonusReceiveInfo = (
                    from p in entity.BonusReceiveInfo
                    where (p.OpenId == openId) && !p.IsTransformedDeposit
                    select p).FirstOrDefault();
                bonusReceiveInfo.IsTransformedDeposit = true;
                bonusReceiveInfo.ChemCloud_Members    = entity.UserMemberInfo.FirstOrDefault((UserMemberInfo p) => p.Id == memberOpenIdInfo.UserId);
                entity.SaveChanges();
                IMemberCapitalService create             = Instance <IMemberCapitalService> .Create;
                CapitalDetailModel    capitalDetailModel = new CapitalDetailModel()
                {
                    UserId = memberOpenIdInfo.UserId,
                    //SourceType = CapitalDetailInfo.CapitalDetailType.RedPacket,
                    Amount     = price,
                    CreateTime = bonusReceiveInfo.ReceiveTime.Value.ToString("yyyy-MM-dd HH:mm:ss")
                };
                create.AddCapital(capitalDetailModel);
            }
            entity.Dispose();
        }
Ejemplo n.º 7
0
        public void Execute(IJobExecutionContext context)
        {
            Entity.Entities entity   = new Entities();
            var             settings = new SiteSettingService().GetSiteSettings();
            var             expried  = settings.SalesReturnTimeout;
            var             now      = DateTime.Now;
            var             exday    = now.AddDays(-expried);
            var             t        = entity.BrokerageIncomeInfo.Where(a => a.Status == Model.BrokerageIncomeInfo.BrokerageStatus.NotSettled);
            var             order    = entity.OrderInfo.Where(b => b.OrderStatus == Model.OrderInfo.OrderOperateStatus.Finish && b.FinishDate.Value <= exday);
            var             models   = t.Join(order, a => a.OrderId, b => b.Id, (a, b) => new
            {
                a.Id,
                a.OrderId,
                a.OrderTime,
                a.OrderItemId,
                a.Brokerage,
                a.Himall_BrokerageRefund,
                a.ProductID,
                a.UserId,
                b.FinishDate,
                b.OrderStatus,
            }).ToList();

            foreach (var model in models)
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    IMemberCapitalService capitalServicer = Himall.ServiceProvider.Instance <IMemberCapitalService> .Create;
                    CapitalDetailModel    capita          = new CapitalDetailModel
                    {
                        UserId     = model.UserId,
                        SourceType = CapitalDetailInfo.CapitalDetailType.Brokerage,
                        CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                    };
                    capita.Amount = model.Brokerage;
                    var refund = model.Himall_BrokerageRefund.FirstOrDefault();
                    if (refund != null)
                    {
                        capita.Amount = model.Brokerage - refund.Brokerage;
                    }
                    var paid = entity.ProductBrokerageInfo.Where(a => a.ProductId == model.ProductID).FirstOrDefault();
                    var b    = entity.BrokerageIncomeInfo.Where(a => a.OrderItemId == model.OrderItemId && a.Status == BrokerageIncomeInfo.BrokerageStatus.NotSettled).FirstOrDefault();
                    if (b != null)
                    {
                        b.Status              = BrokerageIncomeInfo.BrokerageStatus.Settled;
                        b.SettlementTime      = DateTime.Now;
                        paid.BrokerageAmount += capita.Amount;
                        capita.Remark         = "分佣佣金,预约单Id:" + model.OrderId + ",诊疗项目ID:" + model.ProductID;
                        capita.SourceData     = model.OrderId.HasValue ? model.OrderId.Value.ToString() : "";
                        capitalServicer.AddCapital(capita);
                        //已结算累加
                        entity.SaveChanges();
                        transaction.Complete();
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public JsonResult ChageCapital(long userId, decimal amount, string remark)
        {
            var result = new Result {
                msg = "错误的会员编号"
            };
            var _user = MemberApplication.GetMember(userId);

            if (_user != null)
            {
                if (string.IsNullOrWhiteSpace(remark))
                {
                    result.msg = "请填写备注信息";
                }
                else
                {
                    if (amount < 0)
                    {
                        var balance = MemberCapitalApplication.GetBalanceByUserId(userId);
                        if (balance < Math.Abs(amount))
                        {
                            throw new HimallException("用户余额不足相减");
                        }
                    }
                    if (amount < 0)
                    {
                        CapitalDetailModel capita = new CapitalDetailModel
                        {
                            UserId     = userId,
                            SourceType = CapitalDetailType.ChargeAmount,
                            Amount     = amount,
                            CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            Remark     = remark,
                            PayWay     = "管理员操作"
                        };
                        _iMemberCapitalService.AddCapital(capita);
                    }
                    else
                    {
                        var detail = new Entities.ChargeDetailInfo()
                        {
                            ChargeAmount = amount,
                            ChargeStatus = Entities.ChargeDetailInfo.ChargeDetailStatus.WaitPay,
                            CreateTime   = DateTime.Now,
                            MemId        = userId,
                            ChargeWay    = "管理员操作"
                        };
                        long id = _iMemberCapitalService.AddChargeApply(detail);
                        _iMemberCapitalService.ChargeSuccess(id, remark + " 管理员操作");
                    }
                    result.success = true;
                    result.msg     = "操作成功";
                }
            }

            return(Json(result));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 微信活动 将红包金额存到预存款里  (领取红包时执行)
        /// 只会出现一条红包记录
        /// </summary>
        private void WeiDepositToMember(long userId, decimal price)
        {
            IMemberCapitalService capitalServicer = Mall.ServiceProvider.Instance <IMemberCapitalService> .Create;
            CapitalDetailModel    capita          = new CapitalDetailModel
            {
                UserId     = userId,
                SourceType = Mall.Entities.CapitalDetailInfo.CapitalDetailType.RedPacket,
                Amount     = price,
                CreateTime = (DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss")
            };

            capitalServicer.AddCapital(capita);
        }
 /// <summary>
 /// 添加会员资产
 /// </summary>
 /// <param name="capitalModel"></param>
 public static void AddCapital(CapitalDetailModel model)
 {
     _iMemberCapitalService.AddCapital(model);
 }