Exemplo n.º 1
0
        public bool CheckChargeItemConfigLogic(int zhigouID, int PurchaseNum, string GoodsOne, string GoodsTwo, string FromSystem)
        {
            Dictionary <int, ChargeItemData> ChargeItemDict = Data.ChargeItemDict;
            bool result;

            if (null == ChargeItemDict)
            {
                LogManager.WriteLog(LogTypes.Fatal, string.Format("警告:充值直购文件尚未成功加载", new object[0]), null, true);
                result = false;
            }
            else
            {
                ChargeItemData configdata = null;
                if (!ChargeItemDict.TryGetValue(zhigouID, out configdata))
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("警告:充值直购配置错误 zhigouID={0} fromSys={1}", zhigouID, FromSystem), null, true);
                    result = false;
                }
                else if (configdata.SinglePurchase != PurchaseNum && configdata.DayPurchase != PurchaseNum && configdata.ThemePurchase != PurchaseNum)
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("警告:充值直购配置错误 Purchase={0} fromSys={1}", PurchaseNum, FromSystem), null, true);
                    result = false;
                }
                else if (configdata.GoodsStringOne != GoodsOne || configdata.GoodsStringTwo != GoodsTwo)
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("警告:充值直购配置错误 GoodsOne={0} GoodsTwo={1} fromSys={2}", GoodsOne, GoodsTwo, FromSystem), null, true);
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
 public void InitItemChargeConfigData()
 {
     try
     {
         GeneralCachingXmlMgr.RemoveCachingXml(Global.GameResPath("Config/ZhiGou.xml"));
         XElement xml = GeneralCachingXmlMgr.GetXElement(Global.GameResPath("Config/ZhiGou.xml"));
         if (xml != null)
         {
             Dictionary <int, ChargeItemData> ChargeItemDict = new Dictionary <int, ChargeItemData>();
             IEnumerable <XElement>           xmlItems       = xml.Elements();
             foreach (XElement xmlItem in xmlItems)
             {
                 if (null != xmlItem)
                 {
                     ChargeItemData chargeItem = new ChargeItemData();
                     chargeItem.ChargeItemID   = (int)Global.GetSafeAttributeLong(xmlItem, "ZhiGouID");
                     chargeItem.ChargeDangID   = (int)Global.GetSafeAttributeLong(xmlItem, "ChongZhiID");
                     chargeItem.SinglePurchase = (int)Global.GetSafeAttributeLong(xmlItem, "SinglePurchase");
                     chargeItem.DayPurchase    = (int)Global.GetSafeAttributeLong(xmlItem, "EverydayPurchase");
                     string ThemePurchase = Global.GetDefAttributeStr(xmlItem, "ThemePurchase", "");
                     chargeItem.ThemePurchase = Global.SafeConvertToInt32(ThemePurchase);
                     chargeItem.FromDate      = Global.GetSafeAttributeStr(xmlItem, "FromDate");
                     chargeItem.ToDate        = Global.GetSafeAttributeStr(xmlItem, "ToDate");
                     if (0 == chargeItem.FromDate.CompareTo("-1"))
                     {
                         chargeItem.FromDate = "2008-08-08 08:08:08";
                     }
                     if (0 == chargeItem.ToDate.CompareTo("-1"))
                     {
                         chargeItem.ToDate = "2028-08-08 08:08:08";
                     }
                     chargeItem.GoodsStringOne = Global.GetSafeAttributeStr(xmlItem, "GoodsOne");
                     if (!string.IsNullOrEmpty(chargeItem.GoodsStringOne))
                     {
                         string[] fields = chargeItem.GoodsStringOne.Split(new char[]
                         {
                             '|'
                         });
                         chargeItem.GoodsDataOne = HuodongCachingMgr.ParseGoodsDataList(fields, "ZhiGou.xml励配置文件1");
                     }
                     chargeItem.GoodsStringTwo = Global.GetSafeAttributeStr(xmlItem, "GoodsTwo");
                     if (!string.IsNullOrEmpty(chargeItem.GoodsStringTwo))
                     {
                         string[] fields = chargeItem.GoodsStringTwo.Split(new char[]
                         {
                             '|'
                         });
                         chargeItem.GoodsDataTwo = HuodongCachingMgr.ParseGoodsDataList(fields, "ZhiGou.xml励配置文件1");
                     }
                     ChargeItemDict[chargeItem.ChargeItemID] = chargeItem;
                 }
             }
             Data.ChargeItemDict = ChargeItemDict;
         }
         else
         {
             LogManager.WriteLog(LogTypes.Fatal, string.Format("丢失充值直购配置文件{0}", "Config/ZhiGou.xml"), null, true);
         }
     }
     catch (Exception e)
     {
         LogManager.WriteLog(LogTypes.Fatal, "读取Config/ZhiGou.xml错误:" + e.ToString(), e, true);
     }
 }
