public void ReflashUsablePoint(InsurePoint insurePoint) { /*兌點*/ //1.找同一Appid資料 List <InsurePoint> pointList = _pointRepo.SearchPoint(insurePoint.ApplicantId, null); int pointBeExchanged = insurePoint.Point;//負的 //2.歷史點數UP是正 foreach (var apoint in pointList) { //判斷可用點數是否為負 if (apoint.UsablePoint > 0) { //3.1 該筆歷史點數UP不夠換;會繼續找下一筆 if (pointBeExchanged + apoint.UsablePoint < 0) { pointBeExchanged += apoint.UsablePoint; //-7=-12+5 -2=-7+5 apoint.UsablePoint = 0; //該筆UsablePoint清零 apoint.UpdatedDate = insurePoint.CreateDate; var repo = _pointRepo.UpdatePoint(apoint); } //3.2 該筆歷史點數UP剛好換完或有餘;結束foreach else { apoint.UsablePoint += pointBeExchanged; //3=5+-2 pointBeExchanged = 0; apoint.UpdatedDate = insurePoint.CreateDate; var repo = _pointRepo.UpdatePoint(apoint); break; } } } }
public ActionResult Search(string AppId, int?Search_AcType) { List <InsurePoint> resultList = _pointRepo.SearchPoint(AppId, Search_AcType); if (resultList.Count == 0) { return(Json(new { IsSuccess = false, Code = "0001", Message = "查無資料" })); } else { //所有點數:依點數LOG Table統計客戶點數。 ViewBag.sum = _insurService.PointSum(AppId); return(PartialView("_QueryResult", resultList)); }//return Helper.PointHelper.AppliSearchResult(resultList, PartialView("_QueryResult", resultList)); }