Exemplo n.º 1
0
        private string SaveBuyPointShipmentsTx(NbManagerEntity manager, int point, int bonus,
                                               PayChargehistoryEntity payEntity, ManagerMonthcardEntity monthcardEntity, MailBuilder mail,
                                               ManagerChargenumberEntity buyRecord, DicMallitemEntity mallConfig, string zoneId)
        {
            if (point > 0 || bonus > 0)
            {
                var messCode1 = PayCore.Instance.AddPoint(payEntity.Account, point, bonus, EnumChargeSourceType.GmCharge,
                                                          payEntity.BillingId, null, zoneId);
                if (messCode1 != MessageCode.Success)
                {
                    return("增加钻石失败" + point + "," + bonus + "," + (int)messCode1);
                }
                PayChargehistoryMgr.Insert(payEntity, null, zoneId);
            }
            if (monthcardEntity != null)
            {
                if (monthcardEntity.BuyNumber == 1)
                {
                    if (!ManagerMonthcardMgr.Insert(monthcardEntity, null, zoneId))
                    {
                        return("月卡发送失败");
                    }
                }
                else
                {
                    if (!ManagerMonthcardMgr.Update(monthcardEntity, null, zoneId))
                    {
                        return("月卡发送失败");
                    }
                }
            }
            if (!mail.Save(zoneId))
            {
                return("邮件发送失败");
            }

            if (buyRecord.Idx == 0)
            {
                ManagerChargenumberMgr.Insert(buyRecord, null, zoneId);
            }
            else
            {
                ManagerChargenumberMgr.Update(buyRecord, null, zoneId);
            }
            try
            {
                if (manager != null)
                {
                    var curScore   = mallConfig.EffectValue * 10;
                    var vipManager = VipManagerMgr.GetById(manager.Idx, zoneId);
                    if (vipManager != null)
                    {
                        curScore         += vipManager.VipExp;
                        vipManager.VipExp = curScore;
                        VipManagerMgr.Update(vipManager, null, zoneId);
                    }
                    else
                    {
                        vipManager = new VipManagerEntity(manager.Idx, curScore, DateTime.Now, DateTime.Now,
                                                          DateTime.Now);
                        VipManagerMgr.Insert(vipManager, null, zoneId);
                    }

                    var newlevel = CacheFactory.VipdicCache.GetVipLevel(curScore);
                    if (newlevel > manager.VipLevel)
                    {
                        manager.VipLevel = newlevel;
                        ManagerUtil.SaveManagerData(manager, null, null, zoneId);
                    }
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("ChargeUpVip", ex);
                return(ex.Message);
            }
            return("");
        }
Exemplo n.º 2
0
        public string TxBuyPointShipments(Guid managerId, string orderId, int mallCode, string zoneId)
        {
            try
            {
                var manager = NbManagerMgr.GetById(managerId, zoneId);
                if (manager == null)
                {
                    return("找不到经理信息");
                }
                var mallConfig = DicMallitemMgr.GetById(mallCode);
                //var mallConfig = CacheFactory.MallCache.GetMallEntityWithoutPoint(mallCode);
                if (mallConfig == null ||
                    (mallConfig.MallType != (int)EnumMallType.QP && mallConfig.MallType != (int)EnumMallType.Mystery))
                {
                    return("请输入正确的商城ID");
                }

                ManagerMonthcardEntity monthcardEntity = null;
                DateTime date       = DateTime.Now;
                int      bonus      = 0;
                var      recordList = ManagerChargenumberMgr.GetManagerIdList(managerId, zoneId);
                ManagerChargenumberEntity buyRecord = null;
                bool isFirst = false;
                if (recordList.Count > 0)
                {
                    buyRecord = recordList.Find(r => r.MallCode == mallCode);
                }
                else
                {
                    isFirst = true;
                }
                if (buyRecord == null)
                {
                    buyRecord = new ManagerChargenumberEntity(0, managerId, mallCode, 1, date, date);
                }
                else
                {
                    buyRecord.BuyNumber++;
                }
                MailBuilder mail = null;
                List <ConfigMallgiftbagEntity> prizeList = null;
                EnumMailType mailType = EnumMailType.ChargeSuccess;
                int          point    = mallConfig.CurrencyCount;
                if (mallConfig.EffectType == (int)EnumMallEffectType.MonthCard) //月卡
                {
                    MonthcardShipments(managerId, ref monthcardEntity, zoneId);
                }
                else if (mallConfig.MallType == (int)EnumMallType.Mystery)
                {
                    if (mallConfig.EffectType == (int)EnumMallEffectType.GiftBag)
                    {
                        //if (!IsHaveBuyWeekGiftBag(buyRecord, DateTime.Now))
                        //{
                        //    mailType = EnumMailType.ChargeSuccess;
                        //    point = mallConfig.EffectValue * 10;
                        //}
                        //else
                        //{
                        prizeList = GetGiftBag(mallCode);
                        if (prizeList.Count <= 0)
                        {
                            return("获取配置失败");
                        }
                        mailType = EnumMailType.GiftBagSuccess;
                        //}
                    }
                    else if (mallConfig.EffectType == (int)EnumMallEffectType.WeeklyGiftBag)
                    {
                        //if (!IsHaveBuyWeekGiftBag(buyRecord))
                        //{
                        //    mailType = EnumMailType.ChargeSuccess;
                        //    point = mallConfig.EffectValue * 10;
                        //}
                        //else
                        //{
                        prizeList = GetGiftBag(mallCode);
                        if (prizeList.Count <= 0)
                        {
                            return("获取配置失败");
                        }
                        mailType = EnumMailType.GiftBagSuccess;
                        //}
                    }
                    //else if (buyRecord.Idx > 0)
                    //{
                    //    mailType = EnumMailType.ChargeSuccess;
                    //    point = mallConfig.EffectValue * 10;
                    //}
                    else
                    {
                        prizeList = GetGiftBag(mallCode);
                        if (prizeList.Count <= 0)
                        {
                            return("获取配置失败");
                        }
                        mailType = EnumMailType.GiftBagSuccess;
                    }
                }
                prizeList = GetGiftBag(mallCode);


                var payEntity = new PayChargehistoryEntity();
                payEntity.Idx        = orderId;
                payEntity.Account    = _account.Account;
                payEntity.BillingId  = orderId;
                payEntity.Bonus      = bonus;
                payEntity.Cash       = 0;
                payEntity.IsFirst    = isFirst;
                payEntity.MallCode   = mallCode;
                payEntity.Point      = point;
                payEntity.RowTime    = DateTime.Now;
                payEntity.SourceType = (int)EnumChargeSourceType.GmCharge;
                payEntity.States     = 2;
                payEntity.UpdateTime = DateTime.Now;
                //邮件发货
                mail = new MailBuilder(managerId, mallConfig.Name, point + bonus, prizeList, mailType, 0,
                                       0);
                buyRecord.UpdateTiem = DateTime.Now;
                payEntity.Bonus      = bonus;
                var code = SaveBuyPointShipmentsTx(manager, point, bonus, payEntity,
                                                   monthcardEntity, mail,
                                                   buyRecord, mallConfig, zoneId);
                return(code);
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("充值发货", ex);
                return(ex.Message);
            }
        }