Exemplo n.º 3
0
 public void HandleClientChargeItem(GameClient client, byte HandleDel = 0)
 {
     if (client != null && !GameManager.IsKuaFuServer)
     {
         lock (client.ClientData.ChargeItemMutex)
         {
             List <TempItemChargeInfo> list = new List <TempItemChargeInfo>();
             string cmd = string.Format("{0}:{1}:{2}", client.strUserID, client.ClientData.RoleID, HandleDel);
             list = Global.sendToDB <List <TempItemChargeInfo>, string>(13320, cmd, client.ServerId);
             if (list != null && list.Count != 0)
             {
                 if (HandleDel == 1)
                 {
                     this.ComputeClientChargeItem(client, list);
                 }
                 Dictionary <int, ChargeItemData> ChargeItemDict = Data.ChargeItemDict;
                 for (int i = 0; i < list.Count; i++)
                 {
                     TempItemChargeInfo tempitem = list[i];
                     if (tempitem.isDel == 0)
                     {
                         int            ProcessChargeMoney = 0;
                         int            ReturnUserMoney    = 0;
                         ChargeItemData configdata         = null;
                         if (!ChargeItemDict.TryGetValue(tempitem.zhigouID, out configdata))
                         {
                             LogManager.WriteLog(LogTypes.Error, string.Format("充值直购zhigouID错误 uid={0},rid={1},money={2},itemid={3},chargeTm={4}", new object[]
                             {
                                 tempitem.userID,
                                 tempitem.chargeRoleID,
                                 tempitem.addUserMoney,
                                 tempitem.zhigouID,
                                 tempitem.chargeTime
                             }), null, true);
                             ProcessChargeMoney = 1;
                         }
                         else if (string.Compare(tempitem.chargeTime, configdata.FromDate) < 0 || string.Compare(tempitem.chargeTime, configdata.ToDate) > 0)
                         {
                             LogManager.WriteLog(LogTypes.Error, string.Format("充值直购Time错误 uid={0},rid={1},money={2},itemid={3},chargeTm={4}", new object[]
                             {
                                 tempitem.userID,
                                 tempitem.chargeRoleID,
                                 tempitem.addUserMoney,
                                 tempitem.zhigouID,
                                 tempitem.chargeTime
                             }), null, true);
                             ProcessChargeMoney = 1;
                         }
                         else
                         {
                             int Money = 0;
                             if (!Data.ChargeData.ChargeIDVsMoneyDict.TryGetValue(configdata.ChargeDangID, out Money))
                             {
                                 LogManager.WriteLog(LogTypes.Error, string.Format("充值直购Dang错误 uid={0},rid={1},money={2},itemid={3},chargeTm={4}", new object[]
                                 {
                                     tempitem.userID,
                                     tempitem.chargeRoleID,
                                     tempitem.addUserMoney,
                                     tempitem.zhigouID,
                                     tempitem.chargeTime
                                 }), null, true);
                                 ProcessChargeMoney = 1;
                             }
                             else
                             {
                                 int ZhiGouImplicit = GameManager.PlatConfigMgr.GetGameConfigItemInt("zhigou_implicit", 0);
                                 if (ZhiGouImplicit > 0)
                                 {
                                     if (tempitem.addUserMoney < Money)
                                     {
                                         LogManager.WriteLog(LogTypes.Error, string.Format("充值直购Money错误 uid={0},rid={1},money={2},itemid={3},chargeTm={4}", new object[]
                                         {
                                             tempitem.userID,
                                             tempitem.chargeRoleID,
                                             tempitem.addUserMoney,
                                             tempitem.zhigouID,
                                             tempitem.chargeTime
                                         }), null, true);
                                         ProcessChargeMoney = 1;
                                     }
                                     else
                                     {
                                         ReturnUserMoney = Math.Max(tempitem.addUserMoney - Money, 0);
                                     }
                                 }
                                 else if (tempitem.addUserMoney != Money)
                                 {
                                     LogManager.WriteLog(LogTypes.Error, string.Format("充值直购Money错误 uid={0},rid={1},money={2},itemid={3},chargeTm={4}", new object[]
                                     {
                                         tempitem.userID,
                                         tempitem.chargeRoleID,
                                         tempitem.addUserMoney,
                                         tempitem.zhigouID,
                                         tempitem.chargeTime
                                     }), null, true);
                                     ProcessChargeMoney = 1;
                                 }
                             }
                         }
                         int PurchaseNum    = this.GetChargeItemPurchaseNum(client, tempitem.zhigouID);
                         int DayPurchaseNum = this.GetChargeItemDayPurchaseNum(client, tempitem.zhigouID);
                         if (configdata != null && configdata.SinglePurchase > 0 && PurchaseNum >= configdata.SinglePurchase)
                         {
                             ProcessChargeMoney = 1;
                         }
                         if (configdata != null && configdata.DayPurchase > 0)
                         {
                             EverydayActivity everyAct = HuodongCachingMgr.GetEverydayActivity();
                             if (everyAct == null || !everyAct.CheckValidChargeItem(tempitem.zhigouID))
                             {
                                 ProcessChargeMoney = 1;
                             }
                             if (DayPurchaseNum >= configdata.DayPurchase)
                             {
                                 ProcessChargeMoney = 1;
                             }
                         }
                         if (configdata != null && configdata.ThemePurchase > 0)
                         {
                             ThemeZhiGouActivity zhigouAct = HuodongCachingMgr.GetThemeZhiGouActivity();
                             if (zhigouAct == null || !zhigouAct.CheckValidChargeItem(tempitem.zhigouID))
                             {
                                 ProcessChargeMoney = 1;
                             }
                             if (DayPurchaseNum >= configdata.ThemePurchase)
                             {
                                 ProcessChargeMoney = 1;
                             }
                         }
                         SpecPriorityActivity spAct = HuodongCachingMgr.GetSpecPriorityActivity();
                         if (spAct != null && !spAct.CheckValidChargeItem(tempitem.zhigouID))
                         {
                             ProcessChargeMoney = 1;
                         }
                         RegressActiveDayBuy radbAct = HuodongCachingMgr.GetRegressActiveDayBuy();
                         if (radbAct != null && !radbAct.CheckValidChargeItem(client, tempitem.zhigouID))
                         {
                             ProcessChargeMoney = 1;
                         }
                         cmd = string.Format("{0}:{1}:{2}", tempitem.ID, ProcessChargeMoney, ReturnUserMoney);
                         string[]             dbFields        = null;
                         TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 13321, cmd, out dbFields, client.ServerId);
                         if (dbRequestResult != TCPProcessCmdResults.RESULT_FAILED && dbFields.Length > 0)
                         {
                             if (ProcessChargeMoney == 0)
                             {
                                 this.AddChargeItemPurchaseNum(client, tempitem.zhigouID);
                                 this.AddChargeItemDayPurchaseNum(client, tempitem.zhigouID, tempitem.chargeTime);
                             }
                             if (configdata != null && ProcessChargeMoney == 0)
                             {
                                 ChargeItemBaseEventObject evObj_ChargeItem = new ChargeItemBaseEventObject(client, configdata);
                                 GlobalEventSource.getInstance().fireEvent(evObj_ChargeItem);
                             }
                             if (ProcessChargeMoney != 1)
                             {
                                 if (null != configdata)
                                 {
                                     List <GoodsData> awardList = new List <GoodsData>();
                                     if (configdata.GoodsDataOne != null)
                                     {
                                         awardList.AddRange(configdata.GoodsDataOne);
                                     }
                                     List <GoodsData> proGoods = GoodsHelper.GetAwardPro(client, configdata.GoodsDataTwo);
                                     if (proGoods != null)
                                     {
                                         awardList.AddRange(proGoods);
                                     }
                                     this.GiveClientChargeItem(client, awardList);
                                     this.HandleClientChargeMoney(client.strUserID, client.ClientData.RoleID, tempitem.addUserMoney - ReturnUserMoney, false, 0);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        public IHttpActionResult Post(ChargeItemData request)
        {
            var response = service.SaveChargeGroupRec(request);

            return(Ok(response));
        }
 public ChargeItemBaseEventObject(GameClient player, ChargeItemData Config) : base(36)
 {
     this.Player           = player;
     this.ChargeItemConfig = Config;
 }
Exemplo n.º 6
0
        public BaseResponse <ChargeGroupRec> SaveChargeGroupRec(ChargeItemData request)
        {
            var chargeGroupRecModel = new ChargeGroupRec()
            {
                ChargeGroupId = request.ChargeGroupRec.ChargeGroupId,
                FeeNo         = request.ChargeGroupRec.FeeNo,
                CreateTime    = DateTime.Now,
                CreateBy      = SecurityHelper.CurrentPrincipal.EmpNo,
                UpdateTime    = DateTime.Now,
                UpdateBy      = SecurityHelper.CurrentPrincipal.EmpNo,
                IsDelete      = false,
            };
            var response = base.Save <LTC_CHARGEGROUP_CHARGERECORD, ChargeGroupRec>(chargeGroupRecModel, (q) => q.CGCRID == chargeGroupRecModel.CgcrId);

            unitOfWork.BeginTransaction();
            request.ChargeItem.ForEach(p =>
            {
                if (p.CHARGEITEMTYPE == 1)
                {
                    var drugRecordsModel = new DrugRecords()
                    {
                        CGCRID            = response.Data.CgcrId,
                        DRUGID            = p.CHARGEITEMID,
                        NSID              = SecurityHelper.CurrentPrincipal.OrgId,
                        FEENO             = p.FEENO,
                        CNNAME            = p.NAME,
                        CONVERSIONRATIO   = p.CONVERSIONRATIO ?? 1,
                        FORM              = p.FORM ?? "",
                        PRESCRIBEUNITS    = p.PRESCRIBEUNITS,
                        DRUGQTY           = p.FEEITEMCOUNT,
                        UNITS             = p.UNITS,
                        QTY               = p.QTY,
                        UNITPRICE         = p.UNITPRICE,
                        COST              = p.COST ?? 0,
                        DOSAGE            = p.DOSAGE,
                        TAKEWAY           = p.TAKEWAY ?? "",
                        FERQ              = p.FERQ ?? "",
                        TAKETIME          = p.TAKETIME,
                        OPERATOR          = SecurityHelper.CurrentPrincipal.EmpNo,
                        ISCHARGEGROUPITEM = true,
                        ISNCIITEM         = p.ISNCIITEM,
                        STATUS            = 0,
                        CREATETIME        = DateTime.Now,
                        CREATEBY          = SecurityHelper.CurrentPrincipal.EmpNo,
                        UPDATETIME        = DateTime.Now,
                        UPDATEBY          = SecurityHelper.CurrentPrincipal.EmpNo,
                        ISDELETE          = false,
                    };
                    base.Save <LTC_DRUGRECORD, DrugRecords>(drugRecordsModel, (q) => q.DRUGRECORDID == drugRecordsModel.DRUGRECORDID);
                }
                else if (p.CHARGEITEMTYPE == 2)
                {
                    var materialRecordsModel = new MaterialRecords()
                    {
                        CGCRID            = response.Data.CgcrId,
                        MATERIALID        = p.CHARGEITEMID,
                        NSID              = SecurityHelper.CurrentPrincipal.OrgId,
                        FEENO             = p.FEENO,
                        MATERIALNAME      = p.NAME,
                        UNITS             = p.UNITS,
                        QTY               = p.QTY,
                        UNITPRICE         = p.UNITPRICE,
                        COST              = p.COST ?? 0,
                        TAKEWAY           = p.TAKEWAY ?? "",
                        TAKETIME          = p.TAKETIME,
                        OPERATOR          = SecurityHelper.CurrentPrincipal.EmpNo,
                        ISCHARGEGROUPITEM = true,
                        ISNCIITEM         = p.ISNCIITEM,
                        STATUS            = 0,
                        CREATETIME        = DateTime.Now,
                        CREATEBY          = SecurityHelper.CurrentPrincipal.EmpNo,
                        UPDATETIME        = DateTime.Now,
                        UPDATEBY          = SecurityHelper.CurrentPrincipal.EmpNo,
                        ISDELETE          = false,
                    };
                    base.Save <LTC_MATERIALRECORD, MaterialRecords>(materialRecordsModel, (q) => q.MATERIALRECORDID == materialRecordsModel.MATERIALRECORDID);
                }
                else if (p.CHARGEITEMTYPE == 3)
                {
                    var serviceRecordsModel = new ServiceRecords()
                    {
                        CGCRID            = response.Data.CgcrId,
                        SERVICEID         = p.CHARGEITEMID,
                        NSID              = SecurityHelper.CurrentPrincipal.OrgId,
                        FEENO             = p.FEENO,
                        SERVICENAME       = p.NAME,
                        UNITS             = p.UNITS,
                        QTY               = p.QTY,
                        UNITPRICE         = p.UNITPRICE,
                        COST              = p.COST ?? 0,
                        TAKEWAY           = p.TAKEWAY ?? "",
                        TAKETIME          = p.TAKETIME,
                        OPERATOR          = SecurityHelper.CurrentPrincipal.EmpNo,
                        ISCHARGEGROUPITEM = true,
                        ISNCIITEM         = p.ISNCIITEM,
                        STATUS            = 0,
                        CREATETIME        = DateTime.Now,
                        CREATEBY          = SecurityHelper.CurrentPrincipal.EmpNo,
                        UPDATETIME        = DateTime.Now,
                        UPDATEBY          = SecurityHelper.CurrentPrincipal.EmpNo,
                        ISDELETE          = false,
                    };
                    base.Save <LTC_SERVICERECORD, ServiceRecords>(serviceRecordsModel, (q) => q.SERVICERECORDID == serviceRecordsModel.SERVICERECORDID);
                }
            });
            unitOfWork.Commit();
            response.IsSuccess = true;
            return(response);
        }