public PurchaseManager(string filename) { PurchaseRecord = PurchaseRecord.Load(filename); }
public int CreateNewTrackForEp(Guid epId, string TrackTitle, string ArtistName, bool ArtistAlreadyInSpotify, string ArtistSpotifyUrl, DateTime ReleaseDate, string Genre, string CopyrightClaimerName, string AuthorName, string ComposerName, string ArrangerName, string ProducerName, bool AlreadyHaveAnISRC, string ISRC_Number, int PriceTier, bool ExplicitContent, bool IsTrackInstrumental, string LyricsLanguage, string TrackZipFileLink, string ArtWork_Link) { EPQueriesCommands EpCQ = new EPQueriesCommands(); PurchaseRecordQueriesCommands PurchaseCQ = new PurchaseRecordQueriesCommands(); logic = new GeneralLogics(); var epObject = EpCQ.GetEpById(epId); if (epObject != null) { if (PurchaseCQ.GetPurchaseRecordById(epObject.PurchaseTrack_RefNo).Usage_Exp_Date < logic.CurrentIndianTime()) { //Can't add more track in the album as purchase expired return(7); } if (epObject.Total_Track <= epObject.Submitted_Track) { //can't add more track in the album as the album is full return(8); } byte ArtistSpotifyAppearance = 1; byte PresenceOfISRCnumber = 1; byte PresenceOfExplicitContent = 1; byte InstrumentalTrackPresence = 1; if (ArtistAlreadyInSpotify == false) { ArtistSpotifyAppearance = 0; } if (AlreadyHaveAnISRC == false) { PresenceOfISRCnumber = 0; } if (IsTrackInstrumental == false) { InstrumentalTrackPresence = 0; } if (ExplicitContent == false) { PresenceOfExplicitContent = 0; } SingleTrackDetail std = new SingleTrackDetail(); std.Id = logic.CreateUniqueId(); std.TrackTitle = TrackTitle; std.ArtistName = ArtistName; std.ArtistAlreadyInSpotify = ArtistSpotifyAppearance; std.ArtistSpotifyUrl = ArtistSpotifyUrl; std.ReleaseDate = ReleaseDate; std.Genre = Genre; std.CopyrightClaimerName = CopyrightClaimerName; std.AuthorName = AuthorName; std.ComposerName = ComposerName; std.ArrangerName = ArrangerName; std.ProducerName = ProducerName; std.AlreadyHaveAnISRC = PresenceOfISRCnumber; std.ISRC_Number = ISRC_Number; std.PriceTier = PriceTier; std.ExplicitContent = PresenceOfExplicitContent; std.IsTrackInstrumental = InstrumentalTrackPresence; std.LyricsLanguage = LyricsLanguage; std.TrackZipFileLink = TrackZipFileLink; std.ArtworkFileLink = ArtWork_Link.Trim(); TrackQueriesCommands TrackCQ = new TrackQueriesCommands(); //add single track var singleTrackSaveResult = TrackCQ.AddTrack(std); if (singleTrackSaveResult == 1) { //Link track with the album. Work on albumtrackMaster table EpTrackMaster etm = new EpTrackMaster(); etm.Id = logic.CreateUniqueId(); etm.Ep_Id = epId; etm.Track_Id = std.Id; etm.Submitted_At = logic.CurrentIndianTime(); //Status = pending etm.StoreSubmissionStatus = 2; var etmSaveResult = TrackCQ.AddtoEpTrackMaster(etm); if (etmSaveResult == 1) { //increment the number of the submitted track for the album epObject.Submitted_Track = epObject.Submitted_Track + 1; var epEditResult = EpCQ.EditEpDetails(epObject); if (epEditResult == 1) { //if it's the first track of the album then set purchase record usage expire time epObject = EpCQ.GetEpById(epId); if (epObject != null) { if (epObject.Submitted_Track == 1) { PurchaseRecord pr = PurchaseCQ.GetPurchaseRecordById(epObject.PurchaseTrack_RefNo); if (pr != null) { pr.Usage_Exp_Date = logic.CurrentIndianTime().AddHours(24); var purchaseEditResult = PurchaseCQ.UpdatePurchaseRecord(pr); if (purchaseEditResult == 1) { //purchase expire date set return(1); } else { //Error while setting the expire date return(11); } } else { //error while fetching the purchase record of the album return(10); } } return(1); } else { //error while fetching the album return(9); } } else { //Error occured while updating album record return(6); } } else { //Error occured while adding albumTrackMaster record return(5); } } else { //Error occured while saving single track to the database return(4); } } else { //No album found with the provided Album Id return(0); } }
public void ShowCardItem(PurchaseRecord purchase) { GameObject newItem = CardListItemPool.Instance.GetListItem(purchaseListItem); newItem.SetActive(false); GameObject buttons = newItem.transform.FindChild("Buttons").gameObject; GameObject checkBtn = buttons.transform.GetChild(0).gameObject; checkBtn.SetActive(true); newItem.transform.parent = gridPurchase.transform; newItem.transform.localPosition = new Vector3(0, 0, -1); newItem.transform.localScale = new Vector3(1, 1, 1); UILabel goodID = newItem.transform.FindChild("Labels/Label-ID-Value").GetComponent <UILabel>(); goodID.text = purchase.goodsId; UILabel price = newItem.transform.FindChild("Labels/Label-Price-Value").GetComponent <UILabel>(); #if UNITY_ANDROID //2013-11-27 11:30 lihao_yd 修改官网包充值记录显示价格不对的bug if (DeviceHelper.IAPStyle() == (int)IAPStyle.PAY_CHANGYOU) { float cyouPayMoney = purchase.goodsPrice / 100; price.text = cyouPayMoney + "$"; Debug.Log("----lee-PurchaseRecord-showUI-PAY_CHANGYOU-price.text==" + cyouPayMoney); } else if (DeviceHelper.IAPStyle() == (int)IAPStyle.PAY_THIRD) { price.text = purchase.goodsPrice.ToString() + "$"; Debug.Log("----lee-PurchaseRecord-showUI-PAY_THIRD-price.text==" + purchase.goodsPrice.ToString()); } else if (DeviceHelper.IAPStyle() == (int)IAPStyle.PAY_GooglePay) { price.text = purchase.goodsPrice.ToString() + "$"; Debug.Log("----lee-PurchaseRecord-showUI-GooglePay-price.text==" + price.text); } #else price.text = purchase.goodsPrice.ToString() + "$"; #endif UILabel channel = newItem.transform.FindChild("Labels/Label-Channel-Value").GetComponent <UILabel>(); channel.text = purchase.channel; UILabel state = newItem.transform.FindChild("Labels/Label-State-Value").GetComponent <UILabel>(); if (purchase.goodState == 0) { state.text = "[d07771]订单未完成"; } else if (purchase.goodState == 1) { state.text = "[7bc26a]订单已完成"; } else if (purchase.goodState == 2) { state.text = "[7a7a78]订单已失效"; } UILabel time = newItem.transform.FindChild("Labels/Label-Time-Value").GetComponent <UILabel>(); time.text = purchase.date; checkBtn.name = purchase.goodsId; if (purchase.goodState == 0) { //checkBtn.transform.localPosition = btnEnablePos; checkBtn.SetActive(true); //checkBtn.GetComponent<UIImageButton>().isEnabled = true; UIEventListener.Get(checkBtn).onClick += SelectPurchaseRecord; } else if (purchase.goodState == 1) { //checkBtn.GetComponent<UIImageButton>().isEnabled = false; checkBtn.SetActive(false); //checkBtn.transform.localPosition = btnDisablePos; } else if (purchase.goodState == 2) { //checkBtn.GetComponent<UIImageButton>().isEnabled = false; checkBtn.SetActive(false); //checkBtn.transform.localPosition = btnDisablePos; } newItem.SetActive(true); items.Add(newItem); }
internal void SaveQuantityChange() { PurchaseRecord.AddQuantity(QuantityChange, Stock.CurrentStockPrice); Player.AddCredit(-(QuantityChange * Stock.CurrentStockPrice)); }
//排序算法 static public int CompareTo(PurchaseRecord goodA, PurchaseRecord goodB) { //按时间排序 return(goodA.date.CompareTo(goodB.date)); }
public ActionResult SeriesDetail(SeriesDetailViewModel model) { try { //驗證授權:一般會員 var pass = roleAuth.UserAuth(); if (pass == true) { ViewBag.UserName = roleAuth.UserName(); ViewBag.RoleName = "User"; } else { TempData["Msg"] = "無權限瀏覽該網頁,請登入會員瀏覽,謝謝!"; return(RedirectToAction("Logout", "Home")); } var UserEmail = User.Identity.Name; MemberOperation member = new MemberOperation(); //取得會員Id var MemberId = member.GetNo(UserEmail); //取得會員資料 var memberData = member.Get(UserEmail); //購買方案數量 var BuyCnt = Convert.ToInt16(model.Count); //新增方案購買紀錄 PurchaseRecord purchaseRecord = new PurchaseRecord(); purchaseRecord.Date = DateTime.Now; //購買日期 purchaseRecord.Count = BuyCnt; //購買數量 purchaseRecord.PayStatus = true; //付款狀態 purchaseRecord.CourseSeries_No = model.SeriesId; //方案代號 purchaseRecord.Member_No = MemberId; //會員id PurchaseRecordOperation pr = new PurchaseRecordOperation(); pr.Add(purchaseRecord); //找出課程方案內容 CourseSeriesDetailOperation csd = new CourseSeriesDetailOperation(); var seriesDetails = csd.Get(model.SeriesId); //找出會員課程table筆數 MemberCourseOperation mco = new MemberCourseOperation(); int dataCnt = mco.GetCount(); //將課程方案內容新增至會員課程 List <MemberCourse> LstCourses = new List <MemberCourse>(); foreach (var item in seriesDetails) { MemberCourse memberCourse = new MemberCourse(); CourseTypeOperation cto = new CourseTypeOperation(); memberCourse.MemberCourseNo = dataCnt + 1; memberCourse.CourseType_no = item.CourseType_No; //課程類型代號 memberCourse.Member_No = MemberId; //會員id memberCourse.Num = item.Num * BuyCnt; //課程堂數=原方案內容課程數*購買數量 LstCourses.Add(memberCourse); } mco.Add(LstCourses); return(RedirectToAction("MyPurchaseSeries", new { MemberId })); } catch (Exception ex) { TempData["Msg"] = ex.ToString(); return(RedirectToAction("Logout", "Home")); } }
/// <summary> /// 购买产品 /// </summary> /// <returns></returns> public ActionResult Purchase(int? customerAccountId, string purchaseItems) { if (this.Request.IsPost() && customerAccountId != null && !string.IsNullOrEmpty(purchaseItems) && purchaseItems.StartsWith("[") && purchaseItems.EndsWith("]")) { PurchaseRecord purchaseRecord = new PurchaseRecord(); purchaseRecord.CustomerAccount = this.CustomerService.FindCustomerAccountById(customerAccountId.Value); purchaseRecord.Items = new List<PurchaseItem>(); JArray array = JArray.Parse(purchaseItems); if (array != null && array.Count > 0) { foreach (var item in array) { PurchaseItem purchaseItem = new PurchaseItem(); purchaseItem.PurchaseRecord = purchaseRecord; purchaseItem.Product = this.ProductService.FindById(item["Product"].Value<int>("Id")); purchaseItem.DonatedCount = item.Value<int>("DonatedCount"); purchaseItem.ChargedCount = item.Value<int>("ChargedCount"); purchaseRecord.Items.Add(purchaseItem); } } this.ProductService.Purchase(purchaseRecord); return View("Purchase/Details", purchaseRecord); } return View("Purchase/Purchase"); }
/// <summary> /// 查询相应的表,执行相应的硬件控制方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timerDo_Tick(object sender, ElapsedEventArgs e) { try { var time = DateTime.Now; Console.WriteLine(time); Console.WriteLine(time.Second); if (time.Second % 10 != 0) { Console.WriteLine("跳出"); LogHelper.WriteLog(typeof(FrmMain), "非时间段"); return; } LogHelper.WriteLog(typeof(FrmMain), "计时器事件触发"); LogHelper.WriteLog(typeof(FrmMain), time.ToString("yyyyy-MM-dd HH:mm:ss:fff")); t.Enabled = false; schools = context_m.School.Where(x => x.IsDelete == 0).Select(x => new Schinfo { ID = x.ID, SchoolUUID = x.SchoolUUID, SchoolName = x.SchoolName }).ToList(); //schools = new List<Schinfo>() { new Schinfo() { ID = 26, SchoolUUID = Guid.Parse("46E110F7-DD05-4BB8-93C4-30F9CB803A94"),SchoolName= "渔浦小学" } }; for (int n = 0; n < schools.Count; n++) { var schname = schools[n].SchoolName; if (!dic.ContainsKey(schname)) { dic.Add(schname, 0); } LogHelper.WriteLog(typeof(FrmMain), "循环学校名称:" + schname); var schuuid = schools[n].SchoolUUID; var query_buyers = from wbb in context_dj.world_barn_buyers join wbu in context_dj.world_barn_users on wbb.world_barn_user_id equals wbu.id where wbu.school_name.Contains(schname) && (!wbb.buyer_order_shortname.Contains("教师")) select wbb.id; var buyersdata = query_buyers.ToList(); List <long> buyers = buyersdata.ConvertAll(x => decimal.ToInt64(x)); LogHelper.WriteLog(typeof(string), JsonConvert.SerializeObject(buyers)); if (buyers.Count > 0) { LogHelper.WriteLog(typeof(FrmMain), "存在学校数据:" + schname); LogHelper.WriteLog(typeof(FrmMain), "学校uuid:" + schuuid); #region 食材同步 LogHelper.WriteLog(typeof(FrmMain), "食材同步开始"); //var count = context_m.Ingredient.Where(x => x.SchoolUUID == school.SchoolUUID && x.IsDelete == 0).Count(); //Console.WriteLine(count); //LogHelper.WriteLog(typeof(FrmMain), "原食材查询(条)" + count); var query = from wbg in context_dj.world_barn_goods join wbgc in context_dj.world_barn_goods_categories on wbg.small_class_id equals wbgc.id select new { wbg.id, wbg.goods_name, wbg.goods_code, type = wbgc.name, wbg.goods_desc, wbg.unit_code, wbg.rs_memo, }; var goods = query.ToList(); LogHelper.WriteLog(typeof(FrmMain), "食材查询(条)" + goods.Count); if (goods.Count != ingcount) { LogHelper.WriteLog(typeof(FrmMain), "循环开始1"); string ty = ""; for (int i = 0; i < goods.Count; i++) { var name = goods[i].goods_name; if (context_m.Ingredient.Any(x => x.SchoolUUID == schuuid && x.FoodName == name && x.IsDelete == 0)) { var entity = context_m.Ingredient.FirstOrDefault(x => x.SchoolUUID == schuuid && x.FoodName == name && x.IsDelete == 0); entity.TypeUUID = types.Find(x => x.Name == goods[i].type).TypeUUID; if (string.IsNullOrEmpty(entity.Accessory) && (!string.IsNullOrEmpty(goods[i].rs_memo))) { //int index = goods[i].rs_memo.LastIndexOf('.'); //string suffix = goods[i].rs_memo.Substring(index); //string infix = DateTime.Now.ToString("yyyyMMdd_HHmmssfff") + "_" + Guid.NewGuid().ToString(); //string filename = @"C:\inetpub\wwwroot\wwwroot\UploadFiles\LiveShotPicture\" + infix + suffix; //var check = WriteBytesToFile(filename, GetBytesFromUrl(goods[i].rs_memo)); //if (check) //{ // entity.Accessory = infix + suffix; //} context_m.SaveChanges(); } ty = "修改"; } else { Ingredient ingredient = new Ingredient() { IngredientUUID = Guid.NewGuid(), FoodName = goods[i].goods_name, AddTime = DateTime.Now.ToString("yyyy-MM-dd"), AddPeople = "狗", SchoolUUID = schuuid, IsDelete = 0, TypeUUID = types.Find(x => x.Name == goods[i].type).TypeUUID, HeatEnergy = 0, Protein = 0, Fat = 0, Saccharides = 0, VA = 0, }; if (!string.IsNullOrEmpty(goods[i].rs_memo)) { int index = goods[i].rs_memo.LastIndexOf('.'); string suffix = goods[i].rs_memo.Substring(index); string infix = DateTime.Now.ToString("yyyyMMdd_HHmmssfff") + "_" + Guid.NewGuid().ToString(); string filename = @"C:\inetpub\wwwroot\wwwroot\UploadFiles\LiveShotPicture\" + infix + suffix; var check = WriteBytesToFile(filename, GetBytesFromUrl(goods[i].rs_memo)); if (check) { ingredient.Accessory = infix + suffix; } } context_m.Ingredient.Add(ingredient); context_m.SaveChanges(); ty = "添加"; } Console.WriteLine("循环1第" + i + "次" + ty); if (i % 50 == 0) { LogHelper.WriteLog(typeof(FrmMain), "循环1第" + i + "次"); } } //context_m.SaveChanges(); LogHelper.WriteLog(typeof(FrmMain), "循环结束1"); } else { LogHelper.WriteLog(typeof(FrmMain), "总数不变,未进循环1"); } //ingcount = goods.Count; //手动填写的食材 LogHelper.WriteLog(typeof(FrmMain), "手动食材名称同步"); var query3 = context_dj.world_barn_order_items.GroupBy(x => x.goods_name).ToList(); LogHelper.WriteLog(typeof(FrmMain), "手动食材名称查询(条)" + query3.Count); LogHelper.WriteLog(typeof(FrmMain), "循环开始2"); for (int i = 0; i < query3.Count; i++) { var key = query3[i].Key; Console.WriteLine(query3[i].Key); if (!context_m.Ingredient.Any(x => x.SchoolUUID == schuuid && x.FoodName == key && x.IsDelete == 0)) { Ingredient ingredient = new Ingredient() { IngredientUUID = Guid.NewGuid(), FoodName = key, AddTime = DateTime.Now.ToString("yyyy-MM-dd"), AddPeople = "狗", SchoolUUID = schuuid, IsDelete = 0, }; context_m.Ingredient.Add(ingredient); context_m.SaveChanges(); } Console.WriteLine("循环2第" + i + "次"); if (i % 50 == 0) { LogHelper.WriteLog(typeof(FrmMain), "循环2第" + i + "次"); } } //context_m.SaveChanges(); LogHelper.WriteLog(typeof(FrmMain), "循环结束2"); //} #endregion //同步采购记录 LogHelper.WriteLog(typeof(FrmMain), "采购记录同步开始"); var query2 = from wboi in context_dj.world_barn_order_items join wbo in context_dj.world_barn_orders on wboi.order_id equals wbo.order_id where wbo.status == 8 && buyers.Contains(wbo.buyer_id) select new { wbo.customer_delivery_date, wbo.order_id, wbo.total_amount, wboi.id, wboi.goods_name, wboi.demanded_quantity, wboi.real_price, wboi.unit_price, wboi.subtotal, wboi.unit, wboi.note, wboi.supplier_name, wbo.buyer_name, }; //二次遍历只遍历之前3个月的数据(可自行修改) if (dic[schname] > 0) { var date = DateTime.Now.AddMonths(-3); query2 = query2.Where(x => x.customer_delivery_date > date); } var records = query2.ToList(); LogHelper.WriteLog(typeof(FrmMain), "采购记录查询(条)" + records.Count); LogHelper.WriteLog(typeof(FrmMain), "循环开始3"); for (int i = 0; i < records.Count; i++) { var foodname = records[i].goods_name; //Console.WriteLine(foodname); var date = records[i].customer_delivery_date.Value.ToString("yyyy-MM-dd HH:mm:ss"); var ing = context_m.Ingredient.Select(x => new { x.FoodName, x.IngredientUUID, x.ID, x.IsDelete, x.SchoolUUID }).FirstOrDefault(x => x.FoodName == foodname && x.IsDelete == 0 && x.SchoolUUID == schuuid); //if ((foodname == "茭白肉(斤)"||foodname== "冷鲜全精后腿肉片(斤)")&& date=="2020-10-29 08:00:00") //{ // Console.WriteLine(JsonConvert.SerializeObject(ing)); // Console.WriteLine(!context_m.PurchaseRecord.Any(x => x.IngredientUUID == ing.IngredientUUID && x.PurchaseDate == date && x.IsDelete == 0)); //} if (!context_m.PurchaseRecord.Any(x => x.IngredientUUID == ing.IngredientUUID && x.PurchaseDate == date && x.IsDelete == 0 && x.SchoolUUID == schuuid)) { PurchaseRecord purchase = new PurchaseRecord() { PurchaseUUID = Guid.NewGuid(), IngredientUUID = ing.IngredientUUID, Supplier = records[i].supplier_name, PurchaseDate = records[i].customer_delivery_date.Value.ToString("yyyy-MM-dd HH:mm:ss"), PurchaseNum = records[i].demanded_quantity.ToString(), Price = (double)records[i].real_price, State = "1", SystemUserUUID = records[i].buyer_name, IsDelete = 0, AddPeople = "狗", AddTime = DateTime.Now.ToString("yyyy-MM-dd"), SchoolUUID = schuuid, Unit = records[i].unit, }; context_m.PurchaseRecord.Add(purchase); context_m.SaveChanges(); //if ((foodname == "茭白肉(斤)" || foodname == "冷鲜全精后腿肉片(斤)" )&& date == "2020-10-29 08:00:00.0") //{ //Console.WriteLine(JsonConvert.SerializeObject(purchase)); //} } Console.WriteLine("循环3第" + i + "次"); if (i % 50 == 0) { LogHelper.WriteLog(typeof(FrmMain), "循环3第" + i + "次"); } } LogHelper.WriteLog(typeof(FrmMain), "循环结束3"); var endtime = DateTime.Now; var td = endtime - time; LogHelper.WriteLog(typeof(FrmMain), td.ToString("g")); //try //{ // t.Enabled = true; // LogHelper.WriteLog(typeof(FrmMain), "看门狗程序完毕!"); //} //catch (Exception ex) //{ // t.Enabled = true; // LogHelper.WriteLog(typeof(FrmMain), "遇到错误:" + ex); //} //if (dic.ContainsKey(schname)) //{ dic[schname]++; //} //else //{ // dic.Add(schname, 1); //} //num++; } } } catch (Exception ex) { LogHelper.WriteLog(typeof(FrmMain), "错误:" + ex.Message); //t.Enabled = true; } t.Enabled = true; }
private async Task GetPurchaseRecords() { PurchaseRecords = await PurchaseRecord.GetPurchaseRecords(); }