public EAccount DeliverGoods(int accountid, int goodsid) { EAccount account = DBBase.Get <EAccount>(accountid); EStore goods = DBBase.Get <EStore>(goodsid); if (goods.Type != "Bag" && goods.Type != "Gold") { return(null); } int getGold = Convert.ToInt32(goods.Name); if (account.Diamond < goods.Price) { return(null); } account.Diamond -= goods.Price; account.Gold += getGold; DBBase.Change(account); EBuyRecord record = new EBuyRecord() { BuyerID = accountid, BuyTime = DateTime.Now, GoodsID = goodsid, Num = 1, NowDiamond = account.Diamond, NowGold = account.Gold, CostDiamond = -goods.Price, CostGold = getGold }; DBBase.Create(record); return(account); }
public string GetUnifiedOrderResult(int accountid, int goodsid) { //统一下单 EAccount account = DBBase.Get <EAccount>(accountid); EStore goods = DBBase.Get <EStore>(goodsid); if (goods.Type != "Damion" && goods.Type != "Vip") { return("-1"); //不用用人民币购买 } string openid = account.OpenID; // "oWsnW06q3aPEkggMC9ZDB2ATohsA"; int totalfee = goods.Price * 100; // 100; WxPayData data = new WxPayData(); data.SetValue("body", "卡五梅-游戏充值"); data.SetValue("attach", "kawumei"); data.SetValue("out_trade_no", WXHelper.GenerateOutTradeNo()); data.SetValue("total_fee", totalfee);//订单总金额,单位为分 data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss")); data.SetValue("goods_tag", goods.Name); data.SetValue("trade_type", "JSAPI"); data.SetValue("openid", openid); WxPayData result = WXHelper.UnifiedOrder(data); Console.Write(result.ToXml()); return(result.ToXml()); }
public void SetGoods(EStore eStore) { this.eStore = eStore; gameObject.transform.GetChild(0).GetComponent <Image>().sprite = App.Instance.ImageManger.Get(eStore.Icon); if (gameObject.transform.childCount > 1) { gameObject.transform.GetChild(1).GetComponent <Text>().text = eStore.Description; } }
public string PayNotice() { log4net.ILog log = log4net.LogManager.GetLogger(this.GetType());//获取一个日志记录器 try { ResponseBean responseBean = new ResponseBean(this.Request); var sign = GetSign(responseBean); if (responseBean.p4_status == "1" && sign.Equals(responseBean.p10_sign)) { string[] data = responseBean.p11_remark.Split('|'); log.Info(DateTime.Now.ToString() + ": pay info:uid>" + data[0] + " goodsid>" + data[1]); int uid = Convert.ToInt32(data[0]); int goodsid = Convert.ToInt32(data[1]); EAccount account = DBBase.Get <EAccount>(uid); EStore goods = DBBase.Get <EStore>(goodsid); int oldDiamon = account.Diamond; if (goods.Type == "Damion") { account.Diamond += Convert.ToInt32(goods.Name); } else if (goods.Type == "Vip") { account.Vip = Convert.ToInt32(goods.Name); account.VipBeginTime = DateTime.Now; } DBBase.Change(account); EBuyRecord record = new EBuyRecord() { BuyerID = account.ID, BuyTime = DateTime.Now, GoodsID = goodsid, Num = 1, NowDiamond = account.Diamond, NowGold = account.Gold, CostDiamond = account.Diamond - oldDiamon, CostGold = 0 }; DBBase.Create(record); log.Info(DateTime.Now.ToString() + ": pay success:uid>" + uid + " goodsid>" + goodsid);//写入一条新log //服务器操作 return("success"); } else { log.Info(DateTime.Now.ToString() + ": pay error: status>" + responseBean.p4_status);//写入一条新log return("error"); } } catch (Exception ex) { log.Error(DateTime.Now.ToString() + ": pay error: " + ex.Message + " " + ex.StackTrace);//写入一条新log return("error"); } }
public void StartStore(string savePath) { this._objMask.Clear(); this._isQueue.Clear(); this._esQueue.Clear(); this._ms.Position = 0L; this._bw.Seek(0, SeekOrigin.Begin); Dictionary <ushort, ClassDelegate[]> .Enumerator enumerator = this._classDlgsDict.GetEnumerator(); while (enumerator.MoveNext()) { this.WriteByte(0); KeyValuePair <ushort, ClassDelegate[]> current = enumerator.Current; this.WriteUInt16(current.Key); KeyValuePair <ushort, ClassDelegate[]> pair2 = enumerator.Current; pair2.Value[0](this); } while ((this._isQueue.Count > 0) || (this._esQueue.Count > 0)) { while (this._isQueue.Count > 0) { IStore store = this._isQueue.Dequeue(); this.WriteByte(1); this.WriteUInt16(store.__TypKey); this.WriteUInt32(store.__RefKey); store.__Store(this); } while (this._esQueue.Count > 0) { EStore store2 = this._esQueue.Dequeue(); this.WriteByte(1); this.WriteUInt16(store2.typKey); this.WriteUInt32(store2.refKey); store2.storeDelegate(store2.val, this); } } try { this._bw.Flush(); FileStream stream = new FileStream(savePath, FileMode.Create); stream.Write(this._ms.GetBuffer(), 0, (int)this._ms.Position); stream.WriteByte(0xff); stream.Flush(); stream.Close(); } catch (Exception) { } finally { this._refObjDict.Clear(); } }
public void PrintPathsHaveHash2_WithTree4_A() { AddEntriesX4(); var ee = new EntryEnumerator(EStore); Assert.That(ee.MoveNext(), Is.True, "t1"); Assert.That(ee.Current.Index, Is.EqualTo(File1Index), "Did not get Dir2Index entry."); Assert.That(ee.MoveNext(), Is.True, "t2"); Assert.That(ee.Current.Index, Is.EqualTo(Dir2Index), "Did not get File1Index entry."); Assert.That(ee.MoveNext(), Is.True, "t3"); Assert.That(ee.Current.Index, Is.EqualTo(Dir5Index), "Did not get File4Dir5IndexIndex entry."); Assert.That(ee.MoveNext(), Is.False, "t6"); EStore.PrintPathsHaveHash2(); }
public void WriteEStore(object val, ushort typKey, StoreDelegate sd, RestoreDelegate rd) { if (val != null) { uint refKey = this.GetRefKey(val); this.WriteUInt32(refKey); if (refKey < uint.MaxValue) { if (this._objMask.Add(refKey)) { EStore item = new EStore(val, typKey, refKey, sd, rd); this._esQueue.Enqueue(item); } } else { sd(val, this); } } else { this.WriteUInt32(0); } }